diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ed56c6619..c84e9b688 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -33,12 +33,7 @@ First, you will want to check out `igir`'s source code from GitHub: git clone https://github.com/emmercm/igir.git ``` -`igir` is written in TypeScript for the Node.js runtime. The current version of Node.js that `igir` uses is defined in the `.nvmrc` file. After [installing](https://github.com/nvm-sh/nvm#installing-and-updating), nvm will let you easily switch to the correct Node.js version: - -```shell -nvm install -nvm use -``` +`igir` is written in TypeScript for the Node.js runtime. The current version of Node.js that `igir` uses is defined under the `"volta"` object in the `package.json` file. After [installing](https://docs.volta.sh/guide/getting-started), Volta will make sure you're always using the correct Node.js version. Third-party dependencies are managed and easily installed with npm: diff --git a/.github/renovate.json5 b/.github/renovate.json5 index f7d576378..745d3d486 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -165,7 +165,7 @@ // Everything else { - matchDepTypes: ['optionalDependencies', 'peerDependencies', 'engines', 'volta'], + matchDepTypes: ['optionalDependencies', 'peerDependencies', 'engines'], enabled: false, }, ], diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 704d87182..5071ee63b 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -33,10 +33,7 @@ jobs: steps: # Setup and install - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci # Run test coverage diff --git a/.github/workflows/gh-release-drafter.yml b/.github/workflows/gh-release-drafter.yml index 3edc784ad..e2f54400c 100644 --- a/.github/workflows/gh-release-drafter.yml +++ b/.github/workflows/gh-release-drafter.yml @@ -45,10 +45,7 @@ jobs: file-url: ${{ github.event_name == 'workflow_dispatch' && 'https://unpkg.com/igir/package.json' || '' }} - if: steps.check.outputs.changed == 'true' - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + uses: volta-cli/action@v4 - if: steps.check.outputs.changed == 'true' run: npm ci diff --git a/.github/workflows/node-compile.yml b/.github/workflows/node-compile.yml index cc8fe23e1..149a8d4b0 100644 --- a/.github/workflows/node-compile.yml +++ b/.github/workflows/node-compile.yml @@ -61,7 +61,7 @@ jobs: echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}" cp package.json build/ docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \ - "node:$(cat .nvmrc)" sh -c \ + "node:$(jq --raw-output '.volta.node' package.json)" sh -c \ "./node_modules/.bin/caxa --input build/ --output igir -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/index.js\" && ./igir --help" tar cvf - igir | gzip --best > "${BIN_OUTPUT}" - os: ubuntu @@ -73,7 +73,7 @@ jobs: echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}" cp package.json build/ docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \ - "node:$(cat .nvmrc)" sh -c \ + "node:$(jq --raw-output '.volta.node' package.json)" sh -c \ "./node_modules/.bin/caxa --input build/ --output igir -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/index.js\" && ./igir --help" tar cvf - igir | gzip --best > "${BIN_OUTPUT}" - os: ubuntu @@ -85,7 +85,7 @@ jobs: echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}" cp package.json build/ docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \ - "node:$(cat .nvmrc)" sh -c \ + "node:$(jq --raw-output '.volta.node' package.json)" sh -c \ "./node_modules/.bin/caxa --input build/ --output igir -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/index.js\" && ./igir --help" tar cvf - igir | gzip --best > "${BIN_OUTPUT}" # TODO(cemmer): macOS arm64: https://github.com/github/roadmap/issues/528 @@ -116,10 +116,7 @@ jobs: ref: ${{ env.ref }} - if: matrix.os == 'ubuntu' uses: docker/setup-qemu-action@v3 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci - run: npm run build # Compile and upload @@ -142,10 +139,7 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ env.ref }} - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci - run: echo "NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')" >> "${GITHUB_ENV}" # Download and update diff --git a/.github/workflows/node-publish.yml b/.github/workflows/node-publish.yml index 6a5ef5c4a..fcc6a61ce 100644 --- a/.github/workflows/node-publish.yml +++ b/.github/workflows/node-publish.yml @@ -20,10 +20,7 @@ jobs: pull-requests: write steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci - id: publish name: npm publish diff --git a/.github/workflows/node-test.yml b/.github/workflows/node-test.yml index 399651155..f067cfd08 100644 --- a/.github/workflows/node-test.yml +++ b/.github/workflows/node-test.yml @@ -41,10 +41,7 @@ jobs: steps: # Setup and install - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci # Lint the source files - run: npm start -- --help @@ -61,15 +58,13 @@ jobs: strategy: matrix: os: [ ubuntu, macos, windows ] - node-version: [ lts/*, lts/-1, 16.6.0 ] + node-version: [ lts, 18, 16.6.0 ] steps: # Setup and install - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + - uses: volta-cli/action@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - run: npm ci # Test the source files - run: npm run test:unit @@ -81,15 +76,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [ lts/*, lts/-1, 16.6.0 ] + node-version: [ lts, 18, 16.6.0 ] steps: # Setup and install - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + - uses: volta-cli/action@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - run: npm ci # Test the built files - run: npm run build @@ -106,10 +99,7 @@ jobs: steps: # Setup and install - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci # Test building - run: npm run build @@ -121,14 +111,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [ lts/*, lts/-1, 16.6.0 ] + node-version: [ lts, 18, 16.6.0 ] steps: # Setup and install - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: volta-cli/action@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - run: npm ci # Test the packaging - run: | diff --git a/.github/workflows/node-version-bump.yml b/.github/workflows/node-version-bump.yml index e98f11e18..77b2c8a86 100644 --- a/.github/workflows/node-version-bump.yml +++ b/.github/workflows/node-version-bump.yml @@ -28,10 +28,7 @@ jobs: steps: # Setup and install - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache: 'npm' + - uses: volta-cli/action@v4 - run: npm ci # Bump the version and commit to the default branch diff --git a/.github/workflows/pr-commenter.yml b/.github/workflows/pr-commenter.yml index 969bfee39..4f630ca6e 100644 --- a/.github/workflows/pr-commenter.yml +++ b/.github/workflows/pr-commenter.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ ubuntu, macos, windows ] steps: - - uses: actions/setup-node@v3 + - uses: volta-cli/action@v4 - env: # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable HEAD_REF: ${{ github.event.pull_request.head.ref }} diff --git a/.husky/pre-commit b/.husky/pre-commit index 7614e23ba..049512be3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -5,17 +5,7 @@ # Change to the project's root directory cd "$(dirname -- "$0")/.." || exit 1 -# Ensure node is available (same as asciinema-rec.sh) -if [ ! -x "$(command -v node)" ]; then - if [ ! -x "$(command -v nvm)" ] && [ -f ~/.nvm/nvm.sh ]; then - # shellcheck disable=SC1090,SC2240 - . ~/.nvm/nvm.sh --install - fi - if [ ! -x "$(command -v nvm)" ]; then - nvm install || true - nvm use || exit 1 - fi -fi +# Ensure node is available node --version > /dev/null 2>&1 || exit 1 # Ensure node modules are installed diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index f3f52b42d..000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.9.0 diff --git a/package.json b/package.json index a69362c61..26f774f64 100644 --- a/package.json +++ b/package.json @@ -139,5 +139,8 @@ ], "engines": { "node": ">=16.6.0" + }, + "volta": { + "node": "20.9.0" } } diff --git a/scripts/asciinema-rec.sh b/scripts/asciinema-rec.sh index 4d0a4e1dd..f408939a3 100755 --- a/scripts/asciinema-rec.sh +++ b/scripts/asciinema-rec.sh @@ -75,16 +75,7 @@ if [[ ! -x "$(command -v pv)" ]]; then exit 1 fi -# Ensure node is available (same as .husky/pre-commit) -if [[ ! -x "$(command -v node)" ]]; then - if [[ ! -x "$(command -v nvm)" && -f ~/.nvm/nvm.sh ]]; then - # shellcheck disable=SC1090 - . ~/.nvm/nvm.sh - fi - if [[ ! -x "$(command -v nvm)" ]]; then - nvm use || exit 1 - fi -fi +# Ensure node is available npm --version &> /dev/null || exit 1 # Make sure we're using the latest version