version

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package version checks GitHub for latest releases, compares semantic versions, and manages update workflows for the sidecar and td binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAsync

func CheckAsync(currentVersion string) tea.Cmd

CheckAsync returns a Bubble Tea command that checks for updates in background.

func CheckTdAsync

func CheckTdAsync() tea.Cmd

CheckTdAsync returns a Bubble Tea command that checks td version in background. Returns TdVersionMsg with installation status and version info.

func ForceCheckAsync

func ForceCheckAsync(currentVersion string) tea.Cmd

ForceCheckAsync checks for updates, ignoring the cache.

func ForceCheckTdAsync

func ForceCheckTdAsync() tea.Cmd

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.

Jump to

Keyboard shortcuts

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