@hyperfrontend/versioning/semver/incrementincrement
Version bumping: increment a SemVer by a BumpType and compute the diff between two versions.
increment(version, bumpType) produces the next version for major, minor, patch, and the equivalent prerelease bumps. incrementPrerelease is the dedicated helper for advancing -rc.1 → -rc.2 style identifiers without touching the numeric core. diff(a, b) returns the smallest BumpType that explains the change between two versions, used by changelog and dependent-package logic to decide what kind of bump a downstream package needs.
API Reference
ƒ Functions
Calculates the difference type between two versions.
Returns
BumpTypeThe type of difference, or null if versions are equal
Example
Calculate the difference type between two versions
diff(parseVersion('1.0.0'), parseVersion('2.0.0')) // 'major'
diff(parseVersion('1.0.0'), parseVersion('1.1.0')) // 'minor'
diff(parseVersion('1.0.0'), parseVersion('1.0.1')) // 'patch'Increments a version based on the bump type.
Parameters
Returns
SemVerA new incremented SemVer
Example
Increment version by bump type
increment(parseVersion('1.2.3'), 'minor') // 1.3.0
increment(parseVersion('1.2.3'), 'major') // 2.0.0
increment(parseVersion('1.2.3'), 'prerelease', 'alpha') // 1.2.4-alpha.0Increments the prerelease portion of a version.
Parameters
Returns
SemVerA new version with incremented prerelease
Example
Increment the prerelease portion of a version
incrementPrerelease(parseVersionStrict('1.0.0')) // => 1.0.1-alpha.0
incrementPrerelease(parseVersionStrict('1.0.0-alpha.0')) // => 1.0.0-alpha.1
incrementPrerelease(parseVersionStrict('1.0.0'), 'beta') // => 1.0.1-beta.0