update

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package update implements GitHub-release update detection and the in-app upgrade flow: a once-per-day check against the latest published release, a version comparator, install-method detection, and the command used to perform the upgrade.

Index

Constants

View Source
const (
	MethodBrew    = "brew"    // installed via the Homebrew tap; upgrade with `brew upgrade`
	MethodScript  = "script"  // installed via getvix.dev/install.sh into a writable/sudo path
	MethodUnknown = "unknown" // origin couldn't be determined; offer manual instructions only
)

Install method identifiers carried in EventUpdateAvailable.Method and used to pick the upgrade command.

View Source
const Repo = "get-vix/vix"

Repo is the GitHub repository whose releases drive update detection.

Variables

This section is empty.

Functions

func DetectMethod

func DetectMethod() string

DetectMethod infers how the running binary was installed by inspecting the path of the current executable. A path under a Homebrew prefix means brew; anything else is assumed to be a script install. It resolves symlinks because Homebrew links binaries from the Cellar into bin directories on PATH.

func InstallCommand

func InstallCommand(method, version string) *exec.Cmd

InstallCommand returns the command that upgrades vix to version for the given install method. The command is intended to run in the foreground terminal of the TUI (via bubbletea's ExecProcess) so that interactive prompts — sudo for the script path — can reach the user's TTY. Returns nil for MethodUnknown.

func IsDev

func IsDev(v string) bool

IsDev reports whether v is an unstamped local build ("dev" or empty). Such builds never trigger an update prompt — there is no meaningful release to compare against.

func ManualInstruction

func ManualInstruction(method string) string

ManualInstruction returns the command a user should run by hand when an automatic in-app update isn't offered (e.g. MethodUnknown).

func NewerThan

func NewerThan(a, b string) bool

NewerThan reports whether release tag a is strictly newer than tag b using a minimal semantic-version comparison. Both may carry a leading "v". A pre-build suffix ("-rc1") is ignored beyond the numeric fields. A "dev"/empty b is treated as older than any real tag; a "dev"/empty a is never newer.

func SelfExecPath

func SelfExecPath() string

SelfExecPath returns the path to re-exec after an update completes. It prefers the resolved current executable so a relaunch picks up the freshly-swapped binary on disk.

Types

type Release

type Release struct {
	Tag  string // tag_name, e.g. "v1.4.0"
	URL  string // html_url to the release page
	Body string // release notes (markdown)
}

Release is the subset of a GitHub release we care about.

func LatestRelease

func LatestRelease(ctx context.Context) (Release, error)

LatestRelease fetches the latest published release from GitHub. It is deliberately best-effort: any network, rate-limit, or decode failure returns an error and callers are expected to silently skip the update check. The caller-supplied ctx should carry a short timeout.

type Status

type Status struct {
	Current string
	Latest  string
	URL     string
	Method  string
}

Status is the outcome of a release check: the running version, the newest release tag (empty when up-to-date / unknown), its page URL, and the detected install method.

func RunDailyCheck

func RunDailyCheck(current, statePath string, network func(context.Context) (Release, error)) Status

RunDailyCheck compares current against the newest GitHub release at most once per calendar day. The result of the most recent check is cached in state.json (statePath); on a same-day re-run the cached release is reused without hitting the network. Returns a Status whose Latest is non-empty only when a strictly newer release exists. The check is skipped entirely (Latest empty) for dev builds and when the user has disabled it.

network is the function used to fetch the latest release; production callers pass LatestRelease. It is a parameter so tests can stub it.

Jump to

Keyboard shortcuts

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