upgrade

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package upgrade implements the `aiwf upgrade` verb (per-verb subpackage of M-0116; cmd/aiwf/main.go newRootCmd wires it via NewCmd).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoBinDir

func GoBinDir(ctx context.Context) (string, error)

GoBinDir returns the directory `go install` writes binaries into. Resolution order matches `go install`'s own logic: GOBIN if set, else GOPATH/bin (where GOPATH defaults to $HOME/go).

Each variable is queried in its own `go env` call rather than as `go env GOBIN GOPATH`. The combined form returns one line per name with empty values rendered as a blank line, and the leading blank for an unset GOBIN was being silently consumed by strings.TrimSpace — see G39 in docs/archive/pocv3/gaps-pre-migration.md for the upgrade-flow regression.

func InstallLocationHint

func InstallLocationHint(pkg string) string

InstallLocationHint returns a best-guess absolute path to the binary `go install <pkg>` would have produced, derived from the caller's environment without invoking `go env`. Used only to help the user recover after locateBinary failed; never load-bearing. Returns an empty string when neither GOBIN/GOPATH nor a home directory can be resolved.

func NewCmd

func NewCmd() *cobra.Command

NewCmd builds `aiwf upgrade`: a one-command flow that fetches a newer (or specified) aiwf binary via `go install` and re-execs the new binary to refresh the consumer repo's framework artifacts via `aiwf update`.

Without flags, installs `<package>@latest`; with --version, pins to the supplied semver. With --check, prints the current/target comparison and exits without installing anything.

Test seams (env-var honored, undocumented for users):

  • AIWF_GO_BIN: path to the `go` binary (default: lookpath "go"). Tests substitute a shell shim that fakes `go install`.
  • AIWF_NO_REEXEC: when set to a non-empty value, skip the syscall.Exec into the new binary after install. Lets tests verify install succeeds without overlaying the test process.

func PathChangedFromStderr

func PathChangedFromStderr(stderr string) (string, bool)

PathChangedFromStderr scans `go install` stderr for the package- path-change signature. Returns the missing package path and true when matched; ("", false) otherwise. Filed under G46.

func RenderVersionLabel

func RenderVersionLabel(info version.Info) string

RenderVersionLabel formats an Info for human display: the version itself plus a parenthetical state ("tagged", "working-tree build", "pseudo-version"). The `+dirty` suffix that Go appends to working- tree builds with uncommitted changes is always rendered as a working-tree build, regardless of the base version shape.

func ResolveTarget

func ResolveTarget(target string) (version.Info, error)

ResolveTarget turns the --version flag value into a concrete Info. The literal "latest" routes through the module proxy; an explicit semver is taken at face value (the install step is the eventual authority on whether the tag exists).

func Run

func Run(root, target string, checkOnly bool) (code int)

Run executes `aiwf upgrade`. Returns one of the cliutil.Exit* codes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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