Dashboard › cli › Distillation
f0a6f3f6-5162-4208-8bee-c8765565805e["lore_tm_v1_Yi6-f1HZLwS5kSeBlD-4hlqXgdQjDz651e0Fpcy4JM0"]
packages/cli/src/lib/binary.ts, packages/cli/src/lib/ghcr.ts, and packages/cli/src/lib/version-check.ts that add ordered fallback upgrade sources and propagate the selected source through stable/nightly version discovery and delta-patch prefetching.packages/cli/src/lib/binary.ts, stripTrailingSep(p) strips one trailing platform separator only when p.length > 1, never from a bare root like /, so entries such as ~/.local/bin/ compare equal to ~/.local/bin.packages/cli/src/lib/binary.ts, samePath(a, b) tolerates trailing separators and, when IS_CASE_INSENSITIVE_FS is true, lowercases both normalized paths so casing differences such as C:\Users\User versus C:\Users\user do not cause false inequality; the platform-specific implementation is selected once at module load.packages/cli/src/lib/binary.ts, new UpgradeSource fields are readonly githubRepo, readonly ghcrRepo, and readonly tagPrefix.packages/cli/src/lib/binary.ts, UPGRADE_SOURCES is a non-empty ordered tuple declared with as const satisfies readonly [UpgradeSource, ...UpgradeSource[]]: 1. { githubRepo: "getsentry/toolkit", ghcrRepo: "getsentry/toolkit", tagPrefix: "cli@" }; 2. { githubRepo: "getsentry/cli", ghcrRepo: "getsentry/cli", tagPrefix: "" }.packages/cli/src/lib/binary.ts, PRIMARY_UPGRADE_SOURCE = UPGRADE_SOURCES[0] is the default for direct helper calls that do not resolve a source.packages/cli/src/lib/binary.ts, getBinaryDownloadUrl(version, source = PRIMARY_UPGRADE_SOURCE) now constructs https://github.com/${source.githubRepo}/releases/download/${source.tagPrefix}${version}/${getPlatformBinaryName()} instead of hard-coding getsentry/cli.packages/cli/src/lib/binary.ts, new source-aware URL helpers are: getGitHubReleasesUrl(source) → https://api.github.com/repos/${source.githubRepo}/releases; getGitHubReleaseByTagUrl(version, source) → /tags/${encodeURIComponent(source.tagPrefix + version)}; getGitHubLatestReleaseUrl(source) → ?per_page=100 for prefixed sources and /latest for unprefixed sources; and getGitHubRepositoryUrl(source) → https://api.github.com/repos/${source.githubRepo}.packages/cli/src/lib/binary.ts, GITHUB_RELEASES_URL is retained as the primary source’s API base via getGitHubReleasesUrl(), rather than a hard-coded https://api.github.com/repos/getsentry/cli/releases.packages/cli/src/lib/binary.ts, new ResolvedUpgradeSource contains the selected source: UpgradeSource and successful response: Response; returning the response ensures the caller never repeats the successful probe request.packages/cli/src/lib/binary.ts, ResolveUpgradeSourceOptions requires getProbeUrl(source) and optionally accepts a fetch implementation, shared AbortSignal, and ordered sources; the defaults are the CA-aware customFetch and UPGRADE_SOURCES.packages/cli/src/lib/binary.ts, fetchUpgradeProbe() sends getGitHubHeaders() and the optional cancellation signal. It rethrows AbortError, maps TLS certificate errors through buildTlsErrorDetail() to UpgradeError("network_error", ...), and maps other connection failures to UpgradeError("network_error", "Failed to connect to GitHub: ...").packages/cli/src/lib/binary.ts, resolveUpgradeSource() probes sources in order, returns { source, response } on the first successful response, advances only for HTTP 404, immediately fails other HTTP statuses with Failed to fetch from GitHub: HTTP ${response.status}, and if all sources return 404 throws No CLI upgrade source was found: every source returned HTTP 404.packages/cli/src/lib/binary.ts, version comparison documentation now identifies semver.compare rather than Bun.semver.order; compareVersions(a, b) continues to return -1 | 0 | 1 and supports stable X.Y.Z plus nightly X.Y.Z-dev.<unix-seconds> versions with numeric prerelease comparison under SemVer.packages/cli/src/lib/ghcr.ts, PRIMARY_UPGRADE_SOURCE and UpgradeSource are imported from ./binary.js; GHCR_REPO now derives from PRIMARY_UPGRADE_SOURCE.ghcrRepo rather than the hard-coded "getsentry/cli".packages/cli/src/lib/ghcr.ts, getAnonymousToken(sourceOrSignal: UpgradeSource | AbortSignal = PRIMARY_UPGRADE_SOURCE, signal?) preserves direct signal-call compatibility while allowing a source; it requests https://ghcr.io/token?scope=repository:${source.ghcrRepo}:pull and applies the correct external abort signal.packages/cli/src/lib/ghcr.ts, source propagation was added to GHCR helpers with PRIMARY_UPGRADE_SOURCE defaults: fetchManifest(token, tag, signal?, source?), fetchNightlyManifest(token, signal?, source?), downloadNightlyBlob(token, digest, signal?, source?), private fetchTagPage(token, lastTag?, signal?, source?), listTags(token, prefix?, signal?, source?), and downloadLayerBlob(token, digest, signal?, source?).packages/cli/src/lib/ghcr.ts, manifest, blob, and tag-list URLs now use ${source.ghcrRepo}; fetchNightlyManifest() forwards source to fetchManifest(), listTags() forwards source through every paginated fetchTagPage() call, and downloadLayerBlob() forwards source to downloadNightlyBlob().packages/cli/src/lib/version-check.ts, the old imports fetchLatestFromGitHub and fetchLatestNightlyVersion were replaced by fetchLatestFromGitHubWithSource and fetchLatestNightlyVersionWithSource, and UpgradeSource is imported as a type from ./binary.js.packages/cli/src/lib/version-check.ts, maybePrefetchPatches(channel, latestVersion, signal, source) now requires the resolved UpgradeSource; it passes that source to prefetchNightlyPatches(latestVersion, signal, source) or prefetchStablePatches(latestVersion, signal, source).packages/cli/src/lib/version-check.ts, checkForUpdateInBackgroundImpl() now destructures { version: latestVersion, source } from the source-aware stable/nightly fetch, stores latestVersion with setVersionCheckInfo(), and prefetches patches from the same selected source, preventing release metadata and patch artifacts from being mixed across repositories.checkForUpdateInBackgroundImpl() does not block, runs its fetch in the background, reports errors to Sentry in a detached span, and never throws because errors are caught and reported to Sentry.packages/cli/src/lib/version-check.ts, database access failures in checkForUpdateInBackgroundImpl() are caught, sent through Sentry.captureException(error), and return without crashing the CLI; expected process-exit AbortErrors are not reported, while other failures become span attributes version_check.error and version_check.error_type.null when up to date, when cached version information is absent, when rate-limited, when stderr is non-TTY, or on error, and never throws because errors are caught and reported to Sentry.