update

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 17 Imported by: 0

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

View Source
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 IsDev

func IsDev(v string) bool

IsDev reports whether v is an untagged development build.

Types

type Asset

type Asset struct {
	Name string
	URL  string
}

Asset is a single downloadable file attached to a release.

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

func DetectMethod(execPath string) Method

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 Release

type Release struct {
	Tag    string
	Assets []Asset
}

Release is the subset of a GitHub release that `spec update` needs.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater orchestrates an update run against a release source.

func NewUpdater

func NewUpdater(token string) *Updater

NewUpdater builds an Updater backed by the live GitHub release API.

func (*Updater) Apply

func (u *Updater) Apply(ctx context.Context, plan *Plan, stdout, stderr io.Writer) error

Apply performs the update described by plan, streaming any subprocess output to stdout/stderr. It is a no-op (nil error) when no update is available and Force was not set. The caller is responsible for any confirmation prompt.

func (*Updater) Plan

func (u *Updater) Plan(ctx context.Context, opts Options) (*Plan, error)

Plan resolves the target release and managing mechanism and compares it against the running version. It performs no mutations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL