Documentation
¶
Overview ¶
Package version checks GitHub for latest releases, compares semantic versions, and manages update workflows for the sidecar and td binaries.
Index ¶
- func CheckAsync(currentVersion string) tea.Cmd
- func CheckTdAsync() tea.Cmd
- func ForceCheckAsync(currentVersion string) tea.Cmd
- func ForceCheckTdAsync() tea.Cmd
- func GetTdVersion() string
- func IsCacheValid(entry *CacheEntry, currentVersion string) bool
- func SaveCache(entry *CacheEntry) error
- func SaveTdCache(entry *CacheEntry) error
- type CacheEntry
- type CheckResult
- type InstallMethod
- type Release
- type TdVersionMsg
- 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 CheckTdAsync ¶
CheckTdAsync returns a Bubble Tea command that checks td version in background. Returns TdVersionMsg with installation status and version info.
func ForceCheckAsync ¶
ForceCheckAsync checks for updates, ignoring the cache.
func ForceCheckTdAsync ¶
ForceCheckTdAsync checks for td updates, ignoring the cache.
func GetTdVersion ¶
func GetTdVersion() string
GetTdVersion returns the installed td version by running `td version --short`. Returns empty string if td is not installed or command fails.
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 SaveCache ¶
func SaveCache(entry *CacheEntry) error
SaveCache writes version check result to disk.
func SaveTdCache ¶
func SaveTdCache(entry *CacheEntry) error
SaveTdCache writes td version check result to disk.
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.
func LoadTdCache ¶
func LoadTdCache() (*CacheEntry, error)
LoadTdCache reads cached td version check result from disk.
type CheckResult ¶
type CheckResult struct {
CurrentVersion string
LatestVersion string
UpdateURL string
ReleaseNotes 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.
func CheckRepo ¶
func CheckRepo(owner, repo, currentVersion string) CheckResult
CheckRepo fetches the latest release for a repo and compares versions.
func CheckTd ¶
func CheckTd(currentVersion string) CheckResult
CheckTd fetches the latest td release from GitHub and compares versions.
type InstallMethod ¶
type InstallMethod string
InstallMethod represents how sidecar was installed.
const ( InstallMethodHomebrew InstallMethod = "homebrew" InstallMethodGo InstallMethod = "go" InstallMethodBinary InstallMethod = "binary" )
func DetectInstallMethod ¶
func DetectInstallMethod() InstallMethod
DetectInstallMethod determines how sidecar was installed. Checks Homebrew first, then Go bin directories, falls back to binary. Result is cached for the lifetime of the process.
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
}
Release represents a GitHub release response.
type TdVersionMsg ¶
type TdVersionMsg struct {
Installed bool
CurrentVersion string
LatestVersion string
HasUpdate bool
}
TdVersionMsg is sent with td version info (installed or not).
type UpdateAvailableMsg ¶
type UpdateAvailableMsg struct {
CurrentVersion string
LatestVersion string
UpdateCommand string
ReleaseNotes string
ReleaseURL string
InstallMethod InstallMethod
}
UpdateAvailableMsg is sent when a new sidecar version is available.