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