update

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check()

Check is the worker's entrypoint. The render path never invokes this directly — it's the value of the `update-check` dispatch case. All worker errors are silent: this is detached, there's nowhere to print.

func MaybeSpawnUpdateCheck

func MaybeSpawnUpdateCheck(cfg config.UpdateConfig, now time.Time)

MaybeSpawnUpdateCheck reads the cache and, if it's stale, spawns a detached `update-check` worker. Returns immediately under all conditions: no network I/O, no blocking, no stdout/stderr output. Called from runRender after the print loop, next to st.Save().

func MaybeSpawnUpdateCheckFor

func MaybeSpawnUpdateCheckFor(cfg config.UpdateConfig, now time.Time, kind InstallKind)

MaybeSpawnUpdateCheckFor is the kind-aware helper; tests drive it directly with a known kind to exercise each branch. Production callers go through MaybeSpawnUpdateCheck.

func RenderSegment

func RenderSegment(ctx segments.RenderCtx) (string, bool)

RenderSegment renders the update-available segment. It depends on the update-check state machinery and is injected into internal/segments via segments.UpdateRenderer.

func Run

func Run(args []string)

Run is the foreground, explicit subcommand. It ignores update.mode (explicit intent) but not the safety rails (kind, version compare, checksum, smoke-test). Behavior:

KindDev        → hint to go install; exit 0.
KindBrew       → brew upgrade (live output); missing brew → exit 1.
newer exists   → download + swap, share the worker's pipeline.
already current → "up to date"; exit 0.
--check        → resolve + report; never install.

func UpdateHintFor

func UpdateHintFor(kind InstallKind) string

UpdateHintFor returns the user-facing update command for an install kind.

func Verify

func Verify()

Verify fetches the latest release's checksums.txt and its cosign bundle and checks the signature against the embedded public key — the same in-process verification the self-swap path runs, exposed on demand. Installs nothing and reads nothing local; fails closed (exit 1) on any error, matching the install path.

Types

type InstallKind

type InstallKind int

InstallKind classifies the running binary so the worker can choose between self-swap and `brew upgrade`. KindDev is the dev/source-build short-circuit — it disables the whole feature and matches the release-notes carve-out so tests and goldens stay inert.

const (
	KindUnknown InstallKind = iota
	KindDev
	KindBrew
	KindManual
	KindNpm
)

func DetectInstallKind

func DetectInstallKind(exePath, version string) InstallKind

DetectInstallKind classifies the running binary. Pure on its inputs (exePath is the resolved path; "" + version "dev" → KindDev without any filesystem call) so the table test needs no real symlinks. The caller resolves the path via os.Executable() + filepath.EvalSymlinks — brew's bin symlink points into the Cellar (formula) or Caskroom (cask), which is the reliable signal.

Jump to

Keyboard shortcuts

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