Skip to content

Update version command and enhance README - #46

Merged
evgenyk merged 5 commits into
mainfrom
ev/semver_check
Sep 8, 2025
Merged

evgenyk merged 5 commits into
mainfrom
ev/semver_check

Conversation

@evgenyk

@evgenyk evgenyk commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

Introduce a version check feature in the Kinde CLI, allowing users to see their current version and check for updates. Update the README with installation and upgrade instructions for clarity. Enhance version comparison using the Masterminds/semver library for accurate version handling. Fix the retrieval of the latest release tag in the update check function.

@coderabbitai

coderabbitai Bot commented Sep 8, 2025

Copy link
Copy Markdown
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ev/semver_check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (7)
pkg/release/release.go (4)

33-41: Surface GitHub API failures to the user.

Currently errors are swallowed; users see the spinner stop with no message. Print a short notice.

- if err != nil {
-   return
- }
+ if err != nil {
+   fmt.Printf("Unable to check for updates: %v\n", err)
+   return
+ }

42-49: Handle empty Version explicitly before semver parsing.

Avoid the “not a semantic version” path when Version is blank in dev builds.

- // Parse versions using semver
- currentVersion, err := semver.NewVersion(strings.TrimPrefix(Version, "v"))
- if err != nil {
-   // Handle development versions or invalid semver
-   fmt.Printf("Current version '%s' is not a semantic version (development build)\n", Version)
-   fmt.Printf("Latest release: %v\n", latest)
-   return
- }
+ // Parse versions using semver
+ cur := strings.TrimSpace(Version)
+ if cur == "" {
+   fmt.Println("Current version: development build")
+   fmt.Printf("Latest release: %v\n", latest)
+   return
+ }
+ currentVersion, err := semver.NewVersion(strings.TrimPrefix(cur, "v"))
+ if err != nil {
+   fmt.Printf("Current version '%s' is not a semantic version (development build)\n", Version)
+   fmt.Printf("Latest release: %v\n", latest)
+   return
+ }

51-55: Be resilient to non-standard tag formats.

If tags ever include prefixes (e.g., “kinde-cli/v1.2.3”), TrimPrefix("v") won’t be enough. Extract the first semver substring before parsing.

@@
-import (
+import (
   "context"
   "fmt"
   "math/rand"
   "strings"
   "time"
 
   "github.com/Masterminds/semver/v3"
   "github.com/briandowns/spinner"
   "github.com/google/go-github/v28/github"
+  "regexp"
 )
@@
- latestVersion, err := semver.NewVersion(strings.TrimPrefix(latest, "v"))
+ re := regexp.MustCompile(`\d+\.\d+\.\d+(?:[-+][0-9A-Za-z\.-]+)?`)
+ latestClean := re.FindString(latest)
+ if latestClean == "" {
+   fmt.Printf("Latest release tag '%s' does not contain a semantic version; cannot check for updates\n", latest)
+   return
+ }
+ latestVersion, err := semver.NewVersion(latestClean)

57-65: Add an actionable upgrade hint when an update is available.

Small UX boost: point users to install instructions.

- if currentVersion.LessThan(latestVersion) {
-   fmt.Printf("An update is available: %v (current: %v)\n", latest, Version)
+ if currentVersion.LessThan(latestVersion) {
+   fmt.Printf("An update is available: %v (current: %v)\n", latest, Version)
+   fmt.Println("Upgrade instructions: https://github.com/kinde-oss/kinde-cli#installation")
pkg/cmd/versionCommand.go (1)

30-31: Show commit and build date when available.

Helps users and support correlate binaries.

- fmt.Printf("Version %v\n", release.Version)
- release.IsNeedingUpdate()
+ if release.Version != "" {
+   fmt.Printf("Version %s", release.Version)
+ } else {
+   fmt.Print("Version development")
+ }
+ if release.Commit != "" {
+   fmt.Printf(" (commit %s)", release.Commit)
+ }
+ if release.Date != "" {
+   fmt.Printf(" built %s", release.Date)
+ }
+ fmt.Println()
+ release.IsNeedingUpdate()
README.md (2)

60-65: Use sudo for APT update/upgrade to match install section.

Most users will need elevated privileges.

-apt update
-apt install --only-upgrade kinde-cli
+sudo apt update
+sudo apt install --only-upgrade kinde-cli

147-161: Clarify behavior when the update check can’t reach GitHub.

Brief note avoids confusion on timeouts/rate limits.

 - Show whether an update is available or if you're using the latest version
 - Handle development builds and pre-release versions appropriately
+ - If the check can’t reach GitHub within ~5 seconds (offline, firewall, or rate-limited), the CLI prints an error and skips the comparison
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec2b703 and 6bfc17a.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (3)
  • README.md (3 hunks)
  • pkg/cmd/versionCommand.go (1 hunks)
  • pkg/release/release.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/cmd/versionCommand.go (1)
pkg/release/release.go (1)
  • Version (16-16)
🔇 Additional comments (4)
pkg/release/release.go (1)

10-10: Good call switching to Masterminds/semver.

This makes comparisons correct for pre-releases and build metadata.

README.md (3)

34-37: Homebrew update instructions look good.


45-49: Scoop update instructions look good.


143-143: Command list entry reads well and aligns with the implementation.

Comment thread pkg/release/release.go
@evgenyk
evgenyk merged commit 65d6b45 into main Sep 8, 2025
5 checks passed
@evgenyk
evgenyk deleted the ev/semver_check branch September 8, 2025 10:19
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