-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.js
67 lines (59 loc) · 1.69 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { dependencies } = require('./server/package.json');
const exec = require('child_process').exec;
const fs = require('fs-extra');
const assets = [
'LICENSE',
'README.md',
'server/schema.prisma',
'server/migrations',
];
const packageJson = {
name: 'nw-company-tool',
version: '0.0.0',
description: 'A tool to organize your new world company',
author: 'Krise',
license: 'MIT',
keywords: ['New World', 'Company', 'Tool', 'Gaming'],
bugs: {
url: 'https://github.com/cbartel/nw-company-tool/issues',
},
homepage: 'https://github.com/cbartel/nw-company-tool',
repository: {
type: 'git',
url: 'https://github.com/cbartel/nw-company-tool.git',
},
dependencies,
};
function run(command) {
return new Promise((resolve) => {
const proc = exec(command);
proc.stdout.on('data', (data) => {
console.log(data);
});
proc.stderr.on('data', (data) => {
console.error(data);
});
proc.on('close', () => {
resolve();
});
});
}
async function build() {
fs.removeSync('./dist');
fs.removeSync('./webapp/dist');
fs.removeSync('./server/dist');
await run('npm --prefix webapp install');
await run('npm --prefix webapp run ng build ');
await run('npm --prefix server install ');
await run('npm --prefix server run build ');
fs.copySync('./server/dist', './dist/dist');
fs.copySync('./webapp/dist/app', './dist/dist/app');
fs.outputJsonSync('./dist/package.json', packageJson, { spaces: 2 });
assets.forEach((asset) => {
const source = asset;
const path = asset.split('/');
const dest = path[path.length - 1];
fs.copySync(`./${source}`, `./dist/${dest}`);
});
}
build().then(() => console.log('build complete.'));