upgrade

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheMaxAge    = 24 * time.Hour
	DefaultFailureBackoff = time.Hour
)
View Source
const (
	DefaultLatestReleaseURL = "https://api.github.com/repos/daveshanley/vacuum/releases/latest"
	DefaultReleaseNotesURL  = "https://github.com/daveshanley/vacuum/releases/latest"
)
View Source
const (
	EnvManagedByNPM = "VACUUM_MANAGED_BY_NPM"
	EnvManagedRoot  = "VACUUM_MANAGED_PACKAGE_ROOT"
	MethodNPM       = "npm"
	MethodHomebrew  = "homebrew"
	MethodShell     = "shell"
	MethodManual    = "manual"
	MethodUnknown   = "unknown"
	BrewCaskToken   = "vacuum"
	NPMPackageName  = "@quobix/vacuum"
)

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) (int, bool)

CompareVersions compares simple stable semver values. It returns ok=false for unknown, source, or prerelease-looking versions.

func HomebrewCaskVersion

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

func IsComparableVersion

func IsComparableVersion(version string) bool

func IsNewer

func IsNewer(latest, current string) bool

IsNewer reports whether latest is newer than current.

func ManualCommands

func ManualCommands(latestVersion string) []string

func NormalizeVersion

func NormalizeVersion(version string) string

NormalizeVersion removes the leading tag prefix used by Vacuum releases.

func RenderNotice

func RenderNotice(w io.Writer, result CheckResult)

func RunAction

func RunAction(ctx context.Context, action Action, stdout, stderr io.Writer) error

func RunShellArchiveUpgrade

func RunShellArchiveUpgrade(ctx context.Context, action Action, stdout, stderr io.Writer) error

func ShellInstallerURLForTag

func ShellInstallerURLForTag(tag string) string

func VerifyUpgrade

func VerifyUpgrade(ctx context.Context, installContext InstallContext, method, latestVersion string) error

Types

type Action

type Action struct {
	Method  string
	Command string
	Args    []string
	CanRun  bool
	Reason  string

	Executable    string
	LatestVersion string
	ManualCommand string
}

func PlanUpgrade

func PlanUpgrade(ctx InstallContext, latestVersion string) Action

func (Action) CommandString

func (a Action) CommandString() string

type Check

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

func CompletedCheck

func CompletedCheck(result CheckResult) *Check

func StartCheck

func StartCheck(opts CheckOptions) *Check

StartCheck begins a latest-release probe in the background.

func (*Check) Cancel

func (c *Check) Cancel()

func (*Check) TryResult

func (c *Check) TryResult() (result CheckResult, ok bool)

TryResult returns immediately. If the network request has not finished, ok is false and callers should cancel the check and exit.

func (*Check) WaitResult

func (c *Check) WaitResult() (CheckResult, bool)

WaitResult waits until the latest-release probe finishes or times out.

type CheckOptions

type CheckOptions struct {
	CurrentVersion   string
	LatestReleaseURL string
	HTTPClient       *http.Client
	Timeout          time.Duration
}

type CheckResult

type CheckResult struct {
	CurrentVersion string
	LatestVersion  string
	ReleaseURL     string
	Err            error
}

func (CheckResult) UpdateAvailable

func (r CheckResult) UpdateAvailable() bool

type InstallContext

type InstallContext struct {
	Method      string
	Executable  string
	PackageRoot string
	Reason      string
}

func DetectInstallContext

func DetectInstallContext() InstallContext

func DetectInstallContextFrom

func DetectInstallContextFrom(executable string, getenv func(string) string) InstallContext

type LatestRelease

type LatestRelease struct {
	TagName    string `json:"tag_name"`
	HTMLURL    string `json:"html_url"`
	Prerelease bool   `json:"prerelease"`
	Draft      bool   `json:"draft"`
}

func FetchLatestRelease

func FetchLatestRelease(ctx context.Context, opts CheckOptions) (*LatestRelease, error)

type ManualUpgradeCommands

type ManualUpgradeCommands struct {
	Homebrew string
	NPM      string
	Shell    string
}

func ManualCommandSet

func ManualCommandSet(latestVersion string) ManualUpgradeCommands

type UpdateCache

type UpdateCache struct {
	Path string
	Now  func() time.Time
}

func DefaultUpdateCache

func DefaultUpdateCache() (*UpdateCache, error)

func (*UpdateCache) MarkChecked

func (c *UpdateCache) MarkChecked() error

func (*UpdateCache) ReadFresh

func (c *UpdateCache) ReadFresh(currentVersion string, maxAge time.Duration) (CheckResult, bool)

func (*UpdateCache) ReadStatus

func (c *UpdateCache) ReadStatus(currentVersion string, releaseMaxAge, failureBackoff time.Duration) (result CheckResult, hasFreshRelease bool, recentlyChecked bool)

func (*UpdateCache) RecentlyChecked

func (c *UpdateCache) RecentlyChecked(maxAge time.Duration) bool

func (*UpdateCache) Write

func (c *UpdateCache) Write(result CheckResult) error

type UpdateCacheData

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

Jump to

Keyboard shortcuts

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