Documentation
¶
Index ¶
- Constants
- func BuildAssetName(version, goos, goarch string) string
- func CleanupBackups(executablePath string, keepCount int) error
- func CopyFile(src, dst string) error
- func DownloadAsset(asset *ReleaseAsset, filePath string, config *DownloadConfig) error
- func ExtractExecutableFromArchive(archivePath, extractDir string) (string, error)
- func GetBusyExecutableInfo(err error) (currentPath, newPath string, ok bool)
- func GetTerminalColorSupport() string
- func IsBusyExecutableError(err error) bool
- func LatestVersion() string
- func ReplaceExecutable(currentPath, newPath string, config *UpgradeConfig) error
- func RestoreFromBackup(executablePath, backupPath string) error
- func ValidateAssetIntegrity(filePath string, expectedSize int64) error
- func Version() string
- type BusyExecutableError
- type DownloadConfig
- type GitHubRelease
- type ProgressCallback
- type ReleaseAsset
- type UpgradeConfig
- type UpgradeResult
Constants ¶
const GitHubAPIURL = "https://api.github.com/repos/NiloCK/tuido/releases/latest"
const ReleaseURL = "https://github.com/NiloCK/tuido/releases/latest"
Variables ¶
This section is empty.
Functions ¶
func BuildAssetName ¶ added in v0.0.16
BuildAssetName constructs the expected asset name for a given platform
func CleanupBackups ¶ added in v0.0.16
CleanupBackups removes old backup files
func DownloadAsset ¶ added in v0.0.16
func DownloadAsset(asset *ReleaseAsset, filePath string, config *DownloadConfig) error
DownloadAsset downloads an asset to the specified file path with progress tracking
func ExtractExecutableFromArchive ¶ added in v0.0.16
ExtractExecutableFromArchive extracts the executable from a tar.gz archive
func GetBusyExecutableInfo ¶ added in v0.0.16
GetBusyExecutableInfo returns information about a busy executable error
func GetTerminalColorSupport ¶
func GetTerminalColorSupport() string
returns a string used for chroma syntax highlighting
func IsBusyExecutableError ¶ added in v0.0.16
IsBusyExecutableError checks if an error is a BusyExecutableError
func LatestVersion ¶ added in v0.0.9
func LatestVersion() string
func ReplaceExecutable ¶ added in v0.0.16
func ReplaceExecutable(currentPath, newPath string, config *UpgradeConfig) error
ReplaceExecutable handles the platform-specific logic of replacing the executable
func RestoreFromBackup ¶ added in v0.0.16
RestoreFromBackup restores the executable from a backup file
func ValidateAssetIntegrity ¶ added in v0.0.16
ValidateAssetIntegrity verifies the downloaded asset (placeholder for future checksum validation)
Types ¶
type BusyExecutableError ¶ added in v0.0.16
BusyExecutableError indicates that the executable couldn't be replaced because it's busy
func (*BusyExecutableError) Error ¶ added in v0.0.16
func (e *BusyExecutableError) Error() string
type DownloadConfig ¶ added in v0.0.16
type DownloadConfig struct {
// Context for cancellation
Context context.Context
// Progress callback (optional)
OnProgress ProgressCallback
// Retry count for failed downloads
RetryCount int
// Timeout for each download attempt
Timeout time.Duration
}
DownloadConfig contains configuration for downloading assets
func DefaultDownloadConfig ¶ added in v0.0.16
func DefaultDownloadConfig() *DownloadConfig
DefaultDownloadConfig returns a reasonable default configuration
type GitHubRelease ¶ added in v0.0.16
type GitHubRelease struct {
TagName string `json:"tag_name"`
Assets []ReleaseAsset `json:"assets"`
}
GitHubRelease represents a GitHub release
func FetchLatestReleaseFromURL ¶ added in v0.0.16
func FetchLatestReleaseFromURL(apiURL string) (*GitHubRelease, error)
FetchLatestReleaseFromURL retrieves release information from a specific URL (testable version)
type ProgressCallback ¶ added in v0.0.16
type ProgressCallback func(downloaded, total int64)
ProgressCallback is called during download to report progress
type ReleaseAsset ¶ added in v0.0.16
type ReleaseAsset struct {
Name string `json:"name"`
DownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
}
ReleaseAsset represents a GitHub release asset
func GetCurrentPlatformAsset ¶ added in v0.0.16
func GetCurrentPlatformAsset() (*ReleaseAsset, error)
GetCurrentPlatformAsset returns the appropriate asset for the current platform
type UpgradeConfig ¶ added in v0.0.16
type UpgradeConfig struct {
// Context for cancellation
Context context.Context
// Download configuration
DownloadConfig *DownloadConfig
// Whether to create a backup before replacement
CreateBackup bool
// Backup file suffix
BackupSuffix string
// Whether to attempt restart after upgrade
AttemptRestart bool
}
UpgradeConfig contains configuration for the upgrade process
func DefaultUpgradeConfig ¶ added in v0.0.16
func DefaultUpgradeConfig() *UpgradeConfig
DefaultUpgradeConfig returns a reasonable default configuration
type UpgradeResult ¶ added in v0.0.16
type UpgradeResult struct {
// Whether the upgrade was successful
Success bool
// Path to the new executable
NewExecutablePath string
// Path to the backup file (if created)
BackupPath string
// Whether a restart is required
RestartRequired bool
// Any error that occurred
Error error
}
UpgradeResult contains information about the upgrade process
func PerformUpgrade ¶ added in v0.0.16
func PerformUpgrade(config *UpgradeConfig) *UpgradeResult
PerformUpgrade downloads and replaces the current executable with a new version