Skip to content

relizy / getCanaryVersion

Function: getCanaryVersion()

getCanaryVersion(payload): string

Defined in: src/core/version.ts:760

Checks if a tag's version is compatible with the current version. A tag is compatible if its major version is less than or equal to the current major version.

This prevents accidentally using tags from future major versions (e.g., v5.0.0-beta.0) when bumping a current stable version (e.g., 4.1.1 → 4.1.2).

Parameters

payload

The payload to check

currentVersion

string

The current package version

preid?

string = 'canary'

The pre-release identifier

releaseType

"major" | "minor" | "patch" | undefined

The release type

sha

string

The sha of the commit

Returns

string

true if the tag version's major is <= current major version

Example

ts
isTagVersionCompatibleWithCurrent('4.1.1', '4.1.0') // true - same major
isTagVersionCompatibleWithCurrent('5.0.0-beta.0', '4.1.1') // false - newer major
isTagVersionCompatibleWithCurrent('3.9.9', '4.1.1') // true - older major

Released under the MIT License.