-
Notifications
You must be signed in to change notification settings - Fork 4
/
package-scripts.js
120 lines (114 loc) · 2.68 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
/**
* Windows: Please do not use trailing comma as windows will fail with token error
*/
const { series, crossEnv, concurrent, rimraf, runInNewWindow } = require('nps-utils');
module.exports = {
scripts: {
default: 'nps serve',
/**
* Starts the builded app from the dist directory
*/
start: {
script: 'node bin/index.js',
description: 'Starts the builded app from the dist directory'
},
/**
* Serves the current app and watches for changes to restart it
*/
serve: {
script: series(
'nps banner.serve',
'nodemon -r dotenv/config --watch src --watch config'
),
description: 'Serves the current app and watches for changes to restart it'
},
test: {
script: series(
'nps banner.testUnit',
'jest --coverage --detectOpenHandles'
),
description: 'Runs unit tests'
},
/**
* Builds the app into the dist directory
*/
build: {
script: series(
'nps banner.build',
'nps lint',
'nps clean.bin',
'nps transpile',
'nps transformPath'
),
description: 'Builds the app into the bin directory'
},
/**
* Runs TSLint over your project
*/
lint: {
script: tslint(`./src/**/*.ts`),
hiddenFromHelp: true
},
/**
* Transpile your app into javascript
*/
transpile: {
script: `tsc`,
hiddenFromHelp: true
},
/**
* Transfrom typescript path alias
*/
transformPath : {
script: `tscpaths -p tsconfig.json -s ./src -o ./bin`
},
/**
* Clean files and folders
*/
clean: {
default: {
script: series(
`nps banner.clean`,
`nps clean.bin`
),
description: 'Deletes the ./bin folder'
},
bin: {
script: rimraf('./bin'),
hiddenFromHelp: true
},
dist: {
script: rimraf('./dist'),
hiddenFromHelp: true
}
},
/**
* This creates pretty banner to the terminal
*/
banner: {
build: banner('build'),
serve: banner('serve'),
debug: banner('serve'),
testUnit: banner('test.unit'),
testIntegration: banner('test.integration'),
testE2E: banner('test.e2e'),
package: banner('package'),
revert: banner('revert'),
clean: banner('clean')
}
}
};
function banner(name) {
return {
hiddenFromHelp: true,
silent: true,
description: `Shows ${name} banners to the console`,
script: run(`./commands/banner.ts ${name}`)
}
}
function run(path) {
return `ts-node ${path}`;
}
function tslint(path) {
return `tslint -c ./tslint.json ${path} --format stylish`;
}