-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-scripts.js
More file actions
112 lines (105 loc) · 2.69 KB
/
package-scripts.js
File metadata and controls
112 lines (105 loc) · 2.69 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { series, rimraf } = require('nps-utils');
const packageJSON = require('./package.json');
module.exports = {
scripts: {
default: 'nps start',
dev: {
description: 'serve in development',
script: 'nodemon -L --exec ts-node -- ./test/index.ts',
},
build: {
silent: true,
script: series('nps log.build.init', 'nps lint.check', 'nps clean', 'nps transpile', 'nps log.build.done'),
},
lint: {
check: {
description: 'Check linting',
silent: true,
script: series('nps log.lint.check.init', `eslint 'src/**/*.{js,jsx,ts,tsx}'`),
},
fix: {
description: 'Fix linting',
script: series('nps log.lint.fix.init', `eslint '**/*.{js,jsx,ts,tsx}' --fix`),
},
},
transpile: {
description: 'TS to JS',
silent: true,
script: series('nps log.transpile.init', 'tsc'),
},
version: {
major: release('major'),
minor: release('minor'),
patch: release('patch'),
pre: release('pre'),
release: {
description: `Perform a release v${packageJSON.version}`,
silent: true,
script: series(
'nps log.tag.init',
`release-it --ci --git.tag=true --git.tagName="v${packageJSON.version}" --no-increment`
),
},
},
clean: {
default: {
script: series('nps log.clean.init', 'nps clean.dist'),
silent: true,
description: 'Deletes the ./dist folder',
},
dist: {
script: rimraf('./dist'),
silent: true,
hiddenFromHelp: true,
},
},
log: {
lint: {
check: {
init: log('info', 'Check linting'),
},
fix: {
init: log('info', 'Fix linting'),
},
},
build: {
init: log('info', 'Building'),
done: log('done', 'Building'),
},
clean: {
init: log('info', 'Cleaning'),
},
tag: {
init: log('info', 'Tagging'),
},
transpile: {
init: log('info', 'Transpiling'),
},
version: {
init: log('info', 'Versioning'),
},
},
},
};
function release(version) {
return {
description: `Perform a release by ${version.toUpperCase()}`,
hiddenFromHelp: true,
script: series('nps log.version.init', `release-it --ci -i ${version}`),
silent: true,
};
}
function log(type, msg, label) {
const scriptPath = `./scripts/logger ${type} '${msg}' ${label}`;
return {
description: `Show ${msg} log to the terminal`,
hiddenFromHelp: true,
script: run(scriptPath),
silent: true,
};
}
// utils
function run(path) {
return `node ${path}`;
}