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 ¶
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 ¶
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
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
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
Click to show internal directories.
Click to hide internal directories.