What is conventional-changelog?
The conventional-changelog npm package automates the generation of changelogs based on commit messages that follow the Conventional Commits specification. This tool is widely used to maintain a clear, readable history of project changes which can be easily communicated to other developers and users.
What are conventional-changelog's main functionalities?
Generate changelog
This code demonstrates how to generate a changelog using the Angular preset. The changelog will be written to a file named 'CHANGELOG.md'.
const conventionalChangelog = require('conventional-changelog');
const fs = require('fs');
const changelogStream = conventionalChangelog({ preset: 'angular' });
changelogStream.pipe(fs.createWriteStream('CHANGELOG.md'));
Create a release
This code snippet shows how to automatically determine the semantic version bump based on commit messages. It uses the Angular preset to recommend a bump and then uses npm to update the project version accordingly.
const conventionalRecommendedBump = require('conventional-recommended-bump');
const exec = require('child_process').exec;
conventionalRecommendedBump({ preset: 'angular' }, (error, recommendation) => {
exec(`npm version ${recommendation.releaseType}`, (error, stdout, stderr) => {
console.log('Version bumped to', stdout);
});
});
Other packages similar to conventional-changelog
standard-version
standard-version is a utility for versioning using semver and CHANGELOG generation powered by Conventional Commits. It automates versioning and changelog generation but with a simpler setup compared to conventional-changelog, integrating these steps into a single command.
semantic-release
semantic-release automates the whole package release workflow including determining the next version number, generating the release notes, and publishing the package. This tool provides a more comprehensive solution compared to conventional-changelog by handling the entire release process in a CI/CD environment.
lerna
Lerna is a tool for managing JavaScript projects with multiple packages, known as monorepos. While it includes functionality for generating changelogs similar to conventional-changelog, its primary focus is on managing dependencies and publishing multiple packages from the same repository.
conventional-changelog
Generate a changelog from git metadata, using these conventions.
Example output
Recommended usage: use in your workflow with (TODO: LINKS) grunt-conventional-changelog and gulp-conventional-changelog.
Documentation
Simple usage:
var log = require('changelog')({
repository: 'https://github.com/joyent/node'
});
fs.writeFileSync('CHANGELOG.md', log);
string
changelog(options)
By default, returns a string containing a changelog from the previous tag to HEAD, using pkg.version, prepended to existing CHANGELOG.md (if it exists).
options
is an object which can be passed to the changelog function. The following fields are available (all are optional):
-
repository
{string}
- If this is provided, allows issues and commit hashes to be linked to the actual commit. Usually used with github repositories. For example, {repository: 'http://github.com/joyent/node'}
-
commitLink
{function(commitHash)}
- If repository is provided, this function will be used to link to commits. By default, returns a github commit link based on options.repository: opts.repository + '/commit/' + hash
-
issueLink
{function(issueId)}
- If repository is provided, this function will be used to link to issues. By default, returns a github issue link based on options.repository: opts.repository + '/issues/' + id
-
version
{string}
- The version to be written to the changelog. By default, tries to use package.json version
field.
-
from
{string}
- Which commit the changelog should start at. By default, uses previous tag, or if no previous tag the first commit.
-
to
{string}
- Which commit the changelog should end at. By default, uses HEAD.
-
file
{string}
- Which file to read the current changelog from and prepend the new changelog's contents to. By default, uses 'CHANGELOG.md'
.
-
log
{function()}
- What logging function to use. For example, {log: grunt.log.ok}
. By default, uses console.log
.
-
warn
{function()}
- What warn function to use. For example, {warn: grunt.log.writeln}
. By default, uses console.warn
.
License
BSD