-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.js
103 lines (97 loc) · 2.57 KB
/
Makefile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"use strict";
const del = require("del");
const path = require("path");
const fs = require("fs");
const execa = require("execa");
const through = require("through");
const publicPath = path.join(__dirname, "public");
const nodeModulesPath = path.join(__dirname, "node_modules");
const ravenJSPathDist = path.join(nodeModulesPath, "raven-js/dist");
// Update package json version field also
Promise.resolve()
.then(() => del([`${publicPath}/**/*`]))
.then(() =>
execa("npm", ["outdated", "raven-js"]).catch(error => {
console.log(error.stdout);
console.log("[npm] Update `raven-js` package.");
if (error.code === 1) {
return execa("npm", [
"install",
"raven-js@latest",
"--save-dev",
"--save-exact"
]);
}
})
)
.then(() =>
execa("composer", ["outdated", "sentry/sentry", "--strict"]).catch(
error => {
console.log(error.stdout);
console.log("[composer] Update `sentry/sentry` package.");
if (error.code === 1) {
return execa("composer", [
"require",
"sentry/sentry",
"--prefer-stable",
"--prefer-dist",
"--no-suggest"
]);
}
}
)
)
.then(() =>
fs
.createReadStream(path.join(ravenJSPathDist, "raven.min.js"))
.pipe(fs.createWriteStream(path.join(publicPath, "raven.min.js")))
)
.then(() =>
fs
.createReadStream(path.join(ravenJSPathDist, "raven.min.js"))
.pipe(
through(
function write(buf) {
this.emit(
"data",
buf
.toString()
.replace("//# sourceMappingURL=raven.min.js.map", "")
.trim()
);
},
function end() {
this.emit("end");
}
)
)
.pipe(
fs.createWriteStream(
path.join(publicPath, "raven-hidden-source-map.min.js")
)
)
)
.then(() => {
fs.createReadStream(path.join(ravenJSPathDist, "raven.min.js.map")).pipe(
fs.createWriteStream(path.join(publicPath, "raven.min.js.map"))
);
})
.then(() => {
execa(
"composer",
[
"install",
"--no-dev",
"--optimize-autoloader",
"--classmap-authoritative"
],
{
stdio: "inherit"
}
);
})
.catch(error => {
console.log(error.stack); // eslint-disable-line no-console
const exitCode = typeof err.code === "number" ? error.code : 1;
process.exit(exitCode); // eslint-disable-line no-process-exit
});