Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

generate-changelog

lob192.4kMIT1.8.0TypeScript support: definitely-typed

Generate a changelog from git commits.

changelog, cli, npm, version, git, semver

readme

Generate Changelog

NPM Version Build Status Coverage Status Dependency Status

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.

$ 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):

$ 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:

generate-changelog 420c945...2a83752

Git tags are supported too:

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:

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);
});

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:

"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:

$ npm i
$ npm test

Contributing

To contribute, please see the CONTRIBUTING.md file.

License

This project is released under the MIT license, which can be found in LICENSE.txt.

changelog

1.8.0 (2019-06-25)

Documentation Changes
New Features

1.7.1 (2018-03-28)

Bug Fixes
  • writer: fix commit URL for Gitlab repos (#40) (656a2bcc)

1.7.0 (2017-12-17)

New Features
  • git: add support for breaking changes (#34) (d697b273)
Bug Fixes
  • writer: fix commit URL for BitBucket repos (#33) (0492e91a)

1.6.0 (2017-11-20)

New Features
  • writer: add links to PRs numbers in commits text (#31) (7015d433)

1.5.0 (2017-09-20)

New Features
  • git: generate from specific tag (#28) (cadb4e22)
Bug Fixes
  • git: fix error throwing "stdout maxBuffer exceeded" (#29) (5f515803)

1.4.0 (2017-08-29)

Chores
  • lint: update eslint-config-lob (725beb61)
New Features
  • package: Add support for missing version (#25) (7e91a601)
Bug Fixes
  • npm: ignore all unnecessary files in .npmignore (fe7c3b66)
Tests
  • travis: run against newer versions of node (f7c3ba9b)

1.3.1 (2017-08-15)

Bug Fixes
  • exclude: allow arguments to be passed in to -x (3faf08a6)

1.3.0 (2017-06-25)

New Features
  • writer: update commit types (8945027b)
Bug Fixes
  • writer: fix the issue with one digit month/days (bd566622)

1.2.1 (2017-6-13)

Bug Fixes
  • exclude: REALLY exclude listed commit types (9f836575)

1.2.0 (2017-6-12)

New Features
  • exclude: add -x, --exclude option (fc31e9a8)
Bug Fixes
  • writer: don't print category if empty (a859a9b6)
Tests
  • package: fix coverage for lib/package.js (006a2a04)

1.1.0 (2016-12-15)

New Features
  • version: remove the incrementation flag requirement (a8b45090)

1.0.2 (2016-6-7)

Bug Fixes
  • git: enfore lowercase commit.type (d53e497a)

1.0.1 (2016-2-10)

Documentation Changes
  • readme: add npm and dependency stats badges (69d81f66)
Bug Fixes
  • deps: lockdown eslint-config-lob version (ee06529c)
  • writer: change commit url to use full hash (40fe02a5)

1.0.0 (2015-12-14)

Documentation Changes
  • npm: update recommended npm scripts (2eef1597)
New Features
Bug Fixes
  • cli: prepend to a file instead of printing to stdout (92e1085d)
  • writer: group all uncommon types together (10caf5f2)