This repository was archived by the owner on Jan 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-scripts.js
More file actions
145 lines (136 loc) · 3.59 KB
/
package-scripts.js
File metadata and controls
145 lines (136 loc) · 3.59 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* 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 start',
/**
* Starts the builded app from the dist directory
*/
start: {
script: 'node dist/app.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 --watch src --watch .env'
),
description: 'Serves the current app and watches for changes to restart it'
},
/**
* Creates the needed configuration files
*/
config: {
script: './commands/tsconfig.ts',
hiddenFromHelp: true
},
/**
* Builds the app into the dist directory
*/
build: {
script: series(
'nps banner.build',
'nps config',
'nps lint',
'nps clean.dist',
'nps transpile',
'nps copy'
),
description: 'Builds the app into the dist directory'
},
/**
* Runs TSLint over your project
*/
lint: {
script: tslint(`./src/**/*.ts`),
hiddenFromHelp: true
},
/**
* Transpile your app into javascript
*/
transpile: {
script: `tsc --project ./tsconfig.build.json`,
hiddenFromHelp: true
},
/**
* Clean files and folders
*/
clean: {
default: {
script: series(
`nps banner.clean`,
`nps clean.dist`
),
description: 'Deletes the ./dist folder'
},
dist: {
script: rimraf('./dist'),
hiddenFromHelp: true
}
},
/**
* Copies static files to the build folder
*/
copy: {
default: {
script: series(
`nps copy.swagger`,
`nps copy.public`
),
hiddenFromHelp: true
},
swagger: {
script: copy(
'./src/api/swagger.json',
'./dist'
),
hiddenFromHelp: true
},
public: {
script: copy(
'./src/public/*',
'./dist'
),
hiddenFromHelp: true
}
},
/**
* Database scripts
*/
db: {
},
/**
* This creates pretty banner to the terminal
*/
banner: {
build: banner('build'),
serve: banner('serve'),
clean: banner('clean')
}
}
};
function banner(name) {
return {
hiddenFromHelp: true,
silent: true,
description: `Shows ${name} banners to the console`,
script: runFast(`./commands/banner.ts ${name}`),
};
}
function copy(source, target) {
return `copyup ${source} ${target}`;
}
function run(path) {
return `ts-node --typeCheck ${path}`;
}
function runFast(path) {
return `ts-node ${path}`;
}
function tslint(path) {
return `tslint -c ./tslint.json ${path} --format stylish`;
}