mirror of
https://github.com/supabase/supabase.git
synced 2026-06-21 07:46:01 +08:00
* feat: fetch beta cli release version * Small refactors * Fix * Fix --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
29 lines
872 B
TypeScript
29 lines
872 B
TypeScript
type CLIVersionSemver = { major: number; minor: number; patch: number }
|
|
|
|
// [Joshen] Specifically in the syntax of `v0.0.0`
|
|
export const getSemver = (version?: string) => {
|
|
if (!version) return undefined
|
|
const [major, minor, patch] = version.slice(1).split('.')
|
|
return { major: Number(major), minor: Number(minor), patch: Number(patch) }
|
|
}
|
|
|
|
export const semverLte = (a: CLIVersionSemver, b: CLIVersionSemver) => {
|
|
if (
|
|
a.major > b.major ||
|
|
(a.major === b.major && a.minor > b.minor) ||
|
|
(a.major === b.major && a.minor === b.minor && a.patch > b.patch)
|
|
)
|
|
return false
|
|
return true
|
|
}
|
|
|
|
export const semverGte = (a: CLIVersionSemver, b: CLIVersionSemver) => {
|
|
if (
|
|
a.major < b.major ||
|
|
(a.major === b.major && a.minor < b.minor) ||
|
|
(a.major === b.major && a.minor === b.minor && a.patch < b.patch)
|
|
)
|
|
return false
|
|
return true
|
|
}
|