Dashboard › craft › Distillation
e8376782-9ff3-45f2-b3b2-08afda7f1c6f["lore_tm_v1_-_zh9p3exx8UH1kYnMrkMrUaulOUXQwkRcN-LF14QAs","lore_tm_v1_Sk27qb0E8NzEGXv8kG6rD3ZFMQ8UZassHHacP8Q4eN0"]
Date: Aug 24, 2026
/home/byk/Code/getsentry/craft-workspaces-schema/src/utils/version.ts (170 lines).src/utils/version.ts:10-11 defines semverRegex() as /\bv?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-?([\da-z-]+(?:\.[\da-z-]+)*))?(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?\b/gi, matching optional leading v, numeric major/minor/patch components without leading zeroes except 0, optional prerelease, and optional build metadata.src/utils/version.ts:23-29 getVersion(text: string): string | null executes a newly created semverRegex(), returns its first match, and strips a leading case-insensitive v via version.substr(1).src/utils/version.ts:37-39 isValidVersion(text) requires a truthy input and exact equality between text and getVersion(text), so embedded semver substrings are not valid full version strings.src/utils/version.ts:44-55 exports SemVer: required numeric major, minor, and patch; optional string pre and build.src/utils/version.ts:63-74 parseVersion(text) extracts the first regex match and returns SemVer | null, mapping captures matches[1], [2], and [3] to base-10 integer major, minor, and patch, [4] to pre, and [5] to build.src/utils/version.ts:81-108 versionGreaterOrEqualThan(v1, v2) compares major, then minor, then patch; a stable release is greater than an equivalent prerelease, and a prerelease is less than an equivalent stable release. It compares distinct all-numeric prerelease strings with v1.pre > v2.pre; for unequal versions involving build metadata or unsupported prerelease comparison, it throws Cannot compare the two versions: "${JSON.stringify(v1)}" and "${JSON.stringify(v2)}". Completely equal versions return true.src/utils/version.ts:113-124 exports PREVIEW_RELEASE_REGEX = /(?:[^a-z])(preview|pre|rc|dev|alpha|beta|unstable|a|b)(?:[^a-z]|$)/i; isPreviewRelease(text) returns true only when text is a valid complete version and matches that preview-release regex.src/utils/version.ts:135-138 versionToTag(version, tagPrefix?) prepends explicit tagPrefix when supplied; otherwise it uses getGitTagPrefix() imported from ../config.src/utils/version.ts:143-150 getPackage() loads ../../package.json with require, throws Invalid package.json: the file is empty! when Object.keys(pkg).length === 0, and otherwise returns the package object.src/utils/version.ts:155-161 getPackageVersion() returns package.json’s version, appending (${process.env.CRAFT_BUILD_SHA}) when CRAFT_BUILD_SHA is set at build time.src/utils/version.ts:166-170 semVerToString(s: SemVer) serializes as major.minor.patch, appending -${s.pre} when pre exists and +${s.build} when build exists.