updater

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package updater implements auto-update checking and installation for DevClaw.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker periodically checks for new versions against a remote assets URL.

func NewChecker

func NewChecker(currentVersion, assetsURL string, interval time.Duration, logger *slog.Logger) *Checker

NewChecker creates a new update checker. If currentVersion is "dev", the checker will not perform checks.

func (*Checker) CheckNow

func (c *Checker) CheckNow() (UpdateInfo, error)

CheckNow performs an immediate update check. Supports both GitHub releases URLs and plain latest.txt endpoints.

func (*Checker) LastCheck

func (c *Checker) LastCheck() UpdateInfo

LastCheck returns the result of the most recent update check (thread-safe).

func (*Checker) Start

func (c *Checker) Start(ctx context.Context)

Start begins periodic update checking in a background goroutine. It performs an initial check immediately, then repeats at the configured interval.

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer handles downloading and installing new versions.

func NewInstaller

func NewInstaller(assetsURL string, logger *slog.Logger) *Installer

NewInstaller creates a new installer.

func (*Installer) Install

func (inst *Installer) Install() error

Install downloads the latest release and replaces the current binary. It performs a safe install with backup/rollback.

func (*Installer) InstallAndRestart

func (inst *Installer) InstallAndRestart() error

InstallAndRestart performs Install followed by a PM2 restart.

type UpdateInfo

type UpdateInfo struct {
	Available      bool      `json:"available"`
	CurrentVersion string    `json:"current_version"`
	LatestVersion  string    `json:"latest_version"`
	CheckedAt      time.Time `json:"checked_at"`
}

UpdateInfo holds the result of an update check.

type Version

type Version struct {
	Major, Minor, Patch int
	// Pre is the number of commits after the tag (git-describe format: v0.0.4-9 → Pre=9).
	// Zero means this is an exact tag match.
	Pre int
	Raw string
}

Version represents a parsed semantic version with optional git-describe metadata.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion parses a version string like "v1.2.3", "1.2.3", or "v1.2.3-9-gabcdef" into a Version.

func (Version) IsNewerThan

func (v Version) IsNewerThan(other Version) bool

IsNewerThan returns true if v is a newer version than other.

func (Version) String

func (v Version) String() string

String returns the raw version string.

Jump to

Keyboard shortcuts

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