1 | const ChildProcess = require('child_process');
|
2 | const Fs = require('fs-extra');
|
3 | const Path = require('path');
|
4 |
|
5 |
|
6 | const cwd = Path.resolve(__dirname, '..');
|
7 |
|
8 | const main = () => {
|
9 |
|
10 | if (compileProject()) return
|
11 | chmodCLI()
|
12 | archiveSkeleton()
|
13 | }
|
14 |
|
15 |
|
16 | const compileProject = () => {
|
17 | const tscFile = Path.resolve(cwd, 'node_modules/typescript/bin/tsc');
|
18 | const tsConfig = Path.resolve(cwd, 'tsconfig.json');
|
19 |
|
20 | const { status } = ChildProcess.spawnSync(tscFile, ['-p', tsConfig], {
|
21 | stdio: 'inherit',
|
22 | cwd
|
23 | });
|
24 |
|
25 | return status
|
26 | }
|
27 |
|
28 |
|
29 | const chmodCLI = () => {
|
30 | const cliDir = Path.resolve(cwd, 'dist/cli');
|
31 | const cliFiles = Fs.readdirSync(cliDir).map(fileName => Path.resolve(cliDir, fileName));
|
32 |
|
33 | cliFiles.forEach((cliFile) => {
|
34 | Fs.chmodSync(cliFile, '755');
|
35 | });
|
36 | }
|
37 |
|
38 |
|
39 |
|
40 | const archiveSkeleton = () => {
|
41 | ChildProcess.spawnSync('tar', ['-cvf', 'dist/skeleton.tar', 'skeleton'], {
|
42 | stdio: 'inherit',
|
43 | cwd,
|
44 | });
|
45 | }
|
46 |
|
47 | main()
|