Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShouldCheckForUpdate ¶
func ShouldCheckForUpdate(state *StateEntry, now time.Time) bool
ShouldCheckForUpdate reports whether the cached state is stale enough to justify a network request for a newer release.
func StateFilePath ¶
StateFilePath returns the XDG-compliant path for the update state file.
func Upgrade ¶
Upgrade performs the appropriate upgrade flow for the detected install method.
Managed installs print the correct package manager command. Direct binary installs perform an in-place self-update.
func WriteState ¶
func WriteState(path string, entry *StateEntry) error
WriteState writes the update cache to disk, creating parent directories when needed.
Types ¶
type InstallMethod ¶
type InstallMethod int
InstallMethod identifies how the productize binary was installed.
const ( InstallBinary InstallMethod = iota InstallHomebrew InstallNPM InstallGo )
func DetectInstallMethod ¶
func DetectInstallMethod() InstallMethod
DetectInstallMethod determines how the current executable was installed.
type ReleaseInfo ¶
type ReleaseInfo struct {
Version string `yaml:"version"`
URL string `yaml:"url"`
PublishedAt time.Time `yaml:"published_at"`
}
ReleaseInfo holds metadata about an available release.
func CheckForUpdate ¶
func CheckForUpdate(ctx context.Context, currentVersion, stateFilePath string) (*ReleaseInfo, error)
CheckForUpdate returns release metadata when a newer version is available.
The function skips all work for dev builds and when PRODUCTIZE_NO_UPDATE_NOTIFIER is set. Cached results are reused for 24 hours to avoid redundant GitHub API calls.
type StateEntry ¶
type StateEntry struct {
CheckedForUpdateAt time.Time `yaml:"checked_for_update_at"`
LatestRelease ReleaseInfo `yaml:"latest_release"`
}
StateEntry stores the cached release-check metadata on disk.
func ReadState ¶
func ReadState(path string) (*StateEntry, error)
ReadState reads the persisted update cache from disk.
Missing or malformed files are treated as empty cache entries.