Commit f375eaa
Add urgent upgrade warning when CLI is many versions behind (#163)
## Summary
The CLI already shows a friendly "a new release is available" banner
once a day via `update.MaybeShowMessage`. This adds a louder variant for
users who are very far behind modeled on the Pulumi-style "you are
running a very old version and should upgrade as soon as possible"
prompt.
A version is considered "very old" when either:
- the latest release is a full major version ahead, or
- the latest release is at least 5 minor versions ahead within the same
major.
When that condition fires, the banner switches from `pterm.Info` to
`pterm.Warning` and uses urgent copy. Otherwise behavior is unchanged.
## Test plan
- [x] `go test ./pkg/update/...` passes (added `TestIsVeryOldVersion`
covering same-version, one/four/five minor behind, major bump,
patch-only, v-prefix, non-semver).
- [x] `go build ./...` succeeds.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to update-notification messaging and
when the banner is shown (TTY-only), with no impact on core command
execution beyond suppressing output in piped/redirected scenarios.
>
> **Overview**
> Adds a new `IsVeryOldVersion` semver check (2+ major versions behind,
or 5+ minors behind within the same major) and uses it to **escalate the
update banner** from `pterm.Info` to a more urgent `pterm.Warning`
message.
>
> Upgrade messaging is now consistently written to **stderr**, and
`MaybeShowMessage` skips printing the banner when stdout is not a TTY
(e.g., piped/redirected). A dedicated `TestIsVeryOldVersion` suite
covers the new version-threshold logic and error cases.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
26c8729. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Sayan- <1415138+Sayan-@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent af19b8a commit f375eaa
2 files changed
Lines changed: 97 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
80 | 112 | | |
81 | 113 | | |
82 | 114 | | |
| |||
158 | 190 | | |
159 | 191 | | |
160 | 192 | | |
161 | | - | |
| 193 | + | |
| 194 | + | |
162 | 195 | | |
163 | 196 | | |
164 | 197 | | |
165 | | - | |
166 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
167 | 206 | | |
168 | | - | |
| 207 | + | |
169 | 208 | | |
170 | 209 | | |
171 | 210 | | |
172 | 211 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
179 | 218 | | |
180 | 219 | | |
181 | 220 | | |
182 | 221 | | |
183 | | - | |
| 222 | + | |
184 | 223 | | |
185 | | - | |
| 224 | + | |
186 | 225 | | |
187 | 226 | | |
188 | 227 | | |
| |||
200 | 239 | | |
201 | 240 | | |
202 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
203 | 245 | | |
204 | 246 | | |
205 | 247 | | |
| |||
415 | 457 | | |
416 | 458 | | |
417 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
0 commit comments