-
Notifications
You must be signed in to change notification settings - Fork 1
/
export.js
81 lines (63 loc) · 1.54 KB
/
export.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
const exec = require('child_process').execSync;
const {
saveScheduleHtml,
saveScheduleJson,
writeFileSWJS,
writeFileManifestJson,
writeFileNowJson,
deleteFolder
} = require('./src/utils');
const _package = require('./package.json');
const { config } = _package;
const { outputFolder } = config;
const json = async () => {
// save schedule.html
await saveScheduleHtml();
// schedule.json
saveScheduleJson();
};
const build = () => {
// update package version
const output = exec('npm run patch').toString().trim();
const last = output.lastIndexOf('v');
const ver = output.substring(last + 1);
console.log(`bumped version to ${ver}`);
// delete output folder
deleteFolder(outputFolder);
// run next build & export
exec('npm run export');
console.log('\nbuilt and exported');
// remove output/_next folder
deleteFolder(`${outputFolder}/_next`);
// add sw.js
writeFileSWJS(ver);
// add manifest.json
writeFileManifestJson();
// add now.json
writeFileNowJson();
// run beautify
exec('npm run beautify');
console.log('beautified');
};
const deploy = () => {
// deploy
exec('npm run now-deploy && npm run now-alias');
console.log('deployed');
};
const all = async () => {
await json();
build();
deploy();
};
if (process.argv.includes('json')) {
json();
}
if (process.argv.includes('build')) {
build();
}
if (process.argv.includes('deploy')) {
deploy();
}
if (process.argv.includes('all')) {
all();
}