fix(pgpm): clear update cache after pgpm update and use semver comparison#713
Open
pyramation wants to merge 1 commit intomainfrom
Open
fix(pgpm): clear update cache after pgpm update and use semver comparison#713pyramation wants to merge 1 commit intomainfrom
pyramation wants to merge 1 commit intomainfrom
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Two small fixes for the
pgpm updatecheck:Stale cache after update: After
pgpm updatesucceeds, the update-check cache (~/.pgpm/cache/update-check.json) was not cleared, so subsequent commands kept showing "update available" until the 24h TTL expired. Now we delete the cache file after a successful install usingappstash(already a dependency) to resolve the cache path.String-based version comparison: The upstream
checkForUpdatesin@inquirerer/utilsuses JS string comparison (>) which silently fails for multi-digit semver segments (e.g.,"3.10.0" > "3.9.0"isfalse). Instead of trustingupdateResult.hasUpdate, we now usesemver.gt()on the returnedlatestVersiondirectly.semveris already a dependency ofpgpm/cli.This is a minimal alternative to #704, which added
execFilecalls (the CLI invoking itself), new exported functions, and 222 lines of tests. This PR achieves the same result in ~13 lines across 2 files with no new dependencies or exports.Review & Testing Checklist for Human
appstash('pgpm').cache + '/update-check.json'matches what@inquirerer/utilscheckForUpdateswrites to (it should — both callappstash('pgpm'))pgpm update, then immediately run another pgpm command (e.g.pgpm --help) and confirm no stale "update available" prompt appearssemverdefault import works correctly with the existing"semver": "^7.6.2"dependency and@types/semverin devDependenciesNotes
@inquirerer/utilscheckForUpdates— this PR works around it at the call site. A proper fix upstream would let us revert thesemverworkaround incommands.ts.