MCPcopy Create free account
hub / github.com/codeaashu/claude-code / getVersionHistory

Function getVersionHistory

src/utils/autoUpdater.ts:421–454  ·  view source on GitHub ↗
(limit: number)

Source from the content-addressed store, hash-verified

419 * 3. This prevents rollback from listing versions that don't have native binaries
420 */
421export async function getVersionHistory(limit: number): Promise<string[]> {
422 if (process.env.USER_TYPE !== 'ant') {
423 return []
424 }
425
426 // Use native package URL when available to ensure we only show versions
427 // that have native binaries (not all JS package versions have native builds)
428 const packageUrl = MACRO.NATIVE_PACKAGE_URL ?? MACRO.PACKAGE_URL
429
430 // Run from home directory to avoid reading project-level .npmrc
431 const result = await execFileNoThrowWithCwd(
432 'npm',
433 ['view', packageUrl, 'versions', '--json', '--prefer-online'],
434 // Longer timeout for version list
435 { abortSignal: AbortSignal.timeout(30000), cwd: homedir() },
436 )
437
438 if (result.code !== 0) {
439 logForDebugging(`npm view versions failed with code ${result.code}`)
440 if (result.stderr) {
441 logForDebugging(`npm stderr: ${result.stderr.trim()}`)
442 }
443 return []
444 }
445
446 try {
447 const versions = jsonParse(result.stdout.trim()) as string[]
448 // Take last N versions, then reverse to get newest first
449 return versions.slice(-limit).reverse()
450 } catch (error) {
451 logForDebugging(`Failed to parse version history: ${error}`)
452 return []
453 }
454}
455
456export async function installGlobalPackage(
457 specificVersion?: string | null,

Callers

nothing calls this directly

Calls 3

execFileNoThrowWithCwdFunction · 0.85
logForDebuggingFunction · 0.85
jsonParseFunction · 0.85

Tested by

no test coverage detected