version

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheDuration is how long to cache version check results
	CacheDuration = 24 * time.Hour
	// CheckTimeout is the maximum time to wait for version check
	CheckTimeout = 2 * time.Second
)

Variables

This section is empty.

Functions

func FetchLatestVersion

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

FetchLatestVersion fetches the latest version from GitHub Releases

func GetUpdateCommand

func GetUpdateCommand(method InstallMethod) string

GetUpdateCommand returns the update command for the given install method

func IsNewerVersion

func IsNewerVersion(latest, current string) bool

IsNewerVersion returns true if latest is newer than current Handles semver format: v1.2.3 or 1.2.3

func IsUpdateCheckDisabled

func IsUpdateCheckDisabled() bool

IsUpdateCheckDisabled returns true if update check is disabled via env var

func SaveCache

func SaveCache(cache *CacheData) error

SaveCache saves the version check data to cache

Types

type CacheData

type CacheData struct {
	LastCheck     time.Time     `json:"lastCheck"`
	LatestVersion string        `json:"latestVersion"`
	InstallMethod InstallMethod `json:"installMethod"`
}

CacheData represents the cached version check data

func LoadCache

func LoadCache() (*CacheData, error)

LoadCache loads the cached version check data

type InstallMethod

type InstallMethod string

InstallMethod represents how the CLI was installed

const (
	InstallMethodNPM      InstallMethod = "npm"
	InstallMethodNPX      InstallMethod = "npx"
	InstallMethodHomebrew InstallMethod = "homebrew"
	InstallMethodBinary   InstallMethod = "binary"
)

func DetectInstallMethod

func DetectInstallMethod() InstallMethod

DetectInstallMethod detects how the CLI was installed

type UpdateInfo

type UpdateInfo struct {
	Available      bool
	CurrentVersion string
	LatestVersion  string
	InstallMethod  InstallMethod
	UpdateCommand  string
}

UpdateInfo contains information about an available update

func CheckForUpdate

func CheckForUpdate(ctx context.Context, currentVersion string) *UpdateInfo

CheckForUpdate checks if a newer version is available Returns nil if no update is available, check is disabled, or on any error

Jump to

Keyboard shortcuts

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