@wroud/conventional-commits-bump
is a utility designed to determine the appropriate version bump type based on conventional commits. This library helps automate the versioning process by analyzing commit messages and categorizing them as major, minor, or patch updates.
- Version Bumping Logic: Automatically determines the version bump type ("major", "minor", or "patch") based on commit types and breaking changes.
- TypeScript Support: Written in TypeScript for enhanced type safety and modern JavaScript features.
- Pure ESM package
Install via npm:
npm install @wroud/conventional-commits-bump @wroud/conventional-commits-parser
Use the getConventionalCommitsBump
function to analyze an array of conventional commits and determine the appropriate version bump:
import type { IConventionalCommit } from "@wroud/conventional-commits-parser";
import { getConventionalCommitsBump } from "@wroud/conventional-commits-bump";
const commits: IConventionalCommit[] = [
{ type: "feat", breakingChanges: [] },
{ type: "fix", breakingChanges: [] },
];
const bump = getConventionalCommitsBump(commits);
console.log(bump); // Output: "minor"
-
fix
type commits should be translated to PATCH releases. -
feat
type commits should be translated to MINOR releases. - Commits with BREAKING CHANGE in the commit messages, regardless of type, should be translated to MAJOR releases.
In this example, if any commit includes breaking changes, the bump will be "major". If there are no breaking changes but a commit of type "feat" is present, it will result in a "minor" bump; otherwise, it will return "patch" if there are any "fix" commits.
All notable changes to this project will be documented in the CHANGELOG file.
This project is licensed under the MIT License - see the LICENSE file for details.