Skip to content

Commit 7d7cdde

Browse files
yinzaraclaude
andcommitted
build!: drop Node.js 18 support and modernize the dev toolchain
Raise the supported Node.js baseline to >= 20 and bring the test, git-hook, coverage and dependency toolchain up to currently-maintained versions. Several dependency upgrades (notably glob 13 and pnpm 10+) surfaced latent runtime bugs, which are fixed here as well. Runtime fixes ------------- * config discovery (src/configLoader/findup.js): switch to the named `import { globSync } from 'glob'`. glob v9+ removed the default export, so with glob 13 `glob` resolved to `undefined` and every config lookup threw `TypeError: Cannot read properties of undefined (reading 'sync')`. * `commitizen init --pnpm` (src/commitizen/init.js, src/commitizen/adapter.js): - forward the `exact` option into `getInstallStringMappings()` and key the pnpm `--save-exact` flag off `exact` instead of `saveExact` (which is never set on the pnpm path). `commitizen init --pnpm --save-exact` now pins an exact version instead of silently writing a caret range. - pass `--ignore-scripts` to the pnpm install. pnpm >= 10 turns "ignored build scripts" (ERR_PNPM_IGNORED_BUILDS) into a fatal error, which aborted the install before `config.commitizen.path` was written. Commitizen adapters never need their dependencies' lifecycle scripts. Dependency upgrades ------------------- * mocha 9.2.2 -> 12.0.0 * nyc 15.1.0 -> 18.0.0 * babel-plugin-istanbul 6.1.1 -> 7.0.1 * nodemon 2.0.22 -> 3.1.14 * sinon 12.0.1 -> 22.1.0 * uuid 8.3.2 -> 11.1.1 * conventional-changelog-conventionalcommits 4.6.3 -> 7.0.2 * glob 7.2.3 -> 13.0.6 (runtime dependency) * fs-extra 9.1.0 -> 11.4.0 (runtime dependency) * find-node-modules ^2.1.2 -> ^2.1.3 (runtime dependency) Dependency removals and replacements ------------------------------------ * ghooks -> husky 9. Drop the `config.ghooks` block, add `.husky/pre-commit` (`npm run test && npm run check-coverage`), and run `husky` from the `prepare` script. Replace the `in-publish` / `not-in-install` build-on- publish hack with a standard `prepublishOnly` script; `in-publish` removed. * Remove `codecov`. The npm `codecov` uploader is end-of-life and the `report-coverage` script was unused: Azure Pipelines already publishes coverage from `npm run write-coverage` (cobertura). Stale `codecov.io` and `travis.ci` badges removed from the README. * Remove `mocha-multi-reporters` and `mocha-junit-reporter`. Both are unmaintained and throw "Class constructor Base cannot be invoked without 'new'" on mocha >= 11. Replaced with a small in-repo composite reporter, test/reporters/multi-reporter.cjs, that drives mocha's built-in `spec` and `xunit` reporters from a single run and fans `done()` out to flush the JUnit XML file. `test/mochareporters.json` deleted. Test harness ------------ * `test-actual` now runs `mocha --require @babel/register ...` directly, so it works when invoked on its own and not only through the `nyc` wrapper. The test files use extensionless ESM imports that only resolve once Babel rewrites them to `require`. * JUnit output is written to `./junit-testresults.xml` via `--reporter-option output=`; added to `.gitignore`. * test/tools/clean.js: the per-test artifact archive no longer copies `node_modules`. It is large and slow, and on Windows pnpm's nested junctions under `.pnpm` make a later recursive walk of `test/artifacts` (Azure's PublishTestResults glob) fail with `EPERM: operation not permitted, stat`. * babel.config.js: `@babel/preset-env` target bumped from node 10 to node 20. CI -- jobs/build.yml: * Node matrix is now 20, 22, 24 and 26 (Node 18 removed); `maxParallel` 3 -> 4. * Node install task `NodeTool@0` -> `UseNode@1`. * pnpm bumped 9 -> 12. * PublishTestResults@2 now points at the exact `junit-testresults.xml` under `$(System.DefaultWorkingDirectory)` instead of the recursive `**/junit-*.xml` glob, so it never walks the artifacts tree (which is what triggered the Windows `EPERM: operation not permitted, stat` failure on pnpm's `.pnpm` junctions). * PublishCodeCoverageResults@1 -> @2; drop the removed `codeCoverageTool` input and point `summaryFileLocation` at the single `$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml` rather than a recursive glob. Housekeeping ------------ * .gitignore: add `.idea`, `.omc`, `junit-testresults.xml`. * package-lock.json regenerated. BREAKING CHANGE: Node.js 18 is no longer supported. The minimum supported runtime is now Node.js 20 (`engines.node` is `>= 20`), and npm 9 or newer is recommended. Installing or running commitizen on Node.js 18 or earlier will fail the engine check. This is required because upgraded tooling and transitive dependencies (mocha 12, nyc 18, glob 13's `minimatch`/`lru-cache`, and the pnpm 10+ CLI used in CI) have themselves dropped Node.js 18. Fixes #1020, fixes #1006 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 1a8c49c commit 7d7cdde

13 files changed

Lines changed: 2955 additions & 12636 deletions

File tree

