feat: add non-blocking version update check (#104)#214
Merged
Conversation
Add automatic version check that runs in the background on every command. If a newer version is available, prints a one-line notice after output. - New internal/version package with Checker (async GitHub API check), 24h cache in ~/.waza/version-check.json, and PrintNotice helper - Functional options pattern (WithHTTPClient, WithCacheDir, WithAPIBaseURL) - --no-update-check flag and WAZA_NO_UPDATE_CHECK env var to disable - Filters azd-ext-* tags, only checks v-prefixed CLI releases - Graceful on all failures: API errors, timeouts, bad cache, dev builds - 18 tests covering: newer/current/ahead versions, cache hit/expired, API failure/timeout, azd-ext tag filtering, context cancellation - Updated CLI reference, README, docs site Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix gofmt formatting (tabs vs spaces from heredoc creation) - Handle resp.Body.Close() error return (errcheck) - Handle w.Close() error return in tests (errcheck) - Fix 'cancelled' → 'canceled' spelling (misspell) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Closes #104. Adds a non-blocking version check that runs in the background on every command. If a newer waza version exists, prints a one-line notice after command output.
Changes
New:
internal/version/packageChecker— async version check against GitHub releases API (goroutine)~/.waza/version-check.jsonto avoid API hitsPrintNotice()— prints upgrade notice to stderrWithHTTPClient,WithCacheDir,WithAPIBaseURL,WithRepoazd-ext-*tags; only checksv-prefixed CLI releasesModified:
cmd/waza/root.goPersistentPreRun: starts background checker (unless--no-update-checkorWAZA_NO_UPDATE_CHECK)PersistentPostRun: prints notice if update available (100ms max wait — never blocks)Docs
--no-update-checkflag,WAZA_NO_UPDATE_CHECKenv var, "Automatic Update Check" sectionTests (18 total)
Non-blocking guarantee
The check runs in a goroutine.
Result()waits at most 100ms. If the check hasn't finished, it returns nil and the command output is unaffected.