UNPKG

5.59 kBMarkdownView Raw
1# conventional-changelog-cli
2
3[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coverage-image]][coverage-url]
4
5> Generate a changelog from git metadata
6
7*[Changelog?](https://speakerdeck.com/stevemao/compose-a-changelog)*
8
9**Note** You don't have to use the angular commit convention. For the best result of the tool to tokenize your commit and produce flexible output, it's recommended to use a commit convention.
10
11
12## Quick start
13
14```sh
15$ npm install -g conventional-changelog-cli
16$ cd my-project
17$ conventional-changelog -p angular -i CHANGELOG.md -s
18```
19
20This will *not* overwrite any previous changelogs. The above generates a changelog based on commits since the last semver tag that matches the pattern of "Feature", "Fix", "Performance Improvement" or "Breaking Changes".
21
22If this is your first time using this tool and you want to generate all previous changelogs, you could do
23
24```sh
25$ conventional-changelog -p angular -i CHANGELOG.md -s -r 0
26```
27
28This *will* overwrite any previous changelogs if they exist.
29
30All available command line parameters can be listed using CLI: `conventional-changelog --help`.
31
32**Hint:** You can alias your command or add it to your package.json. EG: `"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"`.
33
34To fully customize the tool, please checkout [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) and [conventional-changelog-core](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core) docs. You can find more details there. **Note: `config` here can work with `preset`, which is different than `options.config` in conventional-changelog.**
35
36
37## Example output
38
39- https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog/CHANGELOG.md
40- https://github.com/karma-runner/karma/blob/master/CHANGELOG.md
41- https://github.com/btford/grunt-conventional-changelog/blob/master/CHANGELOG.md
42
43
44## Recommended workflow
45
461. Make changes
471. Commit those changes
481. Make sure Travis turns green
491. Bump version in `package.json`
501. `conventionalChangelog`
511. Commit `package.json` and `CHANGELOG.md` files
521. Tag
531. Push
54
55The reason why you should commit and tag after `conventionalChangelog` is that the CHANGELOG should be included in the new release, hence `gitRawCommitsOpts.from` defaults to the latest semver tag.
56
57
58### With `npm version`
59
60Using the npm scripts to our advantage with the following hooks:
61
62```json
63{
64 "scripts": {
65 "version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md"
66 }
67}
68```
69
70You could follow the following workflow
71
721. Make changes
731. Commit those changes
741. Pull all the tags
751. Run the [`npm version [patch|minor|major]`](https://docs.npmjs.com/cli/version) command
761. Push
77
78You could optionally add a `preversion` script to package your project or running a full suit of test.
79And a `postversion` script to clean your system and push your release and tags.
80
81By adding a `.npmrc` you could also automate your commit message and set your tag prefix as such:
82
83```
84tag-version-prefix=""
85message="chore(release): %s :tada:"
86```
87
88
89## Why
90
91- Used by AngularJS, JSHint and related projects.
92- Easy fully automate changelog generation. You could still add more points on top of it.
93- Ignoring reverted commits, templating with [handlebars.js](https://github.com/wycats/handlebars.js) and links to references, etc. Open an [issue](../../issues/new) if you want more reasonable features.
94- Intelligently setup defaults but yet fully configurable with presets of [popular projects](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog#preset).
95- Everything internally or externally is pluggable.
96- A lot of tests and actively maintained.
97
98### Problems with [github-changelog-generator](https://github.com/skywinder/github-changelog-generator) or similar projects
99
100- Opinionated on how to write commits, issues or PRs.
101- No or partially support reference links.
102- Not system agnostic. Only support GitHub.
103- No template support. The output is mostly certain format of markdown.
104- No presets of popular commit message conventions.
105- Not modularized. Over the years [modularization is proven to be the best practice](https://github.com/sindresorhus/ama/issues/10#issuecomment-117766328).
106- No tests or coverage is too low. Program might be buggy.
107- Do not read your project's environment.
108- No or few task runner or build tool integrations.
109
110
111## API
112
113Please use [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog)
114
115
116## License
117
118MIT © [Steve Mao](https://github.com/stevemao)
119
120
121[npm-image]: https://badge.fury.io/js/conventional-changelog-cli.svg
122[npm-url]: https://npmjs.org/package/conventional-changelog-cli
123[travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog-cli.svg?branch=master
124[travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog-cli
125[daviddm-image]: https://david-dm.org/conventional-changelog/conventional-changelog-cli.svg?theme=shields.io
126[daviddm-url]: https://david-dm.org/conventional-changelog/conventional-changelog-cli
127[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
128[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master