@hyperfrontend/versioning/changelog/operationsoperations
Immutable transformations over Changelog objects — every operation returns a new value, leaving the input untouched.
Add operations (addEntry, addUnreleasedEntry, releaseUnreleased, addItemToEntry) build new entries and items into a changelog. Remove operations strip entries or sections by predicate. filterEntries, filterSections, and filterItems produce focused projections. transform applies arbitrary transformer functions per entry/section/item. The merge family (mergeChangelogs, configured via MergeStrategy and MergeOptions) combines two changelogs and reports MergeResult / MergeStats describing what was added, conflicted, or skipped — used for cross-branch and monorepo changelog reconciliation.
API Reference
ƒ Functions
addEntry(changelog: Changelog, entry: ChangelogEntry, options?: AddEntryOptions): Changelog
Parameters
Returns
ChangelogExample
Adding a new entry to a changelog
const newChangelog = addEntry(changelog, {
version: '1.2.0',
date: '2024-01-15',
unreleased: false,
sections: [...]
})addItemToEntry(changelog: Changelog, version: string, sectionType: string, item: ChangelogItem): Changelog
Parameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog containing the entry to modify |
§version | string | The version identifier of the entry to update |
§sectionType | string | Category identifier for grouping changes (e.g., 'features', 'fixes') |
§item | ChangelogItem | Description of the change with optional scope and metadata |
Returns
ChangelogExample
Adding a feature item to an entry
const item = { description: 'Add dark mode support', scope: 'ui' }
const updated = addItemToEntry(changelog, '1.2.0', 'features', item)
// Item added to the features section of version 1.2.0Parameters
Returns
ChangelogExample
Adding an unreleased entry with sections
const sections = [createChangelogSection('features', 'Added', [item])]
const updated = addUnreleasedEntry(changelog, sections)
// => Changelog with unreleased entry at the topappendChangelog(source: Changelog, target: Changelog, position: "start" | "end"): Changelog
Parameters
Returns
ChangelogExample
Appending entries to a changelog
const combined = appendChangelog(mainChangelog, newChangelog, 'start')
// newChangelog entries appear before mainChangelog entriesParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to clone |
Returns
ChangelogExample
Cloning a changelog
const copy = cloneChangelog(changelog)
// Independent deep copy, safe to mutateParameters
Returns
ChangelogExample
Combining multiple changelogs
const unified = combineChangelogs([pkg1Changelog, pkg2Changelog], {
strategy: 'merge-sections',
})
// All entries from both changelogs merged with conflict resolutionParameters
Returns
ChangelogExample
Compacting a changelog
const compacted = compact(changelog)
// Empty sections and entries removed (unreleased kept)
const strict = compact(changelog, false)
// Even empty unreleased entry is removedParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to deduplicate |
Returns
ChangelogExample
Deduplicating items across sections
const deduped = deduplicateItems(changelog)
// Duplicate items (same scope:description) are removedParameters
Returns
ChangelogExample
Excluding items by scope
const publicChanges = excludeByScope(changelog, ['internal', 'test'])
// Items scoped to 'internal' or 'test' are removedParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to filter |
Returns
ChangelogExample
Filtering for breaking changes
const breaking = filterBreakingChanges(changelog)
// Only entries containing breaking changes or items marked as breakingParameters
Returns
ChangelogExample
Filtering entries by date range
const q1 = filterByDateRange(changelog, '2024-01-01', '2024-03-31')
// Entries released in Q1 2024Parameters
Returns
ChangelogExample
Filtering items by scope
const apiChanges = filterByScope(changelog, ['api', 'core'])
// Only items scoped to 'api' or 'core'Parameters
Returns
ChangelogExample
Filtering by semver range
const majors = filterByVersionRange(changelog, '>=1.0.0 <2.0.0')Parameters
Returns
ChangelogExample
Filtering out unreleased entries
const filtered = filterEntries(changelog, (entry) => !entry.unreleased)Parameters
Returns
ChangelogExample
Filtering from a start version
const recent = filterFromVersion(changelog, '2.0.0')
// Only entries for version 2.0.0 and laterParameters
Returns
ChangelogExample
Filtering items with references
const withRefs = filterItems(changelog, (item) => item.references.length > 0)
// Only items with issue/PR referencesfilterRecentEntries(changelog: Changelog, count: number, includeUnreleased: boolean): Changelog
Parameters
Returns
ChangelogExample
Getting the most recent entries
const latest = filterRecentEntries(changelog, 5)
// Last 5 released versions (plus unreleased if present)Parameters
Returns
ChangelogExample
Filtering for user-facing sections
const userFacing = filterSections(changelog, (section) =>
['features', 'fixes', 'breaking'].includes(section.type)
)Parameters
Returns
ChangelogExample
Filtering to specific section types
const userChanges = filterSectionTypes(changelog, ['features', 'fixes'])
// Only features and fixes sections remainParameters
Returns
ChangelogExample
Filtering to an end version
const legacy = filterToVersion(changelog, '1.9.9')
// Only entries for versions up to 1.9.9filterVersionRange(changelog: Changelog, startVersion: string, endVersion: string): Changelog
Parameters
Returns
ChangelogExample
Filtering entries within a version range
const range = filterVersionRange(changelog, '1.5.0', '2.0.0')
// Entries from 1.5.0 through 2.0.0Parameters
Returns
MergeResultExample
Merging two changelogs
const result = mergeChangelogs(mainChangelog, branchChangelog)
console.log(`Merged ${result.stats.merged} entries`)Parameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to normalize |
Returns
ChangelogExample
Normalizing section headings
const normalized = normalizeSectionHeadings(changelog)
// 'New Features' becomes 'Added', 'Bug Fixes' becomes 'Fixed', etc.releaseUnreleased(changelog: Changelog, version: string, date?: string, compareUrl?: string): Changelog
Parameters
Returns
ChangelogExample
Releasing unreleased changes as a new version
const released = releaseUnreleased(changelog, '2.0.0', '2024-03-01')
// Unreleased entry becomes version 2.0.0 with the specified dateParameters
Returns
ChangelogExample
Removing empty entries
const cleaned = removeEmptyEntries(changelog)
// Entries with no content are removed (unreleased kept by default)
const strict = removeEmptyEntries(changelog, false)
// Even empty unreleased entry is removedParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to remove empty sections from |
Returns
ChangelogExample
Removing empty sections from all entries
const cleaned = removeEmptySections(changelog)
// Sections with no items are removed from all entriesremoveEntries(changelog: Changelog, versions: unknown, options?: RemoveEntryOptions): Changelog
Parameters
Returns
ChangelogExample
Removing multiple entries
const cleaned = removeEntries(changelog, ['0.1.0', '0.2.0'])
// Pre-release versions removed from changelogremoveEntry(changelog: Changelog, version: string, options?: RemoveEntryOptions): Changelog
Parameters
Returns
ChangelogExample
Removing an entry by version
const newChangelog = removeEntry(changelog, '1.0.0')removeItem(changelog: Changelog, version: string, sectionType: string, itemDescription: string, options?: RemoveSectionOptions): Changelog
Parameters
Returns
ChangelogExample
Removing a specific item from a section
const updated = removeItem(changelog, '1.0.0', 'features', 'Add dark mode')
// The 'Add dark mode' item is removed from features in 1.0.0removeSection(changelog: Changelog, version: string, sectionType: string, options?: RemoveSectionOptions): Changelog
Parameters
Returns
ChangelogExample
Removing a deprecated section
const updated = removeSection(changelog, '1.0.0', 'deprecated')
// Version 1.0.0 no longer has a deprecated sectionParameters
Returns
ChangelogExample
Removing the unreleased entry
const released = removeUnreleased(changelog)
// Changelog without the unreleased entry
// Silently ignore if not found
const safe = removeUnreleased(changelog, { throwIfNotFound: false })Parameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to reverse |
Returns
ChangelogExample
Reversing entry order
const reversed = reverseEntries(changelog)
// Oldest entries now appear firstParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to sort |
Returns
ChangelogExample
Sorting changelog entries by version
const sorted = sortEntries(changelog)
// Entries ordered: Unreleased, 2.0.0, 1.1.0, 1.0.0, ...Parameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to sort |
Returns
ChangelogExample
Sorting entries by date
const sorted = sortEntriesByDate(changelog)
// Entries ordered by release date, most recent firstParameters
Returns
ChangelogExample
Sorting sections within entries
const sorted = sortSections(changelog)
// Sections in each entry follow: breaking, features, fixes, ...
const custom = sortSections(changelog, ['fixes', 'features', 'breaking'])
// Custom ordering: fixes first, then features, then breakingParameters
| Name | Type | Description |
|---|---|---|
§changelog | Changelog | The changelog to strip |
Returns
ChangelogExample
Stripping metadata from a changelog
const stripped = stripMetadata(changelog)
// Source and warnings removed, only format and isConventional retainedParameters
Returns
ChangelogExample
Transforming all entries
const transformed = transformEntries(changelog, (entry) => ({
...entry,
date: entry.date?.toUpperCase()
}))Parameters
Returns
ChangelogExample
Prefixing item descriptions with scope
const prefixed = transformItems(changelog, (item) => ({
...item,
description: `[${item.scope || 'misc'}] ${item.description}`,
}))Parameters
Returns
ChangelogExample
Uppercasing section headings
const renamed = transformSections(changelog, (section) => ({
...section,
heading: section.heading.toUpperCase(),
}))updateEntry(changelog: Changelog, version: string, updates: Partial<ChangelogEntry> | (entry: ChangelogEntry) => ChangelogEntry): Changelog
Parameters
Returns
ChangelogExample
Updating a specific entry
const updated = updateEntry(changelog, '1.0.0', { date: '2024-01-15' })
// Or with transformer function
const modified = updateEntry(changelog, '1.0.0', (entry) => ({
...entry,
compareUrl: `https://github.com/org/repo/compare/v0.9.0...v${entry.version}`,
}))Parameters
Returns
ChangelogExample
Updating the changelog header
const updated = updateHeader(changelog, { title: '# Release Notes' })Parameters
Returns
ChangelogExample
Updating changelog metadata
const updated = updateMetadata(changelog, { repositoryUrl: 'https://github.com/org/repo' })◈ Interfaces
Properties
Properties
◆ Types
type EntryPredicate = (entry: ChangelogEntry, index: number) => booleantype EntryTransformer = (entry: ChangelogEntry, index: number) => ChangelogEntrytype ItemPredicate = (item: ChangelogItem, section: ChangelogSection, entry: ChangelogEntry) => booleantype ItemTransformer = (item: ChangelogItem, section: ChangelogSection, entry: ChangelogEntry) => ChangelogItemtype MergeStrategy = "source" | "target" | "union" | "latest"type SectionPredicate = (section: ChangelogSection, entry: ChangelogEntry) => booleantype SectionTransformer = (section: ChangelogSection, entry: ChangelogEntry) => ChangelogSection