Git changelog generator, to be used as a CLI utility in pre-commit hooks.
> node-autochglog is a CLI tool that generates a changelog based on commit messages, assuming that they're written using the Conventional Commits syntax. It is meant to be used in CI/CD pipelines, or in pre-commit hooks.
Here are some concepts to better understand the logic behind the tool:
- to the purpose of this tool, a Changelog is a list of Release items;
- each Release item contains a list of Category items;
- each Category item contains a list of Commit items.
In other words, a _changelog_ is a list of _releases_, each _release_ contains a number of _commits_, that are arranged in _categories_ within the _release_ they belong to.
_Releases_ are defined by git tags, _categories_ are defined by Conventional Commit prefixes of _commit_ messages.
node-autochglog can be launched through npx, so no installation is required. If you still want to install it, this section explains how to do that.
For making it available within a project:
``bash`
npm install save-dev node-autochglog
For making it available globally:
`bash`
npm install -g node-autochglog
In order to use node-autochglog, just run the following command in the root of the project you want to generate a changelog for:
`bash`
npx node-autochglog
The tool accepts configuration from a node-autochglog.config.json, expected to be found in the directory where the node-autochglog command is executed; the file is expected to contain a single JSON object adhering to the NodeAutoChglogConfig interface:
`typescript``
export interface NodeAutoChglogConfig {
tagFilter: string;
initialTag: string;
templateLocation: string;
targetBranch: string;
outputFilepath: string;
allowedCategories: { key: string; label?: string }[];
stripPRNumbers: boolean;
}
| Config key | Purpose | Default |
|---|---|---|
tagFilter | RegEx used for determining which tags are considered as versions; tags not matching the RegEx will be ignored | SemVer |
initialTag | Fallback "tag" to be used as release name when no tags exist yet, or for recent commits that do not (yet) fall under a version tag | Unreleased |
templateLocation | Path to the Mustache template to be used for the changelog; whatever custom template you provide, it will have to work with the metadata provided by the tool, represented by the Changelog interface | DEFAULT_TEMPLATE.mustache |
targetBranch | Branch from which the commits shall be read for composing the changelog | develop |
outputFilepath | Path where the generated changelog shall be written | Project root |
stripPRNumbers | Whether the tool should strip PR numbers from the end of commit messages | false |
allowedCategories | List of key/label objects defining which commit prefixes (key) shall be considered as valid categories and which labels (label) shall be used in order to represent them; the label property is optional, if absent the key property will be used in its place. | |