version

package
v0.12.10 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitHubDownloadURL = func(version, osName, arch string) string {
	var ext string
	if osName == "windows" {
		ext = ".exe"
	}
	return fmt.Sprintf(
		"https://github.com/%s/releases/download/%s/wpprobe_%s_%s_%s%s",
		githubRepo,
		version,
		version,
		osName,
		arch,
		ext,
	)
}
View Source
var GitHubLatestReleaseURL = func() string {
	return fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", githubRepo)
}
View Source
var Version = "dev"

Functions

func AutoUpdate

func AutoUpdate(currentVersion string) error

func CleanupOldBinary added in v0.11.4

func CleanupOldBinary()

func GetPluginVersion

func GetPluginVersion(target, plugin string, cfg http.Config) string

func GetPluginVersionWithClient added in v0.10.13

func GetPluginVersionWithClient(ctx context.Context, client *http.HTTPClientManager, target, plugin string) string

GetPluginVersionWithClient uses an existing HTTP client instead of creating a new one.

func GetPluginVersionWithContext added in v0.10.0

func GetPluginVersionWithContext(ctx context.Context, target, plugin string, cfg http.Config) string

func GetThemeVersionWithClient added in v0.12.7

func GetThemeVersionWithClient(
	ctx context.Context,
	httpClient *http.HTTPClientManager,
	target, theme string,
) string

GetThemeVersionWithClient uses an existing HTTP client instead of creating a new one, so a scan reuses connections across every theme it looks up.

func GetThemeVersionWithContext added in v0.11.0

func GetThemeVersionWithContext(ctx context.Context, target, theme string, cfg http.Config) string

GetThemeVersionWithContext fetches the theme version from style.css. Only reads the first 8KB since the Version header is at the top of the file.

func IsVersionVulnerable

func IsVersionVulnerable(version, fromVersion, toVersion string) bool

func RememberLatestRelease added in v0.12.8

func RememberLatestRelease(tag string)

RememberLatestRelease records a release tag learned elsewhere, so a lookup the update command already paid for corrects the banner instead of leaving it to contradict what the user was just told. The tag is normalized to match what fetchLatestTag stores.

Types

type Info added in v0.12.6

type Info struct {
	// Display is the short form shown in the banner.
	Display string
	// Comparable is the form checked against the published releases. It is
	// empty when the build carries no version the toolchain could derive, in
	// which case no comparison should be attempted at all.
	Comparable string
	// Release reports whether the version was linked in at build time, which
	// only the release pipeline does. A build from source is not a release even
	// when its derived version is perfectly comparable.
	Release bool
}

Info describes the running build.

func Current added in v0.12.6

func Current() Info

Current describes the running binary.

A release binary carries its version through -ldflags and needs nothing else. A build from source does not, and used to report itself as "dev", which the semver comparison could not parse, so every such build was labelled outdated and pointed at `wpprobe update` - which would have replaced it with an older release binary. The Go toolchain already embeds a usable version in both source install paths, so that is what fills the gap.

type Latest added in v0.12.6

type Latest struct {
	// Version is the newest published release. Empty when Known is false.
	Version string
	// Known reports whether the lookup produced an answer at all. A failed
	// lookup used to be indistinguishable from "you are behind", so running
	// offline reported the build as outdated and advised an update.
	Known bool
	// Current reports whether the running build is at or ahead of Version. It
	// carries no meaning when Known is false.
	Current bool
}

Latest is what the release check could establish.

func CheckLatestVersion

func CheckLatestVersion(currentVersion string) Latest

CheckLatestVersion compares currentVersion with the newest published tag, reusing a cached answer for releaseCheckTTL so the lookup does not run on every invocation.

func RefreshLatestVersion added in v0.12.8

func RefreshLatestVersion(currentVersion string) Latest

RefreshLatestVersion is CheckLatestVersion without the cached shortcut, for the moments where the answer has to be current rather than recent: `wpprobe update` is about to act on it, and a banner contradicting the command running underneath it is worse than a request.

Jump to

Keyboard shortcuts

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