| 1 | import type { DesktopUpdateChannel } from "@t3tools/contracts"; |
| 2 | |
| 3 | const NIGHTLY_VERSION_PATTERN = /^[^-+]+-nightly\.\d{8}\.\d+$/; |
| 4 | // Preview builds are the maintainers' test train, cut by hand from unreleased |
| 5 | // branches to exercise the release flow. They share nightly's branding but |
| 6 | // are packaged without an update feed (see |
| 7 | // isDesktopPreviewVersion in scripts/build-desktop-artifact.ts), so the |
| 8 | // channel a preview install reports is cosmetic: it never checks for updates |
| 9 | // and no updater feed ever lists a preview release. |
| 10 | const PRERELEASE_VERSION_PATTERN = /^[^-+]+-(?:nightly|preview)\.\d{8}\.\d+$/; |
| 11 | |
| 12 | export function isNightlyDesktopVersion(version: string): boolean { |
| 13 | return PRERELEASE_VERSION_PATTERN.test(version); |
| 14 | } |
| 15 | |
| 16 | export function resolveDefaultDesktopUpdateChannel(appVersion: string): DesktopUpdateChannel { |
| 17 | return NIGHTLY_VERSION_PATTERN.test(appVersion) ? "nightly" : "latest"; |
| 18 | } |