MCPcopy
hub / github.com/learnhouse/learnhouse / checkForUpdates

Function checkForUpdates

apps/cli/src/services/version-check.ts:21–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19 * Non-blocking — silently fails on network errors.
20 */
21export 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.

Callers 2

unit.test.tsFile · 0.85
learnhouse.tsFile · 0.85

Calls 3

fetchFunction · 0.85
compareVersionsFunction · 0.85
jsonMethod · 0.45

Tested by

no test coverage detected