npm.io
0.6.1 • Published 6d agoCLI

@hyperfrontend/versioning

Licence
MIT
Version
0.6.1
Deps
0
Size
5.1 MB
Vulns
0
Weekly
0

@hyperfrontend/versioning

Build Coverage npm version npm bundle size

All Contributors License npm downloads GitHub stars Node Version Tree Shakeable

Versioning library with changelog parsing, conventional commits, and semver flow orchestration.

• See documentation • See roadmap

What is @hyperfrontend/versioning?

@hyperfrontend/versioning provides a comprehensive toolkit for managing software versioning in JavaScript/TypeScript projects. The library is built on a purely functional architecture with factory functions, immutable data structures, and composable operations.

Key Features

  • Interactive Commit Author (cz) - npx cz launches a keystroke-live conventional-commit session (type, scope, subject countdown, body, breaking marker, issues, preview, commit)
  • Commit Validator (cl) - npx cl <path> plugs into any commit-msg git hook to enforce your ruleset
  • Changelog Parsing - Parse CHANGELOG.md files into structured objects with lossless round-tripping
  • Conventional Commits - Parse, validate, format, and classify messages following the Conventional Commits specification
  • Semver Utilities - Parse, compare, increment, and validate semantic versions
  • Registry Client - Query npm registry for published versions and package metadata
  • Compare URLs - Generate platform-specific compare URLs for changelog entries (GitHub, GitLab, Bitbucket, Azure DevOps)
  • Monorepo Scope Filtering - Intelligent commit classification ensures changelogs only include relevant commits
  • Composable Operations - Build complex versioning workflows from simple, pure functions
  • Zero External Dependencies - Self-contained implementation with no third-party runtime dependencies
Architecture Highlights

Built on a purely functional architecture with factory functions and immutable data structures. All parsing uses character-by-character state machines for predictable O(n) performance. The library integrates with @hyperfrontend/project-scope for virtual file system operations and @hyperfrontend/data-utils for deep comparison.

See ARCHITECTURE.md for detailed design principles, data flow diagrams, and module composition.

Why Use @hyperfrontend/versioning?

Type-Safe Changelog Manipulation

Working with CHANGELOG.md files programmatically typically involves fragile string manipulation. This library parses changelogs into fully typed data structures with factory functions for creating entries, sections, and items. Modify changelog content with confidence using immutable operations and round-trip safely back to markdown.

Unified Versioning Primitives

Version management requires coordinating semver parsing, commit analysis, changelog generation, and registry queries. This library provides all these primitives in one cohesive package with consistent APIs. Query npm for published versions, parse commit history, calculate version bumps, and generate changelog entries — all composable into custom release workflows.

Zero-Dependency CI Integration

Designed for automated pipelines where minimal attack surface matters. Zero external runtime dependencies and state-machine parsing ensure predictable performance on any input. All parsers enforce input length limits to prevent resource exhaustion.

One-Stop Commit Toolchain

The interactive cz and validator cl bins cover the same ground as commitizen + cz-conventional-changelog + @commitlint/cli — in one package, without patch-package workarounds, with a config-driven session (commit.config.{js,mjs,cjs}), a live 72-char header countdown, and scope choices derived from staged files. Acknowledgment to those projects: they shaped the conventions this library now implements natively.

Installation

npm install @hyperfrontend/versioning

Quick Start

Parsing a Changelog
import { parseChangelog } from '@hyperfrontend/versioning'
import fs from 'fs'

// Parse existing changelog content
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
const changelog = parseChangelog(content)

// Access entries
for (const entry of changelog.entries) {
  console.log(`Version ${entry.version} - ${entry.date}`)
  for (const section of entry.sections) {
    console.log(`  ${section.heading}: ${section.items.length} changes`)
  }
}

// Access metadata
// Formats: 'keep-a-changelog' (https://keepachangelog.com), 'conventional', etc.
console.log(changelog.metadata.format)
Parsing Conventional Commits
import { parseConventionalCommit } from '@hyperfrontend/versioning'

const commit = parseConventionalCommit('feat(api): add user authentication')

console.log(commit.type) // 'feat'
console.log(commit.scope) // 'api'
console.log(commit.subject) // 'add user authentication'
console.log(commit.breaking) // false
Checking for Breaking Changes
import { parseConventionalCommit } from '@hyperfrontend/versioning'

// Breaking change via !
const commit1 = parseConventionalCommit('feat(api)!: remove deprecated endpoint')
console.log(commit1.breaking) // true

// Breaking change via footer
const commit2 = parseConventionalCommit(\`fix: update API response format

BREAKING CHANGE: Response structure has changed\`)
console.log(commit2.breaking) // true
console.log(commit2.breakingDescription) // 'Response structure has changed'

API Overview

Changelog Models
  • Changelog - Complete representation of a CHANGELOG.md file
  • ChangelogEntry - A single version entry with date and sections
  • ChangelogSection - A category of changes (Features, Bug Fixes, etc.)
  • ChangelogItem - An individual change with description and references
Commit Models
  • ConventionalCommit - Parsed conventional commit message
  • CommitType - Type constants (feat, fix, docs, etc.)
  • CommitFooter - Parsed footer/trailer from commit message
Parser Functions
  • parseChangelog(content: string) - Parse markdown changelog content
  • parseConventionalCommit(message: string) - Parse a commit message
  • tokenize(input: string) - Low-level tokenizer for changelog content

Module Documentation

Module Description Documentation
changelog/ Parse and manipulate CHANGELOG.md files README
commits/ Parse conventional commit messages README
semver/ Semantic version parsing and comparison README
registry/ npm registry client README
git/ Git operations abstraction README
workspace/ Project discovery and package.json README
flow/ Version release workflow orchestration README
repository/ Repository detection and compare URLs README

See ARCHITECTURE.md for module composition diagrams and data flow.

Compatibility

Platform Support
Node.js
Browser
Output Formats
Format File Tree-Shakeable
ESM index.esm.js
CJS index.cjs.js

Security

All parsers use state-machine tokenization with O(n) complexity and enforce input length limits (commit messages: 10KB, changelog files: 1MB) to prevent resource exhaustion. Character-by-character parsing eliminates regex-based vulnerabilities.

Part of hyperfrontend

This library is part of the hyperfrontend monorepo.

Full documentation

License

MIT

Keywords