Files
supabase/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.utils.ts
Han Qiao 698e585a65 feat: fetch beta cli release version (#34923)
* feat: fetch beta cli release version

* Small refactors

* Fix

* Fix

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-04-14 16:20:03 +08:00

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
}