Skip to content

Commit

Permalink
feat: replace commitizen library to original one (#78)
Browse files Browse the repository at this point in the history
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>
Éverton Arruda and Saeger authored Dec 20, 2022
1 parent 660ec86 commit a97a2e9
Showing 5 changed files with 951 additions and 1,005 deletions.
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# cz-conventional-changelog-for-jira

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.

**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.
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.

[![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)
[![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
### Installation

```bash
npm install @ryansonshine/commitizen @digitalroute/cz-conventional-changelog-for-jira
npm install commitizen @digitalroute/cz-conventional-changelog-for-jira
```

and then add the following to package.json:
@@ -46,15 +44,15 @@ and then add the following to package.json:
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.

| Environment variable | package.json | Default | Description |
|----------------------|-----------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -------------------- | --------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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. |
| CZ_MAX_HEADER_WIDTH | maxHeaderWidth | 72 | This limits how long a commit message head can be. |
| CZ_MIN_HEADER_WIDTH | minHeaderWidth | 2 | This limits how short a commit message can be. |
| CZ_MAX_LINE_WIDTH | maxLineWidth | 100 | Commit message bodies are automatically wrapped. This decides how long the lines will be. |
| CZ_SKIP_SCOPE | skipScope | true | If scope should be used in commit messages. |
| CZ_SKIP_TYPE | skipType | false | If type should be used in commit messages. |
| CZ_SKIP_DESCRIPTION | skipDescription | false | If description should be used in commit messages. |
| CZ_SKIP_BREAKING | skipBreaking | false | If breaking changes should be used in commit messages. |
| CZ_SKIP_DESCRIPTION | skipDescription | false | If description should be used in commit messages. |
| CZ_SKIP_BREAKING | skipBreaking | false | If breaking changes should be used in commit messages. |
| | 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'. |
| CZ_TYPE | defaultType | undefined | The default type. |
| CZ_SCOPE | defaultScope | undefined | The default scope. |
@@ -72,26 +70,31 @@ Like commitizen, you can specify the configuration of cz-conventional-changelog-
### Jira Location Options

pre-type:

```text
JIRA-1234 type(scope): commit subject
```

pre-description:

```text
type(scope): JIRA-1234 commit subject
```

post-description:

```text
type(scope): commit subject JIRA-1234
```

post-body:

```text
type(scope): commit subject
JIRA-1234
```

```text
type(scope): commit subject
@@ -105,6 +108,7 @@ JIRA-1234
Alternatively, if you want to create your own profile, you can use the _configurable_ approach.
Here is an example:
**./index.js**

```javascript
const custom = require('@digitalroute/cz-conventional-changelog-for-jira/configurable');
// You can do this optionally if you want to extend the commit types
@@ -123,7 +127,9 @@ module.exports = custom({
customScope: true
});
```

**./package.json**

```json
{
"config": {
@@ -135,14 +141,15 @@ module.exports = custom({
```

This example would:
* Display _"perf"_ as an extra commit type
* Ask you to add a commit scope
* Limit the scope selection to either `myScope` or `myScope2`

- Display _"perf"_ as an extra commit type
- Ask you to add a commit scope
- Limit the scope selection to either `myScope` or `myScope2`

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

| Key | Default | Description |
|-----------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| --------------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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. |
| maxHeaderWidth | 72 | This limits how long a commit message head can be. |
| 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
| jiraAppend | "" | Appends JIRA ID with an optional decorator. e.g.: `DAZ-1234]` |
| 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. |


### 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 72. This can be ovewritten by setting the 'maxHeaderWidth' configuration in package.json or the CZ_MAX_HEADER_WIDTH environment variable.
8 changes: 5 additions & 3 deletions engine.test.js
Original file line number Diff line number Diff line change
@@ -663,11 +663,13 @@ describe('commit message', function() {
jira,
subject,
body,
breaking,
breaking
},
{ ...defaultOptions, jiraLocation: 'post-body' }
)
).to.equal(`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}\n\n${breakingChange}${breaking}`);
).to.equal(
`${type}(${scope}): ${subject}\n\n${body}\n\n${jiraUpperCase}\n\n${breakingChange}${breaking}`
);
});
it('jiraPrepend decorator', function() {
expect(
@@ -903,7 +905,7 @@ describe('commitlint config header-max-length', function() {
});

it('with commitizen config override', function() {
mock('@ryansonshine/commitizen', {
mock('commitizen', {
configLoader: {
load: function() {
return {
24 changes: 9 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
var engine = require('./engine');
var conventionalCommitTypes = require('./types');
var defaults = require('./defaults');
var configLoader = require('@ryansonshine/commitizen').configLoader;
var configLoader = require('commitizen').configLoader;

var config = configLoader.load();

@@ -75,26 +75,20 @@ const options = {
defaults.jiraOptional
),
jiraPrefix:
process.env.CZ_JIRA_PREFIX ||
config.jiraPrefix ||
defaults.jiraPrefix,
process.env.CZ_JIRA_PREFIX || config.jiraPrefix || defaults.jiraPrefix,
jiraLocation:
process.env.CZ_JIRA_LOCATION ||
config.jiraLocation ||
defaults.jiraLocation,
jiraPrepend:
process.env.CZ_JIRA_PREPEND ||
config.jiraPrepend ||
defaults.jiraPrepend,
process.env.CZ_JIRA_PREPEND || config.jiraPrepend || defaults.jiraPrepend,
jiraAppend:
process.env.CZ_JIRA_APPEND ||
config.jiraAppend ||
defaults.jiraAppend,
exclamationMark: getEnvOrConfig(
process.env.CZ_EXCLAMATION_MARK,
config.exclamationMark,
defaults.exclamationMark
)
process.env.CZ_JIRA_APPEND || config.jiraAppend || defaults.jiraAppend,
exclamationMark: getEnvOrConfig(
process.env.CZ_EXCLAMATION_MARK,
config.exclamationMark,
defaults.exclamationMark
)
};

(function(options) {
Loading

0 comments on commit a97a2e9

Please sign in to comment.