cz-conventional-changelog 3.3.0 → 4.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.
package/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # cz-conventional-changelog
2
2
 
3
- [![Greenkeeper badge](https://badges.greenkeeper.io/commitizen/cz-conventional-changelog.svg)](https://greenkeeper.io/)
4
-
5
3
  Status:
6
4
  [![npm version](https://img.shields.io/npm/v/cz-conventional-changelog.svg?style=flat-square)](https://www.npmjs.org/package/cz-conventional-changelog)
7
5
  [![npm downloads](https://img.shields.io/npm/dm/cz-conventional-changelog.svg?style=flat-square)](http://npm-stat.com/charts.html?package=cz-conventional-changelog&from=2015-08-01)
8
- [![Build Status](https://img.shields.io/travis/commitizen/cz-conventional-changelog.svg?style=flat-square)](https://travis-ci.org/commitizen/cz-conventional-changelog)
6
+ [![CI](https://github.com/commitizen/cz-conventional-changelog/actions/workflows/ci.yml/badge.svg)](https://github.com/commitizen/cz-conventional-changelog/actions/workflows/ci.yml)
9
7
 
10
8
  Part of the [commitizen](https://github.com/commitizen/cz-cli) family. Prompts for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) standard.
11
9
 
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
+
12
14
  ## Configuration
13
15
 
14
16
  ### package.json
@@ -46,7 +48,7 @@ Like commitizen, you specify the configuration of cz-conventional-changelog thro
46
48
 
47
49
  ### Environment variables
48
50
 
49
- The following environment varibles can be used to override any default configuration or package.json based configuration.
51
+ The following environment variables can be used to override any default configuration or package.json based configuration.
50
52
 
51
53
  * CZ_TYPE = defaultType
52
54
  * CZ_SCOPE = defaultScope
@@ -58,3 +60,34 @@ The following environment varibles can be used to override any default configura
58
60
  ### Commitlint
59
61
 
60
62
  If using the [commitlint](https://github.com/conventional-changelog/commitlint) js library, the "maxHeaderWidth" configuration property will default to the configuration of the "header-max-length" rule instead of the hard coded value of 100. This can be ovewritten by setting the 'maxHeaderWidth' configuration in package.json or the CZ_MAX_HEADER_WIDTH environment variable.
63
+
64
+ ## Development
65
+
66
+ You need the latest Node.js 22, 24 or 26, and [pnpm 12](https://pnpm.io/installation).
67
+ The exact pnpm version is pinned in the `packageManager` field of `package.json`.
68
+
69
+ ```sh
70
+ pnpm install
71
+ pnpm test
72
+ ```
73
+
74
+ ## Releasing
75
+
76
+ Releases are automated with [semantic-release](https://github.com/semantic-release/semantic-release),
77
+ but nothing reaches npm without a maintainer's approval:
78
+
79
+ 1. Every push to `master` runs the release workflow. If there are `fix`, `feat`
80
+ or breaking-change commits since the last release, it tags the new version,
81
+ creates a **draft** GitHub release, and **stages** the package on npm with
82
+ `npm stage publish`. A staged version can't be installed yet.
83
+ 2. A maintainer reviews the staged version and approves it, which prompts for 2FA:
84
+
85
+ ```sh
86
+ npm stage list cz-conventional-changelog
87
+ npm stage download <stage-id> # optional: inspect the tarball
88
+ npm stage approve <stage-id>
89
+ ```
90
+
91
+ To discard it instead, run `npm stage reject <stage-id>`, then delete the
92
+ tag and the draft GitHub release.
93
+ 3. Publish the draft GitHub release.
package/engine.js CHANGED
@@ -1,9 +1,7 @@
1
1
  'format cjs';
2
2
 
3
+ var { styleText } = require('node:util');
3
4
  var wrap = require('word-wrap');
4
- var map = require('lodash.map');
5
- var longest = require('longest');
6
- var chalk = require('chalk');
7
5
 
8
6
  var filter = function(array) {
9
7
  return array.filter(function(x) {
@@ -39,10 +37,14 @@ var filterSubject = function(subject, disableSubjectLowerCase) {
39
37
  module.exports = function(options) {
40
38
  var types = options.types;
41
39
 
42
- var length = longest(Object.keys(types)).length + 1;
43
- var choices = map(types, function(type, key) {
40
+ var keys = Object.keys(types);
41
+ var length =
42
+ keys.reduce(function(max, key) {
43
+ return Math.max(max, key.length);
44
+ }, 0) + 1;
45
+ var choices = keys.map(function(key) {
44
46
  return {
45
- name: (key + ':').padEnd(length) + ' ' + type.description,
47
+ name: (key + ':').padEnd(length) + ' ' + types[key].description,
46
48
  value: key
47
49
  };
48
50
  });
@@ -114,9 +116,12 @@ module.exports = function(options) {
114
116
  var filteredSubject = filterSubject(subject, options.disableSubjectLowerCase);
115
117
  var color =
116
118
  filteredSubject.length <= maxSummaryLength(options, answers)
117
- ? chalk.green
118
- : chalk.red;
119
- return color('(' + filteredSubject.length + ') ' + subject);
119
+ ? 'green'
120
+ : 'red';
121
+ return styleText(
122
+ color,
123
+ '(' + filteredSubject.length + ') ' + subject
124
+ );
120
125
  },
121
126
  filter: function(subject) {
122
127
  return filterSubject(subject, options.disableSubjectLowerCase);
package/index.js CHANGED
@@ -31,19 +31,28 @@ var options = {
31
31
  (function(options) {
32
32
  try {
33
33
  var commitlintLoad = require('@commitlint/load');
34
- commitlintLoad().then(function(clConfig) {
35
- if (clConfig.rules) {
36
- var maxHeaderLengthRule = clConfig.rules['header-max-length'];
37
- if (
38
- typeof maxHeaderLengthRule === 'object' &&
39
- maxHeaderLengthRule.length >= 3 &&
40
- !process.env.CZ_MAX_HEADER_WIDTH &&
41
- !config.maxHeaderWidth
42
- ) {
43
- options.maxHeaderWidth = maxHeaderLengthRule[2];
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
+ }
44
51
  }
45
- }
46
- });
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() {});
47
56
  } catch (err) {}
48
57
  })(options);
49
58
 
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "cz-conventional-changelog",
3
- "version": "3.3.0",
3
+ "version": "4.0.1",
4
4
  "description": "Commitizen adapter following the conventional-changelog format.",
5
5
  "main": "index.js",
6
+ "files": [
7
+ "index.js",
8
+ "engine.js"
9
+ ],
6
10
  "scripts": {
7
11
  "commit": "git-cz",
8
12
  "test": "mocha *.test.js",
@@ -12,39 +16,68 @@
12
16
  "homepage": "https://github.com/commitizen/cz-conventional-changelog",
13
17
  "repository": {
14
18
  "type": "git",
15
- "url": "https://github.com/commitizen/cz-conventional-changelog.git"
19
+ "url": "git+https://github.com/commitizen/cz-conventional-changelog.git"
16
20
  },
17
- "engineStrict": true,
18
21
  "engines": {
19
- "node": ">= 10"
22
+ "node": "^22.23.5 || ^24.22.3 || >=26.13.1"
20
23
  },
24
+ "devEngines": {
25
+ "runtime": {
26
+ "name": "node",
27
+ "version": "^22.23.5 || ^24.22.3 || ^26.13.1",
28
+ "onFail": "error"
29
+ }
30
+ },
31
+ "packageManager": "pnpm@12.25.1",
21
32
  "author": "Jim Cummins <jimthedev@gmail.com>",
22
33
  "license": "MIT",
23
34
  "dependencies": {
24
- "chalk": "^2.4.1",
25
- "commitizen": "^4.0.3",
35
+ "commitizen": "^4.3.2 || ^5.0.0",
26
36
  "conventional-commit-types": "^3.0.0",
27
- "lodash.map": "^4.5.1",
28
- "longest": "^2.0.1",
29
- "word-wrap": "^1.0.3"
37
+ "word-wrap": "^1.2.5"
30
38
  },
31
39
  "devDependencies": {
32
- "@types/chai": "^4.1.7",
33
- "@types/mocha": "^5.2.7",
34
- "chai": "^4.2.0",
35
- "cosmiconfig": "^5.2.1",
36
- "mocha": "^6.2.0",
37
- "mock-require": "^3.0.3",
38
- "prettier": "^1.15.3",
39
- "semantic-release": "^15.13.3",
40
- "semver": "^6.2.0"
40
+ "@semantic-release/exec": "^7.1.0",
41
+ "chai": "^6.3.0",
42
+ "conventional-changelog-conventionalcommits": "^10.4.1",
43
+ "mocha": "^12.0.3",
44
+ "mock-require": "3.0.3",
45
+ "prettier": "^3.10.1",
46
+ "semantic-release": "^26.0.1"
41
47
  },
42
48
  "optionalDependencies": {
43
- "@commitlint/load": ">6.1.1"
49
+ "@commitlint/load": "^21.3.0"
44
50
  },
45
51
  "config": {
46
52
  "commitizen": {
47
53
  "path": "./index.js"
48
54
  }
55
+ },
56
+ "release": {
57
+ "preset": "conventionalcommits",
58
+ "plugins": [
59
+ "@semantic-release/commit-analyzer",
60
+ "@semantic-release/release-notes-generator",
61
+ [
62
+ "@semantic-release/npm",
63
+ {
64
+ "npmPublish": false
65
+ }
66
+ ],
67
+ [
68
+ "@semantic-release/exec",
69
+ {
70
+ "publishCmd": "npm stage publish --tag latest --provenance --loglevel verbose"
71
+ }
72
+ ],
73
+ [
74
+ "@semantic-release/github",
75
+ {
76
+ "draftRelease": true,
77
+ "successComment": false,
78
+ "releasedLabels": false
79
+ }
80
+ ]
81
+ ]
49
82
  }
50
83
  }
package/.editorconfig DELETED
@@ -1,8 +0,0 @@
1
- [*]
2
- end_of_line = lf
3
- charset = utf-8
4
- indent_size = 2
5
- indent_style = space
6
- insert_final_newline = true
7
- max_line_length = 80
8
- trim_trailing_whitespace = true
package/.prettierrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "printWidth": 80,
3
- "endOfLine": "lf",
4
- "singleQuote": true
5
- }
package/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: node_js
2
-
3
- node_js:
4
- - 12
5
- - 10
6
-
7
- jobs:
8
- include:
9
- - stage: release
10
- node_js: lts/*
11
- deploy:
12
- provider: script
13
- skip_cleanup: true
14
- script:
15
- - npm run semantic-release
16
-
17
- branches:
18
- only:
19
- - master
20
- - /^greenkeeper/.*$/
package/engine.test.js DELETED
@@ -1,594 +0,0 @@
1
- var chai = require('chai');
2
- var chalk = require('chalk');
3
- var engine = require('./engine');
4
- var mock = require('mock-require');
5
- var semver = require('semver');
6
-
7
- var types = require('conventional-commit-types').types;
8
-
9
- var expect = chai.expect;
10
- chai.should();
11
-
12
- var defaultOptions = {
13
- types,
14
- maxLineWidth: 100,
15
- maxHeaderWidth: 100
16
- };
17
-
18
- var type = 'func';
19
- var scope = 'everything';
20
- var subject = 'testing123';
21
- var longBody =
22
- 'a a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a' +
23
- 'a a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a' +
24
- 'a a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a';
25
- var longBodySplit =
26
- longBody.slice(0, defaultOptions.maxLineWidth).trim() +
27
- '\n' +
28
- longBody
29
- .slice(defaultOptions.maxLineWidth, 2 * defaultOptions.maxLineWidth)
30
- .trim() +
31
- '\n' +
32
- longBody.slice(defaultOptions.maxLineWidth * 2, longBody.length).trim();
33
- var body = 'A quick brown fox jumps over the dog';
34
- var issues = 'a issues is not a person that kicks things';
35
- var longIssues =
36
- 'b b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b' +
37
- 'b b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b' +
38
- 'b b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b bb b';
39
- var breakingChange = 'BREAKING CHANGE: ';
40
- var breaking = 'asdhdfkjhbakjdhjkashd adhfajkhs asdhkjdsh ahshd';
41
- var longIssuesSplit =
42
- longIssues.slice(0, defaultOptions.maxLineWidth).trim() +
43
- '\n' +
44
- longIssues
45
- .slice(defaultOptions.maxLineWidth, defaultOptions.maxLineWidth * 2)
46
- .trim() +
47
- '\n' +
48
- longIssues.slice(defaultOptions.maxLineWidth * 2, longIssues.length).trim();
49
-
50
- describe('commit message', function() {
51
- it('only header w/ out scope', function() {
52
- expect(
53
- commitMessage({
54
- type,
55
- subject
56
- })
57
- ).to.equal(`${type}: ${subject}`);
58
- });
59
- it('only header w/ scope', function() {
60
- expect(
61
- commitMessage({
62
- type,
63
- scope,
64
- subject
65
- })
66
- ).to.equal(`${type}(${scope}): ${subject}`);
67
- });
68
- it('header and body w/ out scope', function() {
69
- expect(
70
- commitMessage({
71
- type,
72
- subject,
73
- body
74
- })
75
- ).to.equal(`${type}: ${subject}\n\n${body}`);
76
- });
77
- it('header and body w/ scope', function() {
78
- expect(
79
- commitMessage({
80
- type,
81
- scope,
82
- subject,
83
- body
84
- })
85
- ).to.equal(`${type}(${scope}): ${subject}\n\n${body}`);
86
- });
87
- it('header and body w/ uppercase scope', function() {
88
- var upperCaseScope = scope.toLocaleUpperCase();
89
- expect(
90
- commitMessage(
91
- {
92
- type,
93
- scope: upperCaseScope,
94
- subject,
95
- body
96
- },
97
- {
98
- ...defaultOptions,
99
- disableScopeLowerCase: true
100
- }
101
- )
102
- ).to.equal(`${type}(${upperCaseScope}): ${subject}\n\n${body}`);
103
- });
104
- it('header and body w/ uppercase subject', function() {
105
- var upperCaseSubject = subject.toLocaleUpperCase();
106
- expect(
107
- commitMessage(
108
- {
109
- type,
110
- scope,
111
- subject: upperCaseSubject,
112
- body
113
- },
114
- {
115
- ...defaultOptions,
116
- disableSubjectLowerCase: true
117
- }
118
- )
119
- ).to.equal(`${type}(${scope}): ${upperCaseSubject}\n\n${body}`);
120
- });
121
- it('header, body and issues w/ out scope', function() {
122
- expect(
123
- commitMessage({
124
- type,
125
- subject,
126
- body,
127
- issues
128
- })
129
- ).to.equal(`${type}: ${subject}\n\n${body}\n\n${issues}`);
130
- });
131
- it('header, body and issues w/ scope', function() {
132
- expect(
133
- commitMessage({
134
- type,
135
- scope,
136
- subject,
137
- body,
138
- issues
139
- })
140
- ).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${issues}`);
141
- });
142
- it('header, body and long issues w/ out scope', function() {
143
- expect(
144
- commitMessage({
145
- type,
146
- subject,
147
- body,
148
- issues: longIssues
149
- })
150
- ).to.equal(`${type}: ${subject}\n\n${body}\n\n${longIssuesSplit}`);
151
- });
152
- it('header, body and long issues w/ scope', function() {
153
- expect(
154
- commitMessage({
155
- type,
156
- scope,
157
- subject,
158
- body,
159
- issues: longIssues
160
- })
161
- ).to.equal(
162
- `${type}(${scope}): ${subject}\n\n${body}\n\n${longIssuesSplit}`
163
- );
164
- });
165
- it('header and long body w/ out scope', function() {
166
- expect(
167
- commitMessage({
168
- type,
169
- subject,
170
- body: longBody
171
- })
172
- ).to.equal(`${type}: ${subject}\n\n${longBodySplit}`);
173
- });
174
- it('header and long body w/ scope', function() {
175
- expect(
176
- commitMessage({
177
- type,
178
- scope,
179
- subject,
180
- body: longBody
181
- })
182
- ).to.equal(`${type}(${scope}): ${subject}\n\n${longBodySplit}`);
183
- });
184
- it('header, long body and issues w/ out scope', function() {
185
- expect(
186
- commitMessage({
187
- type,
188
- subject,
189
- body: longBody,
190
- issues
191
- })
192
- ).to.equal(`${type}: ${subject}\n\n${longBodySplit}\n\n${issues}`);
193
- });
194
- it('header, long body and issues w/ scope', function() {
195
- expect(
196
- commitMessage({
197
- type,
198
- scope,
199
- subject,
200
- body: longBody,
201
- issues
202
- })
203
- ).to.equal(
204
- `${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${issues}`
205
- );
206
- });
207
- it('header, long body and long issues w/ out scope', function() {
208
- expect(
209
- commitMessage({
210
- type,
211
- subject,
212
- body: longBody,
213
- issues: longIssues
214
- })
215
- ).to.equal(`${type}: ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`);
216
- });
217
- it('header, long body and long issues w/ scope', function() {
218
- expect(
219
- commitMessage({
220
- type,
221
- scope,
222
- subject,
223
- body: longBody,
224
- issues: longIssues
225
- })
226
- ).to.equal(
227
- `${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
228
- );
229
- });
230
- it('header, long body, breaking change, and long issues w/ scope', function() {
231
- expect(
232
- commitMessage({
233
- type,
234
- scope,
235
- subject,
236
- body: longBody,
237
- breaking,
238
- issues: longIssues
239
- })
240
- ).to.equal(
241
- `${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
242
- );
243
- });
244
- it('header, long body, breaking change (with prefix entered), and long issues w/ scope', function() {
245
- expect(
246
- commitMessage({
247
- type,
248
- scope,
249
- subject,
250
- body: longBody,
251
- breaking: `${breakingChange}${breaking}`,
252
- issues: longIssues
253
- })
254
- ).to.equal(
255
- `${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
256
- );
257
- });
258
- });
259
-
260
- describe('validation', function() {
261
- it('subject exceeds max length', function() {
262
- expect(() =>
263
- commitMessage({
264
- type,
265
- scope,
266
- subject: longBody
267
- })
268
- ).to.throw(
269
- 'length must be less than or equal to ' +
270
- `${defaultOptions.maxLineWidth - type.length - scope.length - 4}`
271
- );
272
- });
273
- it('empty subject', function() {
274
- expect(() =>
275
- commitMessage({
276
- type,
277
- scope,
278
- subject: ''
279
- })
280
- ).to.throw('subject is required');
281
- });
282
- });
283
-
284
- describe('defaults', function() {
285
- it('defaultType default', function() {
286
- expect(questionDefault('type')).to.be.undefined;
287
- });
288
- it('defaultType options', function() {
289
- expect(
290
- questionDefault('type', customOptions({ defaultType: type }))
291
- ).to.equal(type);
292
- });
293
- it('defaultScope default', function() {
294
- expect(questionDefault('scope')).to.be.undefined;
295
- });
296
- it('defaultScope options', () =>
297
- expect(
298
- questionDefault('scope', customOptions({ defaultScope: scope }))
299
- ).to.equal(scope));
300
-
301
- it('defaultSubject default', () =>
302
- expect(questionDefault('subject')).to.be.undefined);
303
- it('defaultSubject options', function() {
304
- expect(
305
- questionDefault(
306
- 'subject',
307
- customOptions({
308
- defaultSubject: subject
309
- })
310
- )
311
- ).to.equal(subject);
312
- });
313
- it('defaultBody default', function() {
314
- expect(questionDefault('body')).to.be.undefined;
315
- });
316
- it('defaultBody options', function() {
317
- expect(
318
- questionDefault('body', customOptions({ defaultBody: body }))
319
- ).to.equal(body);
320
- });
321
- it('defaultIssues default', function() {
322
- expect(questionDefault('issues')).to.be.undefined;
323
- });
324
- it('defaultIssues options', function() {
325
- expect(
326
- questionDefault(
327
- 'issues',
328
- customOptions({
329
- defaultIssues: issues
330
- })
331
- )
332
- ).to.equal(issues);
333
- });
334
- it('disableScopeLowerCase default', function() {
335
- expect(questionDefault('disableScopeLowerCase')).to.be.undefined;
336
- });
337
- it('disableSubjectLowerCase default', function() {
338
- expect(questionDefault('disableSubjectLowerCase')).to.be.undefined;
339
- });
340
- });
341
-
342
- describe('prompts', function() {
343
- it('commit subject prompt for commit w/ out scope', function() {
344
- expect(questionPrompt('subject', { type })).to.contain(
345
- `(max ${defaultOptions.maxHeaderWidth - type.length - 2} chars)`
346
- );
347
- });
348
- it('commit subject prompt for commit w/ scope', function() {
349
- expect(questionPrompt('subject', { type, scope })).to.contain(
350
- `(max ${defaultOptions.maxHeaderWidth -
351
- type.length -
352
- scope.length -
353
- 4} chars)`
354
- );
355
- });
356
- });
357
-
358
- describe('transformation', function() {
359
- it('subject w/ character count', () =>
360
- expect(
361
- questionTransformation('subject', {
362
- type,
363
- subject
364
- })
365
- ).to.equal(chalk.green(`(${subject.length}) ${subject}`)));
366
- it('long subject w/ character count', () =>
367
- expect(
368
- questionTransformation('subject', {
369
- type,
370
- subject: longBody
371
- })
372
- ).to.equal(chalk.red(`(${longBody.length}) ${longBody}`)));
373
- });
374
-
375
- describe('filter', function() {
376
- it('lowercase scope', () =>
377
- expect(questionFilter('scope', 'HelloMatt')).to.equal('hellomatt'));
378
- it('lowerfirst subject trimmed and trailing dots striped', () =>
379
- expect(questionFilter('subject', ' A subject... ')).to.equal(
380
- 'a subject'
381
- ));
382
- });
383
-
384
- describe('when', function() {
385
- it('breaking by default', () =>
386
- expect(questionWhen('breaking', {})).to.be.undefined);
387
- it('breaking when isBreaking', () =>
388
- expect(
389
- questionWhen('breaking', {
390
- isBreaking: true
391
- })
392
- ).to.be.true);
393
- it('issues by default', () =>
394
- expect(questionWhen('issues', {})).to.be.undefined);
395
- it('issues when isIssueAffected', () =>
396
- expect(
397
- questionWhen('issues', {
398
- isIssueAffected: true
399
- })
400
- ).to.be.true);
401
- });
402
-
403
- describe('commitlint config header-max-length', function() {
404
- //commitlint config parser only supports Node 6.0.0 and higher
405
- if (semver.gte(process.version, '6.0.0')) {
406
- function mockOptions(headerMaxLength) {
407
- var options = undefined;
408
- mock('./engine', function(opts) {
409
- options = opts;
410
- });
411
- if (headerMaxLength) {
412
- mock('cosmiconfig', function() {
413
- return {
414
- load: function(cwd) {
415
- return {
416
- filepath: cwd + '/.commitlintrc.js',
417
- config: {
418
- rules: {
419
- 'header-max-length': [2, 'always', headerMaxLength]
420
- }
421
- }
422
- };
423
- }
424
- };
425
- });
426
- }
427
-
428
- mock.reRequire('./index');
429
- try {
430
- return mock
431
- .reRequire('@commitlint/load')()
432
- .then(function() {
433
- return options;
434
- });
435
- } catch (err) {
436
- return Promise.resolve(options);
437
- }
438
- }
439
-
440
- afterEach(function() {
441
- delete require.cache[require.resolve('./index')];
442
- delete require.cache[require.resolve('@commitlint/load')];
443
- delete process.env.CZ_MAX_HEADER_WIDTH;
444
- mock.stopAll();
445
- });
446
-
447
- it('with no environment or commitizen config override', function() {
448
- return mockOptions(72).then(function(options) {
449
- expect(options).to.have.property('maxHeaderWidth', 72);
450
- });
451
- });
452
-
453
- it('with environment variable override', function() {
454
- process.env.CZ_MAX_HEADER_WIDTH = '105';
455
- return mockOptions(72).then(function(options) {
456
- expect(options).to.have.property('maxHeaderWidth', 105);
457
- });
458
- });
459
-
460
- it('with commitizen config override', function() {
461
- mock('commitizen', {
462
- configLoader: {
463
- load: function() {
464
- return {
465
- maxHeaderWidth: 103
466
- };
467
- }
468
- }
469
- });
470
- return mockOptions(72).then(function(options) {
471
- expect(options).to.have.property('maxHeaderWidth', 103);
472
- });
473
- });
474
- } else {
475
- //Node 4 doesn't support commitlint so the config value should remain the same
476
- it('default value for Node 4', function() {
477
- return mockOptions(72).then(function(options) {
478
- expect(options).to.have.property('maxHeaderWidth', 100);
479
- });
480
- });
481
- }
482
- });
483
- function commitMessage(answers, options) {
484
- options = options || defaultOptions;
485
- var result = null;
486
- engine(options).prompter(
487
- {
488
- prompt: function(questions) {
489
- return {
490
- then: function(finalizer) {
491
- processQuestions(questions, answers, options);
492
- finalizer(answers);
493
- }
494
- };
495
- }
496
- },
497
- function(message) {
498
- result = message;
499
- }
500
- );
501
- return result;
502
- }
503
-
504
- function processQuestions(questions, answers, options) {
505
- for (var i in questions) {
506
- var question = questions[i];
507
- var answer = answers[question.name];
508
- var validation =
509
- answer === undefined || !question.validate
510
- ? true
511
- : question.validate(answer, answers);
512
- if (validation !== true) {
513
- throw new Error(
514
- validation ||
515
- `Answer '${answer}' to question '${question.name}' was invalid`
516
- );
517
- }
518
- if (question.filter && answer) {
519
- answers[question.name] = question.filter(answer);
520
- }
521
- }
522
- }
523
-
524
- function getQuestions(options) {
525
- options = options || defaultOptions;
526
- var result = null;
527
- engine(options).prompter({
528
- prompt: function(questions) {
529
- result = questions;
530
- return {
531
- then: function() {}
532
- };
533
- }
534
- });
535
- return result;
536
- }
537
-
538
- function getQuestion(name, options) {
539
- options = options || defaultOptions;
540
- var questions = getQuestions(options);
541
- for (var i in questions) {
542
- if (questions[i].name === name) {
543
- return questions[i];
544
- }
545
- }
546
- return false;
547
- }
548
-
549
- function questionPrompt(name, answers, options) {
550
- options = options || defaultOptions;
551
- var question = getQuestion(name, options);
552
- return question.message && typeof question.message === 'string'
553
- ? question.message
554
- : question.message(answers);
555
- }
556
-
557
- function questionTransformation(name, answers, options) {
558
- options = options || defaultOptions;
559
- var question = getQuestion(name, options);
560
- return (
561
- question.transformer &&
562
- question.transformer(answers[name], answers, options)
563
- );
564
- }
565
-
566
- function questionFilter(name, answer, options) {
567
- options = options || defaultOptions;
568
- var question = getQuestion(name, options);
569
- return (
570
- question.filter &&
571
- question.filter(typeof answer === 'string' ? answer : answer[name])
572
- );
573
- }
574
-
575
- function questionDefault(name, options) {
576
- options = options || defaultOptions;
577
- var question = getQuestion(name, options);
578
- return question.default;
579
- }
580
-
581
- function questionWhen(name, answers, options) {
582
- options = options || defaultOptions;
583
- var question = getQuestion(name, options);
584
- return question.when(answers);
585
- }
586
-
587
- function customOptions(options) {
588
- Object.keys(defaultOptions).forEach(key => {
589
- if (options[key] === undefined) {
590
- options[key] = defaultOptions[key];
591
- }
592
- });
593
- return options;
594
- }
package/renovate.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "extends": [
3
- "config:base"
4
- ],
5
- "packageRules": [
6
- {
7
- "updateTypes": ["major"]
8
- }
9
- ],
10
- "automerge": false,
11
- "assigneesFromCodeOwners": true,
12
- "assigneesSampleSize": 2,
13
- "bumpVersion": "minor",
14
- "commitBodyTable": true,
15
- "rangeStrategy": "pin",
16
- "labels": [
17
- "maintenance", "renovate"
18
- ]
19
- }