-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpackage-scripts.js
More file actions
152 lines (146 loc) · 4.2 KB
/
package-scripts.js
File metadata and controls
152 lines (146 loc) · 4.2 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
146
147
148
149
150
151
152
const { series, rimraf, } = require('nps-utils');
module.exports = {
scripts: {
default: 'nps start',
start: {
script: 'cross-env NODE_ENV=production node dist/app.js',
description: 'Starts the builded app',
},
serve: {
inspector: {
script: series(
'nps banner.serve',
'nodemon --watch src --watch .env --inspect'
),
description: 'Serves the current app and watches for changes to restart it, you may attach inspector to it.'
},
script: series(
'nps banner.serve',
'nodemon --watch src --watch .env'
),
description: 'Serves the current app and watches for changes to restart it'
},
setup: {
script: series(
'yarn install',
'nps db.setup',
)
},
config: {
script: series(
runFast('./commands/tsconfig.ts'),
),
hiddenFromHelp: true
},
build: {
script: series(
'nps config',
'nps lint',
'nps clean.dist',
'nps transpile',
'nps copy',
'nps copy.tmp',
'nps clean.tmp',
),
description: 'Builds the app into the dist directory'
},
lint: {
script: tslint(`./src/**/*.ts`),
hiddenFromHelp: true
},
transpile: {
script: `tsc --project ./tsconfig.build.json`,
hiddenFromHelp: true
},
clean: {
default: {
script: series(
`nps banner.clean`,
`nps clean.dist`
),
description: 'Deletes the ./dist folder'
},
dist: {
script: rimraf('./dist'),
hiddenFromHelp: true
},
tmp: {
script: rimraf('./.tmp'),
hiddenFromHelp: true
}
},
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
},
tmp: {
script: copyDir(
'./.tmp/src',
'./dist'
),
hiddenFromHelp: true
}
},
db: {
migrate: {
script: series(
'nps banner.migrate',
'nps config',
runFast('./node_modules/typeorm/cli.js migration:run')
),
description: 'Migrates the database to newest version available'
},
setup: {
script: series(
'nps db.migrate',
),
description: 'Recreates the database with seeded data'
}
},
banner: {
build: banner('build'),
serve: banner('RENTME-API'),
revert: banner('revert'),
migrate: banner('migrate'),
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 `copyfiles --up 1 ${source} ${target}`;
}
function copyDir(source, target) {
return `ncp ${source} ${target}`;
}
function runFast(path) {
return `ts-node --transpileOnly ${path}`;
}
function tslint(path) {
return `tslint -c ./tslint.json ${path} --format stylish`;
}