-
Notifications
You must be signed in to change notification settings - Fork 6
/
package-scripts.cjs
37 lines (34 loc) · 1.22 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
/* eslint-disable @typescript-eslint/no-var-requires */
const {series} = require('nps-utils')
const {version} = require('./package.json')
const isPR = process.env.GH_EVENT === 'pull_request'
const comparisonRef = isPR ? `origin/${process.env.BASE_REF}` : 'HEAD^'
const scripts = {
build: {
default: `nps build.clean build.lib`,
git: `sh build-git.sh v${version.split('.')[0]}`,
clean: '[ ! -e dist-types ] || rm -r dist-types/',
lib: 'vite build --mode lib',
types: `tsc --emitDeclarationOnly`,
},
lint: {
default: 'eslint .',
// The setup-node action parses eslint errors, no formatter needed
ci: isPR
? `git diff --name-only --diff-filter=ACMRTUXB ${comparisonRef} | grep -E "\\.[jt]sx?$" | xargs -d \\\\n eslint`
: `eslint .`,
errors: 'eslint --format visualstudio --quiet .',
fix: `eslint --fix .; prettier --write .`,
},
test: {
default: series.nps('lint', 'test.full'),
// Note, this changes the repo during the run
ci: isPR
? `git reset ${comparisonRef} && vitest --coverage --color --changed; out=$?; git reset HEAD@{1}; exit $out`
: `vitest run --coverage --color`,
full: 'vitest run --coverage --color',
watch: 'vitest --color --watch',
},
publish: `npx np`,
}
module.exports = {scripts}