( version: string, stagingPath: string, )
| 478 | } |
| 479 | |
| 480 | export async function downloadVersion( |
| 481 | version: string, |
| 482 | stagingPath: string, |
| 483 | ): Promise<'npm' | 'binary'> { |
| 484 | // Test-fixture versions route to the private sentinel bucket. DCE'd in all |
| 485 | // shipped builds — the sentinel string and the gcloud call never exist in |
| 486 | // compiled binaries. Same gcloud-token pattern as |
| 487 | // remoteSkillLoader.ts:175-195. |
| 488 | if (feature('ALLOW_TEST_VERSIONS') && /^99\.99\./.test(version)) { |
| 489 | const { stdout } = await execFileNoThrowWithCwd('gcloud', [ |
| 490 | 'auth', |
| 491 | 'print-access-token', |
| 492 | ]) |
| 493 | await downloadVersionFromBinaryRepo( |
| 494 | version, |
| 495 | stagingPath, |
| 496 | 'https://storage.googleapis.com/ncode-ci-sentinel', |
| 497 | { headers: { Authorization: `Bearer ${stdout.trim()}` } }, |
| 498 | ) |
| 499 | return 'binary' |
| 500 | } |
| 501 | |
| 502 | const binaryRepoUrl = getPublicBinaryUrl() |
| 503 | if (binaryRepoUrl) { |
| 504 | await downloadVersionFromBinaryRepo(version, stagingPath, binaryRepoUrl) |
| 505 | return 'binary' |
| 506 | } |
| 507 | |
| 508 | await downloadVersionFromGithubRelease(version, stagingPath) |
| 509 | return 'binary' |
| 510 | } |
| 511 | |
| 512 | // Exported for testing |
| 513 | export { StallTimeoutError, MAX_DOWNLOAD_RETRIES } |
no test coverage detected