MCPcopy Index your code
hub / github.com/codeaashu/claude-code / downloadVersion

Function downloadVersion

src/utils/nativeInstaller/download.ts:487–518  ·  view source on GitHub ↗
(
  version: string,
  stagingPath: string,
)

Source from the content-addressed store, hash-verified

485}
486
487export async function downloadVersion(
488 version: string,
489 stagingPath: string,
490): Promise<'npm' | 'binary'> {
491 // Test-fixture versions route to the private sentinel bucket. DCE'd in all
492 // shipped builds — the string 'claude-code-ci-sentinel' and the gcloud call
493 // never exist in compiled binaries. Same gcloud-token pattern as
494 // remoteSkillLoader.ts:175-195.
495 if (feature('ALLOW_TEST_VERSIONS') && /^99\.99\./.test(version)) {
496 const { stdout } = await execFileNoThrowWithCwd('gcloud', [
497 'auth',
498 'print-access-token',
499 ])
500 await downloadVersionFromBinaryRepo(
501 version,
502 stagingPath,
503 'https://storage.googleapis.com/claude-code-ci-sentinel',
504 { headers: { Authorization: `Bearer ${stdout.trim()}` } },
505 )
506 return 'binary'
507 }
508
509 if (process.env.USER_TYPE === 'ant') {
510 // Use Artifactory for ant users
511 await downloadVersionFromArtifactory(version, stagingPath)
512 return 'npm'
513 }
514
515 // Use GCS for external users
516 await downloadVersionFromBinaryRepo(version, stagingPath, GCS_BUCKET_URL)
517 return 'binary'
518}
519
520// Exported for testing
521export { StallTimeoutError, MAX_DOWNLOAD_RETRIES }

Callers 1

performVersionUpdateFunction · 0.85

Calls 4

featureFunction · 0.85
execFileNoThrowWithCwdFunction · 0.85

Tested by

no test coverage detected