/** * Binary upgrade strategy for `ref upgrade` on single-binary installs. * * Downloads the latest release asset for the current platform to * `{dest}.tmp.{pid}`, verifies it by invoking `--version`, then atomically * replaces the running binary: a single overwriting `rename()` on Unix, a * `.old` rotation on Windows (where the running exe cannot be replaced). * * See: spec/features/self-upgrade.md §Atomic replace. */ import { type ReleaseInfo } from "./check.js"; export type UpgradeStatus = "success" | "already-up-to-date" | "guidance" | "error"; export interface UpgradeResult { status: UpgradeStatus; fromVersion?: string; toVersion?: string; url?: string; message?: string; error?: string; /** Non-fatal caveat about the applied upgrade (e.g. checksum skipped). */ notice?: string; } export interface UpgradeBinaryOptions { /** Absolute path to the binary that should be replaced. */ destPath: string; /** The version of the currently running `ref`, without leading `v`. */ currentVersion: string; /** Explicit release tag (e.g. "v0.34.0" or "0.34.0"). When unset, uses `getLatest`. */ version?: string; /** Report mode only: do not mutate anything. */ check?: boolean; /** Defaults to `process.platform`. */ platform?: NodeJS.Platform; /** Defaults to `process.arch`. */ arch?: string; /** Defaults to `process.pid`. */ pid?: number; /** Injection points. */ fetch?: typeof globalThis.fetch; getLatest?: (options?: { force?: boolean; }) => Promise; /** * Runs the downloaded binary's `--version` command and returns the stdout * (or null on failure). Injected so unit tests don't execute real children. */ verifyBinary?: (path: string) => Promise; } export declare function computeAssetName(platform: NodeJS.Platform, arch: string): string; export declare function upgradeBinary(options: UpgradeBinaryOptions): Promise; //# sourceMappingURL=apply-binary.d.ts.map