-
Notifications
You must be signed in to change notification settings - Fork 214
/
package-scripts.js
124 lines (121 loc) · 5.79 KB
/
package-scripts.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const npsUtils = require('nps-utils');
const os = require('os');
function withPlatform(command) {
let platform;
switch (os.platform()) {
case 'win32':
platform = 'win';
break;
case 'darwin':
platform = 'mac';
break;
default:
platform = 'linux';
break;
}
return `${platform}.${command}`;
}
function electronBuilder(platform, dashP) {
return `electron-builder ${platform} -p ${dashP} --config.win.certificateSubjectName="Narwhal Technologies Inc."`
}
module.exports = {
scripts: {
frontend: {
ng: 'ng',
build: 'ng build angular-console --prod',
serve: {
default: 'ng serve angular-console',
prod: 'ng serve angular-console --prod'
},
format: {
default: 'prettier **/*.ts **/*.css **/*.scss **/*.html --write',
write: 'prettier **/*.ts **/*.css **/*.scss **/*.html --write',
check: 'prettier --list-different **/*.ts **/*.css **/*.scss **/*.html --write'
},
lint: npsUtils.series('nx lint', 'nx affected:lint --base=master --parallel'),
test: 'nx affected:test --base=master'
},
server: {
compile: npsUtils.series.nps('server.gen-graphql-types', 'server.gen-apollo-angular', 'server.compile-only'),
'compile-only': 'tsc -p server/tsconfig.json',
format: {
default: npsUtils.series.nps('server.format.write'),
write: 'prettier --write \"./server/**/*.ts\"',
check: 'prettier --list-different \"./server/**/*.ts\"'
},
test: 'node ./tools/scripts/test ./server/test',
'gen-graphql-types': 'ts-node tools/gen-graphql-types.ts',
'gen-apollo-angular': 'ts-node tools/gen-apollo-angular.ts'
},
mac: {
'clean': 'rm -rf dist',
'copy-assets': 'cp server/package.json dist/server/package.json && cp -r server/assets dist/server',
'install-node-modules': 'cd dist/server && yarn',
'copy-frontend': 'cp -r dist/apps/angular-console dist/server/src/public',
'pack': 'electron-builder --mac --dir -p never',
'copy-to-osbuilds': 'cp -r dist/packages osbuilds/mac',
'start-server': 'electron dist/server --server --inspect=9229',
'start-electron': 'NODE_ENV=development electron dist/server',
'builder-dist': 'electron-builder --mac -p never',
},
linux: {
'clean': 'rm -rf dist',
'copy-assets': 'cp server/package.json dist/server/package.json && cp -r server/assets dist/server',
'install-node-modules': 'cd dist/server && yarn',
'copy-frontend': 'cp -r dist/apps/angular-console dist/server/src/public',
'pack': 'electron-builder --linux --dir -p never',
'copy-to-osbuilds': 'cp -r dist/packages osbuilds/linux',
'start-server': 'electron dist/server --server --inspect=9229',
'start-electron': 'NODE_ENV=development electron dist/server',
'builder-dist': 'electron-builder --linux -p never'
},
win: {
'clean': 'if exist dist rmdir dist /s /q',
'copy-assets': 'copy server\\package.json dist\\server\\package.json && (robocopy server\\assets dist\\server\\assets /e || echo 0)',
'install-node-modules': 'cd dist\\server && yarn',
'copy-frontend': 'robocopy dist\\apps\\angular-console dist\\server\\src\\public /e || echo 0',
'pack': 'electron-builder --win --dir -p never',
'copy-to-osbuilds': 'robocopy dist\\packages osbuilds\\win /e || echo 0',
'start-server': 'electron dist\\server --server --inspect=9229',
'start-electron': 'electron dist\\server',
'builder-dist': 'electron-builder --win -p never'
},
dev: {
'patch-cli': 'node ./tools/scripts/patch-cli.js',
'compile-server': npsUtils.series.nps('server.compile', withPlatform('copy-assets')),
'prepare': npsUtils.series.nps(withPlatform('clean'), 'dev.compile-server', 'frontend.build', withPlatform('copy-frontend'), withPlatform('pack'), 'dev.patch-cli'),
'server': npsUtils.series.nps('dev.compile-server', withPlatform('start-server')),
'up': npsUtils.concurrent.nps('dev.server', 'frontend.serve'),
'dist': npsUtils.series.nps('dev.prepare', withPlatform('builder-dist'), withPlatform('copy-to-osbuilds'))
},
publish: {
'win-builder-prerelease': electronBuilder('--win', 'never'),
'win-builder-publish': electronBuilder('--win', 'always'),
'mac-builder-prerelease': electronBuilder('--mac --linux', 'never'),
'mac-builder-publish': electronBuilder('--mac --linux', 'always'),
'win-prerelease': npsUtils.series.nps('dev.prepare', 'publish.win-builder-prerelease'),
'win-publish': npsUtils.series.nps('dev.prepare', 'publish.win-builder-publish'),
'mac-prerelease': npsUtils.series.nps('dev.prepare', 'publish.mac-builder-prerelease'),
'mac-publish': npsUtils.series.nps('dev.prepare', 'publish.mac-builder-publish')
},
e2e: {
'compile': 'tsc -p apps/angular-console-e2e/tsconfig.json',
'compile-watch': 'tsc -p apps/angular-console-e2e/tsconfig.json --watch',
'fixtures': 'node ./tools/scripts/set-up-e2e-fixtures.js',
'cypress': `cypress run --project ./apps/angular-console-e2e --env projectsRoot=${__dirname + '/tmp'} --record`,
'open-cypress': `cypress open --project ./apps/angular-console-e2e --env projectsRoot=${__dirname + '/tmp'}`,
'run': 'node ./tools/scripts/run-e2e.js',
'up': npsUtils.concurrent.nps('dev.up', 'e2e.compile-watch', 'e2e.open-cypress')
},
format: {
default: npsUtils.series.nps('format.write'),
check: npsUtils.concurrent.nps('frontend.format.check', 'server.format.check'),
write: npsUtils.concurrent.nps('frontend.format.write', 'server.format.write')
},
lint: {
default: npsUtils.concurrent.nps('frontend.lint'),
fix: npsUtils.concurrent.nps('frontend.lint.fix')
},
test: npsUtils.concurrent.nps('frontend.test', 'server.test')
}
};