checker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package checker resolves the latest upstream version for a pack and compares it against what the pack repo vendors.

It is one half of a two-implementation contract: `ichava/core`'s IconPackUpdateChecker powers host-app discovery through `php artisan ichava::ichava-core.check-updates`, and this drives the maintainer-side refresh. Where the two disagreed, see version.go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyStale

func AnyStale(results []Result) bool

AnyStale reports whether any result is behind upstream. `check` exits 1 on this, which is what makes it usable as a CI gate.

func CountErrored

func CountErrored(results []Result) int

CountErrored returns how many results could not be resolved at all.

This exists because summarising on stale alone produces a false green: when every registry is unreachable nothing is *known* to be stale, so a naive "0 stale, therefore all up to date" reports success for a run that checked nothing. The Python reporter had exactly that bug, and it is the shape of failure this estate keeps paying for -- a green that means "did not look".

func CountStale

func CountStale(results []Result) int

CountStale returns how many results are behind upstream.

func IsStale

func IsStale(current, latest string) bool

IsStale reports whether current is behind latest. An unknown current is stale: a pack with no vendored version has never been synced.

func ParseLatest

func ParseLatest(source config.SourceConfig, payload any) string

ParseLatest extracts the latest version from a registry payload.

Returns "" for a shape it does not recognise, which the caller reports as "could not parse latest" rather than treating as an error. Note that github-archive and script sources fall through here: neither declares a pollable endpoint, so neither has a latest version to find.

func ResolveReleaseURL

func ResolveReleaseURL(source config.SourceConfig, payload any, version string) string

ResolveReleaseURL synthesises a clickable release link.

The order is checked, not incidental: a github-release payload's own html_url is authoritative and wins over anything synthesised from owner and repo, because a project can publish a release whose page is not at the conventional tag URL.

func TrimVersion

func TrimVersion(tag string) string

TrimVersion strips a leading "v" from a tag.

Both existing implementations use a character-set trim -- PHP's ltrim($tag, 'vV ') and Python's lstrip("vV ") -- which also eats a leading "V" or space, and would turn "Version1" into "ersion1". That is a latent oddity rather than a live defect: no registry these packs poll emits such a tag. It is preserved rather than quietly corrected, because changing it here would put this port out of step with *both* of the implementations it has to agree with, and the PHP side is the one that decides.

func VersionCompare

func VersionCompare(a, b string) int

VersionCompare returns -1, 0 or 1 for a<b, a==b, a>b, matching PHP's version_compare with no operator.

When one version runs out of parts first, PHP decides by the next part of the longer one: a numeric part or one ranking at or above "#" makes the longer version greater (1.0.1 > 1.0), and anything below -- dev, alpha, beta, RC -- makes it lesser (1.0-rc1 < 1.0).

Types

type Checker

type Checker struct{ Fetch Fetcher }

Checker resolves upstream versions.

func New

func New() *Checker

New returns a checker over the default HTTP client.

func (*Checker) CheckPack

func (c *Checker) CheckPack(ctx context.Context, pack *config.PackConfig) Result

CheckPack resolves the latest version and compares it against the pack.

The comparison base is config.ResolvedCurrentVersion, which reads the pack repo's own record first. Comparing against this repository's current_version is what made the sync non-convergent (V49): the bump was written into the runner's throwaway checkout and never committed, so every run saw the same stale value and re-proposed the same refresh.

type Fetcher

type Fetcher interface {
	GetJSON(ctx context.Context, url string, out any) error
}

Fetcher is the HTTP surface the checker needs, narrowed so a test can supply a payload without a network or a live registry.

type Result

type Result struct {
	Package    string
	Current    string
	Latest     string
	Stale      bool
	ReleaseURL string

	// Reason is set when Latest could not be established. It is not a failure:
	// an unreachable registry leaves the pack unchanged rather than aborting a
	// multi-pack run.
	Reason string
}

Result is one pack's upstream status.

func (Result) Detail

func (r Result) Detail() string

Detail is the rightmost column: the reason a check could not complete, or the release link when it did.

func (Result) Status

func (r Result) Status() Status

Status classifies a result the way the TTY reporter does.

type Status

type Status string

Status is the one-word verdict the reporter renders.

const (
	StatusOK              Status = "ok"
	StatusUpdateAvailable Status = "update-available"
	StatusError           Status = "error"
)

Jump to

Keyboard shortcuts

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