Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cz-conventional-changelog

Package Overview
Dependencies
Maintainers
5
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cz-conventional-changelog - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

.editorconfig

166

engine.js

@@ -1,2 +0,2 @@

"format cjs";
'format cjs';

@@ -7,2 +7,3 @@ var wrap = require('word-wrap');

var rightPad = require('right-pad');
var chalk = require('chalk');

@@ -15,11 +16,32 @@ var filter = function(array) {

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) {
subject = subject.trim();
if (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) {
module.exports = function(options) {
var types = options.types;
var length = longest(Object.keys(types)).length + 1;
var choices = map(types, function (type, key) {
var choices = map(types, function(type, key) {
return {

@@ -44,4 +66,2 @@ name: rightPad(key + ':', length) + ' ' + type.description,

prompter: function(cz, commit) {
console.log('\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n');
// Let's ask some questions of the user

@@ -58,17 +78,59 @@ // so that we can populate our commit

name: 'type',
message: 'Select the type of change that you\'re committing:',
choices: choices
}, {
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)\n'
}, {
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 value.trim().toLowerCase();
}
},
{
type: 'input',
name: 'subject',
message: 'Write a short, imperative tense description of the change:\n'
}, {
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);
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);
var color =
filteredSubject.length <= maxSummaryLength(options, answers)
? chalk.green
: chalk.red;
return color('(' + filteredSubject.length + ') ' + subject);
},
filter: function(subject) {
return filterSubject(subject);
}
},
{
type: 'input',
name: 'body',
message: 'Provide a longer description of the change: (press enter to skip)\n'
}, {
message:
'Provide a longer description of the change: (press enter to skip)\n',
default: options.defaultBody
},
{
type: 'confirm',

@@ -78,4 +140,21 @@ name: 'isBreaking',

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',

@@ -86,9 +165,24 @@ message: 'Describe the breaking changes:\n',

}
}, {
},
{
type: 'confirm',
name: 'isIssueAffected',
message: 'Does this change affect any open issues?',
default: false
}, {
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',

@@ -98,35 +192,33 @@ message: 'Add issue references (e.g. "fix #123", "re #123".):\n',

return answers.isIssueAffected;
}
},
default: options.defaultIssues ? options.defaultIssues : undefined
}
]).then(function(answers) {
var maxLineWidth = 100;
var wrapOptions = {
trim: true,
cut: false,
newline: '\n',
indent:'',
width: maxLineWidth
indent: '',
width: options.maxLineWidth
};
// parentheses are only needed when a scope is present
var scope = answers.scope.trim();
scope = scope ? '(' + answers.scope.trim() + ')' : '';
var scope = answers.scope ? '(' + answers.scope + ')' : '';
// Hard limit this line
var head = (answers.type + scope + ': ' + answers.subject.trim()).slice(0, maxLineWidth);
// Hard limit this line in the validate
var head = answers.type + scope + ': ' + answers.subject;
// Wrap these lines at 100 characters
var body = wrap(answers.body, wrapOptions);
// 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 = wrap(breaking, wrapOptions);
breaking = breaking
? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '')
: '';
breaking = breaking ? wrap(breaking, wrapOptions) : false;
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : '';
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : false;
var footer = filter([ breaking, issues ]).join('\n\n');
commit(head + '\n\n' + body + '\n\n' + footer);
commit(filter([head, body, breaking, issues]).join('\n\n'));
});

@@ -133,0 +225,0 @@ }

@@ -1,8 +0,46 @@

"format cjs";
'format cjs';
var engine = require('./engine');
var conventionalCommitTypes = require('conventional-commit-types');
var configLoader = require('commitizen').configLoader;
module.exports = engine({
types: conventionalCommitTypes.types
});
var config = configLoader.load();
var options = {
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,
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);
{
"name": "cz-conventional-changelog",
"version": "2.1.0",
"version": "3.0.0",
"description": "Commitizen adapter following the conventional-changelog format.",

@@ -8,4 +8,5 @@ "main": "index.js",

"commit": "git-cz",
"test": "echo 'Tests need to be setup!'",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"test": "mocha *.test.js",
"format": "prettier --write *.js",
"semantic-release": "semantic-release"
},

@@ -17,5 +18,10 @@ "homepage": "https://github.com/commitizen/cz-conventional-changelog",

},
"engineStrict": true,
"engines": {
"node": ">= 10"
},
"author": "Jim Cummins <jimthedev@gmail.com>",
"license": "MIT",
"dependencies": {
"chalk": "^2.4.1",
"conventional-commit-types": "^2.0.0",

@@ -28,5 +34,16 @@ "lodash.map": "^4.5.1",

"devDependencies": {
"commitizen": "2.9.6",
"semantic-release": "^6.3.2"
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.7",
"chai": "^4.2.0",
"commitizen": "^4.0.2",
"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": {

@@ -37,2 +54,2 @@ "commitizen": {

}
}
}

@@ -8,2 +8,42 @@ # cz-conventional-changelog

Part of the [commitizen](https://github.com/commitizen/cz-cli) family. Prompts for [conventional changelog](https://github.com/stevemao/conventional-changelog-angular/blob/master/index.js) standard.
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",
"maxHeaderWidth": 100,
"maxLineWidth": 100,
"defaultType": "",
"defaultScope": "",
"defaultSubject": "",
"defaultBody": "",
"defaultIssues": ""
}
}
// ...
}
```
### 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.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc