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 ¶
- func GoBinDir(ctx context.Context) (string, error)
- func InstallLocationHint(pkg string) string
- func NewCmd() *cobra.Command
- func PathChangedFromStderr(stderr string) (string, bool)
- func RenderVersionLabel(info version.Info) string
- func ResolveTarget(target string) (version.Info, error)
- func Run(root, target string, checkOnly bool) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoBinDir ¶
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/pocv3/gaps.md for the upgrade-flow regression.
func InstallLocationHint ¶
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 ¶
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 ¶
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 ¶
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 ¶
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).
Types ¶
This section is empty.