commitizen 4.3.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,10 +16,13 @@ jobs:
16
16
  - uses: actions/checkout@v4
17
17
  - uses: actions/setup-node@v4
18
18
  with:
19
- cache: npm
20
- node-version: lts/*
21
- - run: npm install -g npm@latest
22
- - run: npm clean-install
23
- - run: npx semantic-release
19
+ # semantic-release 26 requires Node >= 26.13
20
+ node-version: 26
21
+ # npm@latest: releases are staged with `npm stage publish` (see
22
+ # "release" in package.json), signed in through npm trusted publishing
23
+ # (OIDC). A maintainer approves each staged version with 2FA.
24
+ - run: npm install -g npm@latest pnpm@12
25
+ - run: pnpm install --frozen-lockfile
26
+ - run: pnpm run semantic-release
24
27
  env:
25
28
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1 @@
1
+ pnpm test && pnpm run check-coverage
package/CONTRIBUTING.md CHANGED
@@ -1,37 +1,88 @@
1
1
  # Contribution guide
2
2
 
3
+ Thanks for considering a contribution to commitizen!
4
+
5
+ ## Prerequisites
6
+
7
+ * **Node.js 22.18+, 24.11+ or 26.** Developing commitizen needs a newer Node.js
8
+ than using it: Babel 8 requires `^22.18.0 || >=24.11.0`. Installing
9
+ commitizen itself only needs Node.js 22.13 or newer.
10
+ The supported development range is declared in `devEngines.runtime` in
11
+ `package.json`, and pnpm refuses to install with a Node.js outside it. If your
12
+ `node` is managed by pnpm, pnpm picks a matching version for this repository
13
+ automatically.
14
+ * **pnpm 12.** Install it with the [pnpm installation guide](https://pnpm.io/installation).
15
+ The exact version is pinned in the `packageManager` field of `package.json`.
16
+
17
+ You don't need npm or yarn installed. The tests that exercise
18
+ `commitizen init --npm/--yarn/--pnpm` use the npm and yarn versions pinned in
19
+ `devDependencies` (`npm-cli` and `yarn-cli`).
20
+
3
21
  ## Developing commitizen
4
22
 
5
- You consider contributing changes to commitizen – thank you!
6
- Please consider these guidelines when filing a pull request:
23
+ ```sh
24
+ pnpm install # also builds dist/ and installs the git hooks
25
+ pnpm build # rebuild dist/ from src/
26
+ pnpm test # full test suite with coverage
27
+ pnpm run check-coverage
28
+ pnpm run test:watch # re-run the tests when src/ or test/ changes (no coverage)
29
+ ```
30
+
31
+ * The test suite runs real `npm`, `yarn` and `pnpm` installs, so it needs
32
+ network access. Each run works in its own temporary directory under your OS
33
+ temp folder (`cz-cli-test-*`), so test runs can't interfere with each other or
34
+ with your checkout.
35
+ * Coverage must stay at 100% for statements, branches, functions and lines.
36
+ The pre-commit hook and CI both run `pnpm test && pnpm run check-coverage`.
37
+ * To make commits with commitizen itself, run `pnpm commit`.
38
+
39
+ ## Code guidelines
7
40
 
8
- * Commits follow the [Angular commit convention](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
9
- * JavaScript is written using ES2015 features
10
- * 2 spaces indentation
11
- * Features and bug fixes should be covered by test cases
41
+ * Commits follow [Conventional Commits](https://www.conventionalcommits.org/).
42
+ * Source in `src/` is modern JavaScript using ES module syntax. Babel compiles
43
+ it to **CommonJS** in `dist/`, and it has to stay CommonJS: adapters and other
44
+ consumers load commitizen with `require('commitizen')`.
45
+ * Import Node.js built-ins with the `node:` prefix (`import fs from 'node:fs'`).
46
+ * Prefer Node.js built-ins over adding a dependency.
47
+ * 2 spaces indentation.
48
+ * Features and bug fixes should be covered by tests.
12
49
 
13
50
  ## Creating releases
14
51
 
15
52
  commitizen uses [semantic-release](https://github.com/semantic-release/semantic-release)
16
- to release new versions automatically.
53
+ to release new versions automatically. The release workflow runs on Node.js 26,
54
+ which semantic-release requires.
17
55
 
18
- * Commits of type `fix` will trigger bugfix releases, think `0.0.1`
19
- * Commits of type `feat` will trigger feature releases, think `0.1.0`
20
- * Commits with `BREAKING CHANGE` in body or footer will trigger breaking releases, think `1.0.0`
56
+ * Commits of type `fix` will trigger bugfix releases, think `0.0.1`
57
+ * Commits of type `feat` will trigger feature releases, think `0.1.0`
58
+ * Commits with `BREAKING CHANGE` in body or footer will trigger breaking releases, think `1.0.0`
21
59
 
22
60
  All other commit types will trigger no new release.
23
61
 
24
- ## Gotchas
62
+ Releases are staged, not published straight to npm. When a release commit lands
63
+ on `master`, the release workflow tags the version, runs `npm stage publish`
64
+ (signed in through npm trusted publishing) and creates a draft GitHub release.
65
+ Nothing reaches npm until a maintainer with publish rights approves it with 2FA,
66
+ using npm 12 or newer:
67
+
68
+ ```sh
69
+ npm stage list commitizen
70
+ npm stage download <stage-id> # optional: inspect the tarball
71
+ npm stage approve <stage-id>
72
+ ```
73
+
74
+ Then publish the draft release at
75
+ https://github.com/commitizen/cz-cli/releases.
25
76
 
26
- ### Atom removes lines with just spaces, breaking tests
77
+ To abandon a staged version instead, run `npm stage reject <stage-id>`,
78
+ delete the draft release, and delete its tag (`git push origin :refs/tags/vX.Y.Z`)
79
+ so the next release can reuse the version.
80
+
81
+ ## Gotchas
27
82
 
28
- When using Atom, if you edit some of our tests, atom will remove the whitespace on some lines. Unfortunately we wanted this whitespace to
29
- able to test multiline commits and their difference across operating
30
- systems. Atom has decided to keep the stripping of whitespace as a
31
- default. Although we understand this decision, it has the unfortunate
32
- side effect of editing parts of the file that you might not have
33
- intended. We think this should be left up to more configurable tools
34
- like eslint.
83
+ ### Editors that strip trailing whitespace can break tests
35
84
 
36
- For now, in order to work around this, you can take the steps outlined
37
- [here](https://github.com/atom/whitespace/issues/10#issuecomment-85183781) to temporarily disable automatic whitespace removal in Atom.
85
+ Some tests deliberately contain lines with only whitespace, to check how
86
+ multiline commit messages behave across operating systems. If your editor
87
+ strips trailing whitespace on save, turn that off for `test/` before editing
88
+ those files, or the tests will change in ways you didn't intend.
package/README.md CHANGED
@@ -2,13 +2,12 @@
2
2
 
3
3
  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.
4
4
 
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)
7
7
 
8
8
  ## Installing the command line tool
9
9
 
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 requires Node.js 22.13 or newer and is tested against Node.js 22, 24 & 26.
12
11
 
13
12
  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):
14
13
 
@@ -173,12 +172,12 @@ For `husky` users, add the following configuration to the project's `package.jso
173
172
  Add the "Commitizen friendly" badge to your README using the following markdown:
174
173
 
175
174
  ```
176
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
175
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](https://commitizen.github.io/cz-cli/)
177
176
  ```
178
177
 
179
178
  Your badge will look like this:
180
179
 
181
- [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
180
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](https://commitizen.github.io/cz-cli/)
182
181
 
183
182
  It may also make sense to change your `README.md` or `CONTRIBUTING.md` files to include or link to the Commitizen project so that your new contributors may learn more about installing and using Commitizen.
184
183
 
@@ -280,6 +279,7 @@ We know that every project and build process has different requirements, so we'v
280
279
  - [cz-emoji-conventional](https://www.npmjs.com/package/cz-emoji-conventional)
281
280
  - [cz-git](https://github.com/Zhengqbbb/cz-git)
282
281
  - [cz-vinyl](https://github.com/Exlint/cz-vinyl)
282
+ - [commit-jazzer](https://github.com/Zilero232/commit-jazzer)
283
283
 
284
284
  To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/), but you can capture input using whatever means necessary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
285
285
 
package/babel.config.js CHANGED
@@ -1,13 +1,24 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- "@babel/preset-env",
5
- {
6
- targets: {
7
- node: "10",
1
+ module.exports = (api) => {
2
+ // Only instrument for coverage when running under nyc. Without this guard the
3
+ // published dist/ shipped istanbul counters. NYC_CONFIG is set by nyc for
4
+ // every process it spawns, so this works on Windows too (no NODE_ENV=...).
5
+ const underNyc = Boolean(process.env.NYC_CONFIG);
6
+ api.cache.invalidate(() => underNyc);
7
+
8
+ return {
9
+ presets: [
10
+ [
11
+ "@babel/preset-env",
12
+ {
13
+ targets: {
14
+ node: "22.13",
15
+ },
16
+ // Babel 8 no longer converts ES modules to CommonJS by default. dist/
17
+ // must stay CommonJS: adapters and other consumers require('commitizen').
18
+ modules: "commonjs",
8
19
  },
9
- },
20
+ ],
10
21
  ],
11
- ],
12
- plugins: ["@babel/plugin-proposal-object-rest-spread", "istanbul"],
22
+ plugins: underNyc ? ["istanbul"] : [],
23
+ };
13
24
  };
package/bin/git-cz.js CHANGED
@@ -1,4 +1,4 @@
1
- var path = require('path');
1
+ var path = require('node:path');
2
2
 
3
3
  process.on('uncaughtException', function (err) {
4
4
  console.error(err.message || err);
@@ -13,7 +13,13 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
13
13
  */
