From 57c091b0c09c409c6b650570284f3b02970e3612 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Tue, 30 Jul 2024 12:32:13 +0200 Subject: [PATCH] Force corepack usage --- .github/workflows/ci.js.yml | 8 ++++---- .github/workflows/pr.ci.js.yml | 8 ++++---- Dockerfile | 12 ++++++------ README.md | 6 +++--- bin/check-formatting.sh | 28 ++++++++++++++-------------- bin/format.sh | 28 ++++++++++++++-------------- bin/lint.sh | 2 +- bin/test.sh | 4 ++-- package.json | 16 ++++++++-------- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.js.yml b/.github/workflows/ci.js.yml index f86ae3f..3a8bd26 100644 --- a/.github/workflows/ci.js.yml +++ b/.github/workflows/ci.js.yml @@ -21,8 +21,8 @@ jobs: - name: Install project dependencies run: | corepack enable yarn - yarn -v - yarn install --immutable + corepack yarn -v + corepack yarn install --immutable - name: Run exercism/typescript-test-runner ci precheck (lint code) run: bin/lint.sh @@ -44,8 +44,8 @@ jobs: - name: Install project dependencies run: | corepack enable yarn - yarn -v - yarn install --immutable + corepack yarn -v + corepack yarn install --immutable - name: Build the test-runner (using Node ${{ matrix.node-version }}) run: bin/test.sh diff --git a/.github/workflows/pr.ci.js.yml b/.github/workflows/pr.ci.js.yml index 9f503e5..d80390e 100644 --- a/.github/workflows/pr.ci.js.yml +++ b/.github/workflows/pr.ci.js.yml @@ -21,8 +21,8 @@ jobs: - name: Install project dependencies run: | corepack enable yarn - yarn -v - yarn install --immutable + corepack yarn -v + corepack yarn install --immutable - name: Run exercism/javascript ci precheck (lint code) run: bin/lint.sh @@ -46,8 +46,8 @@ jobs: - name: Install project dependencies run: | corepack enable yarn - yarn -v - yarn install --immutable + corepack yarn -v + corepack yarn install --immutable - name: Build the test-runner (using Node ${{ matrix.node-version }}) run: bin/test.sh diff --git a/Dockerfile b/Dockerfile index 570a184..bbf16c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,15 +40,15 @@ RUN chmod 555 /idk/corepack # Build the test runner RUN set -ex; \ # install all the development modules (used for building) - yarn cache clean; \ - yarn install; \ - yarn build; - # yarn cache clean; \ + corepack yarn cache clean; \ + corepack yarn install; \ + corepack yarn build; + # corepack yarn cache clean; \ # # install only the node_modules we need for production # I don't know how to get this to work with zero-installs enabled # - # TODO: yarn workspaces focus --production; + # TODO: corepack yarn workspaces focus --production; # Disable network for corepack ENV COREPACK_ENABLE_NETWORK=0 @@ -59,6 +59,6 @@ ENV YARN_ENABLE_OFFLINE_MODE=1 ENV YARN_ENABLE_HARDENED_MODE=0 # Let's check to be certain -RUN yarn --version +RUN corepack yarn --version ENTRYPOINT [ "/opt/test-runner/bin/run.sh" ] diff --git a/README.md b/README.md index 42d1404..f49ceb5 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ corepack yarn build If you're developing this, you can run this via `yarn` or the provided shell script. -- `.sh` enabled systems (UNIX, WSL): `yarn execute:dev` +- `.sh` enabled systems (UNIX, WSL): `corepack yarn execute:dev` - `.bat` fallback (cmd.exe, Git Bash for Windows): _unsupported_ You'll want these `:dev` variants because it will _build_ the required code (it will transpile from TypeScript to JavaScript, which is necessary to run this in Node environments, unlike Deno environments). @@ -34,7 +34,7 @@ When on Windows, if you're using Git Bash for Windows or a similar terminal, the The `.bat` scripts will work in the same terminal. In this case it might be much easier to run `bin/run.sh` directly, so a new shell won't open. -You can also manually build using `yarn` or `yarn build`, and then run the script directly: `./bin/run.sh arg1 arg2 arg3`. +You can also manually build using `corepack yarn` or `corepack yarn build`, and then run the script directly: `./bin/run.sh arg1 arg2 arg3`. ## Running the Solution's Tests @@ -120,7 +120,7 @@ corepack yarn dlx @yarnpkg/sdks vscode ### Testing Running the tests of the test-runner itself can be achieved by using the `test` script from `package.json`. -The tests delegate to the _build output_, which is why `yarn test` first calls `yarn build` before running `jest`. +The tests delegate to the _build output_, which is why `corepack yarn test` first calls `corepack yarn build` before running `corepack yarn test:bare`. **The tests take over a minute to run on a decent machine**. [web-exercism]: https://exercism.io diff --git a/bin/check-formatting.sh b/bin/check-formatting.sh index 7d6d859..30a5615 100755 --- a/bin/check-formatting.sh +++ b/bin/check-formatting.sh @@ -6,14 +6,14 @@ corepack enable yarn if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "[format] pulling prettier version from yarn.lock using sed" - EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" + EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" fi if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "Version could not be pulled using sed" >&2 echo "[format] pulling prettier version from yarn.lock using grep" - EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" + EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" fi @@ -24,23 +24,23 @@ if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work." echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance." echo "---------------------------------------------------" - echo "$(yarn -v)" + echo "$(corepack yarn -v)" echo "" - echo "This is what yarn why reports:" - echo "$ yarn why prettier" - echo "$(yarn why prettier)" + echo "This is what corepack yarn why reports:" + echo "$ corepack yarn why prettier" + echo "$(corepack yarn why prettier)" echo "" - echo "And yarn info reports the following:" - echo "$ yarn info prettier --name-only" - echo "$(yarn info prettier --name-only)" + echo "And corepack yarn info reports the following:" + echo "$ corepack yarn info prettier --name-only" + echo "$(corepack yarn info prettier --name-only)" echo "" echo "This is the version that can be extracted using grep:" - echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'" - echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" + echo "$ corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'" + echo "└─ $(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" echo "" echo "This is the version that can be extracted using sed:" - echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'" - echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" + echo "$ corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'" + echo "└─ $(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" echo "" echo "These files are found in the repo root:" echo "$(ls -p | grep -v /)" @@ -50,4 +50,4 @@ else echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION" fi -yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" +corepack yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" diff --git a/bin/format.sh b/bin/format.sh index f074529..e42a34c 100755 --- a/bin/format.sh +++ b/bin/format.sh @@ -6,14 +6,14 @@ corepack enable yarn if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "[format] pulling prettier version from yarn.lock using sed" - EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" + EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" fi if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "Version could not be pulled using sed" >&2 echo "[format] pulling prettier version from yarn.lock using grep" - EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" + EXERCISM_PRETTIER_VERSION="$(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}" fi @@ -24,23 +24,23 @@ if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work." echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance." echo "---------------------------------------------------" - echo "$(yarn -v)" + echo "$(corepack yarn -v)" echo "" - echo "This is what yarn why reports:" - echo "$ yarn why prettier" - echo "$(yarn why prettier)" + echo "This is what corepack yarn why reports:" + echo "$ corepack yarn why prettier" + echo "$(corepack yarn why prettier)" echo "" - echo "And yarn info reports the following:" - echo "$ yarn info prettier --name-only" - echo "$(yarn info prettier --name-only)" + echo "And corepack yarn info reports the following:" + echo "$ corepack yarn info prettier --name-only" + echo "$(corepack yarn info prettier --name-only)" echo "" echo "This is the version that can be extracted using grep:" - echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'" - echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" + echo "$ corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'" + echo "└─ $(corepack yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')" echo "" echo "This is the version that can be extracted using sed:" - echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'" - echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" + echo "$ corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'" + echo "└─ $(corepack yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')" echo "" echo "These files are found in the repo root:" echo "$(ls -p | grep -v /)" @@ -50,4 +50,4 @@ else echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION" fi -yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" +corepack yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}" diff --git a/bin/lint.sh b/bin/lint.sh index d47efd4..3e9b972 100755 --- a/bin/lint.sh +++ b/bin/lint.sh @@ -3,4 +3,4 @@ set -euo pipefail corepack enable yarn -yarn lint +corepack yarn lint diff --git a/bin/test.sh b/bin/test.sh index 2bdcb71..0af956b 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -3,5 +3,5 @@ set -euo pipefail corepack enable yarn -yarn build || exit -yarn test:bare +corepack yarn build || exit +corepack yarn test:bare diff --git a/package.json b/package.json index b17b590..73a501a 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,15 @@ "bin": "bin/run.sh", "scripts": { "execute": "./bin/run.sh", - "execute:dev": "yarn build && yarn execute", + "execute:dev": "corepack yarn build && corepack yarn execute", "prebuild": "rimraf ./dist", - "build": "yarn tsc --project ./src/tsconfig.json --outDir ./dist", - "watch": "yarn build -w", - "prepack": "yarn build", - "prepublish": "yarn test:bare && yarn lint", - "lint": "yarn eslint src -c eslint.config.mjs && yarn eslint test -c eslint.config.mjs", - "test": "yarn build && yarn test:bare", - "test:bare": "yarn node test/smoke.test.mjs && yarn node test/skip.test.mjs && yarn node test/import.test.mjs" + "build": "corepack yarn tsc --project ./src/tsconfig.json --outDir ./dist", + "watch": "corepack yarn build -w", + "prepack": "corepack yarn build", + "prepublish": "corepack yarn test:bare && corepack yarn lint", + "lint": "corepack yarn eslint src -c eslint.config.mjs && corepack yarn eslint test -c eslint.config.mjs", + "test": "corepack yarn build && corepack yarn test:bare", + "test:bare": "corepack yarn node test/smoke.test.mjs && corepack yarn node test/skip.test.mjs && corepack yarn node test/import.test.mjs" }, "dependencies": { "@exercism/babel-preset-typescript": "^0.5.0",