@wroud/conventional-commits-bump

0.1.2 • Public • Published

@wroud/conventional-commits-bump

ESM-only package NPM version

@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.

Features

  • 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

Installation

Install via npm:

npm install @wroud/conventional-commits-bump @wroud/conventional-commits-parser

Usage

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"

How does this relate to SemVer?

  • 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.

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @wroud/conventional-commits-bump

Weekly Downloads

4

Version

0.1.2

License

none

Unpacked Size

7.71 kB

Total Files

10

Last publish

Collaborators

  • wroud