Skip to content

Commit

Permalink
maint/build ~ (package.json) polish dev scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Feb 10, 2021
1 parent fdb8180 commit 53c494d
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@
],
"scripts": {
"# build # build/compile package": "",
"build": "run-s \"+:regen:build\"",
"build:cjs": "shx rm -fr build/cjs && tsc -p tsconfig/tsconfig.cjs.json",
"build:cjs/esm": "shx rm -fr build/cjs/esm-wrapper && shx mkdir -p build/cjs && shx cp -r src/esm-wrapper build/cjs",
"## build:esm * [2020-12-22; rivy] TS compiles to ESMs are broken due to extension mishandling (use `rollup`)": "tsc -p tsconfig/tsconfig.esm.json",
"build:esm": "shx rm -fr build/esm && rollup -c .rollup.config.js",
"build:umd": "shx rm -fr build/umd && tsc -p tsconfig/tsconfig.umd.json",
"build:tests": "shx rm -fr build/cjs+tests && tsc -p tsconfig/tsconfig.tests.json",
"build:types": "shx rm -fr build/types && tsc -p tsconfig/tsconfig.types.json && run-s --silent _:update:dist.types",
"build": "run-p --silent \"build:*\"",
"build:cjs": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/cjs/**\" \"run-s -n rebuild:cjs\"",
"build:esm": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/esm/**\" \"run-s -n rebuild:esm\"",
"build:umd": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/umd/**\" \"run-s -n rebuild:umd\"",
"build:tests": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/cjs+tests/**\" \"run-s -n rebuild:tests\"",
"build:types": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/types/**\" \"run-s -n rebuild:types\"",
"# clean # remove build artifacts": "",
"clean": "rimraf build dist",
"# coverage # calculate and display (or send) code coverage [alias: 'cov']": "",
Expand All @@ -73,7 +71,7 @@
"# help # display help": "",
"help": "run-s --silent _:help",
"# lint # check for package code 'lint'": "",
"lint": "run-s --silent +:max-node-8 && shx echo \"[lint] WARN Lint checks skipped [for NodeJS < v10]\" 1>&2 || run-p \"lint:*\"",
"lint": "run-s --silent +:max-node-8 && shx echo \"[lint] WARN Lint checks skipped [for NodeJS < v10]\" 1>&2 || run-p --print-name \"lint:*\"",
"# lint:commits # check for commit flaws (using `commitlint` and `cspell`)": "",
"lint:commits": "run-s --silent _:v_tag:missing || run-p --silent \"_:lint:commits.new:*\"",
"# lint:lint # check for code 'lint' (using `eslint`)": "",
Expand All @@ -88,14 +86,20 @@
"realclean": "run-s clean && rimraf coverage .nyc_output",
"# rebuild # clean and (re-)build project": "",
"rebuild": "run-s clean build",
"rebuild:cjs": "shx rm -fr build/cjs && tsc -p tsconfig/tsconfig.cjs.json && shx cp -r src/esm-wrapper build/cjs",
"## rebuild:esm * [2020-12-22; rivy] TS compiles to ESMs are broken due to extension mishandling (use `rollup`)": "tsc -p tsconfig/tsconfig.esm.json",
"rebuild:esm": "shx rm -fr build/esm && rollup -c .rollup.config.js",
"rebuild:umd": "shx rm -fr build/umd && tsc -p tsconfig/tsconfig.umd.json",
"rebuild:tests": "shx rm -fr build/cjs+tests && tsc -p tsconfig/tsconfig.tests.json",
"rebuild:types": "shx rm -fr build/types && tsc -p tsconfig/tsconfig.types.json",
"# retest # clean and (re-)test project": "",
"retest": "run-s clean test",
"# reset:hard # remove *all* generated files and reinstall dependencies": "",
"reset:hard": "git clean -dfx && git reset --hard && npm install",
"# show:deps # show package dependencies": "",
"show:deps": "run-s --silent _:show:deps:prod _:show:deps:dev || shx true",
"# test # test package": "",
"test": "run-s \"+:regen:lint/build\" \"+:regen:update\" && run-p test:*",
"test": "run-s --silent lint update:dist && run-p test:*",
"# test:code # test package code": "",
"test:code": "run-s --silent +:max-node-8 && ava || ( run-s --silent +:min-node-10 && nyc --silent ava )",
"# test:types # test for type declaration errors (using `tsd`)": "",
Expand All @@ -105,19 +109,15 @@
"# update:changelog # update CHANGELOG (using `git changelog ...`)": "",
"update:changelog": "run-s --silent _:update:changelog && git diff --quiet --exit-code CHANGELOG.mkd || shx echo \"[update] info CHANGELOG updated\"",
"# update:dist # update distribution content": "",
"update:dist": "run-s \"+:regen:build\" \"+:update:dist\"",
"update:dist": "run-s build && exec-if-updated --source \"build/**\" --target \"dist/**\" --target \"dist\" \"run-s --silent \"_:update:dist:rebuild\"\"",
"## +:... == sub-scripts (may run 'visibly', but not user-facing)": "",
"+:coverage": "run-s \"+:regen:build+test:code\" && is-ci && run-s cov:send || run-s cov:view",
"+:coverage": "run-s build test:code && is-ci && run-s cov:send || run-s cov:view",
"+:max-node-8": "is-node-not-modern 10",
"+:min-node-10": "is-node-modern 10",
"+:regen:build": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/**\" run-p \"build:*\"",
"+:regen:build+test:code": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/**\" run-p \"build:*\" && run-s test:code",
"+:regen:update": "exec-if-updated --source \"build/**\" --target \"dist/**\" --target \"dist/cjs\" --target \"dist/esm\" --target \"dist/types\" run-s --silent _:update:dist.build _:update:dist.types _:update:dist.build _:update:dist.normalizeEOL _:update:dist.pack",
"+:regen:lint/build": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/**\" run-s lint \"+:regen:build\"",
"+:update:dist": "run-s --silent _:update:dist.build _:update:dist.types _:update:dist.normalizeEOL _:update:dist.pack",
"## _:... == sub-scripts ('hidden'; generally should be run 'silently' using `run-s/run-p --silent ...`": "",
"_:exists:git-changelog": "node -e \"if (!require('command-exists').sync('git-changelog')){process.exit(1);};\" || ( shx echo \"WARN `git-changelog` missing (try `go get -u github.com/rivy-go/git-changelog/cmd/git-changelog`)\" & exit 1 )",
"_:help": "< package.json node -e \"s = {p:'',e:'npm'}; if (new String(process.env.npm_execpath).match(/yarn.js$/)) { s = {p:'\\n',e:'yarn'}; }; console.log('%susage: \\`%s run TARGET\\` or \\`npx run-s TARGET [TARGET..]\\`\\n\\nTARGETs:\\n', s.p, s.e); re = /^.*?\\x22(?:\\W+\\s*)([^#\\x22]+)\\s+#+\\s+([^#\\x22]+?)(\\s+#+)?\\x22.*$/; require('readline').createInterface({ input: process.stdin, output: process.stdout, terminal: false }).on('line', function(line){ if (match = re.exec(line)) { console.log('%s %s', match[1].padEnd(19), match[2]); } });\"",
"_:if-newer:lint": "exec-if-updated --source package.json --source tsconfig.json --source \"tsconfig/**\" --source rollup.config.js --source \"src/**\" --target \"build/**\" --target build \"run-s --print-name lint\"",
"_:lint:commits.all:spell": "node -e \"result=require('child_process').spawnSync('git log --color=never | cspell stdin --no-summary --config \".vscode/cspell.json\"',{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[cspell] ERR! Unknown words in commit(s)\\n'+result.stdout); process.exit(1);} else {console.log(result.stdout);};\"",
"_:lint:commits.new:commitlint": "node -e \"v=require('./package.json').version; result=require('child_process').spawnSync('commitlint --config .commitlint.config.js --from v'+v,{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[commitlint] ERR! Flawed commit(s) found\\n'+result.stdout+'\\n'+result.stderr); process.exit(1);} else {console.log(result.stdout);};\"",
"_:lint:commits.new:spell": "node -e \"v=require('./package.json').version; result=require('child_process').spawnSync('git log v'+v+'.. --color=never | cspell stdin --no-summary --config \".vscode/cspell.json\"',{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[cspell] ERR! Unknown words in commit(s)\\n'+result.stdout); process.exit(1);} else {console.log(result.stdout);};\"",
Expand All @@ -134,16 +134,18 @@
"_:update:dist.normalizeEOL": "eolConverter lf dist/**/*.{cjs,js,mjs,ts,json}",
"_:update:dist.pack": "node -e \"name=require('./package.json').name; result=require('child_process').spawnSync('npm pack && shx mkdir -p dist && shx mv '+name+'-*.tgz dist/'+name+'.tgz',{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('[update] ERR! Unable to package (into *.tgz) for distribution\\n'+result.stdout); process.exit(1);} else {console.log(result.stdout);};\"",
"_:update:dist.types": "shx mkdir -p dist && shx rm -fr dist/types && shx cp -r build/types dist",
"_:update:dist:rebuild": "shx rm -fr dist && run-s --silent _:update:dist.build _:update:dist.types _:update:dist.normalizeEOL _:update:dist.pack",
"_:version:spell:changelog_update": "run-s --silent _:exists:git-changelog && git changelog -u | cspell stdin --config \".vscode/cspell.json\" || shx echo \"[lint] WARN CHANGELOG update `cspell` exception\" 1>&2",
"_:version:update:changelog": "run-s --silent _:exists:git-changelog && node -e \"v=require('./package.json').version; result=require('child_process').spawnSync('git changelog --next-tag v'+v,{shell:true,encoding:'utf-8'}); if (result.status != 0) {console.error('ERR! '+result.stderr); process.exit(1);} else {require('fs').writeFileSync('CHANGELOG.mkd',result.stdout);};\" || shx echo \"[version] WARN CHANGELOG not updated\" 1>&2",
"## lifecycle scripts ##": "",
"prepublishOnly": "npm run test --test-for-dist && run-s --silent _:update:changelog _:update:dist.build _:update:dist.normalizeEOL && run-s --silent _:vcs-strictly-clean-err",
"preversion": "npm run test --test-for-dist && run-s --silent _:version:spell:changelog_update && run-s --silent _:vcs-strictly-clean-err",
"version": "run-s --silent _:version:update:changelog && run-s lint:spell \"+:update:dist\" && git add CHANGELOG.mkd dist"
"preversion": "run-s --silent _:version:spell:changelog_update && npm run test --test-for-dist",
"version": "run-s --silent _:version:update:changelog && run-s lint:spell && run-s --silent update:dist && git add CHANGELOG.mkd dist"
},
"dependencies": {
"os-paths": "^6.2.0"
},
"devDependencies:#": "* for testing, Node-v6 requires ava < v2 and nyc < v15",
"devDependencies": {
"@ava/typescript": "^1.1.1",
"@commitlint/cli": "^11.0.0",
Expand Down

0 comments on commit 53c494d

Please sign in to comment.