Skip to content

Commit a97a2e9

Browse files
Éverton ArrudaSaeger
andauthored
feat: replace commitizen library to original one (#78)
The official repository was able to address the security fixes BREAKING CHANGE: Switching back commitizen and cz-conventional-changelog libraries to the official ones Co-authored-by: Márcio Saeger <marcio.saeger@digitalroute.com>
1 parent 660ec86 commit a97a2e9

File tree

5 files changed

+951
-1005
lines changed

5 files changed

+951
-1005
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# cz-conventional-changelog-for-jira
22

3-
Part of the [@ryansonshine/commitizen](https://github.com/ryansonshine/cz-cli) family. Prompts for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) standard and also prompts for a mandatory JIRA issue.
4-
5-
**Note**: [commitizen](https://www.npmjs.com/package/commitizen) has been replaced by [@ryansonshine/commitizen](https://github.com/ryansonshine/cz-cli) because the latest version published in NPM has critical security issues and it appears that the developers can't publish new versions to NPM. [@ryansonshine/commitizen](https://github.com/ryansonshine/cz-cli) has fixed the critical issues and published a newer version in NPM. Read [this comment](https://github.com/commitizen/cz-cli/issues/914#issuecomment-1131383383) for more information.
3+
Part of the [commitizen/cz-cli](https://github.com/commitizen/cz-cli) family. Prompts for [conventional changelog](https://github.com/conventional-changelog/conventional-changelog) standard and also prompts for a mandatory JIRA issue.
64

75
[![npm version](https://img.shields.io/npm/v/@digitalroute/cz-conventional-changelog-for-jira.svg?style=flat-square)](https://www.npmjs.org/package/@digitalroute/cz-conventional-changelog-for-jira)
86
[![npm downloads](https://img.shields.io/npm/dm/@digitalroute/cz-conventional-changelog-for-jira.svg?style=flat-square)](http://npm-stat.com/charts.html?package=@digitalroute/cz-conventional-changelog-for-jira)
@@ -19,7 +17,7 @@ Part of the [@ryansonshine/commitizen](https://github.com/ryansonshine/cz-cli) f
1917
### Installation
2018

2119
```bash
22-
npm install @ryansonshine/commitizen @digitalroute/cz-conventional-changelog-for-jira
20+
npm install commitizen @digitalroute/cz-conventional-changelog-for-jira
2321
```
2422

2523
and then add the following to package.json:
@@ -46,15 +44,15 @@ and then add the following to package.json:
4644
Like commitizen, you can specify the configuration of cz-conventional-changelog-for-jira through the package.json's `config.commitizen` key, or with environment variables.
4745

4846
| Environment variable | package.json | Default | Description |
49-
|----------------------|-----------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
47+
| -------------------- | --------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5048
| CZ_JIRA_MODE | jiraMode | true | If this is set to true, CZ will ask for a Jira issue and put it in the commit head. If set to false CZ will ask for the issue in the end, and can be used for GitHub. |
5149
| CZ_MAX_HEADER_WIDTH | maxHeaderWidth | 72 | This limits how long a commit message head can be. |
5250
| CZ_MIN_HEADER_WIDTH | minHeaderWidth | 2 | This limits how short a commit message can be. |
5351
| CZ_MAX_LINE_WIDTH | maxLineWidth | 100 | Commit message bodies are automatically wrapped. This decides how long the lines will be. |
5452
| CZ_SKIP_SCOPE | skipScope | true | If scope should be used in commit messages. |
5553
| CZ_SKIP_TYPE | skipType | false | If type should be used in commit messages. |
56-
| CZ_SKIP_DESCRIPTION | skipDescription | false | If description should be used in commit messages. |
57-
| CZ_SKIP_BREAKING | skipBreaking | false | If breaking changes should be used in commit messages. |
54+
| CZ_SKIP_DESCRIPTION | skipDescription | false | If description should be used in commit messages. |
55+
| CZ_SKIP_BREAKING | skipBreaking | false | If breaking changes should be used in commit messages. |
5856
| | scopes | undefined | A list (JS Array) of scopes that will be available for selection. Note that adding this will change the scope field from Inquirer 'input' to 'list'. |
5957
| CZ_TYPE | defaultType | undefined | The default type. |
6058
| CZ_SCOPE | defaultScope | undefined | The default scope. |
@@ -72,26 +70,31 @@ Like commitizen, you can specify the configuration of cz-conventional-changelog-
7270
### Jira Location Options
7371

7472
pre-type:
73+
7574
```text
7675
JIRA-1234 type(scope): commit subject
7776
```
7877

7978
pre-description:
79+
8080
```text
8181
type(scope): JIRA-1234 commit subject
8282
```
8383

8484
post-description:
85+
8586
```text
8687
type(scope): commit subject JIRA-1234
8788
```
8889

8990
post-body:
91+
9092
```text
9193
type(scope): commit subject
9294
9395
JIRA-1234
9496
```
97+
9598
```text
9699
type(scope): commit subject
97100
@@ -105,6 +108,7 @@ JIRA-1234
105108
Alternatively, if you want to create your own profile, you can use the _configurable_ approach.
106109
Here is an example:
107110
**./index.js**
111+
108112
```javascript
109113
const custom = require('@digitalroute/cz-conventional-changelog-for-jira/configurable');
110114
// You can do this optionally if you want to extend the commit types
@@ -123,7 +127,9 @@ module.exports = custom({
123127
customScope: true
124128
});
125129
```
130+
126131
**./package.json**
132+
127133
```json
128134
{
129135
"config": {
@@ -135,14 +141,15 @@ module.exports = custom({
135141
```
136142

137143
This example would:
138-
* Display _"perf"_ as an extra commit type
139-
* Ask you to add a commit scope
140-
* Limit the scope selection to either `myScope` or `myScope2`
144+
145+
- Display _"perf"_ as an extra commit type
146+
- Ask you to add a commit scope
147+
- Limit the scope selection to either `myScope` or `myScope2`
141148

142149
List of all supported configurable options when using the _configurable_ approach:
143150

144151
| Key | Default | Description |
145-
|-----------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
152+
| --------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
146153
| jiraMode | true | If this is set to true, CZ will ask for a Jira issue and put it in the commit head. If set to false CZ will ask for the issue in the end, and can be used for GitHub. |
147154
| maxHeaderWidth | 72 | This limits how long a commit message head can be. |
148155
| minHeaderWidth | 2 | This limits how short a commit message can be. |
@@ -163,7 +170,6 @@ List of all supported configurable options when using the _configurable_ approac
163170
| jiraAppend | "" | Appends JIRA ID with an optional decorator. e.g.: `DAZ-1234]` |
164171
| exclamationMark | false | On breaking changes, adds an exclamation mark (!) after the scope, e.g.: `type(scope)!: break stuff`. When activated, reduces the effective allowed header length by 1. |
165172

166-
167173
### Commitlint
168174

169175
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 72. This can be ovewritten by setting the 'maxHeaderWidth' configuration in package.json or the CZ_MAX_HEADER_WIDTH environment variable.

engine.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,11 +663,13 @@ describe('commit message', function() {
663663
jira,
664664
subject,
665665
body,
666-
breaking,
666+
breaking
667667
},
668668
{ ...defaultOptions, jiraLocation: 'post-body' }
669669
)
670-
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}\n\n${breakingChange}${breaking}`);
670+
).to.equal(
671+
`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}\n\n${breakingChange}${breaking}`
672+
);
671673
});
672674
it('jiraPrepend decorator', function() {
673675
expect(
@@ -903,7 +905,7 @@ describe('commitlint config header-max-length', function() {
903905
});
904906

905907
it('with commitizen config override', function() {
906-
mock('@ryansonshine/commitizen', {
908+
mock('commitizen', {
907909
configLoader: {
908910
load: function() {
909911
return {

index.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var engine = require('./engine');
44
var conventionalCommitTypes = require('./types');
55
var defaults = require('./defaults');
6-
var configLoader = require('@ryansonshine/commitizen').configLoader;
6+
var configLoader = require('commitizen').configLoader;
77

88
var config = configLoader.load();
99

@@ -75,26 +75,20 @@ const options = {
7575
defaults.jiraOptional
7676
),
7777
jiraPrefix:
78-
process.env.CZ_JIRA_PREFIX ||
79-
config.jiraPrefix ||
80-
defaults.jiraPrefix,
78+
process.env.CZ_JIRA_PREFIX || config.jiraPrefix || defaults.jiraPrefix,
8179
jiraLocation:
8280
process.env.CZ_JIRA_LOCATION ||
8381
config.jiraLocation ||
8482
defaults.jiraLocation,
8583
jiraPrepend:
86-
process.env.CZ_JIRA_PREPEND ||
87-
config.jiraPrepend ||
88-
defaults.jiraPrepend,
84+
process.env.CZ_JIRA_PREPEND || config.jiraPrepend || defaults.jiraPrepend,
8985
jiraAppend:
90-
process.env.CZ_JIRA_APPEND ||
91-
config.jiraAppend ||
92-
defaults.jiraAppend,
93-
exclamationMark: getEnvOrConfig(
94-
process.env.CZ_EXCLAMATION_MARK,
95-
config.exclamationMark,
96-
defaults.exclamationMark
97-
)
86+
process.env.CZ_JIRA_APPEND || config.jiraAppend || defaults.jiraAppend,
87+
exclamationMark: getEnvOrConfig(
88+
process.env.CZ_EXCLAMATION_MARK,
89+
config.exclamationMark,
90+
defaults.exclamationMark
91+
)
9892
};
9993

10094
(function(options) {

0 commit comments

Comments
 (0)