upgrade

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BinaryName = "haft"
	RepoOwner  = "KashifKhn"
	RepoName   = "haft"
)
View Source
const (
	GitHubAPIURL   = "https://api.github.com/repos/%s/%s/releases/latest"
	RequestTimeout = 30 * time.Second
	UserAgent      = "haft-cli"
	MaxRetries     = 3
	RetryDelay     = 2 * time.Second
)

Variables

This section is empty.

Functions

func CleanupBackup

func CleanupBackup(backup *BackupInfo)

func CleanupDownload

func CleanupDownload(result *DownloadResult)

func CompareVersions

func CompareVersions(current, latest string) (int, error)

func ExtractBinary

func ExtractBinary(archivePath string, platform *PlatformInfo) (string, error)

func FetchChecksums

func FetchChecksums(version string) (map[string]string, error)

func FindAllInstallations

func FindAllInstallations() []string

func GetArch

func GetArch() string

func GetCurrentVersion

func GetCurrentVersion() string

func GetExecutablePath

func GetExecutablePath() (string, error)

func GetInstallDir

func GetInstallDir() string

func GetLatestVersion

func GetLatestVersion() (string, error)

func GetOS

func GetOS() string

func InstallBinary

func InstallBinary(sourcePath, destPath string) error

func InstallToMultipleLocations

func InstallToMultipleLocations(sourcePath string, locations []string) ([]string, []error)

func IsNewerAvailable

func IsNewerAvailable(current, latest string) (bool, error)

func NewCommand

func NewCommand() *cobra.Command

func NormalizeVersion

func NormalizeVersion(v string) string

func RestoreBackup

func RestoreBackup(backup *BackupInfo) error

func SetCurrentVersion

func SetCurrentVersion(v string)

func VerifyChecksum

func VerifyChecksum(filePath, expectedHash string) error

func VerifyInstallation

func VerifyInstallation(binaryPath string) error

Types

type BackupInfo

type BackupInfo struct {
	OriginalPath string
	BackupPath   string
	CreatedAt    time.Time
}

func CreateBackup

func CreateBackup(binaryPath string) (*BackupInfo, error)

type DownloadResult

type DownloadResult struct {
	FilePath   string
	Size       int64
	Checksum   string
	BinaryPath string
}

func DownloadRelease

func DownloadRelease(version string, platform *PlatformInfo) (*DownloadResult, error)

func DownloadReleaseWithProgress added in v0.1.16

func DownloadReleaseWithProgress(version string, platform *PlatformInfo, progress ProgressCallback) (*DownloadResult, error)

type GitHubRelease

type GitHubRelease struct {
	TagName     string `json:"tag_name"`
	Name        string `json:"name"`
	Prerelease  bool   `json:"prerelease"`
	Draft       bool   `json:"draft"`
	PublishedAt string `json:"published_at"`
	HTMLURL     string `json:"html_url"`
}

type PlatformInfo

type PlatformInfo struct {
	OS         string
	Arch       string
	BinaryName string
	ArchiveExt string
}

func GetPlatformInfo

func GetPlatformInfo() (*PlatformInfo, error)

func (*PlatformInfo) GetArchiveName

func (p *PlatformInfo) GetArchiveName(version string) string

func (*PlatformInfo) GetBinaryNameInArchive

func (p *PlatformInfo) GetBinaryNameInArchive() string

func (*PlatformInfo) GetChecksumsURL

func (p *PlatformInfo) GetChecksumsURL(version string) string

func (*PlatformInfo) GetDownloadURL

func (p *PlatformInfo) GetDownloadURL(version string) string

func (*PlatformInfo) String

func (p *PlatformInfo) String() string

type ProgressCallback added in v0.1.16

type ProgressCallback func(downloaded, total int64)

type UpgradeResult

type UpgradeResult struct {
	CurrentVersion  string `json:"current_version"`
	LatestVersion   string `json:"latest_version"`
	UpdateAvailable bool   `json:"update_available"`
	Upgraded        bool   `json:"upgraded"`
	Platform        struct {
		OS   string `json:"os"`
		Arch string `json:"arch"`
	} `json:"platform"`
	InstalledPaths []string `json:"installed_paths,omitempty"`
	Error          string   `json:"error,omitempty"`
}

type Version

type Version struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Original   string
}

func ParseVersion

func ParseVersion(v string) (*Version, error)

func (*Version) String

func (v *Version) String() string

Jump to

Keyboard shortcuts

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