feat(upgrade): implement awf upgrade self-update command#299
Merged
Conversation
- `.go-arch-lint.yml`: Add `infra-updater` component and dependency rules - `CHANGELOG.md`: Document F076 upgrade command feature - `CLAUDE.md`: Remove stale pitfall entries, add upgrade pitfalls - `README.md`: Add upgrade command to feature list - `docs/README.md`: Add upgrade command reference - `docs/user-guide/commands.md`: Add upgrade command entry - `docs/user-guide/upgrade.md`: Add full upgrade command user guide - `internal/domain/errors/codes.go`: Add USER.UPGRADE.* and SYSTEM.UPGRADE.* error codes - `internal/domain/errors/codes_test.go`: Add tests for new upgrade error codes - `internal/infrastructure/updater/replacer.go`: Add ReplaceBinary() with symlink resolution and cross-FS fallback - `internal/infrastructure/updater/replacer_test.go`: Add unit tests for ReplaceBinary - `internal/interfaces/cli/root.go`: Register upgrade command - `internal/interfaces/cli/upgrade.go`: Implement upgrade CLI command with --check, --force, --version flags - `internal/interfaces/cli/upgrade_test.go`: Add 400+ line test suite for upgrade command Closes #298
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
awf upgradeself-update command (F076), which was previously a stub returningNotImplementedError--check,--force, and--versionflags; warns when the binary appears managed by a package manager; supportsGITHUB_TOKENfor rate-limited environmentspkg/registrytransport (already used by plugin and workflow pack installers) with no new application service layer — command is wired directly in the CLI interfaces layerChanges
CLI Command
internal/interfaces/cli/upgrade.go: Newupgradecommand implementing version check, GitHub release fetch, binary download + SHA256 verification, and atomic binary replacement viaupdater.ReplaceBinary(); flags:--check,--force,--version; package-manager path heuristic with--forceescape hatchinternal/interfaces/cli/root.go: RegisterupgradeCmdon the root commandInfrastructure
internal/infrastructure/updater/replacer.go: NewReplaceBinary()function — resolves symlinks viaEvalSymlinks, writes to temp file, atomically renames (with copy+chmod cross-FS fallback), and verifies the replaced binary is executableDomain
internal/domain/errors/codes.go: Five new typed error codes —USER.UPGRADE.VERSION_NOT_FOUND,USER.UPGRADE.ALREADY_LATEST,SYSTEM.UPGRADE.CHECKSUM_MISMATCH,SYSTEM.UPGRADE.BINARY_REPLACE_FAILED,SYSTEM.UPGRADE.DOWNLOAD_FAILEDArchitecture
.go-arch-lint.yml: Registerinfra-updatercomponent; allowinterfaces-clito depend on it alongside existing infra componentsTests
internal/interfaces/cli/upgrade_test.go: Table-driven tests covering update-available, already-latest,--checkmode,--force,--version, checksum mismatch, permission error, and package-manager warning pathsinternal/infrastructure/updater/replacer_test.go: Unit tests forReplaceBinary()covering same-FS success, cross-FS fallback, symlink resolution, and permission denialinternal/domain/errors/codes_test.go: Extend existing exhaustive constant, uniqueness, and exit-code tests to include all five new upgrade error codesDocumentation
docs/user-guide/upgrade.md: New reference page covering all flags, authentication, and troubleshootingdocs/user-guide/commands.md: Addawf upgrade,--check, and--versionrows to command tabledocs/README.md: Link to new upgrade guideREADME.md: Addawf upgradeto the quick-reference command tableCHANGELOG.md: Document F076 under[Unreleased] → AddedCLAUDE.md: Add two new pitfall entries for symlink-aware binary replacement and package-manager path warningsTest plan
awf upgrade --checkagainst a repo with a newer release reports the available version without modifying the binaryawf upgradedownloads, verifies checksum, and replaces the binary;awf versionreflects the new version after executionawf upgrade --version v0.5.0installs the specified older version (downgrade path)make testCloses #298
Generated with awf commit workflow