fix: drop stale target version from root upgrade prompt - #2100
fix: drop stale target version from root upgrade prompt#2100dc-bytedance wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe root upgrade prompt no longer displays the cached latest version. It displays the current version, while tests verify the cached target is absent and the current version is present. ChangesRoot upgrade prompt
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2100 +/- ##
==========================================
+ Coverage 75.18% 75.19% +0.01%
==========================================
Files 913 914 +1
Lines 96656 96781 +125
==========================================
+ Hits 72671 72776 +105
- Misses 18395 18407 +12
- Partials 5590 5598 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@291fd857c3277df165220f008a3b35f3726b55e5🧩 Skill updatenpx skills add larksuite/cli#fix/upgrade-prompt-drop-version -y -g |
Summary
The interactive upgrade prompt for bare
lark-clinamed a target version thatcould differ from the version actually installed. The prompt's version came from
the on-disk cache read by
update.CheckCached, which has no expiry — the 24hcacheTTLonly throttlesRefreshCache, and a failed refresh leaves the oldvalue in place, so on an offline or registry-unreachable machine the cached
latest_versioncan persist indefinitely. The version actually installed isresolved live: pressing
yruns theupdatesubcommand, which re-queries thenpm registry and pins that version. Any release published between the cache write
and the keypress made the prompt wrong.
The prompt now names only the current version, so everything it states is locally
verifiable. The
updatesubcommand still printsUpdating lark-cli <cur> -> <latest> via <pm> ...before installing, so the userstill sees the real target version before anything is written.
Changes
cmd/root_upgrade.go: dropinfo.Latestfrom the prompt; the text is nowA newer lark-cli is available (current <version>). Upgrade now? [y/N]:.Added a comment recording why no target version is named, and that the upgrade
must keep going through the
updatesubcommand — callingRunNpmInstalldirectly would remove the only place the real target version is shown.
cmd/root_upgrade_test.go: strengthenTestOfferRootUpgrade. The existingContains(stderr, "available")assertion holds for both the old and the newtext, so it could not detect this change or a regression. On prompting cases the
test now asserts stderr does not contain the cached target version and does
contain the current version.
Not touched: the JSON
_noticechannel (update.Message()),cacheTTL,CheckCached/RefreshCache, and everything undercmd/update/.Test Plan
go test ./cmd/ -run TestOfferRootUpgrade -v— 12/12 subtests pass. Verifiedred-green: with the new assertions but the old text, the 5 prompting subtests
fail with
prompt must not name the cached target version "2.0.0".go test ./cmd/ -run 'TestReadYes|TestIsBareRootInvocation|TestInstallRootUpgradePrompt|TestRunRootUpgradeDispatchesToUpdate'— pass.go build ./...,go vet, unit and integration tests — pass.golangci-lint run --new-from-rev=origin/main— 0 issues.version so
isRelease()does not suppress the prompt): stderr is exactlyA newer lark-cli is available (current 1.0.79). Upgrade now? [y/N]:— 68bytes, no trailing newline, no target version. All four gates behave as before:
silent when any stream is not a TTY, silent under
LARKSUITE_CLI_NO_UPDATE_NOTIFIER=1, silent underCI=true, no prompt when aflag token is present, and Enter is treated as No.
Related Issues
None.
Summary by CodeRabbit