update

package
v1.0.42 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient *http.Client

DefaultClient is the HTTP client used for npm registry requests. Override in tests with an httptest server client.

Functions

func FetchLatest

func FetchLatest() (string, error)

FetchLatest queries the npm registry and returns the latest published version. This is a synchronous call with timeout, intended for diagnostic commands (doctor).

func IsCIEnv added in v1.0.25

func IsCIEnv() bool

IsCIEnv returns true when any of the standard CI environment variables is set. Exported for internal/skillscheck so its skip rules track the same CI-suppression behavior as the update notifier.

func IsNewer

func IsNewer(a, b string) bool

IsNewer returns true if version a should be considered an update over b.

When both parse as semver, standard comparison applies. When b cannot be parsed (e.g. bare commit hash "9b933f1"), any valid a is considered newer — an unparseable local version is assumed outdated. When a cannot be parsed, returns false (can't confirm it's newer).

func IsRelease added in v1.0.25

func IsRelease(version string) bool

IsRelease reports whether version looks like a clean published release (semver "1.0.0", or npm prerelease "1.0.0-beta.1") and not a git-describe dev build like "1.0.0-12-g9b933f1-dirty". Exported so internal/skillscheck can apply the same release-only gating without duplicating the regex.

func ParseVersion

func ParseVersion(v string) []int

ParseVersion parses "X.Y.Z" (with optional "v" prefix and pre-release suffix) into [major, minor, patch]. Returns nil on invalid input.

func RefreshCache

func RefreshCache(currentVersion string)

RefreshCache fetches the latest version from npm and updates the local cache. No-op if the cache is still fresh (< 24h). Safe to call from a goroutine.

func SetPending

func SetPending(info *UpdateInfo)

SetPending stores the update info for consumption by output decorators.

Types

type UpdateInfo

type UpdateInfo struct {
	Current string `json:"current"`
	Latest  string `json:"latest"`
}

UpdateInfo holds version update information.

func CheckCached

func CheckCached(currentVersion string) *UpdateInfo

CheckCached checks the local cache only (no network). Always fast.

func GetPending

func GetPending() *UpdateInfo

GetPending returns the pending update info, or nil.

func (*UpdateInfo) Message

func (u *UpdateInfo) Message() string

Message returns a concise update notification including the canonical fix command. Aligned with skillscheck.StaleNotice.Message style so AI agents can parse a unified "run: lark-cli update" hint across both notice types.

Jump to

Keyboard shortcuts

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