()
| 19 | * Non-blocking — silently fails on network errors. |
| 20 | */ |
| 21 | export async function checkForUpdates(): Promise<void> { |
| 22 | try { |
| 23 | const resp = await fetch(NPM_REGISTRY_URL, { |
| 24 | signal: AbortSignal.timeout(3000), |
| 25 | headers: { Accept: 'application/json' }, |
| 26 | }) |
| 27 | if (!resp.ok) return |
| 28 | const data = await resp.json() as { 'dist-tags'?: { latest?: string } } |
| 29 | const latest = data['dist-tags']?.latest |
| 30 | if (!latest) return |
| 31 | |
| 32 | if (compareVersions(latest, VERSION) > 0) { |
| 33 | console.log() |
| 34 | console.log(pc.yellow(` Update available: ${VERSION} → ${pc.bold(latest)}`)) |
| 35 | console.log(pc.dim(` Run: npx learnhouse@latest`)) |
| 36 | console.log() |
| 37 | } |
| 38 | } catch { |
| 39 | // Network error — skip silently |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Resolve the Docker image tag for the LearnHouse app. |
no test coverage detected