feat(update): detect install method to tailor or suppress update notices#107
Open
pjcdawkins wants to merge 1 commit into
Open
feat(update): detect install method to tailor or suppress update notices#107pjcdawkins wants to merge 1 commit into
pjcdawkins wants to merge 1 commit into
Conversation
Detect how the CLI was installed and adjust the "new release available" notice accordingly: - System package managers (apt, yum/dnf, apk) are detected via a marker file installed by the nfpm packages. The notice is suppressed and the network check is skipped, since the OS handles updates. - Homebrew, Scoop, npm, and the bash installer get the exact upgrade command, built from config fields so vendor builds stay correct. - Unknown installs keep the generic GitHub link. Detection precedence: an explicit override (<PREFIX>INSTALL_METHOD env or wrapper.install_method config), then the package marker, then the resolved executable path (npm/scoop/homebrew), then standard bin dirs (script). The notice is now shown before the command runs, using a latest-version cache in state.json refreshed by the background check, and throttled to once a week (LastNotified). This removes the per-run nagging. Adds Wrapper.NpmPackage, Wrapper.InstallerURL, and Wrapper.InstallMethod config fields, and the packaging/install-source marker to both nfpm entries. Documents the behavior in README and the design doc; Phase 2 (opt-in self-update) is planned in docs/design. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds install-method detection to tailor (or suppress) update notifications, moves the “new release available” notice to run before command execution using a cached latest-version in state.json, and throttles notices to once per week while skipping update checks entirely for auto-updating package-manager installs.
Changes:
- Introduces install-method detection (
homebrew,scoop,npm,package,script,unknown) and a cheapIsAutoUpdatinggate to suppress notices and network checks for system packages. - Adds cached update metadata (
KnownLatestVersion,LastNotified) tostate.jsonand uses it to show notices inPersistentPreRun. - Adds tailored per-method upgrade commands and updates packaging/docs/config to support detection and messaging.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents new update-notification behavior and env overrides. |
| packaging/install-source | Adds package-manager marker file content used for suppression. |
| internal/update.go | Caches latest version in state; adds weekly throttle + notification helpers; skips checks for auto-updating installs. |
| internal/update_test.go | Unit tests for cached-notification/throttle logic. |
| internal/state/state.go | Extends persisted state with LastNotified and KnownLatestVersion. |
| internal/install.go | Adds install-method detection + cheap auto-updating check. |
| internal/install_test.go | Unit tests for method detection and parsing. |
| internal/config/upsun-cli.yaml | Populates npm/installer fields used to build upgrade commands. |
| internal/config/schema.go | Extends wrapper config schema with npm/installer/install_method fields. |
| internal/config/platformsh-cli.yaml | Adds installer URL for the platform flavor (see review comments). |
| docs/design/update-message-install-detection.md | Design doc describing approach, precedence, and planned Phase 2. |
| commands/root.go | Moves notice to PersistentPreRun; prints from cache; runs background refresh; adds per-method upgrade commands. |
| commands/root_test.go | Tests upgrade-command selection per install method. |
| CLAUDE.md | Updates internal documentation about update checks and install detection. |
| .goreleaser.yaml | Installs package marker file in nfpm packages to enable suppression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+206
to
210
| fmt.Fprintf(w, "\n%s %s → %s\n", | ||
| color.YellowString(fmt.Sprintf("A new release of the %s is available:", cnf.Application.Name)), | ||
| color.CyanString(config.Version), | ||
| color.CyanString(newRelease.Version), | ||
| ) |
Comment on lines
6
to
+9
| wrapper: | ||
| homebrew_tap: upsun/tap/platformsh-cli | ||
| github_repo: upsun/cli | ||
| installer_url: https://raw.githubusercontent.com/upsun/cli/main/installer.sh |
Comment on lines
+244
to
+247
| case internal.InstallScript: | ||
| if cnf.Wrapper.InstallerURL != "" { | ||
| return "curl -fsSL " + cnf.Wrapper.InstallerURL + " | bash" | ||
| } |
Comment on lines
+309
to
+312
| Populate `npm_package` and `installer_url` in `internal/config/upsun-cli.yaml` and | ||
| `internal/config/platformsh-cli.yaml`. A channel with an empty config field | ||
| simply falls back to the generic GitHub link for that branch (graceful for vendor | ||
| builds that don't ship that channel). |
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
Detects how the CLI was installed and adjusts the "new release available" notice accordingly, instead of showing the same generic GitHub link to everyone after every command.
The notice is now shown before the command runs, using a latest-version cache in
state.jsonrefreshed by the background check, and is throttled to once a week. This removes the per-run nagging.Detection precedence
Explicit override (
<PREFIX>INSTALL_METHODenv orwrapper.install_methodconfig) → package marker → resolved executable path (npm / scoop / homebrew) → standard bin dirs (script) → unknown.Changes
internal/install.go:InstallMethodtype,DetectInstallMethod, cheapIsAutoUpdating.internal/update.go: cacheKnownLatestVersion;PendingNotification/MarkNotifiedwith a weekly throttle; suppress checks for auto-updating installs.commands/root.go: show the notice inPersistentPreRunfrom the cache; per-method upgrade command.Wrapper.NpmPackage,Wrapper.InstallerURL,Wrapper.InstallMethod.packaging/install-sourcemarker added to both nfpm entries.docs/design/update-message-install-detection.md(which also describes the planned Phase 2: opt-in self-update).Scope
This is Phase 1 (detection + tailored/suppressed messages + weekly throttle + show-before-via-cache). Phase 2 (interactive prompt + auto-update + re-exec) and the external docs update are tracked separately in the design doc.
Verification
set-remote,db:dump,project:create) also fail onmainand are unrelated.🤖 Generated with Claude Code