tools

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package tools resolves the pinned versions and download URLs of the host tools lerd installs (composer, fnm, mkcert). tools.yaml is the source of truth: embedded at build time as the offline fallback, and fetched from GitHub before use so a bad pin can be fixed without a binary release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIsStale added in v1.36.0

func BuildIsStale(pinned, installed, publishedAt, installedPublished string) bool

BuildIsStale reports whether the published build is not the one on disk: a different version, or the same version rebuilt since it was fetched. A rebuild that replaces what a version ships keeps the version it already had, so the publish date is the only thing separating the two, and an install that predates the date being published has none recorded and takes it once.

Shared so the CLI's fetch and the dashboard's update badge cannot disagree about what counts as an update.

func InstalledPublished added in v1.36.0

func InstalledPublished(name string) string

InstalledPublished reports the publish date recorded for an installed tool, empty when the binary is gone or nothing was recorded.

func InstalledVersion

func InstalledVersion(name string) string

InstalledVersion reports the version of an installed tool: the stamp sidecar while it is trustworthy (not older than the binary, which would mean something else replaced it, e.g. composer self-update), else a version probe. Empty when the binary is missing or undeterminable.

A probed answer is stamped on the way out. The stamp is otherwise only written when lerd downloads a tool, and composer is only downloaded when it is absent, so an install that already had composer.phar before stamping existed never got one. With composer unprobeable by execution, it read as unknown forever and, because the update check needs a known version, was never offered an update either.

func Names

func Names() []string

Names lists the managed tools in display order.

func WritePublished added in v1.36.0

func WritePublished(name, published string) error

WritePublished records when the build now on disk was published, and clears the record when the pin carries no date. Kept beside the version stamp rather than inside it, so a binary that predates the field reads as having no date rather than as having an unparseable version.

func WriteStamp

func WriteStamp(name, version string) error

WriteStamp records the installed version of a tool in its sidecar, so status can report it without executing anything.

Types

type Manifest

type Manifest struct {
	Tools map[string]Tool `yaml:"tools"`
}

Manifest is the parsed tools.yaml.

func Load

func Load(ctx context.Context) *Manifest

Load returns the pinned tool manifest: the embedded copy, overlaid with every valid entry of the published tools.yaml when it is reachable.

func Refresh

func Refresh(ctx context.Context) *Manifest

Refresh reloads the manifest with the disk cache bypassed, for the manual "check for updates" path. The 24h cache is what keeps a passive status rebuild off the network, so a newly published pin is otherwise invisible for up to a day; this is the way out of that window. A fetch that cannot reach the endpoint leaves the cached pins in place rather than reverting to the embedded ones, so being offline never reads as "nothing to update".

func (*Manifest) Digest

func (m *Manifest) Digest(name, goos, goarch string) string

Digest returns the published sha256 for an asset, empty when the manifest pins none for this platform.

func (*Manifest) PublishedAt added in v1.36.0

func (m *Manifest) PublishedAt(name, goos, goarch string) string

PublishedAt returns when an asset was built, empty when the manifest carries no date for it. A pin whose version is unchanged still names a different build when this moves.

func (*Manifest) Size added in v1.34.1

func (m *Manifest) Size(name, goos, goarch string) int64

Size returns the published byte count for an asset, zero when the manifest pins none for this platform.

func (*Manifest) URL

func (m *Manifest) URL(name, goos, goarch string) (string, error)

URL resolves the download URL for the named tool on goos/goarch.

type Tool

type Tool struct {
	Version string            `yaml:"version"`
	URL     string            `yaml:"url"`
	Assets  map[string]string `yaml:"assets"`
	Digests map[string]string `yaml:"digests,omitempty"`
	// Sizes is the asset's byte count per GOOS/GOARCH, so a command can say what
	// it is about to fetch before it starts. Optional, like Digests.
	Sizes map[string]int64 `yaml:"sizes,omitempty"`
	// Published dates the build behind this pin, per GOOS/GOARCH like the two
	// above. A rebuild that replaces what a version ships without changing the
	// version itself moves this and nothing else, so it is what says an install
	// is holding the older one. Optional, like the two above.
	Published map[string]string `yaml:"published,omitempty"`
}

Tool is one pinned download: a version and an HTTPS URL template in which {version} and {asset} expand. Assets maps GOOS/GOARCH to the release asset name, which may itself contain {version}. Digests maps the same GOOS/GOARCH key to the asset's sha256, and is optional so a manifest published without one still installs on binaries that predate the field.

type ToolStatus

type ToolStatus struct {
	Name            string `json:"name"`
	Installed       string `json:"installed,omitempty"`
	Pinned          string `json:"pinned"`
	Present         bool   `json:"present"`
	UpdateAvailable bool   `json:"update_available"`
}

ToolStatus is one row of the tools report shared by the CLI, UI and MCP.

func StatusAll

func StatusAll(ctx context.Context) []ToolStatus

StatusAll compares each installed tool with its pin.

Jump to

Keyboard shortcuts

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