-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
49 lines (38 loc) · 1.18 KB
/
build.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
const {print, filesystem, prompt, system, colors} = require("gluegun");
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
(async () => {
var package = JSON.parse(filesystem.read("./package.json"));
var versao = package.version;
versao = versao.split(".");
var major = Number.parseInt(versao[0]);
var minor = Number.parseInt(versao[1]);
var build = Number.parseInt(versao[2]);
var {newVersion} = await prompt.ask({
type: "select",
name: "newVersion",
message: "Selecione o novo número de versão:",
choices: [
`${major + 1}.0.0`,
`${major}.${minor + 1}.0`,
`${major}.${minor}.${build + 1}`,
`${major}.${minor}.${build}`
]
});
package.version = newVersion;
await filesystem.writeAsync(
"./package.json",
JSON.stringify(package, null, 2)
);
console.log("Realizando build...");
await sleep(300);
await filesystem.removeAsync("./dist");
await filesystem.removeAsync("./types");
await sleep(300);
await filesystem.dirAsync("./types");
try {
await system.run("tsc -d --declarationDir ./types");
console.log("Build realizado com sucesso!");
} catch (e) {
console.error(e);
}
})();