Skip to content

Commit

Permalink
Npm script workspaces fail fast (#1249)
Browse files Browse the repository at this point in the history
* make a command which goes through each workspace member in turn and runs a command, failing as soon as an error is hit

* convert build all and test all scripts to fail immediately if error hit

* make lint commands use fail-fast workspace command

---------

Co-authored-by: Chris <forgetso86@gmail.com>
  • Loading branch information
goastler and forgetso committed May 27, 2024
1 parent 39a9767 commit a6e18d4
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"scripts": {
"hostid": "npm run cmd -- \"dig +short %s.prosopo.io | tail -n1 | tee /dev/tty | nslookup | cut -d = -f 2 | head -n1 | cut -d ' ' -f 2 | sed 's/\\.*$//g'\"",
"about:cmd": "perform string substitution on the command and then execute it. Make sure to use --, e.g. npm run cmd -- my args here",
"cmd:about": "perform string substitution on the command and then execute it. Make sure to use --, e.g. npm run cmd -- my args here",
"cmd": "f() { cmd=$1; shift; cmd=$(printf \"$cmd\" $@); echo exec: $cmd; echo; eval $cmd; }; f",
"build": "npm run cmd -- \"npm run -w @prosopo/%s build\"",
"build:contracts": "cd protocol/dev && npm run build && npm run cli -- build --docker && cd ../..",
"build:typechain": "npm run build:contracts && cd dev/scripts && npm run build && npm run cli -- import_all_contracts && cd ../.. && npm run lint:fix:contracts",
"build:all": "npm run --workspaces --if-present build",
"build:all:cjs": "npm run --workspaces --if-present build:cjs",
"build:all": "npm run ws -- --if-present build",
"build:all:cjs": "npm run ws -- --if-present build:cjs",
"build:provider-gui": "npm run -w @prosopo/provider-gui build",
"build:bundle": "npm run -w @prosopo/procaptcha-bundle bundle:dev",
"rebuild": "f() { npm run cmd -- \"npm run clean %s\" $@ ; npm run cmd -- \"npm run build %s\" $@ ;}; f",
Expand All @@ -31,7 +31,9 @@
"version": "f() { npm run -w @prosopo/scripts cli -- version -v $@; npm i; }; f",
"publish:dry-run": "npm --workspaces publish --dry-run",
"publish": "npm --workspaces publish --access=public",
"ls:ws": "npm run --workspaces env | grep npm_package_name | cut -d '=' -f 2",
"ws:ls": "npm run --workspaces env | grep npm_package_name | cut -d '=' -f 2",
"ws:about": "run a command for each workspace member, exiting immediately if any command fails. Don't forget the `--` !",
"ws": "f() { set -e; npm run --silent ws:ls | while read -r line; do echo $line; npm run -w $line $@; done; }; f",
"cli": "npm -w @prosopo/cli run cli",
"setup": "npm -w @prosopo/scripts run setup",
"setup:all": "npm run deploy_protocol && npm run setup",
Expand All @@ -44,27 +46,27 @@
"start:all": "npx concurrently \"npm run start:server\" \"npm run start:provider\" \"npm run start:demo\" \"npm run start:bundle\" --kill-others",
"start:all:pow": "npx concurrently \"npm run start:server\" \"npm run start:provider\" \"npm run start:demo:pow\" \"npm run start:bundle\" --kill-others",
"populate-data": "npm -w @prosopo/provider run populate-data",
"test": "npm run --workspaces test",
"test:all": "npm run --workspaces --if-present test",
"eslint": "npm --workspaces run eslint && npm run eslint:workspace",
"test": "npm run ws -- test",
"test:all": "npm run ws -- --if-present test",
"eslint": "npm run ws -- eslint && npm run eslint:workspace",
"eslint:workspace": "npm run eslint:cmd -- '.*.*' '*.*' .vscode .github ",
"eslint:cmd": "DEBUG=eslint:cli-engine npx eslint --ignore-path .eslintignore --no-error-on-unmatched-pattern",
"eslint:contracts": "npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run eslint",
"eslint:fix": "npm --workspaces run eslint:fix && npm run eslint:fix:workspace",
"eslint:fix": "npm run ws -- eslint:fix && npm run eslint:fix:workspace",
"eslint:fix:workspace": "npm run eslint:workspace -- --fix",
"eslint:fix:contracts": "npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run eslint:fix",
"prettier": "npm --workspaces run prettier && npm run prettier:workspace",
"prettier": "npm run ws -- prettier && npm run prettier:workspace",
"prettier:workspace": "npm run prettier:cmd -- '.*.*' '*.*' .vscode .github",
"prettier:cmd": "npx prettier --no-error-on-unmatched-pattern --check --ignore-path .eslintignore",
"prettier:contracts": "npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run prettier",
"prettier:fix": "npm --workspaces run prettier:fix && npm run prettier:fix:workspace",
"prettier:fix": "npm run ws -- prettier:fix && npm run prettier:fix:workspace",
"prettier:fix:workspace": "npm run prettier:workspace -- --write",
"prettier:fix:contracts": "npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run prettier:fix",
"lint": "npm run -w @prosopo/scripts license && npm --workspaces run lint && npm run lint:workspace",
"lint": "npm run -w @prosopo/scripts license && npm run ws -- lint && npm run lint:workspace",
"lint:cmd": "f() { npm run -w @prosopo/scripts license; npm run eslint:cmd -- $@; npm run prettier:cmd -- $@; }; f",
"lint:workspace": "npm run eslint:workspace && npm run prettier:workspace",
"lint:contracts": "npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run lint",
"lint:fix": "npm run -w @prosopo/scripts license:fix && npm --workspaces run lint:fix && npm run lint:fix:workspace",
"lint:fix": "npm run -w @prosopo/scripts license:fix && npm run ws -- lint:fix && npm run lint:fix:workspace",
"lint:fix:contracts": "npm run -w @prosopo/scripts license:fix && npm -w @prosopo/captcha-contract -w @prosopo/common-contract -w @prosopo/proxy-contract run lint:fix",
"lint:fix:workspace": "npm run eslint:fix:workspace && npm run prettier:fix:workspace",
"removePolkadotJSWarnings": "sed -i 's/console.warn\\(.*\\);//g' ./node_modules/@polkadot/util/versionDetect.js && sed -i 's/console.warn\\(.*\\);//g' ./node_modules/@polkadot/util/cjs/versionDetect.js || true",
Expand Down

0 comments on commit a6e18d4

Please sign in to comment.