# generate-changelog

> Generate a changelog from git commits.

Latest version **1.8.0** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install generate-changelog
pnpm add generate-changelog
yarn add generate-changelog
bun add generate-changelog
```

Provides the commands `changelog`, `generate-changelog`.

## Health

**Score 33/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2019-06-25 |
| First published | 2015-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/generate-changelog) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 561 |
| Author | Lob |
| Maintainers | lob |
| Keywords | changelog, cli, npm, version, git, semver |

## Links

- npm: https://www.npmjs.com/package/generate-changelog
- Repository: https://github.com/lob/generate-changelog
- Homepage: https://github.com/lob/generate-changelog#readme
- Issues: https://github.com/lob/generate-changelog/issues
- npm.io page: https://npm.io/package/generate-changelog

## Dependencies (3)

- [bluebird](https://npm.io/package/bluebird.md) ^3.0.6
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [github-url-from-git](https://npm.io/package/github-url-from-git.md) ^1.4.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.8.0 (latest) — 2019-06-25
- 1.7.1 — 2018-03-28
- 1.7.0 — 2017-12-17
- 1.6.0 — 2017-11-20
- 1.5.0 — 2017-09-20
- 1.4.0 — 2017-08-29
- 1.3.1 — 2017-08-15
- 1.3.0 — 2017-06-25
- 1.2.1 — 2017-06-13
- 1.2.0 — 2017-06-12
- 1.1.0 — 2016-12-16
- 1.0.2 — 2016-06-07
- 1.0.1 — 2016-02-10
- 1.0.0 — 2015-12-14

## README

# Generate Changelog

[![NPM Version](https://badge.fury.io/js/generate-changelog.svg)](https://www.npmjs.com/package/generate-changelog)
[![Build Status](https://travis-ci.org/lob/generate-changelog.svg)](https://travis-ci.org/lob/generate-changelog)
[![Coverage Status](https://coveralls.io/repos/lob/generate-changelog/badge.svg?branch=master&service=github)](https://coveralls.io/github/lob/generate-changelog?branch=master)
[![Dependency Status](https://david-dm.org/lob/generate-changelog.svg)](https://david-dm.org/lob/generate-changelog)

Generate a changelog from git commits. This is meant to be used so that for every patch, minor, or major version, you update the changelog _prior_ to running `npm version` so that the git tag contains the commit that updated both the changelog and version.

## Installation

You can either install it as a dev dependency to be referenced in your npm scripts, or you can install this module globally to be used for all of your repos on your local machine.

```bash
$ npm i generate-changelog -D # install it as a dev dependency
# OR
$ npm i generate-changelog -g # install it globally
```

## Usage

To use this module, your commit messages have to be in this format:

```
type(category): description [flags]
```

Where `type` is one of the following:

* `breaking`
* `build`
* `ci`
* `chore`
* `docs`
* `feat`
* `fix`
* `other`
* `perf`
* `refactor`
* `revert`
* `style`
* `test`

Where `flags` is an optional comma-separated list of one or more of the following (must be surrounded in square brackets):

* `breaking`: alters `type` to be a breaking change

And `category` can be anything of your choice. If you use a type not found in the list (but it still follows the same format of the message), it'll be grouped under `other`.

### CLI

You can run this module as a CLI app that prepends the new logs to a file (recommended):

```bash
$ changelog -h

  Usage: generate [options]

  Generate a changelog from git commits.

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -p, --patch            create a patch changelog
    -m, --minor            create a minor changelog
    -M, --major            create a major changelog
    -t, --tag <range>      generate from specific tag or range (e.g. v1.2.3 or v1.2.3..v1.2.4)
    -x, --exclude <types>  exclude selected commit types (comma separated)
    -f, --file [file]      file to write to, defaults to ./CHANGELOG.md, use - for stdout
    -u, --repo-url [url]   specify the repo URL for commit links, defaults to checking the package.json
    -a, --allow-unknown    allow unkown commit types
```

It's possible to create a `./CHANGELOG.md` file for a specific commit range:

```bash
generate-changelog 420c945...2a83752
```

Git tags are supported too:

```bash
generate-changelog release/3.1.2822...release/3.1.2858
```

### Code

You can write a script that calls the `generate` function and does whatever you want with the new logs:

```js
var Changelog = require('generate-changelog');
var Fs        = require('fs');

return Changelog.generate({ patch: true, repoUrl: 'https://github.com/lob/generate-changelog' })
.then(function (changelog) {
  Fs.writeFileSync('./CHANGELOG.md', changelog);
});
```

### Recommended

The way that I would recommend using this module would be the way it's being used in this module: as npm scripts. You should install it as a dev dependency and then add the following to the `scripts` object in your `package.json`:

```json
"release:major": "changelog -M && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version major && git push origin && git push origin --tags",
"release:minor": "changelog -m && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version minor && git push origin && git push origin --tags",
"release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags",
```

## Testing

To run the test suite, just clone the repository and run the following:

```bash
$ npm i
$ npm test
```

## Contributing

To contribute, please see the [CONTRIBUTING.md](CONTRIBUTING.md) file.

## License

This project is released under the MIT license, which can be found in [`LICENSE.txt`](LICENSE.txt).

---
_Source: https://npm.io/package/generate-changelog · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
