diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index f4beb5d7..5475637d 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -68,7 +68,7 @@ jobs: key: ${{ runner.os }}-node-${{ needs.prepare-node.outputs.build-node-version }}-${{ env.GITHUB_SHA }} - run: yarn install - - run: yarn test-e2e:build + - run: npm run test-e2e:build unit-test-and-package-test: name: Unit Test & Package Test diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cb3db89..e4695bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 3.0.1 + - Added `ensure-npm` developer script + - Dependency updates + ### 3.0.0 - BREAKING CHANGE: Drops support for Node 14 - Adds support for Node 20 and Node 22 diff --git a/dev/ensure-npm.mjs b/dev/ensure-npm.mjs new file mode 100755 index 00000000..20520baf --- /dev/null +++ b/dev/ensure-npm.mjs @@ -0,0 +1,25 @@ +import readline from 'node:readline/promises' +import { stdin as input, stdout as output } from 'node:process' + +const agent = process.env.npm_config_user_agent + +// word boundary + "npm/" + a digit +const npmVersionRegEx = /\bnpm\/\d/ + +if (!agent?.match(npmVersionRegEx)) { + console.log('You do not appear to be using `npm` as your Node package manager. Are you using `yarn`? Try the same command with `npm`.') + process.exit(1) +} + +(async () => { + + const rl = readline.createInterface({ input, output }) + + const answer = await rl.question('Are you running "npm publish" or did you pack using "npm"? That\'s "npm" instead of "yarn". Very important!!! [Yy]') + rl.close() + + if (answer?.toLowerCase() !== 'y') { + console.log('You must use `npm` (and not `yarn`) for this command.') + process.exit() + } +})() diff --git a/package.json b/package.json index 23680102..2cb3f133 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spectaql", - "version": "3.0.0", + "version": "3.0.1", "description": "A powerful library for autogenerating static GraphQL API documentation", "author": "Anvil Foundry Inc. ", "homepage": "https://github.com/anvilco/spectaql", @@ -56,7 +56,7 @@ "clean-build:vendor": "npm run clean:vendor && npm run build:vendor", "clean-build": "npm run clean && npm run build", "prepack": "husky install && npm run ensure-npm && npm run clean-build", - "ensure-npm": "read -p \"Are you running \\\"npm publish\\\" or did you pack using \\\"npm\\\"? That's \\\"npm\\\" instead of \\\"yarn\\\". Very important!!! [Yy]\" -n 1 -r; if [[ ! $REPLY =~ ^[Yy]$ ]]\nthen\n[[ \"$0\" = \"$BASH_SOURCE\" ]] && exit 1 || return 1\nfi", + "ensure-npm": "node dev/ensure-npm.mjs", "publish:dry-run": "npm pack --dry-run", "publish:version": "npm version", "publish:beta": "npm publish --tag beta",