@ferrow/conventional-changelog-lite
v1.0.0
Published
Parse Conventional Commits from raw git log text and render a CHANGELOG.md section with a suggested semver bump — zero runtime dependencies.
Downloads
104
Maintainers
Readme
conventional-changelog-lite
Parse Conventional Commits from raw git log text and render
a CHANGELOG.md section with a suggested semver bump. Strict TypeScript, zero runtime dependencies.
Why
Most changelog generators want to shell out to git themselves. This one doesn't — you supply the log text (from whatever git command, CI log artifact, or file you like), and it hands back structured commits, grouped sections, and a bump suggestion. That keeps it usable in sandboxes, CI systems without a git binary, and anywhere else you don't want a library running child processes on your behalf.
Quickstart
import { parseCommits, suggestBump, renderChangelog, gitLogCommand } from "conventional-changelog-lite";
import { execSync } from "node:child_process";
const logText = execSync(gitLogCommand()).toString();
const commits = parseCommits(logText);
console.log(suggestBump(commits)); // "major" | "minor" | "patch" | "none"
console.log(
renderChangelog(commits, {
version: "2.0.0",
repo: "your-org/your-repo",
previousVersion: "1.4.0",
})
);API
gitLogCommand(): string
Returns the exact git log command this parser expects as input:
git log --pretty=format:'commit %H%n%B%n===END==='. The parser also tolerates plain
git log --pretty=%B output and default git log output as fallbacks.
parseCommits(logText: string): ParsedCommit[]
Splits log text into commit records and parses each as a Conventional Commit. Non-conforming
commits are returned with type: "other" rather than dropped.
groupByType(commits): Record<CommitType, ParsedCommit[]>
Buckets parsed commits by type.
suggestBump(commits): "major" | "minor" | "patch" | "none"
Any breaking change → "major". Else any feat → "minor". Else any fix/perf → "patch".
Else "none".
renderChangelog(commits, options): string
Renders a markdown changelog section. options.repo + options.previousVersion add a GitHub
compare link to the heading and commit links.
Types
ParsedCommit, CommitType, SemverBump, RenderOptions — all exported.
Limits
- Text-based parsing only — it does not run git for you and cannot validate that the log text is complete or well-formed.
- The default marker-based split (
===END===) is the most reliable format; plaingit logoutput without markers is parsed best-effort. - Scope detection assumes the standard
type(scope): subjectheader shape; unusual header formats fall back totype: "other".
Part of the ferrow-toolkit collection · Sponsored by Ferrow
