Dashboard › cli › Distillation
83aa2dfa-634f-484d-bf42-8868da7b210a["lore_tm_v1_VryrzUSQaHTsz_256wq-I2mRJoZ-_cfm1LgdkTujHyw","lore_tm_v1_-A-aH3JDXG7Z9I9GqZTT1FkJt11otZUcdgfJWMLsX-I","lore_tm_v1_8yMQmRoRWQ-Z33urM-dcNNWMgrE3ved9r5f37LMiTOs","lore_tm_v1_WgjhBuWRG_uBr1KbSYs0zUFbAna6jT8QHtUWLVLJbpw","lore_tm_v1_GADUsOBanQ0w0EG0dFeBbq9RKkENJ2xeXr4hTPibdS4"]
/home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/packages/cli/test/lib/upgrade.test.ts is 2,153 lines; the displayed section covered lines 1β730.packages/cli/test/lib/upgrade.test.ts mocks node:child_process with a hoisted, swappable spawnImpl.fn; fakeProcess(exitCode, stdoutData) emits stdout chunks and then "close" after a microtask, while fakeErrorProcess(message) emits an "error" event. Dynamic imports run after vi.mock() so upgrade.ts receives the mocked spawn.packages/cli/test/lib/upgrade.test.ts dynamically imports and tests buildKnownCurlPaths, detectInstallationMethod, detectPackageManagerFromPath, downloadBinaryToTemp, executeUpgrade, fetchLatestFromGitHub, fetchLatestFromNpm, fetchLatestNightlyVersion, fetchLatestVersion, getCurlInstallPaths, parseInstallationMethod, startCleanupOldBinary, and versionExists; it also imports acquireLock, getBinaryDownloadUrl, isNightlyVersion, and releaseLock from packages/cli/src/lib/binary.js.parseInstallationMethod() tests accept curl, brew, npm, pnpm, bun, and yarn; normalize case such as NPM, Curl, and YARN; and reject pip, apt, and the empty string with Invalid method: ${value}.fetchLatestFromGitHub() tests expect tag_name values "v1.2.3" and "v0.5.0" to become "1.2.3" and "0.5.0", preserve "1.0.0" without a prefix, map HTTP 404 to UpgradeError message "Failed to fetch from GitHub: 404", map TypeError("fetch failed") to "Failed to connect to GitHub: fetch failed", and reject a successful JSON response lacking tag_name with "No version found in GitHub release".fetchLatestFromNpm() tests expect registry JSON { version: "1.2.3" } to return "1.2.3", HTTP 500 to produce "Failed to fetch from npm: 500", TypeError("fetch failed") to produce "Failed to connect to npm registry: fetch failed", and missing version to produce "No version found in npm registry".UpgradeError tests assert default reason/message mappings: unknown_method β "Could not detect installation method. Use --method to specify."; network_error β "Failed to fetch version information."; execution_failed β "Upgrade command failed."; version_not_found β "The specified version was not found."; unsupported_operation β "This operation is not supported for this installation method."; and offline_cache_miss β "Cannot upgrade offline β no pre-downloaded update is available.". A supplied custom message overrides the default.fetchLatestVersion() tests route curl and brew stable lookups through GitHub, route npm, pnpm, bun, yarn, and unknown through npm, and default an omitted channel to stable. The test value returned in these routing cases is "2.0.0", while the omitted-channel test expects "3.0.0".fetchLatestVersion(method, "nightly") tests require GHCR manifest lookup for both "curl" and "npm" installation methods, because nightly is a curl-only distribution regardless of the detected install method; token exchange returns "tok" and the nightly manifest annotation supplies version "0.0.0-dev.1740393600".versionExists() tests route stable curl and brew versions to GitHub and stable npm, pnpm, bun, and yarn versions to npm; HTTP 200 means true, HTTP 404 means false, and network failures become UpgradeError with GitHub- or npm-specific connection messages.versionExists() recognizes nightly versions such as "0.14.0-dev.1772661724" and checks GHCR tags containing /manifests/nightly- regardless of installation method. A manifest HTTP 200 returns true, HTTP 404 for "0.14.0-dev.9999999999" returns false, while a network failure or HTTP 500 rejects with UpgradeError.executeUpgrade("unknown", "1.0.0") tests require an UpgradeError containing "Could not detect installation method" and reason "unknown_method".getAnonymousToken references: 8 calls/assertions in packages/cli/test/lib/ghcr.test.ts, its declaration at line 192 of packages/cli/src/lib/ghcr.ts, and production calls at lines 476, 523, and 733 of packages/cli/src/lib/upgrade.ts.packages/cli/src/lib/upgrade.ts calls fetchNightlyManifest(token) at lines 482 and 736, fetchManifest(token, \nightly-${version}`)at lines 525 and 735, anddownloadNightlyBlob(token, layer.digest)` at line 739.packages/cli/src/lib/delta-upgrade.ts calls client.listTags(opts.token, PATCH_TAG_PREFIX, opts.signal) at line 294 and calls client.fetchManifest(opts.token, tag, opts.signal) for each chainTags entry at line 308, showing that delta-upgradeβs GHCR client interface currently passes token, tag/prefix, and optional abort signal but no selected upgrade source./home/byk/.local/share/opencode/worktree/0e8c2f3bbe145a3280d6fb6ed900a5121f382cf0/toolkit-bridge-upgrade/packages/cli/test/commands/cli/upgrade.test.ts is 1,202 lines; the displayed section covered lines 1β520 and tests sentry cli upgrade through Stricliβs run().packages/cli/test/commands/cli/upgrade.test.ts mocks node:child_process as a mutable ESM namespace so vi.spyOn works and captures consola/progress output from process.stderr, spinner/rendered output from process.stdout, and Stricli errors from context.stderr.createMockContext() in packages/cli/test/commands/cli/upgrade.test.ts defaults to PATH="/usr/bin:/bin", SHELL="/bin/bash", execPath="/usr/local/bin/sentry", argv=["/usr/local/bin/sentry"], homeDir="/tmp/test-home", cwd="/tmp", and configDir="/tmp/test-config". It temporarily sets SENTRY_PLAIN_OUTPUT="0" to force rich spinner output and restores stdout, stderr, and the prior environment value afterward.mockGhcrNightlyVersion(version) mocks anonymous GHCR token exchange with token "test-token" and a nightly OCI manifest containing schemaVersion: 2, layers: [], and annotations: { version }, with media type "application/vnd.oci.image.manifest.v1+json".mockGitHubVersion(version) handles three routes: releases/latest returns { tag_name: version }; /releases/tags/${requested} returns 200 only when requested === version, using unprefixed tags; and hostname registry.npmjs.org returns { version }. Other URLs return HTTP 404.mockNightlyVersion(version) is the GHCR replacement for the old GitHub version.json mock: it returns token "test-token" for ghcr.io/token and { annotations: { version } } for /manifests/nightly. The file retains an adjacent stale comment reading "Mock fetch for the nightly version.json endpoint.".sentry cli upgrade --check --method curl command tests expect: when latest equals CLI_VERSION, output includes "Method: curl", CLI_VERSION, and "You are already on the target version"; when latest is "99.99.99", output includes that version and "Run 'sentry cli upgrade' to update.".sentry cli upgrade --check --method curl 88.88.88 is tested to display "88.88.88" and the exact hint "Run 'sentry cli upgrade 88.88.88' to update.".sentry cli upgrade --method curl with current and target both equal to CLI_VERSION must display "Already up to date" and must not display "Upgrading to".sentry cli upgrade --method brew 1.2.3 must fail before any network request with "Homebrew does not support installing a specific version". In contrast, sentry cli upgrade --check --method brew with latest "99.99.99" must show "Method: brew", "99.99.99", and "Run 'sentry cli upgrade' to update.".sentry cli upgrade --method curl 0.0.1 to report "Version 0.0.1 not found" when the latest release is "v99.99.99" but the specific-version request returns HTTP 404; a user-provided v${CLI_VERSION} must have its v prefix stripped and produce "Already up to date"."0.0.0-dev.1740000000" and require sentry cli upgrade --check --method curl nightly to fetch from GHCR, show "nightly" and the version, and include "sentry cli upgrade" as the upgrade hint because CLI_VERSION is "0.0.0-dev" and does not equal the timestamped nightly version.packages/cli/test/commands/cli/upgrade.test.ts: positional "nightly" sets and persists channel "nightly"; positional "stable" resets and persists channel "stable"; omitting the positional uses the stored channel; and output assertions include "Channel: nightly" and "Channel: stable".