What is conventional-recommended-bump?
The conventional-recommended-bump npm package is a tool that analyzes conventional-style commit messages (like those used by AngularJS) to determine the type of version bump (major, minor, or patch) that should be recommended based on the changes made. It is often used in automated versioning and release workflows to ensure semantic versioning practices are followed.
What are conventional-recommended-bump's main functionalities?
Determining the type of version bump
This feature allows you to determine whether your next release should be a major, minor, or patch version. The code sample shows how to use the package with the Angular preset to get a recommendation.
const conventionalRecommendedBump = require('conventional-recommended-bump');
conventionalRecommendedBump({
preset: 'angular'
}, (error, recommendation) => {
console.log(recommendation.releaseType);
});
Customizable preset options
This feature allows you to customize the preset options for analyzing commit messages. The code sample demonstrates how to specify a custom header pattern and correspondence for the Angular preset.
const conventionalRecommendedBump = require('conventional-recommended-bump');
conventionalRecommendedBump({
preset: 'angular',
config: {
headerPattern: /^\[(.*)\] (.*)$/,
headerCorrespondence: ['type', 'subject']
}
}, (error, recommendation) => {
console.log(recommendation.releaseType);
});
Using a custom parser
This feature allows you to use a custom parser for commit messages. The code sample shows how to pass custom parser options to the package.
const conventionalRecommendedBump = require('conventional-recommended-bump');
const customParserOpts = require('./custom-parser-opts');
conventionalRecommendedBump({
parserOpts: customParserOpts
}, (error, recommendation) => {
console.log(recommendation.releaseType);
});
Other packages similar to conventional-recommended-bump
semantic-release
semantic-release is an npm package that automates the versioning and package publishing process based on semantic versioning and conventional commit messages. It is more comprehensive than conventional-recommended-bump as it includes the entire release workflow, not just the recommendation for version bumps.
standard-version
standard-version is an automated versioning tool that adheres to Semantic Versioning and uses conventional commit messages to determine version bumps. It is similar to conventional-recommended-bump but also handles the generation of changelogs and tagging of releases.
release-it
release-it is a generic CLI tool for automating versioning and package publishing. It supports conventional commits and can determine version bumps, but it also includes a wide range of release-related tasks, making it more versatile than conventional-recommended-bump.
Get a recommended version bump based on conventional commits
Got the idea from https://github.com/conventional-changelog/conventional-changelog/pull/29
Install
$ npm install --save conventional-recommended-bump
Usage
var conventionalRecommendedBump = require('conventional-recommended-bump');
conventionalRecommendedBump({
preset: 'angular'
}, function(err, result) {
console.log(result.releaseType);
});
$ npm install --global conventional-recommended-bump
$ conventional-recommended-bump --help
API
conventionalRecommendedBump(options, [parserOpts], [callback])
options
ignoreReverted
Type: boolean
Default: true
If true
, reverted commits will be ignored.
preset
Type: string
Possible values: 'angular'
It's recommended to use a preset so you don't have to define everything yourself. Presets are names of built-in config
.
config
Type: object
This should serve as default values for other arguments of conventionalRecommendedBump
so you don't need to rewrite the same or similar config across your projects. Any value in this could be overwritten.
NOTE: options.config
will be overwritten by the values of preset. You should use either preset
or config
, but not both.
whatBump
Type: function
A function that takes parsed commits as argument.
This should return an object including but not limited to level
and reason
. level
is a number
indicating what bump it should be and reason
is the reason of such release.
For backward compatibility, it could return a number
indicating what bump it should be.
whatBump(commits)
####### commits
Type: array
An array of parsed commits. The commits are from last semver tag to HEAD
and is parsed by conventional-commits-parser.
If it returns with level
0
it will be a major
bump. If 1
, minor
bump. If 2
, patch
.
parserOpts
See the conventional-commits-parser docs.
callback
Type: function
callback(error, object)
object
Object includes what's returned by whatBump
and
####### releaseType
Type: string
Possible values: 'major'
, 'minor'
and 'patch'
The value of what it should release as.
Related
License
MIT © Steve Mao