(latest: string, current: string)
| 56 | } |
| 57 | |
| 58 | function isNewerVersion(latest: string, current: string): boolean { |
| 59 | const parse = (v: string) => { |
| 60 | const [core, pre] = v.split('-', 2) |
| 61 | const parts = core.split('.').map(Number) |
| 62 | return { major: parts[0] || 0, minor: parts[1] || 0, patch: parts[2] || 0, pre } |
| 63 | } |
| 64 | const l = parse(latest) |
| 65 | const c = parse(current) |
| 66 | if (l.major !== c.major) return l.major > c.major |
| 67 | if (l.minor !== c.minor) return l.minor > c.minor |
| 68 | if (l.patch !== c.patch) return l.patch > c.patch |
| 69 | // Design note: prerelease users are not prompted for prerelease-to-prerelease updates. |
| 70 | // Only a stable release with the same core version should supersede a prerelease build. |
| 71 | if (c.pre && !l.pre) return true |
| 72 | return false |
| 73 | } |
| 74 | |
| 75 | async function fetchLatestVersion(): Promise<string | null> { |
| 76 | try { |
no test coverage detected