Skip to content

Commit

Permalink
feat: 🎸 automatically infer type list from Types object
Browse files Browse the repository at this point in the history
You no longer need a seperate "list" key in your config to manage what
types are listed.

BREAKING CHANGE: 🧨 we no longer repsect the config.list ordering of types, instead relying
on the ordering of the config.types instead.
  • Loading branch information
StanLindsey committed Apr 29, 2020
1 parent 3206494 commit 5f13da4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 51 deletions.
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)


# git-cz

![image](https://user-images.githubusercontent.com/9773803/49760520-fa6c6f00-fcc4-11e8-84c4-80727f071487.png)


### Without installation

Expand Down Expand Up @@ -57,7 +54,6 @@ run:
git cz
```


## Custom config

You can provide a custom configuration in a `changelog.config.js` file in your repo, or in any parent folder.
Expand All @@ -66,19 +62,9 @@ Below is default config:

```js
module.exports = {
enableWritingScopes: false,
"disableEmoji": false,
"list": [
"test",
"feat",
"fix",
"chore",
"docs",
"refactor",
"style",
"ci",
"perf"
],
"breakingChangePrefix": "🧨 ",
"closedIssuePrefix": "✅ ",
"enableWritingScopes": false,
"maxMessageLength": 64,
"minMessageLength": 3,
"questions": [
Expand Down Expand Up @@ -166,8 +152,7 @@ CLI parameters:
- `--issues`
- `--lerna`


## Commit message format
## Commit Message Format

* A commit message consists of a **header**, **body** and **footer**.
* The header has a **type** and a **subject**:
Expand All @@ -194,15 +179,17 @@ This allows the message to be easier to read on GitHub as well as in various git

Must be one of the following:

- `test` — Adding missing tests
- `feat` — A new feature
- `fix` — A bug fix
- `chore` — Build process or auxiliary tool changes
- `ci` — CI related changes
- `docs` — Documentation only changes
- `feat` — A new feature
- `fix` — A bug fix
- `perf` — A code change that improves performance
- `refactor` — A code change that neither fixes a bug or adds a feature
- `release` — Create a release commit
- `style` — Markup, white-space, formatting, missing semi-colons...
- `ci` — CI related changes
- `perf` — A code change that improves performance
- `test` — Adding missing tests


### Scopes
The scope is the scope of changes on the component you are working on. E.g. "Controllers", "API" etc.
Expand Down Expand Up @@ -247,3 +234,4 @@ Installs in 0.6s vs 31.1s.
npm i -g mol-conventional-changelog
added 345 packages in 31.076s
```

2 changes: 1 addition & 1 deletion build/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const defaults = require('../lib/defaults');
exports.types = () => {
let str = '';

for (const type of defaults.list) {
for (const type of Object.keys(defaults.types)) {
str += `- \`${type}\` — ${defaults.types[type].description}\n`;
}

Expand Down
14 changes: 0 additions & 14 deletions lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ const types = {
}
};

// https://github.com/angular/angular/blob/master/CONTRIBUTING.md#type
const list = [
'test',
'feat',
'fix',
'chore',
'docs',
'refactor',
'style',
'ci',
'perf'
];

// https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope
const scopes = [
];
Expand All @@ -82,7 +69,6 @@ module.exports = {
breakingChangePrefix: '🧨 ',
closedIssuePrefix: '✅ ',
enableWritingScopes: false,
list,
maxMessageLength: 64,
minMessageLength: 3,
questions,
Expand Down
2 changes: 1 addition & 1 deletion lib/questions/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const typeToListItem = ({types, disableEmoji}, type) => {
* @param {string[]} config The whole config.
*/
const findType = function (substring, config) {
const types = config.list;
const types = Object.keys(config.types);

return Promise.resolve(fuzzy.filter(substring || '', types).map(({original: type}) => typeToListItem(config, type)));
};
Expand Down
11 changes: 0 additions & 11 deletions test/formatCommitMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ const defaultConfig = {
breakingChangePrefix: '🧨 ',
closedIssuePrefix: '✅ ',
commitMessageFormat: '<type><(scope)>: <emoji><subject>',
list: [
'test',
'feat',
'fix',
'chore',
'docs',
'refactor',
'style',
'ci',
'perf'
],
maxMessageLength: 64,
minMessageLength: 3,
questions: [
Expand Down

0 comments on commit 5f13da4

Please sign in to comment.