Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
FetchLatest queries the npm registry and returns the latest published version. This is a synchronous call with timeout, intended for diagnostic commands (doctor).
func IsNewer ¶
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 ParseVersion ¶
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 ¶
UpdateInfo holds version update information.
func CheckCached ¶
func CheckCached(currentVersion string) *UpdateInfo
CheckCached checks the local cache only (no network). Always fast.
func (*UpdateInfo) Message ¶
func (u *UpdateInfo) Message() string
Message returns a concise update notification.