cz-conventional-changelog 4.0.0 → 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/README.md CHANGED
@@ -7,7 +7,13 @@ Status:
7
7
 
8
8
  Part of the [commitizen](https://github.com/commitizen/cz-cli) family. Prompts for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) standard.
9
9
 
10
- Requires Node.js 22.13 or newer. Tested against Node.js 22, 24 and 26.
10
+ Requires Node.js 22.23.5+, 24.22.3+ or 26.13.1+: the November 2026 security
11
+ releases, which also include the fix for Node2Shell (CVE-2026-111497). Tested
12
+ against Node.js 22, 24 and 26. Use the latest release of your line.
13
+
14
+ The package is an ES module. CommonJS code can still load it with `require()`,
15
+ which returns `{ prompter }` as before, and `require('cz-conventional-changelog/engine')`
16
+ still returns the engine function.
11
17
 
12
18
  ## Configuration
13
19
 
@@ -61,7 +67,7 @@ If using the [commitlint](https://github.com/conventional-changelog/commitlint)
61
67
 
62
68
  ## Development
63
69
 
64
- You need Node.js 22.13+, 24 or 26, and [pnpm 12](https://pnpm.io/installation).
70
+ You need the latest Node.js 22, 24 or 26, and [pnpm 12](https://pnpm.io/installation).
65
71
  The exact pnpm version is pinned in the `packageManager` field of `package.json`.
66
72
 
67
73
  ```sh
package/engine.js CHANGED
@@ -1,27 +1,28 @@
1
- 'format cjs';
1
+ import { styleText } from 'node:util';
2
+ import wrap from 'word-wrap';
2
3
 
3
- var { styleText } = require('node:util');
4
- var wrap = require('word-wrap');
5
-
6
- var filter = function(array) {
7
- return array.filter(function(x) {
4
+ var filter = function (array) {
5
+ return array.filter(function (x) {
8
6
  return x;
9
7
  });
10
8
  };
11
9
 
12
- var headerLength = function(answers) {
10
+ var headerLength = function (answers) {
13
11
  return (
14
12
  answers.type.length + 2 + (answers.scope ? answers.scope.length + 2 : 0)
15
13
  );
16
14
  };
17
15
 
18
- var maxSummaryLength = function(options, answers) {
16
+ var maxSummaryLength = function (options, answers) {
19
17
  return options.maxHeaderWidth - headerLength(answers);
20
18
  };
21
19
 
22
- var filterSubject = function(subject, disableSubjectLowerCase) {
20
+ var filterSubject = function (subject, disableSubjectLowerCase) {
23
21
  subject = subject.trim();
24
- if (!disableSubjectLowerCase && subject.charAt(0).toLowerCase() !== subject.charAt(0)) {
22
+ if (
23
+ !disableSubjectLowerCase &&
24
+ subject.charAt(0).toLowerCase() !== subject.charAt(0)
25
+ ) {
25
26
  subject =
26
27
  subject.charAt(0).toLowerCase() + subject.slice(1, subject.length);
27
28
  }
@@ -31,21 +32,18 @@ var filterSubject = function(subject, disableSubjectLowerCase) {
31
32
  return subject;
32
33
  };
33
34
 
34
- // This can be any kind of SystemJS compatible module.
35
- // We use Commonjs here, but ES6 or AMD would do just
36
- // fine.
37
- module.exports = function(options) {
35
+ export default function engine(options) {
38
36
  var types = options.types;
39
37
 
40
38
  var keys = Object.keys(types);
41
39
  var length =
42
- keys.reduce(function(max, key) {
40
+ keys.reduce(function (max, key) {
43
41
  return Math.max(max, key.length);
44
42
  }, 0) + 1;
45
- var choices = keys.map(function(key) {
43
+ var choices = keys.map(function (key) {
46
44
  return {
47
45
  name: (key + ':').padEnd(length) + ' ' + types[key].description,
48
- value: key
46
+ value: key,
49
47
  };
50
48
  });
51
49
 
@@ -61,7 +59,7 @@ module.exports = function(options) {
61
59
  //
62
60
  // By default, we'll de-indent your commit
63
61
  // template and will keep empty lines.
64
- prompter: function(cz, commit) {
62
+ prompter: function (cz, commit) {
65
63
  // Let's ask some questions of the user
66
64
  // so that we can populate our commit
67
65
  // template.
@@ -75,7 +73,7 @@ module.exports = function(options) {
75
73
  name: 'type',
76
74
  message: "Select the type of change that you're committing:",
77
75
  choices: choices,
78
- default: options.defaultType
76
+ default: options.defaultType,
79
77
  },
80
78
  {
81
79
  type: 'input',
@@ -83,16 +81,16 @@ module.exports = function(options) {
83
81
  message:
84
82
  'What is the scope of this change (e.g. component or file name): (press enter to skip)',
85
83
  default: options.defaultScope,
86
- filter: function(value) {
84
+ filter: function (value) {
87
85
  return options.disableScopeLowerCase
88
86
  ? value.trim()
89
87
  : value.trim().toLowerCase();
90
- }
88
+ },
91
89
  },
92
90
  {
93
91
  type: 'input',
94
92
  name: 'subject',
95
- message: function(answers) {
93
+ message: function (answers) {
96
94
  return (
97
95
  'Write a short, imperative tense description of the change (max ' +
98
96
  maxSummaryLength(options, answers) +
@@ -100,45 +98,51 @@ module.exports = function(options) {
100
98
  );
101
99
  },
102
100
  default: options.defaultSubject,
103
- validate: function(subject, answers) {
104
- var filteredSubject = filterSubject(subject, options.disableSubjectLowerCase);
101
+ validate: function (subject, answers) {
102
+ var filteredSubject = filterSubject(
103
+ subject,
104
+ options.disableSubjectLowerCase,
105
+ );
105
106
  return filteredSubject.length == 0
106
107
  ? 'subject is required'
107
108
  : filteredSubject.length <= maxSummaryLength(options, answers)
108
- ? true
109
- : 'Subject length must be less than or equal to ' +
110
- maxSummaryLength(options, answers) +
111
- ' characters. Current length is ' +
112
- filteredSubject.length +
113
- ' characters.';
109
+ ? true
110
+ : 'Subject length must be less than or equal to ' +
111
+ maxSummaryLength(options, answers) +
112
+ ' characters. Current length is ' +
113
+ filteredSubject.length +
114
+ ' characters.';
114
115
  },
115
- transformer: function(subject, answers) {
116
- var filteredSubject = filterSubject(subject, options.disableSubjectLowerCase);
116
+ transformer: function (subject, answers) {
117
+ var filteredSubject = filterSubject(
118
+ subject,
119
+ options.disableSubjectLowerCase,
120
+ );
117
121
  var color =
118
122
  filteredSubject.length <= maxSummaryLength(options, answers)
119
123
  ? 'green'
120
124
  : 'red';
121
125
  return styleText(
122
126
  color,
123
- '(' + filteredSubject.length + ') ' + subject
127
+ '(' + filteredSubject.length + ') ' + subject,
124
128
  );
125
129
  },
126
- filter: function(subject) {
130
+ filter: function (subject) {
127
131
  return filterSubject(subject, options.disableSubjectLowerCase);
128
- }
132
+ },
129
133
  },
130
134
  {
131
135
  type: 'input',
132
136
  name: 'body',
133
137
  message:
134
138
  'Provide a longer description of the change: (press enter to skip)\n',
135
- default: options.defaultBody
139
+ default: options.defaultBody,
136
140
  },
137
141
  {
138
142
  type: 'confirm',
139
143
  name: 'isBreaking',
140
144
  message: 'Are there any breaking changes?',
141
- default: false
145
+ default: false,
142
146
  },
143
147
  {
144
148
  type: 'input',
@@ -146,30 +150,30 @@ module.exports = function(options) {
146
150
  default: '-',
147
151
  message:
148
152
  'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:\n',
149
- when: function(answers) {
153
+ when: function (answers) {
150
154
  return answers.isBreaking && !answers.body;
151
155
  },
152
- validate: function(breakingBody, answers) {
156
+ validate: function (breakingBody, answers) {
153
157
  return (
154
158
  breakingBody.trim().length > 0 ||
155
159
  'Body is required for BREAKING CHANGE'
156
160
  );
157
- }
161
+ },
158
162
  },
159
163
  {
160
164
  type: 'input',
161
165
  name: 'breaking',
162
166
  message: 'Describe the breaking changes:\n',
163
- when: function(answers) {
167
+ when: function (answers) {
164
168
  return answers.isBreaking;
165
- }
169
+ },
166
170
  },
167
171
 
168
172
  {
169
173
  type: 'confirm',
170
174
  name: 'isIssueAffected',
171
175
  message: 'Does this change affect any open issues?',
172
- default: options.defaultIssues ? true : false
176
+ default: options.defaultIssues ? true : false,
173
177
  },
174
178
  {
175
179
  type: 'input',
@@ -177,28 +181,28 @@ module.exports = function(options) {
177
181
  default: '-',
178
182
  message:
179
183
  'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself:\n',
180
- when: function(answers) {
184
+ when: function (answers) {
181
185
  return (
182
186
  answers.isIssueAffected && !answers.body && !answers.breakingBody
183
187
  );
184
- }
188
+ },
185
189
  },
186
190
  {
187
191
  type: 'input',
188
192
  name: 'issues',
189
193
  message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
190
- when: function(answers) {
194
+ when: function (answers) {
191
195
  return answers.isIssueAffected;
192
196
  },
193
- default: options.defaultIssues ? options.defaultIssues : undefined
194
- }
195
- ]).then(function(answers) {
197
+ default: options.defaultIssues ? options.defaultIssues : undefined,
198
+ },
199
+ ]).then(function (answers) {
196
200
  var wrapOptions = {
197
201
  trim: true,
198
202
  cut: false,
199
203
  newline: '\n',
200
204
  indent: '',
201
- width: options.maxLineWidth
205
+ width: options.maxLineWidth,
202
206
  };
203
207
 
204
208
  // parentheses are only needed when a scope is present
@@ -221,6 +225,9 @@ module.exports = function(options) {
221
225
 
222
226
  commit(filter([head, body, breaking, issues]).join('\n\n'));
223
227
  });
224
- }
228
+ },
225
229
  };
226
- };
230
+ }
231
+
232
+ // Lets CommonJS code keep calling `require('cz-conventional-changelog/engine')(options)`.
233
+ export { engine as 'module.exports' };
package/index.js CHANGED
@@ -1,59 +1,22 @@
1
- 'format cjs';
1
+ import commitizen from 'commitizen';
2
+ import engine from './engine.js';
3
+ import { applyCommitlintConfig, buildOptions } from './options.js';
2
4
 
3
- var engine = require('./engine');
4
- var conventionalCommitTypes = require('conventional-commit-types');
5
- var configLoader = require('commitizen').configLoader;
5
+ var config = commitizen.configLoader.load() || {};
6
+ var options = buildOptions(config, process.env);
6
7
 
7
- var config = configLoader.load() || {};
8
- var options = {
9
- types: config.types || conventionalCommitTypes.types,
10
- defaultType: process.env.CZ_TYPE || config.defaultType,
11
- defaultScope: process.env.CZ_SCOPE || config.defaultScope,
12
- defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
13
- defaultBody: process.env.CZ_BODY || config.defaultBody,
14
- defaultIssues: process.env.CZ_ISSUES || config.defaultIssues,
15
- disableScopeLowerCase:
16
- process.env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
17
- disableSubjectLowerCase:
18
- process.env.DISABLE_SUBJECT_LOWERCASE || config.disableSubjectLowerCase,
19
- maxHeaderWidth:
20
- (process.env.CZ_MAX_HEADER_WIDTH &&
21
- parseInt(process.env.CZ_MAX_HEADER_WIDTH)) ||
22
- config.maxHeaderWidth ||
23
- 100,
24
- maxLineWidth:
25
- (process.env.CZ_MAX_LINE_WIDTH &&
26
- parseInt(process.env.CZ_MAX_LINE_WIDTH)) ||
27
- config.maxLineWidth ||
28
- 100
29
- };
8
+ // Not awaited: no top-level await, so CommonJS can still require() this module
9
+ // (commitizen loads adapters with require()). The commitlint config is applied
10
+ // while the user answers the first prompts, as before.
11
+ applyCommitlintConfig(options, config, process.env, function () {
12
+ return import('@commitlint/load');
13
+ });
30
14
 
31
- (function(options) {
32
- try {
33
- var commitlintLoad = require('@commitlint/load');
34
- // @commitlint/load 19+ is ESM-only, so require() returns its namespace
35
- // (require(esm) works without a warning from Node.js 22.13).
36
- if (typeof commitlintLoad !== 'function') {
37
- commitlintLoad = commitlintLoad.default;
38
- }
39
- commitlintLoad()
40
- .then(function(clConfig) {
41
- if (clConfig.rules) {
42
- var maxHeaderLengthRule = clConfig.rules['header-max-length'];
43
- if (
44
- typeof maxHeaderLengthRule === 'object' &&
45
- maxHeaderLengthRule.length >= 3 &&
46
- !process.env.CZ_MAX_HEADER_WIDTH &&
47
- !config.maxHeaderWidth
48
- ) {
49
- options.maxHeaderWidth = maxHeaderLengthRule[2];
50
- }
51
- }
52
- })
53
- // Reading commitlint config is best effort. An invalid or missing
54
- // config must not crash the prompt with an unhandled rejection.
55
- .catch(function() {});
56
- } catch (err) {}
57
- })(options);
15
+ var adapter = engine(options);
58
16
 
59
- module.exports = engine(options);
17
+ export var prompter = adapter.prompter;
18
+ export default adapter;
19
+
20
+ // Lets CommonJS code keep getting `{ prompter }` from
21
+ // `require('cz-conventional-changelog')`, as before.
22
+ export { adapter as 'module.exports' };
package/options.js ADDED
@@ -0,0 +1,65 @@
1
+ import conventionalCommitTypes from 'conventional-commit-types' with { type: 'json' };
2
+
3
+ // Builds the adapter options from the commitizen config and the environment.
4
+ // Environment variables win over the config.
5
+ export function buildOptions(config, env) {
6
+ return {
7
+ types: config.types || conventionalCommitTypes.types,
8
+ defaultType: env.CZ_TYPE || config.defaultType,
9
+ defaultScope: env.CZ_SCOPE || config.defaultScope,
10
+ defaultSubject: env.CZ_SUBJECT || config.defaultSubject,
11
+ defaultBody: env.CZ_BODY || config.defaultBody,
12
+ defaultIssues: env.CZ_ISSUES || config.defaultIssues,
13
+ disableScopeLowerCase:
14
+ env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
15
+ disableSubjectLowerCase:
16
+ env.DISABLE_SUBJECT_LOWERCASE || config.disableSubjectLowerCase,
17
+ maxHeaderWidth:
18
+ (env.CZ_MAX_HEADER_WIDTH && parseInt(env.CZ_MAX_HEADER_WIDTH)) ||
19
+ config.maxHeaderWidth ||
20
+ 100,
21
+ maxLineWidth:
22
+ (env.CZ_MAX_LINE_WIDTH && parseInt(env.CZ_MAX_LINE_WIDTH)) ||
23
+ config.maxLineWidth ||
24
+ 100,
25
+ };
26
+ }
27
+
28
+ // Uses header-max-length from the project's commitlint config as
29
+ // options.maxHeaderWidth, unless the environment or commitizen config sets it.
30
+ // `importCommitlintLoad` resolves to the @commitlint/load module, which is an
31
+ // optional dependency.
32
+ //
33
+ // Reading the commitlint config is best effort: the returned promise always
34
+ // resolves, and a missing package or an invalid config leaves options as they
35
+ // are.
36
+ export function applyCommitlintConfig(
37
+ options,
38
+ config,
39
+ env,
40
+ importCommitlintLoad,
41
+ ) {
42
+ return Promise.resolve()
43
+ .then(importCommitlintLoad)
44
+ .then(function (commitlintLoad) {
45
+ // @commitlint/load 19+ is ESM with a default export. Older CommonJS
46
+ // versions exported the function itself, or { default: load }.
47
+ var load = commitlintLoad.default;
48
+ if (typeof load !== 'function') {
49
+ load = load.default;
50
+ }
51
+ return load();
52
+ })
53
+ .then(function (clConfig) {
54
+ var rule = clConfig.rules && clConfig.rules['header-max-length'];
55
+ if (
56
+ typeof rule === 'object' &&
57
+ rule.length >= 3 &&
58
+ !env.CZ_MAX_HEADER_WIDTH &&
59
+ !config.maxHeaderWidth
60
+ ) {
61
+ options.maxHeaderWidth = rule[2];
62
+ }
63
+ })
64
+ .catch(function () {});
65
+ }
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "cz-conventional-changelog",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Commitizen adapter following the conventional-changelog format.",
5
+ "type": "module",
5
6
  "main": "index.js",
6
7
  "files": [
7
8
  "index.js",
8
- "engine.js"
9
+ "engine.js",
10
+ "options.js"
9
11
  ],
10
12
  "scripts": {
11
13
  "commit": "git-cz",
@@ -19,16 +21,16 @@
19
21
  "url": "git+https://github.com/commitizen/cz-conventional-changelog.git"
20
22
  },
21
23
  "engines": {
22
- "node": ">= 22.13"
24
+ "node": "^22.23.5 || ^24.22.3 || >=26.13.1"
23
25
  },
24
26
  "devEngines": {
25
27
  "runtime": {
26
28
  "name": "node",
27
- "version": "^22.13.0 || ^24.0.0 || ^26.0.0",
29
+ "version": "^22.23.5 || ^24.22.3 || ^26.13.1",
28
30
  "onFail": "error"
29
31
  }
30
32
  },
31
- "packageManager": "pnpm@12.16.1",
33
+ "packageManager": "pnpm@12.25.1",
32
34
  "author": "Jim Cummins <jimthedev@gmail.com>",
33
35
  "license": "MIT",
34
36
  "dependencies": {
@@ -41,7 +43,6 @@
41
43
  "chai": "^6.3.0",
42
44
  "conventional-changelog-conventionalcommits": "^10.4.1",
43
45
  "mocha": "^12.0.3",
44
- "mock-require": "3.0.3",
45
46
  "prettier": "^3.10.1",
46
47
  "semantic-release": "^26.0.1"
47
48
  },