commitizen 4.3.2 → 5.0.0
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.
- package/.github/workflows/release.yml +7 -5
- package/.husky/pre-commit +1 -0
- package/CONTRIBUTING.md +53 -21
- package/README.md +3 -4
- package/babel.config.js +21 -10
- package/bin/git-cz.js +1 -1
- package/dist/cli/parsers/commitizen.js +7 -1
- package/dist/cli/parsers.js +2 -1
- package/dist/cli/strategies/git-cz.js +3 -3
- package/dist/cli/strategies/git.js +2 -2
- package/dist/commitizen/adapter.js +52 -1411
- package/dist/commitizen/cache.js +6 -237
- package/dist/commitizen/commit.js +14 -562
- package/dist/commitizen/configLoader.js +1 -84
- package/dist/commitizen/init.js +30 -976
- package/dist/commitizen/staging.js +3 -255
- package/dist/commitizen.js +2 -1
- package/dist/common/util.js +49 -444
- package/dist/configLoader/findup.js +7 -312
- package/dist/configLoader/getContent.js +17 -644
- package/dist/configLoader/getNormalizedConfig.js +9 -382
- package/dist/configLoader/loader.js +4 -371
- package/dist/git/add.js +3 -113
- package/dist/git/commit.js +19 -801
- package/dist/git/init.js +2 -74
- package/dist/git/log.js +2 -175
- package/dist/git/whatChanged.js +2 -175
- package/dist/index.js +1 -56
- package/dist/npm.js +1 -32
- package/jobs/build.yml +17 -16
- package/package.json +36 -44
- package/pnpm-workspace.yaml +7 -0
|
@@ -16,10 +16,12 @@ jobs:
|
|
|
16
16
|
- uses: actions/checkout@v4
|
|
17
17
|
- uses: actions/setup-node@v4
|
|
18
18
|
with:
|
|
19
|
-
|
|
20
|
-
node-version:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- run:
|
|
19
|
+
# semantic-release 26 requires Node >= 26.13
|
|
20
|
+
node-version: 26
|
|
21
|
+
# npm@latest is still needed: semantic-release publishes with `npm publish`
|
|
22
|
+
# (trusted publishing via OIDC).
|
|
23
|
+
- run: npm install -g npm@latest pnpm@12
|
|
24
|
+
- run: pnpm install --frozen-lockfile
|
|
25
|
+
- run: pnpm run semantic-release
|
|
24
26
|
env:
|
|
25
27
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm test && pnpm run check-coverage
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,37 +1,69 @@
|
|
|
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.12 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
|
-
|
|
6
|
-
|
|
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
|
+
```
|
|
7
30
|
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
40
|
+
|
|
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
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
62
|
## Gotchas
|
|
25
63
|
|
|
26
|
-
###
|
|
27
|
-
|
|
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.
|
|
64
|
+
### Editors that strip trailing whitespace can break tests
|
|
35
65
|
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
Some tests deliberately contain lines with only whitespace, to check how
|
|
67
|
+
multiline commit messages behave across operating systems. If your editor
|
|
68
|
+
strips trailing whitespace on save, turn that off for `test/` before editing
|
|
69
|
+
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) [](#sponsors) [](#backers) [](#sponsors) [](https://dev.azure.com/commitizen/cz-cli/_build/latest?definitionId=2)
|
|
6
|
+
[](https://www.npmjs.com/package/commitizen) [](https://www.npmjs.com/package/commitizen) [](https://github.com/semantic-release/semantic-release) [](https://stackoverflow.com/tags/commitizen)
|
|
7
7
|
|
|
8
8
|
## Installing the command line tool
|
|
9
9
|
|
|
10
|
-
Commitizen is
|
|
11
|
-
older versions of Node.js. You should also have npm 6 or greater.
|
|
10
|
+
Commitizen requires Node.js 22.12 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
|
|
package/babel.config.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.12",
|
|
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
|
-
|
|
22
|
+
plugins: underNyc ? ["istanbul"] : [],
|
|
23
|
+
};
|
|
13
24
|
};
|
package/bin/git-cz.js
CHANGED
|
@@ -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
|
}
|
package/dist/cli/parsers.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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 =
|
|
16
|
+
var child = _nodeChild_process.default.spawn('git', vanillaGitArgs, {
|
|
17
17
|
stdio: 'inherit'
|
|
18
18
|
});
|
|
19
19
|
child.on('error', function (e, code) {
|