relizy / getCanaryVersion
Function: getCanaryVersion()
getCanaryVersion(
payload):string
Defined in: src/core/version.ts:846
Computes a canary version with format {nextVersion}-0.{preid}-{sha}.
The leading numeric 0 prerelease identifier makes the canary sort below every named prerelease (alpha, beta, rc...) and the stable release of the same version, so it never matches a range like ^5.0.0-beta.0 and is never suggested by update tools. Keeping preid and sha in a single identifier also keeps the version valid when the sha is all digits with a leading zero.
Parameters
payload
The payload to compute the canary version from
currentVersion
string
The current package version
preid?
string = 'canary'
The pre-release identifier
releaseType
"major" | "minor" | "patch" | undefined
The release type detected from commits (defaults to patch)
sha
string
The short sha of the commit
Returns
string
The canary version
Example
getCanaryVersion({ currentVersion: '1.2.3', releaseType: 'minor', sha: 'a3f4b2c' }) // '1.3.0-0.canary-a3f4b2c'
getCanaryVersion({ currentVersion: '5.0.0-beta.44', releaseType: 'patch', sha: 'a3f4b2c' }) // '5.0.0-0.canary-a3f4b2c'