UNPKG

7.35 kBMarkdownView Raw
1### Commitizen for contributors
2When you commit with Commitizen, you'll be prompted to fill out any required commit fields at commit time. No more waiting until later for a git commit hook to run and reject your commit (though [that](https://github.com/kentcdodds/validate-commit-msg) can still be helpful). No more digging through CONTRIBUTING.md to find what the preferred format is. Get instant feedback on your commit message formatting and be prompted for required fields.
3
4[![travis.ci](https://img.shields.io/travis/commitizen/cz-cli.svg?style=flat-square)](https://travis-ci.org/commitizen/cz-cli) [![Build status](https://ci.appveyor.com/api/projects/status/ha5vb0p6iq8450un/branch/master?svg=true)](https://ci.appveyor.com/project/jimthedev/cz-cli/branch/master)
5 [![codecov.io](https://img.shields.io/codecov/c/github/commitizen/cz-cli.svg?style=flat-square)](https://codecov.io/github/commitizen/cz-cli?branch=master) [![npm monthly downloads](https://img.shields.io/npm/dm/commitizen.svg?style=flat-square)](https://www.npmjs.com/package/commitizen) [![current version](https://img.shields.io/npm/v/commitizen.svg?style=flat-square)](https://www.npmjs.com/package/commitizen) [![bitHound Score](https://www.bithound.io/github/commitizen/cz-cli/badges/score.svg)](https://www.bithound.io/github/commitizen/cz-cli) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
6
7#### Installing the command line tool
8Installation is as simple as running the following command (add sudo if on OSX/Linux):
9
10```
11npm install -g commitizen
12```
13
14#### Using the command line tool
15Now, simply use `git cz` instead of `git commit` when committing.
16
17When you're working in a Commitizen friendly repository, you'll be prompted to fill in any required fields and your commit messages will be formatted according to the the standards defined by project maintainers.
18
19[![Add and commit with Commitizen](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)](https://github.com/commitizen/cz-cli/raw/master/meta/screenshots/add-commit.png)
20
21If you're not working in a Commitizen friendly repository, then `git cz` will work just the same as `git commit`.
22
23### Commitizen for project maintainers
24As a project maintainer, making your repo Commitizen friendly allows you to select pre-existing commit message conventions or to create your own custom commit message convention. When a contributor to your repo uses Commitizen, they will be prompted for the correct fields at commit time.
25
26#### Making your repo Commitizen-friendly
27
28For this example, we'll be setting up our repo to use [AngularJS's commit message convention](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#-git-commit-guidelines) also known as [conventional-changelog](https://github.com/ajoslin/conventional-changelog).
29
30First, install the Commitizen cli tools:
31
32```
33npm install commitizen -g
34```
35
36Next, initialize your project to use the cz-conventional-changelog adapter by typing:
37
38```
39commitizen init cz-conventional-changelog --save --save-exact
40```
41
42Note that if you want to force install over the top of an old adapter, you can apply the `--force` argument. For more information on this, just run `commitizen help`.
43
44The above command does three things for you. It installs the cz-conventional-changelog adapter npm module, it saves it to the package.json's dependencies or devDependencies, and lastly it add the `config.commitizen` key to the root of your **package.json** as shown here:
45
46```json
47...
48 "config": {
49 "commitizen": {
50 "path": "node_modules/cz-conventional-changelog"
51 }
52 }
53```
54
55This just tells Commitizen which adapter we actually want our contributors to use when they try to commit to this repo.
56
57Please note that in previous version of Commitizen we used czConfig. **czConfig has been deprecated** and you should migrate to the new format before Commitizen 3.0.0.
58
59#### Congratulations your repo is Commitizen-friendly. Time to flaunt it!
60
61Add the Commitizen-friendly badge to your README using the following markdown:
62```
63[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
64```
65
66Your badge will look like this:
67
68[![Commitizen-friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
69
70It may also make sense to change your README.md or CONTRIBUTING.md to include or link to the Commitizen project so that your new contributors may learn more about installing and using Commitizen.
71
72
73#### Go further
74
75Commitizen is great on its own, but it shines when you use it with some other amazing open source tools. Kent C. Dodds shows you how to accomplish this in his Egghead.io series, [How to write an open source javascript library](https://egghead.io/series/how-to-write-an-open-source-javascript-library). Many of the concepts can be applied to non-javascript projects as well.
76
77### Adapters
78
79We know that every project and build process has different requirements so we've tried to keep Commitizen open for extension. You can do this by choosing from any of the pre-build adapters or even by building your own. Here are some of the great adapters available to you:
80
81- [cz-conventional-changelog](https://www.npmjs.com/package/cz-conventional-changelog)
82- [cz-jira-smart-commit](https://www.npmjs.com/package/cz-jira-smart-commit)
83- [rb-conventional-changelog](https://www.npmjs.com/package/rb-conventional-changelog)
84- [cz-mapbox-changelog](https://www.npmjs.com/package/cz-mapbox-changelog)
85
86To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/) but you can capture input using whatever means neccesary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
87
88### Philosophy
89
90#### About Commitizen
91Commitizen is an open source project that helps contributors be good open source citizens. It accomplishes this by prompting them to follow commit message conventions at commit time. It also empowers project maintainers to create or use predefined commit message conventions in their repos to better communicate their expectations to potential contributors.
92
93#### Commitizen or Commit Hooks
94Both! Commitizen is not meant to be a replacement for git commit hooks. Rather, it is meant to work side-by-side with them to ensure a consistent and positive experience for your contributors. Commitizen treats the commit command as a declarative action. The contributor is declaring that they wish to contribute to your project. It is up to you as the maintainer to define what rules they should be following.
95
96We accomplish this by letting you define which adapter you'd like to use in your project. Adapters just allow multiple projects to share the same commit message conventions. A good example of an adapter is the cz-conventional-changlog adapter.
97
98### Authors and Contributors
99@JimTheDev (Jim Cummins, author)
100@kentcdodds
101@accraze
102@kytwb
103@Den-dp
104
105Special thanks to @stevelacy, whose [gulp-git](https://www.npmjs.com/package/gulp-git) project makes commitizen possible.
106