14
14
  function parse(rawGitArgs) {
15
15
  var args = (0, _minimist.default)(rawGitArgs, {
16
- boolean: true
16
+ boolean: true,
17
+ // minimist does not camelCase, but init() reads camelCase option names.
18
+ alias: {
19
+ 'save-dev': 'saveDev',
20
+ 'save-exact': 'saveExact',
21
+ 'include-commitizen': 'includeCommitizen'
22
+ }
17
23
  });
18
24
  return args;
19
25
  }
@@ -8,4 +8,5 @@ var commitizen = _interopRequireWildcard(require("./parsers/commitizen"));
8
8
  exports.commitizen = commitizen;
9
9
  var gitCz = _interopRequireWildcard(require("./parsers/git-cz"));
10
10
  exports.gitCz = gitCz;
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ var e;
12
+ function _interopRequireWildcard(t, r) { if (!r && t && t.__esModule) return t; var n, a, o = Object.defineProperty, f = { __proto__: null, default: t }; if (Object(t) !== t) return f; if (e || "function" != typeof WeakMap || (e = new WeakMap()), e) { if (e.has(t)) return e.get(t); e.set(t, f); } for (a in t) "default" !== a && {}.hasOwnProperty.call(t, a) && ((n = o && Object.getOwnPropertyDescriptor(t, a)) && (n.get || n.set) ? o(f, a, n) : f[a] = t[a]); return f; }
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _inquirer = _interopRequireDefault(require("inquirer"));
8
- var _findRoot = _interopRequireDefault(require("find-root"));
9
8
  var _util = require("../../common/util");
