Documentation
¶
Index ¶
- Constants
- func CheckWritePermission(dir string) error
- func DetectPackageManager(binaryPath string) (string, bool)
- func DownloadArchive(httpClient *http.Client, url, dir string, isTTY bool) (string, error)
- func ExtractBinary(archivePath, outDir, binaryName string) (string, error)
- func IsDevBuild(version string) bool
- func IsPrerelease(version string) bool
- func MergeChanges(metas []*VersionMetadata) map[string][]MergedEntry
- func OtherChannel(channel string) string
- func RenderChanges(changes map[string][]ChangelogEntry) string
- func RenderMerged(merged map[string][]MergedEntry) string
- func ReplaceBinary(targetPath, newPath string) error
- func ResolveBinaryPath() (string, string, error)
- func ShouldUpdate(current, latest string, crossChannel bool) bool
- func VerifyCosignBundle(httpClient *http.Client, archivePath, bundleURL string) error
- func VerifySHA256(path, expected string) error
- type Asset
- type ChangelogEntry
- type ChannelIndex
- type Client
- type MergedEntry
- type ReleaseEntry
- type VersionMetadata
Constants ¶
const ( ChannelStable = "stable" ChannelPrerelease = "prerelease" )
Variables ¶
This section is empty.
Functions ¶
func CheckWritePermission ¶
CheckWritePermission checks if the directory is writable by attempting to create a temporary file.
func DetectPackageManager ¶
DetectPackageManager checks if the binary path is inside a known package-managed prefix. Returns the manager name and whether it was detected.
func DownloadArchive ¶
DownloadArchive downloads a file from url to a temp file in dir. Returns the path to the downloaded file. If isTTY is true, displays a progress bar; otherwise uses line-based progress. Checks Content-Length header and caps streaming at maxArchiveSizeLimit.
func ExtractBinary ¶
ExtractBinary extracts the named binary from a .tar.gz archive to a temp file in outDir. Validates that the extracted path contains no separators or traversal components.
func IsDevBuild ¶
IsDevBuild returns true if the version is not a valid semver string, or is a non-canonical short version like "0.0", or has a git describe suffix like "0.1.0-alpha.7-3-gabcdef".
func IsPrerelease ¶
IsPrerelease returns true if the version is a valid semver string with a prerelease suffix (e.g., "0.1.0-alpha.7").
func MergeChanges ¶ added in v0.4.0
func MergeChanges(metas []*VersionMetadata) map[string][]MergedEntry
MergeChanges concatenates the structured changes of multiple releases by category, tagging each entry with its source version. metas must be ordered newest-first so that the newest release's entries lead each category.
func OtherChannel ¶ added in v0.4.0
OtherChannel returns the opposite release channel.
func RenderChanges ¶ added in v0.4.0
func RenderChanges(changes map[string][]ChangelogEntry) string
RenderChanges renders a single version's structured changes to the same text the Python generator produces for the rendered "changelog" field. No version prefix is added.
func RenderMerged ¶ added in v0.4.0
func RenderMerged(merged map[string][]MergedEntry) string
RenderMerged renders merged changes as a single block, prefixing every entry with its source version (e.g. "- v0.4.0: ...").
func ReplaceBinary ¶
ReplaceBinary atomically replaces the binary at targetPath with the new binary at newPath using os.Rename (atomic on POSIX). Preserves the original file permissions.
func ResolveBinaryPath ¶
ResolveBinaryPath returns the absolute path to the currently running binary, resolving any symlinks. It also returns the original (unresolved) path, which is useful for package manager detection where symlinks (e.g. /snap/bin/foo -> /usr/bin/snap) would cause incorrect prefix matching.
func ShouldUpdate ¶
ShouldUpdate returns true if the binary should be updated from current to latest. If crossChannel is true, the update is always offered (the user explicitly chose to switch channels). Dev builds always get offered updates.
func VerifyCosignBundle ¶
VerifyCosignBundle verifies the cosign bundle for the archive at archivePath. Downloads the bundle from bundleURL and verifies against Sigstore's public good instance.
Verification checks: - Certificate issuer: https://token.actions.githubusercontent.com - Certificate SAN (prefix): https://github.com/bernd/vibepit/.github/workflows/build.yml
func VerifySHA256 ¶
VerifySHA256 checks that the SHA256 hash of the file at path matches the expected hex-encoded checksum.
Types ¶
type Asset ¶
type Asset struct {
OS string `json:"os"`
Arch string `json:"arch"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
CosignBundleURL string `json:"cosign_bundle_url"`
}
Asset represents a platform-specific release asset.
type ChangelogEntry ¶ added in v0.4.0
type ChangelogEntry struct {
Msg string `json:"msg"`
PR string `json:"pr,omitempty"`
Issue string `json:"issue,omitempty"`
}
ChangelogEntry is a single structured changelog entry parsed from a docs/changelogs/{version}.yml file.
type ChannelIndex ¶
type ChannelIndex struct {
Latest string `json:"latest"`
Releases []ReleaseEntry `json:"releases"`
}
ChannelIndex represents a channel index file (e.g., stable.json).
func (*ChannelIndex) ReleasesBetween ¶ added in v0.4.0
func (idx *ChannelIndex) ReleasesBetween(current, target string) []ReleaseEntry
ReleasesBetween returns the releases newer than current and no newer than target (current < v <= target), sorted newest-first. The caller must ensure current is a valid release version; an invalid semver sorts below all releases and would match everything.
type Client ¶
Client fetches release metadata from vibepit.dev.
func (*Client) FetchChannelIndex ¶
func (c *Client) FetchChannelIndex(channel string) (*ChannelIndex, bool, error)
FetchChannelIndex fetches and parses a channel index file. Returns the index and a boolean indicating whether the file was found.
func (*Client) FetchVersionMetadata ¶
func (c *Client) FetchVersionMetadata(version string) (*VersionMetadata, error)
FetchVersionMetadata fetches and parses a version metadata file.
func (*Client) ResolveChannel ¶
func (c *Client) ResolveChannel(preferPre bool) (*ChannelIndex, string, error)
ResolveChannel determines which channel to use and fetches the index. Implements fallback logic: if stable is not found and --pre was not explicitly set, falls back to prerelease.
type MergedEntry ¶ added in v0.4.0
type MergedEntry struct {
Entry ChangelogEntry
Version string
}
MergedEntry is a ChangelogEntry tagged with the release version it came from, used when merging changelogs across multiple releases.
type ReleaseEntry ¶
ReleaseEntry is a single entry in the channel index releases array.
func CombineReleases ¶ added in v0.4.0
func CombineReleases(a, b *ChannelIndex) []ReleaseEntry
CombineReleases returns the union of the two indexes' release entries, deduplicated by version (first occurrence wins). Stable and prerelease releases live in separate indexes, so a cross-channel update needs both to see every release it skipped; a single index alone would omit the other channel's intervening releases. nil indexes are ignored.
type VersionMetadata ¶
type VersionMetadata struct {
Version string `json:"version"`
Timestamp string `json:"timestamp"`
Changelog string `json:"changelog"`
Changes map[string][]ChangelogEntry `json:"changes,omitempty"`
Assets []Asset `json:"assets"`
}
VersionMetadata represents a per-version metadata file (e.g., 0.2.0.json).