‎.gitignore‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ artifacts/
66
npm-debug.log
77
.nyc_output
88
test/tools/trigger-appveyor-tests.sh
9-
logo/*.png
9+
logo/*.png
10+
.idea
11+
.omc
12+
junit-testresults.xml

‎.husky/pre-commit‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run test && npm run check-coverage

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
When you commit with Commitizen, you'll be prompted to fill out any required commit fields at commit time. No more waiting until later for a git commit hook to run and reject your commit (though [that](https://github.com/kentcdodds/validate-commit-msg) can still be helpful). No more digging through [CONTRIBUTING.md](CONTRIBUTING.md) to find what the preferred format is. Get instant feedback on your commit message formatting and be prompted for required fields.
44

5-
[![Backers on Open Collective](https://opencollective.com/commitizen/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/commitizen/sponsors/badge.svg)](#sponsors) [![travis.ci](https://img.shields.io/travis/commitizen/cz-cli.svg?branch=master)](https://travis-ci.org/commitizen/cz-cli) [![Azure Build Status](https://dev.azure.com/commitizen/cz-cli/_apis/build/status/commitizen.cz-cli?branchName=master)](https://dev.azure.com/commitizen/cz-cli/_build/latest?definitionId=2)
6-
[![codecov.io](https://img.shields.io/codecov/c/github/commitizen/cz-cli.svg)](https://codecov.io/github/commitizen/cz-cli?branch=master) [![npm monthly downloads](https://img.shields.io/npm/dm/commitizen.svg)](https://www.npmjs.com/package/commitizen) [![current version](https://img.shields.io/npm/v/commitizen.svg)](https://www.npmjs.com/package/commitizen) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![commitizen on stackoverflow](https://img.shields.io/badge/stackoverflow-community-orange.svg?longCache=true&logo=stackoverflow)](https://stackoverflow.com/tags/commitizen)
5+
[![Backers on Open Collective](https://opencollective.com/commitizen/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/commitizen/sponsors/badge.svg)](#sponsors) [![Azure Build Status](https://dev.azure.com/commitizen/cz-cli/_apis/build/status/commitizen.cz-cli?branchName=master)](https://dev.azure.com/commitizen/cz-cli/_build/latest?definitionId=2)
6+
[![npm monthly downloads](https://img.shields.io/npm/dm/commitizen.svg)](https://www.npmjs.com/package/commitizen) [![current version](https://img.shields.io/npm/v/commitizen.svg)](https://www.npmjs.com/package/commitizen) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![commitizen on stackoverflow](https://img.shields.io/badge/stackoverflow-community-orange.svg?longCache=true&logo=stackoverflow)](https://stackoverflow.com/tags/commitizen)
77

88
## Installing the command line tool
99

10-
Commitizen is currently tested against Node.js 12, 14, & 16, although it may work in
11-
older versions of Node.js. You should also have npm 6 or greater.
10+
Commitizen is currently tested against Node.js 20, 22, 24 & 26, although it may work in
11+
older versions of Node.js. You should also have npm 9 or greater.
1212

1313
Installation is as simple as running the following command (if you see `EACCES` error, reading [fixing npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions) may help):
1414

‎babel.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
"@babel/preset-env",
55
{
66
targets: {
7-
node: "10",
7+
node: "20",
88
},
99
},
1010
],

‎jobs/build.yml‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ jobs:
99
- job: ${{ parameters.name }}
1010
pool: ${{ parameters.pool }}
1111
strategy:
12-
maxParallel: 3
12+
maxParallel: 4
1313
matrix:
14+
node-26:
15+
node_version: ^26.8.1
16+
node-24:
17+
node_version: ^24.20.0
1418
node-22:
15-
node_version: ^22.11.0
19+
node_version: ^22.23.2
1620
node-20:
17-
node_version: ^20.9.0
18-
node-18:
19-
node_version: ^18.12.0
21+
node_version: ^20.20.2
2022
steps:
21-
- task: NodeTool@0
22-
displayName: " Install Node.js"
23+
- task: UseNode@1
24+
displayName: "Install Node.js"
2325
inputs:
24-
versionSpec: $(node_version)
26+
version: $(node_version)
2527
- script: git config --global user.email "example@example.com"
2628
- script: git config --global user.name "Example Git User"
27-
- script: npm install -g pnpm@9
29+
- script: npm install -g pnpm@12
2830
displayName: "Setup pnpm"
2931
- script: npm install
3032
- script: npm run build
@@ -34,13 +36,13 @@ jobs:
3436
- task: PublishTestResults@2
3537
displayName: 'Publish Test Results'
3638
inputs:
37-
testResultsFiles: '**/junit-*.xml'
39+
testResultsFiles: 'junit-testresults.xml'
40+
searchFolder: '$(System.DefaultWorkingDirectory)'
3841
testRunTitle: TestRun ${{ parameters.name }} $(node_version)
39-
- task: PublishCodeCoverageResults@1
42+
- task: PublishCodeCoverageResults@2
4043
displayName: 'Publish code coverage results'
4144
inputs:
42-
codeCoverageTool: 'cobertura'
43-
summaryFileLocation: '**/coverage/cobertura-coverage.xml'
45+
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
4446
- task: PublishBuildArtifacts@1
4547
displayName: Publish packages
4648
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))

0 commit comments

Comments
 (0)