Documentation
¶
Overview ¶
Package version provides update checking against GitHub releases and semantic version comparison.
Index ¶
- func CheckAsync(currentVersion string) tea.Cmd
- func IsCacheValid(entry *CacheEntry, currentVersion string) bool
- func IsDevelopmentVersion(v string) bool
- func SaveCache(entry *CacheEntry) error
- func UpdateCommand(version string) string
- type CacheEntry
- type CheckResult
- type Release
- type UpdateAvailableMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAsync ¶
CheckAsync returns a Bubble Tea command that checks for updates in background.
func IsCacheValid ¶
func IsCacheValid(entry *CacheEntry, currentVersion string) bool
IsCacheValid checks if cache exists and is not expired. Also invalidates if user version changed (upgrade or downgrade).
func IsDevelopmentVersion ¶
IsDevelopmentVersion returns true for non-release versions.
func SaveCache ¶
func SaveCache(entry *CacheEntry) error
SaveCache writes version check result to disk.
func UpdateCommand ¶
UpdateCommand generates the go install command for updating. Returns empty string if version is invalid (prevents shell injection).
Types ¶
type CacheEntry ¶
type CacheEntry struct {
LatestVersion string `json:"latestVersion"`
CurrentVersion string `json:"currentVersion"`
CheckedAt time.Time `json:"checkedAt"`
HasUpdate bool `json:"hasUpdate"`
}
CacheEntry stores cached version check result.
func LoadCache ¶
func LoadCache() (*CacheEntry, error)
LoadCache reads cached version check result from disk.
type CheckResult ¶
type CheckResult struct {
CurrentVersion string
LatestVersion string
UpdateURL string
HasUpdate bool
Error error
}
CheckResult holds the result of a version check.
func Check ¶
func Check(currentVersion string) CheckResult
Check fetches the latest release from GitHub and compares versions.
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
}
Release represents a GitHub release response.
type UpdateAvailableMsg ¶
UpdateAvailableMsg is sent when a new version is available.