Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Upgrade command to check if local version matches latest before downloading/installing #50

Conversation

JohnPhamous
Copy link
Contributor

No description provided.

Copy link

semanticdiff-com bot commented Jan 6, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/upgrade.ts  0% smaller

@JohnPhamous JohnPhamous merged commit f733009 into main Jan 6, 2025
1 check passed
@JohnPhamous JohnPhamous deleted the johnphamous/eng-1096-cli-should-check-for-latest-version-before-installing branch January 6, 2025 20:44
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Enhanced the CLI's upgrade command with version checking functionality to prevent unnecessary installations and improve user experience.

  • Added getIsOnLatestVersion function in /src/lib/upgrade.ts to check current version against GitHub's latest release
  • Implemented version existence validation before upgrade attempts using GitHub API
  • Added early exit conditions when user is already on requested version
  • Integrated with existing version display system from /src/checkVersion.ts for consistent version checking

💡 (5/5) You can turn off certain types of comments like style here!

1 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile


const latestVersionUrl =
"https://api.github.com/repos/sfcompute/cli/releases/latest";
const latestVersionResponse = await fetch(latestVersionUrl);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: missing try/catch around fetch - network errors will cause uncaught exceptions

Comment on lines +17 to +18
const latestVersionData = await latestVersionResponse.json();
const latestVersion = latestVersionData.tag_name;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: missing try/catch around json parsing and accessing tag_name - malformed response will throw

const latestVersionData = await latestVersionResponse.json();
const latestVersion = latestVersionData.tag_name;

return latestVersion === currentVersion;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: version comparison should use semver library for proper version string comparison

@JohnPhamous JohnPhamous restored the johnphamous/eng-1096-cli-should-check-for-latest-version-before-installing branch January 7, 2025 01:02
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