Skip to content

fix(pgpm): clear update cache after pgpm update and use semver comparison#713

Open
pyramation wants to merge 1 commit intomainfrom
devin/1770953913-fix-pgpm-update-cache
Open

fix(pgpm): clear update cache after pgpm update and use semver comparison#713
pyramation wants to merge 1 commit intomainfrom
devin/1770953913-fix-pgpm-update-cache

Conversation

@pyramation
Copy link
Contributor

Summary

Two small fixes for the pgpm update check:

  1. Stale cache after update: After pgpm update succeeds, 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 using appstash (already a dependency) to resolve the cache path.

  2. String-based version comparison: The upstream checkForUpdates in @inquirerer/utils uses JS string comparison (>) which silently fails for multi-digit semver segments (e.g., "3.10.0" > "3.9.0" is false). Instead of trusting updateResult.hasUpdate, we now use semver.gt() on the returned latestVersion directly. semver is already a dependency of pgpm/cli.

This is a minimal alternative to #704, which added execFile calls (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

  • Verify the cache path appstash('pgpm').cache + '/update-check.json' matches what @inquirerer/utils checkForUpdates writes to (it should — both call appstash('pgpm'))
  • End-to-end: run pgpm update, then immediately run another pgpm command (e.g. pgpm --help) and confirm no stale "update available" prompt appears
  • Verify the semver default import works correctly with the existing "semver": "^7.6.2" dependency and @types/semver in devDependencies

Notes

  • The upstream string comparison bug still lives in @inquirerer/utils checkForUpdates — this PR works around it at the call site. A proper fix upstream would let us revert the semver workaround in commands.ts.
  • Requested by: @pyramation
  • Link to Devin run

@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant