UNPKG

8.86 kBMarkdownView Raw
1# cz-customizable
2
3The customizable Commitizen plugin (or standalone utility) to help achieve consistent commit messages like the [AngularJS team](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#-git-commit-guidelines).
4
5![screenshot](screenshot.png)
6
7Suitable 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.
8
9
10[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
11[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
12[![npm monthly downloads](https://img.shields.io/npm/dm/cz-customizable.svg?style=flat-square)](https://www.npmjs.com/package/cz-customizable)
13[![bundlephobia](https://badgen.net/bundlephobia/minzip/cz-customizable)](https://bundlephobia.com/package/cz-customizable)
14
15
16You 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.
17
18# Quick start **(New, recommended)**
19## Configuration
20
21* Copy contents of [the example config file](./cz-config-EXAMPLE.js) and paste into a new file `.cz-config.js`
22* move file `cz-config.js` to your home directory.
23
24## cz-customizable via global install
25
26`npm i cz-customizable -g`
27
28Then run `cz-customizable` from your root repo. You can also use the alias `cz-cust`.
29
30If everything is correct, you should see commit questions like the image above.
31
32# Slow start
33
34## Option 1 - cz-customizable via npx
35
36`npx cz-customizable`
37
38
39## Option 2 - cz-customizable in standalone mode
40
41Use `cz-customizable` without `commitzen`.
42
43* npm install `npm install cz-customizable --save-dev`
44* add a new script to your `package.json`:
45
46```
47"scripts" : {
48 ...
49 "commit": "./node_modules/cz-customizable/standalone.js"
50}
51```
52
53* See options below how to create and where you could put your `.cz-config.js` file.
54* now run: `npm run commit`.
55
56
57## Option 3 - cz-customizable as commitizen plugin
58
59This is how this project started.
60
61* install commitizen in case you don't have it: `npm install -g commitizen`. Make sure you have the latest version of commitizen installed globally.
62
63* configure `commitizen` to use `cz-customizable` as plugin. Add those lines to your `package.json`:
64
65```
66...
67"config": {
68 "commitizen": {
69 "path": "node_modules/cz-customizable"
70 }
71}
72```
73
74
75## Configuration (Shared between options 1,2 and 3)
76
77* Copy contents of [the example config file](./cz-config-EXAMPLE.js) and paste into a new file `.cz-config.js`
78
79
80### Option 1 - You can make changes to your git repository, file `package.json`.
81
82* `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`
83* If no config found, it will look for `.cz-config.js` or or `.config/cz-config.js` in your home directory
84* alternatively add the config location in your `package.json`:
85```
86...
87"config": {
88 "commitizen": { // not needed for standlone usage
89 "path": "node_modules/cz-customizable"
90 },
91 "cz-customizable": {
92 "config": "config/path/to/my/config.js"
93 }
94}
95```
96
97Note: 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`.
98
99
100### No Changes to your git repository*.
101
102This 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.
103
104Steps:
105* create config file:
106 * 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;
107 * create a file called `.cz-config.js` your home directory.
108
109#### Additional steps when used as commitizen plugin
110
111* npm install -g commitizen
112* npm install -g cz-customizable. Make sure you have version `>v5.6.x`
113* create global commitizen config file `.czrc`: `echo '{ "path": "cz-customizable" }' > ~/.czrc`
114* now run: `npx git-cz` or `git cz`.
115
116
117**Notes:**
118* you should commit your `.cz-config.js` file to your git when applicable.
119
120
121
122Hopefully this will help you to have consistent commit messages and have a fully automated deployment without any human intervention.
123
124
125
126---
127## Options
128
129Here are the options you can set in your `.cz-config.js`:
130
131* **subjectLimit**: {number, default 100}: This is the subject limit. Example: `this is a new feature` or `fix a bug`
132* **subjectSeparator**: {string, default ': '}: This is the subject separator. Example: `feat: this is a new feature`
133* **typePrefix**: {string, default ''}: This is the commit type prefix. Example: config: `{ typePrefix: '[' }`, result: `[feat: this is a new feature`
134* **typeSuffix**: {string, default ''}: This is the commit type suffix. Example: config: `{ typePrefix: '[', typeSuffix: ']', subjectSeparator: ' ' }`, result: `[feat] this is a new feature`
135
136* **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"]
137* **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`:
138 ```
139 scopeOverrides: {
140 fix: [
141 {name: 'merge'},
142 {name: 'style'},
143 {name: 'e2eTest'},
144 {name: 'unitTest'}
145 ]
146 }
147 ```
148* **allowCustomScopes**: {boolean, default false}: adds the option `custom` to scope selection so you can still type a scope if you need.
149* **allowBreakingChanges**: {Array of Strings: default none}. List of commit types you would like to the question `breaking change` prompted. Eg.: ['feat', 'fix'].
150* **skipQuestions**: {Array of Strings: default none}. List of questions you want to skip. Eg.: ['body', 'footer'].
151* **skipEmptyScopes**: {boolean, default false}: If a chosen type has no scopes declared, skip the scope question
152* **appendBranchNameToCommitMessage**: If you use `cz-customizable` 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`.
153* **ticketNumberPrefix**: {string, default 'ISSUES CLOSED:'}: Set custom prefix for footer ticker number.
154* **breakingPrefix**: {string, default 'BREAKING CHANGE:'}: Set a custom prefix for the breaking change block in commit messages.
155* **footerPrefix**: {string, default 'ISSUES CLOSED:'}: Set a custom prefix for the footer block in commit messages. Set to empty string to remove prefix.
156* **breaklineChar**: {string, default '|'}: It gets replaced with \n to create the breakline in your commit message. This is supported for fields `body` and `footer` at the moment.
157* **upperCaseSubject**: { boolean, default false }: Capitalizes first subject letter if set to `true`
158* **askForBreakingChangeFirst**: { boolean, default false }: It asks for breaking change as first question when set to `true`
159
160## Related tools
161- (https://github.com/commitizen/cz-cli)
162- (https://github.com/leonardoanalista/corp-semantic-release)
163- (https://github.com/semantic-release/semantic-release)
164- (https://github.com/uglow/cz-customizable-ghooks)
165
166
167
168## GOTCHAS
169
170* backticks
171If you wish to have backticks in your content, for example "feat: \`string\`", the commit preview will be "feat: \\\`string\\\`".
172Don't worry because on your `git log` will be "feat: \`string\`" as desired.
173
174* multiline contents on the body of the message
175Body is the only place where you can use a `pipe` to break lines.
176E.g.: you type this: `my items are:| - item01| - item 02`, which will become:
177
178
179```
180my items are:
181 - item01
182 - item 02
183```
184
185
186## CONTRIBUTING
187
188### Contributor Guidelines
189* if you add a new config property, please remember to update files `README.md` and `index.d.ts`.
190* add or update relevant tests
191* Favor non-breaking changes when possible
192* Send preliminary PR if you would like to start a discussion
193
194### Conduct of Code:
195* Be polite, respectful and understanding that we are all here after working hours spending time to build something useful to all.
196* We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience
197
198
199
200Leonardo Correa
201
\No newline at end of file