|
1 |
| -const fs = require('fs').promises; |
2 |
| -const oldFS = require('fs'); |
3 |
| -const path = require('path'); |
4 |
| -const childProcess = require('child_process'); |
| 1 | +const shell = require('shelljs') |
5 | 2 |
|
6 |
| -const ROOT = path.resolve(__dirname, '../'); |
7 |
| -const TEMP_PATH = path.resolve(ROOT, './temp'); |
8 |
| -const OUT_PATH = path.resolve(ROOT, './out'); |
9 |
| -const TEMP_OUT_PATH = path.resolve(TEMP_PATH, './out'); |
10 |
| -const TEMP_NODE_MODULES = path.resolve(TEMP_PATH, './node_modules'); |
11 |
| -const NODE_MODULES = path.resolve(ROOT, './node_modules'); |
| 3 | +shell.pushd('./webviews') |
| 4 | +shell.exec('yarn') |
12 | 5 |
|
13 |
| -const copy = async (source, destination) => { |
14 |
| - let paths = await fs.readdir(source); |
15 |
| - paths.forEach(async (path) => { |
16 |
| - const _source = source + '/' + path; |
17 |
| - const _destination = destination + '/' + path; |
18 |
| - try { |
19 |
| - const stats = await fs.stat(_source); |
20 |
| - if (stats.isFile()) { |
21 |
| - const readable = oldFS.createReadStream(_source); |
22 |
| - const writable = oldFS.createWriteStream(_destination); |
23 |
| - readable.pipe(writable); |
24 |
| - } else if (stats.isDirectory()) { |
25 |
| - checkDirectory(_source, _destination, copy); |
26 |
| - } |
27 |
| - } catch { |
| 6 | +shell.popd() |
| 7 | +shell.exec('yarn') |
| 8 | +shell.exec('yarn build') |
28 | 9 |
|
29 |
| - } |
30 |
| - }); |
31 |
| -} |
| 10 | +shell.mkdir('-p', ['./temp/out', './temp/node_modules']) |
| 11 | +shell.cp('-Rf', './out/*', './temp/out/') |
32 | 12 |
|
33 |
| -const checkDirectory = async (source, destination, callback) => { |
34 |
| - try { |
35 |
| - const res = await fs.stat(destination); |
36 |
| - callback(source, destination); |
37 |
| - } catch { |
38 |
| - const res = await fs.mkdir(destination); |
39 |
| - callback(source, destination); |
40 |
| - } |
41 |
| -}; |
| 13 | +shell.exec('yarn --prod=true') |
| 14 | +shell.cp('-Rf', './node_modules/*', './temp/node_modules/') |
42 | 15 |
|
43 |
| -const release = async () => { |
44 |
| - try { |
45 |
| - await fs.stat(TEMP_PATH); |
46 |
| - } catch { |
47 |
| - await fs.mkdir(TEMP_PATH); |
48 |
| - } |
49 |
| - |
50 |
| - try { |
51 |
| - await fs.stat(TEMP_OUT_PATH); |
52 |
| - } catch { |
53 |
| - await fs.mkdir(TEMP_OUT_PATH); |
54 |
| - } |
55 |
| - |
56 |
| - try { |
57 |
| - await fs.stat(TEMP_NODE_MODULES); |
58 |
| - } catch { |
59 |
| - await fs.mkdir(TEMP_NODE_MODULES); |
60 |
| - } |
61 |
| - |
62 |
| - childProcess.execSync('yarn'); |
63 |
| - childProcess.execSync('yarn build'); |
64 |
| - console.warn('yarn build complete') |
65 |
| - |
66 |
| - await copy(OUT_PATH, TEMP_PATH + '/out'); |
67 |
| - await fs.copyFile(path.resolve(ROOT, './package.json'), path.resolve(TEMP_PATH, './package.json')); |
68 |
| - await fs.copyFile(path.resolve(ROOT, './LICENSE'), path.resolve(TEMP_PATH, './LICENSE')); |
69 |
| - |
70 |
| - childProcess.execSync('yarn --prod=true'); |
71 |
| - await copy(NODE_MODULES, TEMP_PATH + '/node_modules'); |
72 |
| - |
73 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './@babel')}`); |
74 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './@emotion')}`); |
75 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './csstype')}`); |
76 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-emotion')}`); |
77 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-macros')}`); |
78 |
| - childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-syntax-jsx')}`); |
79 |
| -}; |
80 |
| - |
81 |
| -release(); |
| 16 | +shell.cp('./package.json', './temp/') |
| 17 | +shell.cp('./LICENSE', './temp/') |
0 commit comments