Documentation
¶
Overview ¶
Package update finds new audd releases, tells people about them at most once a day, and replaces the binary for installs that no package manager owns.
Index ¶
- Constants
- Variables
- func APIBase() string
- func Apply(ctx context.Context, client *http.Client, rel *Release, ...) error
- func ArchiveName(version, goos, goarch string) string
- func BinaryName(goos string) string
- func Newer(latest, current string) bool
- func Notice(current string, s State, m Method) string
- func NoticeAllowed(env NoticeEnv) bool
- func RemoveOld(exe string)
- func SaveState(dir string, s State) error
- type Asset
- type Method
- type NoticeEnv
- type Release
- type State
Constants ¶
const ( BrewCommand = "brew upgrade audd" NPMCommand = "npm install -g @audd/cli@latest" NPXCommand = "npx @audd/cli@latest" PipCommand = "pip install --upgrade audd-cli" PipxCommand = "pipx upgrade audd-cli" UVCommand = "uv tool upgrade audd-cli" UVXCommand = "uvx audd-cli@latest" ScoopCommand = "scoop update audd" WingetCommand = "winget upgrade --id AudD.CLI" GoCommand = "go install github.com/AudDMusic/audd-cli/cmd/audd@latest" DockerCommand = "docker pull ghcr.io/auddmusic/audd-cli:latest" )
Commands for installs a package manager owns.
const CheckInterval = 24 * time.Hour
CheckInterval is how often the release check runs.
const ChecksumsName = "checksums.txt"
ChecksumsName is the release file with the SHA-256 of every archive.
const DefaultAPIBase = "https://api.github.com"
DefaultAPIBase is the GitHub API.
const Repo = "AudDMusic/audd-cli"
Repo is the GitHub repository releases come from.
Variables ¶
var ErrNoAsset = errors.New("the release has no build for this system")
ErrNoAsset means the release has no build for this system.
Functions ¶
func APIBase ¶
func APIBase() string
APIBase returns the GitHub API base, or AUDD_UPDATE_URL when set (tests).
func Apply ¶
Apply downloads the release's archive for goos/goarch, checks it against checksums.txt, and replaces the binary at exe with the one inside.
func ArchiveName ¶
ArchiveName is the release archive for a system: audd_<version>_<os>_<arch>.tar.gz, or .zip on Windows.
func BinaryName ¶
BinaryName is the executable inside the archive.
func Newer ¶
Newer reports whether latest is a newer version than current. Versions that do not parse are never newer.
func NoticeAllowed ¶
NoticeAllowed reports whether to check for and announce updates: only with stderr on a terminal, never in CI, and not with AUDD_NO_UPDATE_CHECK set.
Types ¶
type Method ¶
type Method struct {
Name string `json:"method"` // homebrew, npm, npx, pip, pipx, uv, uvx, scoop, winget, go, docker, binary
// Command updates this install; empty for SelfUpdate installs.
Command string `json:"command,omitempty"`
// SelfUpdate is true when audd replaces its own binary.
SelfUpdate bool `json:"self_update"`
}
Method is how audd was installed, which decides how it is updated.
func DetectMethod ¶
DetectMethod works out how the binary at exe was installed. A package can say so with AUDD_INSTALL_METHOD (the Docker image sets "docker"); otherwise the path decides. getenv reads AUDD_INSTALL_METHOD, GOPATH, and GOBIN.
type Release ¶
type Release struct {
Version string `json:"version"` // without the leading "v"
Tag string `json:"tag"`
URL string `json:"url"` // the release page
Assets []Asset `json:"-"`
}
Release is a published audd release.
type State ¶
type State struct {
CheckedAt time.Time `json:"checked_at"`
Latest string `json:"latest"`
URL string `json:"url,omitempty"`
// NoticedAt is when the update notice was last shown.
NoticedAt time.Time `json:"noticed_at,omitzero"`
}
State is the cached result of the last release check.
func LoadState ¶
LoadState reads the cached check from dir; a missing or broken file gives an empty State.