Documentation
¶
Overview ¶
Package update implements lstk's self-update: checking GitHub for a newer release and applying it through whichever mechanism installed lstk (Homebrew, npm, or replacing the binary in place).
On the binary channel an update installs the whole set a release archive carries (lstk, the bundled-extensions binary, lstk-extensions.toml) with a stage-then-commit scheme (extract.go). The guarantees to preserve:
- A file under its real name is never truncated or half-written: content is only ever written to a fresh staging file and renamed into place.
- An interrupted update is repaired by re-running `lstk update`: nothing commits until everything is staged, leftovers are cleaned first, and lstk commits last, so a working lstk always remains. Windows caveat: a crash between renaming lstk.exe aside and renaming the new one in leaves no lstk.exe; rename lstk.exe.old back by hand.
- Nothing is deleted: only the members the archive carries are written, so an archive without the bundle (a rollback) replaces lstk alone.
An archive carrying only lstk installs exactly as before bundling existed.
The pre-bundling updater installs a bundling release with only its lstk binary. A release build that then finds neither bundle member beside itself (DetectMissingBundle) points the user at a reinstall, from the unknown-command error and from an up-to-date `lstk update`.
Index ¶
- func Check(ctx context.Context, sink output.Sink, githubToken string) (string, bool, error)
- func CheckQuietly(ctx context.Context, githubToken string) (current, latest string, available bool)
- func NotifyUpdate(ctx context.Context, sink output.Sink, opts NotifyOptions) (exitAfter bool)
- func Update(ctx context.Context, sink output.Sink, checkOnly bool, githubToken string) error
- type InstallInfo
- type InstallMethod
- type MissingBundle
- type NotifyOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check reports whether a newer version is available. Returns the latest version string and true if an update is available. Always emits exactly one UpdateCheckedEvent, whose DevBuild/Available fields tell the sink which of the three possible outcomes (dev build skipped / already up to date / an update is available) occurred.
func CheckQuietly ¶ added in v0.5.2
func NotifyUpdate ¶ added in v0.5.2
Types ¶
type InstallInfo ¶
type InstallInfo struct {
Method InstallMethod
ResolvedPath string
}
InstallInfo holds the detected install method and the resolved binary path.
func DetectInstallMethod ¶
func DetectInstallMethod() InstallInfo
DetectInstallMethod determines how lstk was installed by inspecting the resolved path of the running binary.
type InstallMethod ¶
type InstallMethod int
const ( InstallBinary InstallMethod = iota // standalone binary download InstallHomebrew // installed via Homebrew cask InstallNPM // installed via npm )
func (InstallMethod) String ¶
func (m InstallMethod) String() string
type MissingBundle ¶ added in v1.1.0
type MissingBundle struct {
Dir string // install directory that should hold the bundle
Reinstall string // what restores the complete set
}
MissingBundle describes a binary install of a bundling release whose bundled extensions are not beside lstk: what the pre-bundling updater leaves behind when it installs a bundling release. Homebrew and npm replace the whole package, so they never end up here.
func DetectMissingBundle ¶ added in v1.1.0
func DetectMissingBundle() (MissingBundle, bool)
DetectMissingBundle reports whether the running lstk is a release build (version.BundlesExtensions), installed as a plain binary, with no bundle beside it. Dev builds never report one.
func DetectMissingBundleFor ¶ added in v1.1.0
func DetectMissingBundleFor(command string) (MissingBundle, bool)
DetectMissingBundleFor is DetectMissingBundle limited to the commands the bundle provided at the time of the transition, so a typo never earns a reinstall hint. Retire it with the hint once every supported release ships the set-wise updater.
func (MissingBundle) Summary ¶ added in v1.1.0
func (m MissingBundle) Summary() string
Summary is the one-sentence explanation shown wherever the state is reported.