update

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package update implements the CLI's update check and self-upgrade.

The check is designed to never slow a command down: the banner only reads a small cached state file, and the network refresh (at most once per 24h) runs after the command's real work has finished. BITWAVE_NO_UPDATE_CHECK=1 disables all network checks; dev/snapshot builds never check.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackgroundRefresh

func BackgroundRefresh(currentVersion string)

BackgroundRefresh refreshes the cached latest version if it is stale. Errors are deliberately swallowed: an offline machine should never see update-check noise. Intended to run after a command's real work is done.

func CachedNotice

func CachedNotice(currentVersion string) (string, bool)

CachedNotice returns a one-line upgrade hint if the cached state knows a newer version. It never touches the network.

func Disabled

func Disabled(currentVersion string) bool

Disabled reports whether update checking is off for this process: opted out via env, or a non-release build (anything with a prerelease suffix, e.g. 0.1.0-dev or 0.2.1-SNAPSHOT-abc).

func IsNewer

func IsNewer(a, b string) bool

IsNewer reports whether version a is strictly newer than version b. Versions are plain X.Y.Z with an optional leading v; anything unparseable compares as not-newer (fail safe: no upgrade nag on weird versions).

func Refresh

func Refresh(ctx context.Context) (string, error)

Refresh queries GitHub for the latest release tag and updates the cache.

Types

type InstallMethod

type InstallMethod string

InstallMethod classifies how the running binary was installed, from its (symlink-resolved) path.

const (
	MethodNpm    InstallMethod = "npm"
	MethodBrew   InstallMethod = "brew"
	MethodDirect InstallMethod = "direct"
)

func DetectInstallMethod

func DetectInstallMethod(exePath string) InstallMethod

DetectInstallMethod classifies an executable path. Callers should pass a symlink-resolved path (Homebrew links $(brew --prefix)/bin/bitwave into the Caskroom; npm links into node_modules).

type State

type State struct {
	LatestVersion string    `json:"latestVersion"`
	CheckedAt     time.Time `json:"checkedAt"`
}

State is the on-disk cache at ~/.bitwave/update-check.json.

Jump to

Keyboard shortcuts

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