Add support for 'update' command to the CLI to update itself#154
Add support for 'update' command to the CLI to update itself#154
Conversation
Greptile SummaryThis PR adds a self-update command to the CLI that allows users to easily update to the latest version. The implementation properly handles both npm package and standalone executable modes. Key improvements from previous feedback:
Implementation highlights:
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 0be3345 |
|
|
||
| function updateViaNpm(version: string): void { | ||
| logInfoConsole(`Updating via npm to version ${version}...`); | ||
| execSync(`npm install -g ${NPM_PACKAGE}@${version}`, { |
There was a problem hiding this comment.
What happens if I have @packmind/cli in my local JS dependencies (in my package.json)
My guess is that the general packmind-cli will be updated but if I run it inside my project I'll still have the old version.
There was a problem hiding this comment.
I don't think this should be covered by our update command, since it would imply directly updating the package.json file.
I think it'd more the jobs of some tools like dependabot, don't you think?
- Replace string equality with semver.gt() for correct handling of versions like 0.9.0 vs 0.10.0 - Fix test names to follow verb-first naming convention - Add test for current version newer than latest Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…order Explicitly sort CLI releases using semver.rcompare to ensure the latest version is selected regardless of GitHub API response ordering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add checkOnly boolean flag to IUpdateHandlerDependencies - Skip download/npm install when --check-update is passed - Add tests for check-only mode (update available and up to date) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile thoughts on the "--check-update" flag? |
|
Looking at the implementation, the What works well:
Suggestions:
The implementation in updateHandler.ts handles it cleanly: if (deps.checkOnly) {
return; // Exit after logging version comparison
}Overall, it's a good addition. The only change I'd strongly recommend is shortening the flag to just |
- Rename flag from --check-update to --check for brevity - Exit with code 1 when update is available in check-only mode - Exit with code 0 when already up to date (enables scripting) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile can you report on the updated version? |
|
Great news! Both of your key suggestions have been implemented: ✅ Changes Made1. Flag shortened to check: flag({
long: 'check',
description: 'Only check if a newer version is available without performing the update',
}),Usage is now: 2. Exit codes implemented
This makes it script-friendly: if packmind-cli update --check; then
echo "Up to date!"
else
echo "Update available"
fiThe implementation is clean and follows the conventional pattern you recommended. The handler checks the version, logs the result, and exits appropriately in check-only mode before attempting any actual update. |
|



Explanation
Let users easily update the CLI to its latest version.
Type of Change
Affected Components
Testing
TODO List