Extensible parser for git commit messages following Conventional Commits Specification
Please consider following this project's author, Charlike Mike Reagent, and ⭐ the project to show your ❤️ and support.
If you have any how-to kind of questions, please read the Contributing Guide and Code of Conduct documents. For bugs reports and feature requests, please create an issue or ping @tunnckoCore at Twitter.
[!NOTE] Version 4 was skipped since it was long time in canary state, and some are using it. Version 5 is converted to TypeScript, and MAY have breaking changes compared to v4 like higher minimum Node.js version is v20.
(TOC generated by verb using markdown-toc)
This project requires Node.js >=20 (see
Support & Release Policy). Install it
using yarn or npm.
We highly recommend to
use Yarn when you think to contribute to this project.
[!NOTE] This project is written in TypeScript, and exports CJS, ESM, TS, and Types.
$ npm install recommended-bump
Generated using jest-runner-docs.
Calculates recommended bump (next version), based on given commits
.
It always returns an object. If no commits are given it is { increment: false }
.
Otherwise it may contain patch
, minor
, or major
properties which are
of Array<Commit>
type, based on [parse-commit-message][].
ProTip: Use result[result.increment]
to get most meanigful result.
Each item passed as commits
is validated against the Convetional Comits Specification
and using [parse-commit-message][]. Commits can be string, array of commit message strings,
array of objects (of type Commit as defined) or mix of previous
posibilities.
commits
{Array<object>} - commit messages one ofstring
,Array<string>
orArray<Commit>
options
- pass additionaloptions.plugins
to be passed to [parse-commit-message][]returns
{object} - result like{ increment: boolean | string, patch?, minor?, major? }
See the tests and examples for more clarity.
import recommendedBump from 'recommended-bump';
const commits = [
'chore: foo bar baz',
`fix(cli): some bugfix msg here
Some awesome body.
Great footer and GPG sign off, yeah!
Signed-off-by: Awesome footer <foobar@gmail.com>`
];
const { increment, isBreaking, patch } = recommendedBump(commits);
console.log(isBreaking); // => false
console.log(increment); // => 'patch'
console.log(patch);
// => [{ header: { type, scope, subject }, body, footer }, { ... }]
console.log(patch[0].header.type); // => 'fix'
console.log(patch[0].header.scope); // => 'cli'
console.log(patch[0].header.subject); // => 'some bugfix msg here'
console.log(patch[0].body); // => 'Some awesome body.'
console.log(patch[0].footer);
// => 'Great footer and GPG sign off, yeah!\nSigned-off-by: Awesome footer <foobar@gmail.com>'
import { parse } from 'parse-commit-message';
import recommendedBump from 'recommended-bump';
const commitOne = parse('fix: foo bar');
const commitTwo = parse('feat: some feature subject');
const result = recommendedBump([commitOne, commitTwo]);
console.log(result.increment); // => 'minor'
console.log(result.isBreaking); // => false
console.log(result.minor); // => [{ ... }]
Please read the Contributing Guide and Code of Conduct documents for advices.
For bug reports and feature requests, please join our community forum and open a thread there with prefixing the title of the thread with the name of the project if there's no separate channel for it.
Consider reading the Support and Release Policy guide if you are interested in what are the supported Node.js versions and how we proceed. In short, we support latest two even-numbered Node.js release lines.
Become a Partner or Sponsor? 💵 Check the OpenSource Commision (tier). 🎉 You can get your company logo, link & name on this file. It's also rendered on package's page in npmjs.com and yarnpkg.com sites too! :rocket:
Not financial support? Okey! Pull requests, stars and all kind of contributions are always welcome. ✨
This project follows the all-contributors specification. Contributions of any kind are welcome!
Thanks goes to these wonderful people (emoji key), consider showing your support to them:
Charlike Mike Reagent 🚇 💻 📖 🤔 🚧 |
Copyright (c) 2018-present, Charlike Mike Reagent & contributors.
Released under the
Apache-2.0 License.