10
9
  var _parsers = require("../parsers");
11
10
  var _commitizen = require("../../commitizen");
12
11
  var gitStrategy = _interopRequireWildcard(require("./git"));
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ var e;
13
+ function _interopRequireWildcard(t, r) { if (!r && t && t.__esModule) return t; var n, a, o = Object.defineProperty, f = { __proto__: null, default: t }; if (Object(t) !== t) return f; if (e || "function" != typeof WeakMap || (e = new WeakMap()), e) { if (e.has(t)) return e.get(t); e.set(t, f); } for (a in t) "default" !== a && {}.hasOwnProperty.call(t, a) && ((n = o && Object.getOwnPropertyDescriptor(t, a)) && (n.get || n.set) ? o(f, a, n) : f[a] = t[a]); return f; }
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  // destructure for shorter apis
16
16
  let {
@@ -48,7 +48,7 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
48
48
  // for husky prepare-commit-message
49
49
  let hookMode = !(typeof parsedCommitizenArgs.hook === 'undefined');
50
50
  let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path);
51
- let resolvedAdapterRootPath = (0, _findRoot.default)(resolvedAdapterConfigPath);
51
+ let resolvedAdapterRootPath = (0, _util.findPackageRoot)(resolvedAdapterConfigPath);
52
52
  let prompter = getPrompter(adapterConfig.path);
53
53
  let shouldStageAllFiles = rawGitArgs.includes('-a') || rawGitArgs.includes('--all');
54
54
  isClean(process.cwd(), function (error, stagingIsClean) {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _child_process = _interopRequireDefault(require("child_process"));
7
+ var _nodeChild_process = _interopRequireDefault(require("node:child_process"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  var _default = exports.default = git; // We don't have a config, so either we use raw args to try to commit
10
10
  // or if debug is enabled then we do a strict check for a config file.
@@ -13,7 +13,7 @@ function git(rawGitArgs, environment) {
13
13
  console.error('COMMITIZEN DEBUG: No cz friendly config was detected. I looked for .czrc, .cz.json, or czConfig in package.json.');
14
14
  } else {
15
15
  var vanillaGitArgs = ["commit"].concat(rawGitArgs);
16
- var child = _child_process.default.spawn('git', vanillaGitArgs, {
16
+ var child = _nodeChild_process.default.spawn('git', vanillaGitArgs, {
17
17
  stdio: 'inherit'
18
18
  });
19
19
  child.on('error', function (e, code) {