diff --git a/cmd.go b/cmd.go index 6f7be55..8be14c8 100644 --- a/cmd.go +++ b/cmd.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "runtime" - "strings" "forge.lthn.ai/core/cli/pkg/cli" "github.com/spf13/cobra" @@ -46,7 +45,7 @@ Examples: RunE: runUpdate, } - updateCmd.PersistentFlags().StringVar(&updateChannel, "channel", "stable", "Release channel: stable, beta, alpha, or dev") + updateCmd.PersistentFlags().StringVar(&updateChannel, "channel", "stable", "Release channel: stable, beta, alpha, prerelease, or dev") updateCmd.PersistentFlags().BoolVar(&updateForce, "force", false, "Force update even if already on latest version") updateCmd.Flags().BoolVar(&updateCheck, "check", false, "Only check for updates, do not apply") updateCmd.Flags().IntVar(&updateWatchPID, "watch-pid", 0, "Internal: watch for parent PID to die then restart") @@ -73,7 +72,7 @@ func runUpdate(cmd *cobra.Command, args []string) error { } currentVersion := cli.AppVersion - normalizedChannel := strings.TrimSpace(strings.ToLower(updateChannel)) + normalizedChannel := normaliseGitHubChannel(updateChannel) cli.Print("%s %s\n", cli.DimStyle.Render("Current version:"), cli.ValueStyle.Render(currentVersion)) cli.Print("%s %s/%s\n", cli.DimStyle.Render("Platform:"), runtime.GOOS, runtime.GOARCH) diff --git a/service.go b/service.go index 737e22b..7599038 100644 --- a/service.go +++ b/service.go @@ -30,7 +30,8 @@ type UpdateServiceConfig struct { // repository URL (e.g., "https://github.com/owner/repo") or a base URL // for a generic HTTP update server. RepoURL string - // Channel specifies the release channel to track (e.g., "stable", "prerelease"). + // Channel specifies the release channel to track (e.g., "stable", "beta", or "prerelease"). + // "prerelease" is normalised to "beta" to match the GitHub release filter. // This is only used for GitHub-based updates. Channel string // CheckOnStartup determines the update behavior when the service starts. @@ -134,5 +135,8 @@ func normaliseGitHubChannel(channel string) string { if channel == "" { return "stable" } + if channel == "prerelease" { + return "beta" + } return channel } diff --git a/service_test.go b/service_test.go index c65458c..e0a6bb1 100644 --- a/service_test.go +++ b/service_test.go @@ -38,6 +38,15 @@ func TestNewUpdateService(t *testing.T) { isGitHub: true, wantChannel: "beta", }, + { + name: "GitHub prerelease channel maps to beta", + config: UpdateServiceConfig{ + RepoURL: "https://github.com/owner/repo", + Channel: " prerelease ", + }, + isGitHub: true, + wantChannel: "beta", + }, { name: "Invalid GitHub URL", config: UpdateServiceConfig{