docs(changelog test): i test how to automate ChangeLog
This commit is contained in:
8
node_modules/cz-conventional-changelog/.editorconfig
generated
vendored
Normal file
8
node_modules/cz-conventional-changelog/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
trim_trailing_whitespace = true
|
5
node_modules/cz-conventional-changelog/.prettierrc
generated
vendored
Normal file
5
node_modules/cz-conventional-changelog/.prettierrc
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"endOfLine": "lf",
|
||||
"singleQuote": true
|
||||
}
|
20
node_modules/cz-conventional-changelog/.travis.yml
generated
vendored
Normal file
20
node_modules/cz-conventional-changelog/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 12
|
||||
- 10
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: release
|
||||
node_js: lts/*
|
||||
deploy:
|
||||
provider: script
|
||||
skip_cleanup: true
|
||||
script:
|
||||
- npm run semantic-release
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^greenkeeper/.*$/
|
21
node_modules/cz-conventional-changelog/LICENSE
generated
vendored
Normal file
21
node_modules/cz-conventional-changelog/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2015-2018 Commitizen Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
60
node_modules/cz-conventional-changelog/README.md
generated
vendored
Normal file
60
node_modules/cz-conventional-changelog/README.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# cz-conventional-changelog
|
||||
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
Status:
|
||||
[](https://www.npmjs.org/package/cz-conventional-changelog)
|
||||
[](http://npm-stat.com/charts.html?package=cz-conventional-changelog&from=2015-08-01)
|
||||
[](https://travis-ci.org/commitizen/cz-conventional-changelog)
|
||||
|
||||
Part of the [commitizen](https://github.com/commitizen/cz-cli) family. Prompts for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) standard.
|
||||
|
||||
## Configuration
|
||||
|
||||
### package.json
|
||||
|
||||
Like commitizen, you specify the configuration of cz-conventional-changelog through the package.json's `config.commitizen` key.
|
||||
|
||||
```json5
|
||||
{
|
||||
// ... default values
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog",
|
||||
"disableScopeLowerCase": false,
|
||||
"disableSubjectLowerCase": false,
|
||||
"maxHeaderWidth": 100,
|
||||
"maxLineWidth": 100,
|
||||
"defaultType": "",
|
||||
"defaultScope": "",
|
||||
"defaultSubject": "",
|
||||
"defaultBody": "",
|
||||
"defaultIssues": "",
|
||||
"types": {
|
||||
...
|
||||
"feat": {
|
||||
"description": "A new feature",
|
||||
"title": "Features"
|
||||
},
|
||||
...
|
||||
}
|
||||
}
|
||||
}
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Environment variables
|
||||
|
||||
The following environment varibles can be used to override any default configuration or package.json based configuration.
|
||||
|
||||
* CZ_TYPE = defaultType
|
||||
* CZ_SCOPE = defaultScope
|
||||
* CZ_SUBJECT = defaultSubject
|
||||
* CZ_BODY = defaultBody
|
||||
* CZ_MAX_HEADER_WIDTH = maxHeaderWidth
|
||||
* CZ_MAX_LINE_WIDTH = maxLineWidth
|
||||
|
||||
### Commitlint
|
||||
|
||||
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.
|
221
node_modules/cz-conventional-changelog/engine.js
generated
vendored
Normal file
221
node_modules/cz-conventional-changelog/engine.js
generated
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
'format cjs';
|
||||
|
||||
var wrap = require('word-wrap');
|
||||
var map = require('lodash.map');
|
||||
var longest = require('longest');
|
||||
var chalk = require('chalk');
|
||||
|
||||
var filter = function(array) {
|
||||
return array.filter(function(x) {
|
||||
return x;
|
||||
});
|
||||
};
|
||||
|
||||
var headerLength = function(answers) {
|
||||
return (
|
||||
answers.type.length + 2 + (answers.scope ? answers.scope.length + 2 : 0)
|
||||
);
|
||||
};
|
||||
|
||||
var maxSummaryLength = function(options, answers) {
|
||||
return options.maxHeaderWidth - headerLength(answers);
|
||||
};
|
||||
|
||||
var filterSubject = function(subject, disableSubjectLowerCase) {
|
||||
subject = subject.trim();
|
||||
if (!disableSubjectLowerCase && subject.charAt(0).toLowerCase() !== subject.charAt(0)) {
|
||||
subject =
|
||||
subject.charAt(0).toLowerCase() + subject.slice(1, subject.length);
|
||||
}
|
||||
while (subject.endsWith('.')) {
|
||||
subject = subject.slice(0, subject.length - 1);
|
||||
}
|
||||
return subject;
|
||||
};
|
||||
|
||||
// This can be any kind of SystemJS compatible module.
|
||||
// We use Commonjs here, but ES6 or AMD would do just
|
||||
// fine.
|
||||
module.exports = function(options) {
|
||||
var types = options.types;
|
||||
|
||||
var length = longest(Object.keys(types)).length + 1;
|
||||
var choices = map(types, function(type, key) {
|
||||
return {
|
||||
name: (key + ':').padEnd(length) + ' ' + type.description,
|
||||
value: key
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
// When a user runs `git cz`, prompter will
|
||||
// be executed. We pass you cz, which currently
|
||||
// is just an instance of inquirer.js. Using
|
||||
// this you can ask questions and get answers.
|
||||
//
|
||||
// The commit callback should be executed when
|
||||
// you're ready to send back a commit template
|
||||
// to git.
|
||||
//
|
||||
// By default, we'll de-indent your commit
|
||||
// template and will keep empty lines.
|
||||
prompter: function(cz, commit) {
|
||||
// Let's ask some questions of the user
|
||||
// so that we can populate our commit
|
||||
// template.
|
||||
//
|
||||
// See inquirer.js docs for specifics.
|
||||
// You can also opt to use another input
|
||||
// collection library if you prefer.
|
||||
cz.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'type',
|
||||
message: "Select the type of change that you're committing:",
|
||||
choices: choices,
|
||||
default: options.defaultType
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'scope',
|
||||
message:
|
||||
'What is the scope of this change (e.g. component or file name): (press enter to skip)',
|
||||
default: options.defaultScope,
|
||||
filter: function(value) {
|
||||
return options.disableScopeLowerCase
|
||||
? value.trim()
|
||||
: value.trim().toLowerCase();
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'subject',
|
||||
message: function(answers) {
|
||||
return (
|
||||
'Write a short, imperative tense description of the change (max ' +
|
||||
maxSummaryLength(options, answers) +
|
||||
' chars):\n'
|
||||
);
|
||||
},
|
||||
default: options.defaultSubject,
|
||||
validate: function(subject, answers) {
|
||||
var filteredSubject = filterSubject(subject, options.disableSubjectLowerCase);
|
||||
return filteredSubject.length == 0
|
||||
? 'subject is required'
|
||||
: filteredSubject.length <= maxSummaryLength(options, answers)
|
||||
? true
|
||||
: 'Subject length must be less than or equal to ' +
|
||||
maxSummaryLength(options, answers) +
|
||||
' characters. Current length is ' +
|
||||
filteredSubject.length +
|
||||
' characters.';
|
||||
},
|
||||
transformer: function(subject, answers) {
|
||||
var filteredSubject = filterSubject(subject, options.disableSubjectLowerCase);
|
||||
var color =
|
||||
filteredSubject.length <= maxSummaryLength(options, answers)
|
||||
? chalk.green
|
||||
: chalk.red;
|
||||
return color('(' + filteredSubject.length + ') ' + subject);
|
||||
},
|
||||
filter: function(subject) {
|
||||
return filterSubject(subject, options.disableSubjectLowerCase);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'body',
|
||||
message:
|
||||
'Provide a longer description of the change: (press enter to skip)\n',
|
||||
default: options.defaultBody
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'isBreaking',
|
||||
message: 'Are there any breaking changes?',
|
||||
default: false
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'breakingBody',
|
||||
default: '-',
|
||||
message:
|
||||
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:\n',
|
||||
when: function(answers) {
|
||||
return answers.isBreaking && !answers.body;
|
||||
},
|
||||
validate: function(breakingBody, answers) {
|
||||
return (
|
||||
breakingBody.trim().length > 0 ||
|
||||
'Body is required for BREAKING CHANGE'
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'breaking',
|
||||
message: 'Describe the breaking changes:\n',
|
||||
when: function(answers) {
|
||||
return answers.isBreaking;
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'isIssueAffected',
|
||||
message: 'Does this change affect any open issues?',
|
||||
default: options.defaultIssues ? true : false
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'issuesBody',
|
||||
default: '-',
|
||||
message:
|
||||
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself:\n',
|
||||
when: function(answers) {
|
||||
return (
|
||||
answers.isIssueAffected && !answers.body && !answers.breakingBody
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'issues',
|
||||
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
|
||||
when: function(answers) {
|
||||
return answers.isIssueAffected;
|
||||
},
|
||||
default: options.defaultIssues ? options.defaultIssues : undefined
|
||||
}
|
||||
]).then(function(answers) {
|
||||
var wrapOptions = {
|
||||
trim: true,
|
||||
cut: false,
|
||||
newline: '\n',
|
||||
indent: '',
|
||||
width: options.maxLineWidth
|
||||
};
|
||||
|
||||
// parentheses are only needed when a scope is present
|
||||
var scope = answers.scope ? '(' + answers.scope + ')' : '';
|
||||
|
||||
// Hard limit this line in the validate
|
||||
var head = answers.type + scope + ': ' + answers.subject;
|
||||
|
||||
// Wrap these lines at options.maxLineWidth characters
|
||||
var body = answers.body ? wrap(answers.body, wrapOptions) : false;
|
||||
|
||||
// Apply breaking change prefix, removing it if already present
|
||||
var breaking = answers.breaking ? answers.breaking.trim() : '';
|
||||
breaking = breaking
|
||||
? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '')
|
||||
: '';
|
||||
breaking = breaking ? wrap(breaking, wrapOptions) : false;
|
||||
|
||||
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : false;
|
||||
|
||||
commit(filter([head, body, breaking, issues]).join('\n\n'));
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
594
node_modules/cz-conventional-changelog/engine.test.js
generated
vendored
Normal file
594
node_modules/cz-conventional-changelog/engine.test.js
generated
vendored
Normal file
@ -0,0 +1,594 @@
|
||||
var chai = require('chai');
|
||||
var chalk = require('chalk');
|
||||
var engine = require('./engine');
|
||||
var mock = require('mock-require');
|
||||
var semver = require('semver');
|
||||
|
||||
var types = require('conventional-commit-types').types;
|
||||
|
||||
var expect = chai.expect;
|
||||
chai.should();
|
||||
|
||||
var defaultOptions = {
|
||||
types,
|
||||
maxLineWidth: 100,
|
||||
maxHeaderWidth: 100
|
||||
};
|
||||
|
||||
var type = 'func';
|
||||
var scope = 'everything';
|
||||
var subject = 'testing123';
|
||||
var longBody =
|
||||
'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' +
|
||||
'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' +
|
||||
'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';
|
||||
var longBodySplit =
|
||||
longBody.slice(0, defaultOptions.maxLineWidth).trim() +
|
||||
'\n' +
|
||||
longBody
|
||||
.slice(defaultOptions.maxLineWidth, 2 * defaultOptions.maxLineWidth)
|
||||
.trim() +
|
||||
'\n' +
|
||||
longBody.slice(defaultOptions.maxLineWidth * 2, longBody.length).trim();
|
||||
var body = 'A quick brown fox jumps over the dog';
|
||||
var issues = 'a issues is not a person that kicks things';
|
||||
var longIssues =
|
||||
'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' +
|
||||
'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' +
|
||||
'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';
|
||||
var breakingChange = 'BREAKING CHANGE: ';
|
||||
var breaking = 'asdhdfkjhbakjdhjkashd adhfajkhs asdhkjdsh ahshd';
|
||||
var longIssuesSplit =
|
||||
longIssues.slice(0, defaultOptions.maxLineWidth).trim() +
|
||||
'\n' +
|
||||
longIssues
|
||||
.slice(defaultOptions.maxLineWidth, defaultOptions.maxLineWidth * 2)
|
||||
.trim() +
|
||||
'\n' +
|
||||
longIssues.slice(defaultOptions.maxLineWidth * 2, longIssues.length).trim();
|
||||
|
||||
describe('commit message', function() {
|
||||
it('only header w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject
|
||||
})
|
||||
).to.equal(`${type}: ${subject}`);
|
||||
});
|
||||
it('only header w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject
|
||||
})
|
||||
).to.equal(`${type}(${scope}): ${subject}`);
|
||||
});
|
||||
it('header and body w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${body}`);
|
||||
});
|
||||
it('header and body w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body
|
||||
})
|
||||
).to.equal(`${type}(${scope}): ${subject}\n\n${body}`);
|
||||
});
|
||||
it('header and body w/ uppercase scope', function() {
|
||||
var upperCaseScope = scope.toLocaleUpperCase();
|
||||
expect(
|
||||
commitMessage(
|
||||
{
|
||||
type,
|
||||
scope: upperCaseScope,
|
||||
subject,
|
||||
body
|
||||
},
|
||||
{
|
||||
...defaultOptions,
|
||||
disableScopeLowerCase: true
|
||||
}
|
||||
)
|
||||
).to.equal(`${type}(${upperCaseScope}): ${subject}\n\n${body}`);
|
||||
});
|
||||
it('header and body w/ uppercase subject', function() {
|
||||
var upperCaseSubject = subject.toLocaleUpperCase();
|
||||
expect(
|
||||
commitMessage(
|
||||
{
|
||||
type,
|
||||
scope,
|
||||
subject: upperCaseSubject,
|
||||
body
|
||||
},
|
||||
{
|
||||
...defaultOptions,
|
||||
disableSubjectLowerCase: true
|
||||
}
|
||||
)
|
||||
).to.equal(`${type}(${scope}): ${upperCaseSubject}\n\n${body}`);
|
||||
});
|
||||
it('header, body and issues w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body,
|
||||
issues
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${body}\n\n${issues}`);
|
||||
});
|
||||
it('header, body and issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body,
|
||||
issues
|
||||
})
|
||||
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${issues}`);
|
||||
});
|
||||
it('header, body and long issues w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${body}\n\n${longIssuesSplit}`);
|
||||
});
|
||||
it('header, body and long issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(
|
||||
`${type}(${scope}): ${subject}\n\n${body}\n\n${longIssuesSplit}`
|
||||
);
|
||||
});
|
||||
it('header and long body w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body: longBody
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${longBodySplit}`);
|
||||
});
|
||||
it('header and long body w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body: longBody
|
||||
})
|
||||
).to.equal(`${type}(${scope}): ${subject}\n\n${longBodySplit}`);
|
||||
});
|
||||
it('header, long body and issues w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body: longBody,
|
||||
issues
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${longBodySplit}\n\n${issues}`);
|
||||
});
|
||||
it('header, long body and issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body: longBody,
|
||||
issues
|
||||
})
|
||||
).to.equal(
|
||||
`${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${issues}`
|
||||
);
|
||||
});
|
||||
it('header, long body and long issues w/ out scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
subject,
|
||||
body: longBody,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(`${type}: ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`);
|
||||
});
|
||||
it('header, long body and long issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body: longBody,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(
|
||||
`${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${longIssuesSplit}`
|
||||
);
|
||||
});
|
||||
it('header, long body, breaking change, and long issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body: longBody,
|
||||
breaking,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(
|
||||
`${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
|
||||
);
|
||||
});
|
||||
it('header, long body, breaking change (with prefix entered), and long issues w/ scope', function() {
|
||||
expect(
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject,
|
||||
body: longBody,
|
||||
breaking: `${breakingChange}${breaking}`,
|
||||
issues: longIssues
|
||||
})
|
||||
).to.equal(
|
||||
`${type}(${scope}): ${subject}\n\n${longBodySplit}\n\n${breakingChange}${breaking}\n\n${longIssuesSplit}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validation', function() {
|
||||
it('subject exceeds max length', function() {
|
||||
expect(() =>
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject: longBody
|
||||
})
|
||||
).to.throw(
|
||||
'length must be less than or equal to ' +
|
||||
`${defaultOptions.maxLineWidth - type.length - scope.length - 4}`
|
||||
);
|
||||
});
|
||||
it('empty subject', function() {
|
||||
expect(() =>
|
||||
commitMessage({
|
||||
type,
|
||||
scope,
|
||||
subject: ''
|
||||
})
|
||||
).to.throw('subject is required');
|
||||
});
|
||||
});
|
||||
|
||||
describe('defaults', function() {
|
||||
it('defaultType default', function() {
|
||||
expect(questionDefault('type')).to.be.undefined;
|
||||
});
|
||||
it('defaultType options', function() {
|
||||
expect(
|
||||
questionDefault('type', customOptions({ defaultType: type }))
|
||||
).to.equal(type);
|
||||
});
|
||||
it('defaultScope default', function() {
|
||||
expect(questionDefault('scope')).to.be.undefined;
|
||||
});
|
||||
it('defaultScope options', () =>
|
||||
expect(
|
||||
questionDefault('scope', customOptions({ defaultScope: scope }))
|
||||
).to.equal(scope));
|
||||
|
||||
it('defaultSubject default', () =>
|
||||
expect(questionDefault('subject')).to.be.undefined);
|
||||
it('defaultSubject options', function() {
|
||||
expect(
|
||||
questionDefault(
|
||||
'subject',
|
||||
customOptions({
|
||||
defaultSubject: subject
|
||||
})
|
||||
)
|
||||
).to.equal(subject);
|
||||
});
|
||||
it('defaultBody default', function() {
|
||||
expect(questionDefault('body')).to.be.undefined;
|
||||
});
|
||||
it('defaultBody options', function() {
|
||||
expect(
|
||||
questionDefault('body', customOptions({ defaultBody: body }))
|
||||
).to.equal(body);
|
||||
});
|
||||
it('defaultIssues default', function() {
|
||||
expect(questionDefault('issues')).to.be.undefined;
|
||||
});
|
||||
it('defaultIssues options', function() {
|
||||
expect(
|
||||
questionDefault(
|
||||
'issues',
|
||||
customOptions({
|
||||
defaultIssues: issues
|
||||
})
|
||||
)
|
||||
).to.equal(issues);
|
||||
});
|
||||
it('disableScopeLowerCase default', function() {
|
||||
expect(questionDefault('disableScopeLowerCase')).to.be.undefined;
|
||||
});
|
||||
it('disableSubjectLowerCase default', function() {
|
||||
expect(questionDefault('disableSubjectLowerCase')).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('prompts', function() {
|
||||
it('commit subject prompt for commit w/ out scope', function() {
|
||||
expect(questionPrompt('subject', { type })).to.contain(
|
||||
`(max ${defaultOptions.maxHeaderWidth - type.length - 2} chars)`
|
||||
);
|
||||
});
|
||||
it('commit subject prompt for commit w/ scope', function() {
|
||||
expect(questionPrompt('subject', { type, scope })).to.contain(
|
||||
`(max ${defaultOptions.maxHeaderWidth -
|
||||
type.length -
|
||||
scope.length -
|
||||
4} chars)`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('transformation', function() {
|
||||
it('subject w/ character count', () =>
|
||||
expect(
|
||||
questionTransformation('subject', {
|
||||
type,
|
||||
subject
|
||||
})
|
||||
).to.equal(chalk.green(`(${subject.length}) ${subject}`)));
|
||||
it('long subject w/ character count', () =>
|
||||
expect(
|
||||
questionTransformation('subject', {
|
||||
type,
|
||||
subject: longBody
|
||||
})
|
||||
).to.equal(chalk.red(`(${longBody.length}) ${longBody}`)));
|
||||
});
|
||||
|
||||
describe('filter', function() {
|
||||
it('lowercase scope', () =>
|
||||
expect(questionFilter('scope', 'HelloMatt')).to.equal('hellomatt'));
|
||||
it('lowerfirst subject trimmed and trailing dots striped', () =>
|
||||
expect(questionFilter('subject', ' A subject... ')).to.equal(
|
||||
'a subject'
|
||||
));
|
||||
});
|
||||
|
||||
describe('when', function() {
|
||||
it('breaking by default', () =>
|
||||
expect(questionWhen('breaking', {})).to.be.undefined);
|
||||
it('breaking when isBreaking', () =>
|
||||
expect(
|
||||
questionWhen('breaking', {
|
||||
isBreaking: true
|
||||
})
|
||||
).to.be.true);
|
||||
it('issues by default', () =>
|
||||
expect(questionWhen('issues', {})).to.be.undefined);
|
||||
it('issues when isIssueAffected', () =>
|
||||
expect(
|
||||
questionWhen('issues', {
|
||||
isIssueAffected: true
|
||||
})
|
||||
).to.be.true);
|
||||
});
|
||||
|
||||
describe('commitlint config header-max-length', function() {
|
||||
//commitlint config parser only supports Node 6.0.0 and higher
|
||||
if (semver.gte(process.version, '6.0.0')) {
|
||||
function mockOptions(headerMaxLength) {
|
||||
var options = undefined;
|
||||
mock('./engine', function(opts) {
|
||||
options = opts;
|
||||
});
|
||||
if (headerMaxLength) {
|
||||
mock('cosmiconfig', function() {
|
||||
return {
|
||||
load: function(cwd) {
|
||||
return {
|
||||
filepath: cwd + '/.commitlintrc.js',
|
||||
config: {
|
||||
rules: {
|
||||
'header-max-length': [2, 'always', headerMaxLength]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
mock.reRequire('./index');
|
||||
try {
|
||||
return mock
|
||||
.reRequire('@commitlint/load')()
|
||||
.then(function() {
|
||||
return options;
|
||||
});
|
||||
} catch (err) {
|
||||
return Promise.resolve(options);
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(function() {
|
||||
delete require.cache[require.resolve('./index')];
|
||||
delete require.cache[require.resolve('@commitlint/load')];
|
||||
delete process.env.CZ_MAX_HEADER_WIDTH;
|
||||
mock.stopAll();
|
||||
});
|
||||
|
||||
it('with no environment or commitizen config override', function() {
|
||||
return mockOptions(72).then(function(options) {
|
||||
expect(options).to.have.property('maxHeaderWidth', 72);
|
||||
});
|
||||
});
|
||||
|
||||
it('with environment variable override', function() {
|
||||
process.env.CZ_MAX_HEADER_WIDTH = '105';
|
||||
return mockOptions(72).then(function(options) {
|
||||
expect(options).to.have.property('maxHeaderWidth', 105);
|
||||
});
|
||||
});
|
||||
|
||||
it('with commitizen config override', function() {
|
||||
mock('commitizen', {
|
||||
configLoader: {
|
||||
load: function() {
|
||||
return {
|
||||
maxHeaderWidth: 103
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
return mockOptions(72).then(function(options) {
|
||||
expect(options).to.have.property('maxHeaderWidth', 103);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//Node 4 doesn't support commitlint so the config value should remain the same
|
||||
it('default value for Node 4', function() {
|
||||
return mockOptions(72).then(function(options) {
|
||||
expect(options).to.have.property('maxHeaderWidth', 100);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
function commitMessage(answers, options) {
|
||||
options = options || defaultOptions;
|
||||
var result = null;
|
||||
engine(options).prompter(
|
||||
{
|
||||
prompt: function(questions) {
|
||||
return {
|
||||
then: function(finalizer) {
|
||||
processQuestions(questions, answers, options);
|
||||
finalizer(answers);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
function(message) {
|
||||
result = message;
|
||||
}
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
function processQuestions(questions, answers, options) {
|
||||
for (var i in questions) {
|
||||
var question = questions[i];
|
||||
var answer = answers[question.name];
|
||||
var validation =
|
||||
answer === undefined || !question.validate
|
||||
? true
|
||||
: question.validate(answer, answers);
|
||||
if (validation !== true) {
|
||||
throw new Error(
|
||||
validation ||
|
||||
`Answer '${answer}' to question '${question.name}' was invalid`
|
||||
);
|
||||
}
|
||||
if (question.filter && answer) {
|
||||
answers[question.name] = question.filter(answer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getQuestions(options) {
|
||||
options = options || defaultOptions;
|
||||
var result = null;
|
||||
engine(options).prompter({
|
||||
prompt: function(questions) {
|
||||
result = questions;
|
||||
return {
|
||||
then: function() {}
|
||||
};
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function getQuestion(name, options) {
|
||||
options = options || defaultOptions;
|
||||
var questions = getQuestions(options);
|
||||
for (var i in questions) {
|
||||
if (questions[i].name === name) {
|
||||
return questions[i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function questionPrompt(name, answers, options) {
|
||||
options = options || defaultOptions;
|
||||
var question = getQuestion(name, options);
|
||||
return question.message && typeof question.message === 'string'
|
||||
? question.message
|
||||
: question.message(answers);
|
||||
}
|
||||
|
||||
function questionTransformation(name, answers, options) {
|
||||
options = options || defaultOptions;
|
||||
var question = getQuestion(name, options);
|
||||
return (
|
||||
question.transformer &&
|
||||
question.transformer(answers[name], answers, options)
|
||||
);
|
||||
}
|
||||
|
||||
function questionFilter(name, answer, options) {
|
||||
options = options || defaultOptions;
|
||||
var question = getQuestion(name, options);
|
||||
return (
|
||||
question.filter &&
|
||||
question.filter(typeof answer === 'string' ? answer : answer[name])
|
||||
);
|
||||
}
|
||||
|
||||
function questionDefault(name, options) {
|
||||
options = options || defaultOptions;
|
||||
var question = getQuestion(name, options);
|
||||
return question.default;
|
||||
}
|
||||
|
||||
function questionWhen(name, answers, options) {
|
||||
options = options || defaultOptions;
|
||||
var question = getQuestion(name, options);
|
||||
return question.when(answers);
|
||||
}
|
||||
|
||||
function customOptions(options) {
|
||||
Object.keys(defaultOptions).forEach(key => {
|
||||
if (options[key] === undefined) {
|
||||
options[key] = defaultOptions[key];
|
||||
}
|
||||
});
|
||||
return options;
|
||||
}
|
50
node_modules/cz-conventional-changelog/index.js
generated
vendored
Normal file
50
node_modules/cz-conventional-changelog/index.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'format cjs';
|
||||
|
||||
var engine = require('./engine');
|
||||
var conventionalCommitTypes = require('conventional-commit-types');
|
||||
var configLoader = require('commitizen').configLoader;
|
||||
|
||||
var config = configLoader.load() || {};
|
||||
var options = {
|
||||
types: config.types || conventionalCommitTypes.types,
|
||||
defaultType: process.env.CZ_TYPE || config.defaultType,
|
||||
defaultScope: process.env.CZ_SCOPE || config.defaultScope,
|
||||
defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
|
||||
defaultBody: process.env.CZ_BODY || config.defaultBody,
|
||||
defaultIssues: process.env.CZ_ISSUES || config.defaultIssues,
|
||||
disableScopeLowerCase:
|
||||
process.env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
|
||||
disableSubjectLowerCase:
|
||||
process.env.DISABLE_SUBJECT_LOWERCASE || config.disableSubjectLowerCase,
|
||||
maxHeaderWidth:
|
||||
(process.env.CZ_MAX_HEADER_WIDTH &&
|
||||
parseInt(process.env.CZ_MAX_HEADER_WIDTH)) ||
|
||||
config.maxHeaderWidth ||
|
||||
100,
|
||||
maxLineWidth:
|
||||
(process.env.CZ_MAX_LINE_WIDTH &&
|
||||
parseInt(process.env.CZ_MAX_LINE_WIDTH)) ||
|
||||
config.maxLineWidth ||
|
||||
100
|
||||
};
|
||||
|
||||
(function(options) {
|
||||
try {
|
||||
var commitlintLoad = require('@commitlint/load');
|
||||
commitlintLoad().then(function(clConfig) {
|
||||
if (clConfig.rules) {
|
||||
var maxHeaderLengthRule = clConfig.rules['header-max-length'];
|
||||
if (
|
||||
typeof maxHeaderLengthRule === 'object' &&
|
||||
maxHeaderLengthRule.length >= 3 &&
|
||||
!process.env.CZ_MAX_HEADER_WIDTH &&
|
||||
!config.maxHeaderWidth
|
||||
) {
|
||||
options.maxHeaderWidth = maxHeaderLengthRule[2];
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (err) {}
|
||||
})(options);
|
||||
|
||||
module.exports = engine(options);
|
50
node_modules/cz-conventional-changelog/package.json
generated
vendored
Normal file
50
node_modules/cz-conventional-changelog/package.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "cz-conventional-changelog",
|
||||
"version": "3.3.0",
|
||||
"description": "Commitizen adapter following the conventional-changelog format.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"commit": "git-cz",
|
||||
"test": "mocha *.test.js",
|
||||
"format": "prettier --write *.js",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"homepage": "https://github.com/commitizen/cz-conventional-changelog",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/commitizen/cz-conventional-changelog.git"
|
||||
},
|
||||
"engineStrict": true,
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"author": "Jim Cummins <jimthedev@gmail.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chalk": "^2.4.1",
|
||||
"commitizen": "^4.0.3",
|
||||
"conventional-commit-types": "^3.0.0",
|
||||
"lodash.map": "^4.5.1",
|
||||
"longest": "^2.0.1",
|
||||
"word-wrap": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"chai": "^4.2.0",
|
||||
"cosmiconfig": "^5.2.1",
|
||||
"mocha": "^6.2.0",
|
||||
"mock-require": "^3.0.3",
|
||||
"prettier": "^1.15.3",
|
||||
"semantic-release": "^15.13.3",
|
||||
"semver": "^6.2.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@commitlint/load": ">6.1.1"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./index.js"
|
||||
}
|
||||
}
|
||||
}
|
19
node_modules/cz-conventional-changelog/renovate.json
generated
vendored
Normal file
19
node_modules/cz-conventional-changelog/renovate.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"updateTypes": ["major"]
|
||||
}
|
||||
],
|
||||
"automerge": false,
|
||||
"assigneesFromCodeOwners": true,
|
||||
"assigneesSampleSize": 2,
|
||||
"bumpVersion": "minor",
|
||||
"commitBodyTable": true,
|
||||
"rangeStrategy": "pin",
|
||||
"labels": [
|
||||
"maintenance", "renovate"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user