Commitizen customizable adapter following the conventional-changelog format.
npm install cz-customizableThe customizable Commitizen plugin (or standalone utility) to help achieve consistent commit messages such as Conventional Commits. Note that you can create any commit message pattern. You don't have to use the pattern from the Conventional Commits. For example, my team uses this pattern: [minor] add new feature xyz
Suitable for large teams working with multiple projects with their own commit scopes. It allows you to select the pre-defined scopes or commit types. It works perfectly with https://github.com/semantic-release/semantic-release.




You have two ways to use cz-customizable. Originally, this project started as a commitizen plugin (Option 1). We introduced the second option to run this cz-customizable in standalone mode (Option 2), just like any NodeJS script. It's recommended to use Option 2 for simplicity. The way you configure is shared between both options.
* Copy contents of the example config file and paste into a new file .cz-config.js
* Option 1: Move file cz-config.js to your home directory.
* Option 2: Put file cz-config.js at the root level of your project and commit it to your code repository (Assuming you have a team agreement to use this tool).
npm i cz-customizable -g
Then run cz-customizable from your root repo. You can also use the alias cz-cust.
If everything is correct, you should see commit questions like the image above.
npx cz-customizable
Use cz-customizable without commitzen.
* npm install npm install cz-customizable --save-dev
* add a new script to your package.json:
```
"scripts" : {
...
"commit": "./node_modules/cz-customizable/standalone.js"
}
* See options below how to create and where you could put your .cz-config.js file.npm run commit
* now run: .
This is how this project started.
* install commitizen in case you don't have it: npm install -g commitizen. Make sure you have the latest version of commitizen installed globally.
* configure commitizen to use cz-customizable as plugin. Add those lines to your package.json:
``
...
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
}
}
* Copy contents of the example config file and paste into a new file .cz-config.js
* cz-customizable will first look for a file called .cz-config.js or .config/cz-config.js in the project root, near your package.json.cz-config.js
* If no config found, it will look for or or .config/cz-config.js in your home directorypackage.json
* alternatively add the config location in your :``
...
"config": {
"commitizen": { // not needed for standlone usage
"path": "node_modules/cz-customizable"
},
"cz-customizable": {
"config": "config/path/to/my/config.js"
}
}
Note: option one allows you to have your config away from root directory. It also gives you a change to define any name to your .cz-config.js.
This is suitable when your team is not ready to roll cz-customizable across all teams but you still would like to use it for your own commits, no matter the project.
Steps:
* create config file:
create a file called .cz-config.js in your git repository root (Assumptions: you git ignore global on ~/.gitignore_global for .cz-config.js). Or;.cz-config.js
* create a file called your home directory.
#### Additional steps when used as commitizen plugin
* npm install -g commitizen
* npm install -g cz-customizable. Make sure you have version >v5.6.x.czrc
* create global commitizen config file : echo '{ "path": "cz-customizable" }' > ~/.czrcnpx git-cz
* now run: or git cz.
Notes:
* you should commit your .cz-config.js file to your git when applicable.
Hopefully this will help you to have consistent commit messages and have a fully automated deployment without any human intervention.
---
Here are the options you can set in your .cz-config.js:
* subjectLimit: {number, default 100}: This is the subject limit. Example: this is a new feature or fix a bugfeat: this is a new feature
* subjectSeparator: {string, default ': '}: This is the subject separator. Example: { typePrefix: '[' }
* typePrefix: {string, default ''}: This is the commit type prefix. Example: config: , result: [feat: this is a new feature{ typePrefix: '[', typeSuffix: ']', subjectSeparator: ' ' }
* typeSuffix: {string, default ''}: This is the commit type suffix. Example: config: , result: [feat] this is a new feature
* scopes: {Array of Strings}: Specify the scopes for your particular project. Eg.: for some banking system: ["acccounts", "payments"]. For another travelling application: ["bookings", "search", "profile"]
* scopeOverrides: {Object where key contains a Array of String}: Use this when you want to override scopes for a specific commit type. Example below specify scopes when type is fix:`
`
scopeOverrides: {
fix: [
{name: 'merge'},
{name: 'style'},
{name: 'e2eTest'},
{name: 'unitTest'}
]
}
`
* additionalQuestions:{Array of object} To ask additional question. Answers will be appended to body part. All keys of object are required.
`
additionalQuestions: [
{
type: 'input',
name: 'time',
message: 'Time spent (i.e. 1h 15m) (optional):\n',
mapping: "#time"
},
{
type: 'input',
name: 'comment',
message: 'Jira comment (optional):\n',
mapping: "#comment"
}
],
custom
* allowCustomScopes: {boolean, default false}: adds the option to scope selection so you can still type a scope if you need.breaking change
* allowBreakingChanges: {Array of Strings: default none}. List of commit types you would like to the question prompted. Eg.: ['feat', 'fix'].cz-customizable
* skipQuestions: {Array of Strings: default none}. List of questions you want to skip. Eg.: ['body', 'footer'].
* skipEmptyScopes: {boolean, default false}: If a chosen type has no scopes declared, skip the scope question
* appendBranchNameToCommitMessage: If you use with cz-customizable-ghooks, you can get the branch name automatically appended to the commit message. This is done by a commit hook on cz-customizable-ghooks. This option has been added on cz-customizable-ghooks, v1.3.0. Default value is true.ticketNumber
* ticketNumberPrefix: {string, default 'ISSUES CLOSED:'}: Set custom prefix for footer ticker number.
* ticketNumberSuffix: {string, default ''}: Set custom suffix for footer ticker number.
* fallbackTicketNumber: {string, default ''}: Set fallback ticket number which will be used if is not provided.body
* breakingPrefix: {string, default 'BREAKING CHANGE:'}: Set a custom prefix for the breaking change block in commit messages.
* footerPrefix: {string, default 'ISSUES CLOSED:'}: Set a custom prefix for the footer block in commit messages. Set to empty string to remove prefix.
* breaklineChar: {string, default '|'}: It gets replaced with \n to create the breakline in your commit message. This is supported for fields and footer at the moment.true
* upperCaseSubject: { boolean, default false }: Capitalizes first subject letter if set to true
* askForBreakingChangeFirst: { boolean, default false }: It asks for breaking change as first question when set to true
* usePreparedCommit: { boolean, default false }: It re-uses commit from ./.git/COMMIT_EDITMSG when set to
* backticks
If you wish to have backticks in your content, for example "feat: \string\", the commit preview will be "feat: \\\string\\\".git log
Don't worry because on your will be "feat: \string\" as desired.
* multiline contents on the body of the message
Body is the only place where you can use a pipe to break lines.my items are:| - item01| - item 02
E.g.: you type this: , which will become:
``
my items are:
- item01
- item 02
and index.d.ts`.Leonardo Correa