Documentation
¶
Overview ¶
Package update implements `spec update`: it brings the locally installed spec binary to the newest released version by delegating to whatever mechanism manages the install (Homebrew, go install, or a raw release binary it self-replaces). The engine is split into a side-effect-free Plan phase and a mutating Apply phase so `--check` never touches the system.
Index ¶
Constants ¶
const DevVersion = "dev"
DevVersion is the sentinel version stamped into binaries built without a release tag (the default value of cmd.Version). It never compares as up-to-date, so `spec update` always offers an upgrade for dev builds.
Variables ¶
This section is empty.
Functions ¶
func CheckLatest ¶ added in v0.24.0
CheckLatest reports the newest released version when it is newer than current, for the passive "update available" notice in the TUI. It reuses the same release source, semver comparison, and token resolution as `spec update`, differing only in two deliberate policies: it never nags development builds, and it is throttled by a 24h on-disk cache so startup stays fast and the GitHub API stays unhit on most launches.
It degrades silently: any error (network down, rate-limited, corrupt cache) yields ("", false) — or a still-valid cached value — never a surfaced error, because an ambient notice must never disrupt the session.
func GitHubToken ¶ added in v0.24.0
func GitHubToken() string
GitHubToken returns an optional GitHub token to lift the anonymous API rate limit. Public release lookups work without it; it is read best-effort from the standard environment variables. This is the single source of truth for token resolution shared by `spec update` and the passive TUI check.
Types ¶
type Method ¶
type Method string
Method identifies how the running binary was installed, which determines the mechanism `spec update` delegates to.
const ( // MethodHomebrew indicates a Homebrew-managed install (brew upgrade). MethodHomebrew Method = "homebrew" // MethodGoInstall indicates a `go install`-managed install. MethodGoInstall Method = "go-install" // MethodBinary indicates a raw release binary with no package manager; // `spec update` self-replaces it from the GitHub release. MethodBinary Method = "binary" )
func DetectMethod ¶
DetectMethod classifies how the executable at execPath was installed. The path is resolved through symlinks first so a Homebrew shim in bin/ is traced back to its Cellar location.
type Options ¶
type Options struct {
// CurrentVersion is the version stamped into the running binary.
CurrentVersion string
// ExecPath is the path to the running executable (os.Executable()).
ExecPath string
// TargetVersion pins a specific release tag; empty means latest.
TargetVersion string
// Force proceeds even when already on the target version.
Force bool
}
Options configures an update run.
type Plan ¶
type Plan struct {
Method Method `json:"method"`
CurrentVersion string `json:"current_version"`
LatestVersion string `json:"latest_version"`
UpdateAvailable bool `json:"update_available"`
// contains filtered or unexported fields
}
Plan describes the intended update without performing it. It is produced by Plan and consumed by Apply, and is also the payload for `--check`/`--json`.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater orchestrates an update run against a release source.
func NewUpdater ¶
NewUpdater builds an Updater backed by the live GitHub release API.