-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-scripts.cjs
executable file
·149 lines (136 loc) · 5.42 KB
/
package-scripts.cjs
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
const tasks = {
nps: (command) => {
return `nps -c ./package-scripts.cjs ${command}`;
},
serially: (...scripts) => {
return scripts.join(' && ');
},
concurrently: (scripts) => {
const keys = Object.keys(scripts);
const values = keys.map((k) => `"${scripts[k]}"`);
const defaultColors = [
'bgBlue.bold',
'bgMagenta.bold',
'bgGreen.bold',
'bgBlack.bold',
'bgCyan.bold',
'bgRed.bold',
'bgWhite.bold',
'bgYellow.bold'
];
return (
'concurrently --kill-others-on-fail ' +
`--prefix-colors ${defaultColors.slice(0, keys.length).join(',')} ` +
`--prefix "[{name}]" --names ${keys.join(',')} ` +
values.join(' ')
);
}
};
const defaultConfiguration = {
options: {
scripts: false,
logLevel: 'warn',
'help-style': 'basic'
},
scripts: {
default: {
script: tasks.nps('help'),
hiddenFromHelp: true
},
dev: {
script: tasks.serially('tsc --noEmit', 'tsx ./src/index.tsx'),
description: 'Run "index.ts" in development mode',
watch: {
script: 'tsx ./src/index.ts --watch ./src/**/*.ts',
description: 'Run "index.ts" in development mode and watch for changes'
}
},
build: {
script: tasks.serially(
tasks.nps('clean.dist'),
'rollup -c rollup.config.mjs',
'npx cpy-cli ./static ../../dist --cwd=src'
),
description: 'Build the application into "dist" folder'
},
test: {
script: tasks.serially(tasks.nps('lint'), 'echo "no tests to run"'),
description: 'Run the tests, including linting'
},
doc: {
script: tasks.serially(tasks.nps('clean.docs'), tasks.nps('build'), 'typedoc'),
description: 'Run Typedoc and generate docs',
watch: {
script: tasks.serially(tasks.nps('doc'), 'typedoc --watch'),
description: 'Run Typedoc and generate docs and watch for changes.'
},
serve: {
script: tasks.serially(tasks.nps('doc'), 'typedoc', 'serve ./docs'),
description: 'Run Typedoc and generate docs, then serve the docs as HTML',
watch: {
script: tasks.serially(
tasks.nps('doc'),
tasks.concurrently({
typedoc: 'typedoc --watch',
serve: 'serve ./docs'
})
),
description: 'Run Typedoc and generate docs and watch for changes while serving the docs as HTML'
}
}
},
clean: {
script: tasks.serially(tasks.nps('clean.dist'), tasks.nps('clean.docs')),
description: 'Remove all automatically generated files and folders',
hiddenFromHelp: true,
dist: {
script: 'rimraf ./dist',
description: 'Delete the dist folder',
hiddenFromHelp: true
},
docs: {
script: 'rimraf ./docs',
description: 'Delete the docs folder',
hiddenFromHelp: true
}
},
lint: {
script: 'eslint --format stylish --color',
description: 'Run ESLint on all the files (src and tests)',
fix: {
script: 'eslint --format stylish --color --fix',
description: 'Run ESLint on all the files (src and tests) with --fix option'
}
},
prettify: {
script: tasks.serially(
'prettier --no-error-on-unmatched-pattern --write ./.husky/*[^_]',
'prettier --no-error-on-unmatched-pattern --write ./{.github,.vscode,src,test}/{**,.}/*.{js,jsx,cjs,mjs,ts,tsx,mts,cts,yml,md,json,js}',
'prettier --no-error-on-unmatched-pattern --write {.czrc,.editorconfig,.gitignore,.npmignore,.npmrc,.prettierrc}',
'prettier --no-error-on-unmatched-pattern --write ./*.{js,jsx,cjs,mjs,ts,tsx,mts,cts,yml,md,json,js}'
),
description: 'Run Prettier on all the files, writing the results'
},
changelog: {
script: 'conventional-changelog -p angular -i CHANGELOG.md -s',
hiddenFromHelp: true,
description: 'Generate changelog based on tags',
scratch: {
script: 'conventional-changelog -p angular -i CHANGELOG.md -s -r 0',
description: 'Generate changelog based on tags, starting from scratch',
hiddenFromHelp: true
}
},
license: {
script: tasks.serially(tasks.nps('build'), 'license-check-and-add add -f ./license.config.json '),
hiddenFromHelp: true,
description: 'Add license information to all code files in the project',
remove: {
script: tasks.serially(tasks.nps('build'), 'license-check-and-add remove -f ./license.config.json'),
hiddenFromHelp: true,
description: 'Remove license information to all code files in the project'
}
}
}
};
module.exports = defaultConfiguration;