Dashboard › cli › Distillation
8d85ae8c-e139-440c-a70f-9fbd31883b89["lore_tm_v1_sgIO-OHZNUApnauJ0WV_y20Q7mgQd8s7__Vh7iZM6zg"]
packages/cli/src/lib/upgrade.ts, expanding the upgrade module from 149 to 238 lines in the shown initial hunk and adding source-aware GitHub upgrade handling, release pagination/filtering, nightly-version handling, and binary-download verification.prerelease as semverPrerelease and valid as semverValid imports from semver, plus compareVersions and source-aware binary helpers, while removing direct use of GITHUB_RELEASES_URL in packages/cli/src/lib/upgrade.ts.NEXT_PAGE_LINK_REGEX = /<([^>]+)>;\s*rel="next"/ for GitHub pagination and validates a matched next-page URL with URL.canParse(match[1]).release.draft || release.prerelease.detectInstallationMethod() as: 1. Homebrew via a cheap realpath check that overrides stale stored information; 2. stored install information in the DB as the fast path; 3. legacy detection in the order curl paths β subprocess calls β node_modules path; 4. automatically save the detected method for future runs.detectInstallationMethod() must always check for Homebrew first because stored install information may be staleβfor example, a user may have a recorded curl installation and later switch to Homebrew; the realpath check is cheap and authoritative.signal?: AbortSignal support to GitHub upgrade-fetching behavior in packages/cli/src/lib/upgrade.ts.fetchLatestFromGitHub(signal?: AbortSignal, source?: UpgradeSource): Promise<string> to call fetchLatestFromGitHubWithSource(signal, source ? [source] : UPGRADE_SOURCES) and return its .version, using one explicitly requested source or the ordered UPGRADE_SOURCES fallback list.manifestVersion through getNightlyVersion(manifest), probes releases with getGitHubReleaseByTagUrl(version, source), and returns { version, source: selected.source } after selecting a source.drainBodyToFd(body, fd, (n) => progress.onProgress(n)), awaits both streamError and writeError, and calls progress.done() only after the drain terminates.waitForBinaryVisible(path: string): Promise<number> to repeatedly call probeBinaryFile(path) and return the verified binary size once the downloaded file is visible and non-empty."Binary became visible after ${attempt} attempts"; while retrying, "Downloaded binary not yet visible at ${path}, retrying in ${delay}ms (attempt ${attempt}/${VERIFY_MAX_ATTEMPTS})".waitForBinaryVisible() throws an UpgradeError when the downloaded binary never becomes visible or stays empty.new UpgradeError("execution_failed", "Downloaded binary is missing or empty at ${path}. This is usually transient β rerun \sentry cli upgrade` to retry.")`.setMessage?: SetMessage support to the upgrade/download flow in packages/cli/src/lib/upgrade.ts.