diff --git a/cmd/app.go b/cmd/app.go index c65b5cb..80949af 100644 --- a/cmd/app.go +++ b/cmd/app.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk" "github.com/pterm/pterm" "github.com/samber/lo" "github.com/spf13/cobra" diff --git a/cmd/browser_pools.go b/cmd/browser_pools.go index 7f62ade..8540002 100644 --- a/cmd/browser_pools.go +++ b/cmd/browser_pools.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/browsers.go b/cmd/browsers.go index 5de868a..67ff175 100644 --- a/cmd/browsers.go +++ b/cmd/browsers.go @@ -16,18 +16,18 @@ import ( "strings" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" - "github.com/onkernel/kernel-go-sdk/packages/pagination" - "github.com/onkernel/kernel-go-sdk/packages/ssestream" - "github.com/onkernel/kernel-go-sdk/shared" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk/packages/pagination" + "github.com/kernel/kernel-go-sdk/packages/ssestream" + "github.com/kernel/kernel-go-sdk/shared" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/spf13/pflag" ) // BrowsersService defines the subset of the Kernel SDK browser client that we use. -// See https://github.com/onkernel/kernel-go-sdk/blob/main/browser.go +// See https://github.com/kernel/kernel-go-sdk/blob/main/browser.go type BrowsersService interface { Get(ctx context.Context, id string, opts ...option.RequestOption) (res *kernel.BrowserGetResponse, err error) List(ctx context.Context, query kernel.BrowserListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[kernel.BrowserListResponse], err error) diff --git a/cmd/browsers_test.go b/cmd/browsers_test.go index 2fe489d..901480d 100644 --- a/cmd/browsers_test.go +++ b/cmd/browsers_test.go @@ -13,11 +13,11 @@ import ( "testing" "time" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" - "github.com/onkernel/kernel-go-sdk/packages/pagination" - "github.com/onkernel/kernel-go-sdk/packages/ssestream" - "github.com/onkernel/kernel-go-sdk/shared" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk/packages/pagination" + "github.com/kernel/kernel-go-sdk/packages/ssestream" + "github.com/kernel/kernel-go-sdk/shared" "github.com/pterm/pterm" "github.com/stretchr/testify/assert" ) diff --git a/cmd/deploy.go b/cmd/deploy.go index 2644074..2928610 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -16,8 +16,8 @@ import ( "github.com/joho/godotenv" "github.com/kernel/cli/pkg/util" - kernel "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + kernel "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/samber/lo" "github.com/spf13/cobra" diff --git a/cmd/extensions.go b/cmd/extensions.go index 3b0d766..2c9118d 100644 --- a/cmd/extensions.go +++ b/cmd/extensions.go @@ -11,8 +11,8 @@ import ( "time" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/extensions_test.go b/cmd/extensions_test.go index 9a7897d..4a1770c 100644 --- a/cmd/extensions_test.go +++ b/cmd/extensions_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/stretchr/testify/assert" ) diff --git a/cmd/invoke.go b/cmd/invoke.go index c034588..02bcbfb 100644 --- a/cmd/invoke.go +++ b/cmd/invoke.go @@ -13,9 +13,10 @@ import ( "syscall" "time" + "github.com/kernel/cli/pkg/update" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) @@ -188,7 +189,11 @@ func handleSdkError(err error) error { pterm.Info.Println("- Validate that your payload is properly formatted") pterm.Info.Println("- Check `kernel app history ` to see if the app is deployed") pterm.Info.Println("- Try redeploying the app") - pterm.Info.Println("- Make sure you're on the latest version of the CLI: `brew upgrade onkernel/tap/kernel`") + if cmd := update.SuggestUpgradeCommand(); cmd != "" { + pterm.Info.Printf("- Make sure you're on the latest version of the CLI: `%s`\n", cmd) + } else { + pterm.Info.Println("- Make sure you're on the latest version of the CLI") + } return nil } diff --git a/cmd/logs.go b/cmd/logs.go index 965a3ad..4715eeb 100644 --- a/cmd/logs.go +++ b/cmd/logs.go @@ -5,8 +5,8 @@ import ( "time" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/profiles.go b/cmd/profiles.go index 2b3b129..f356377 100644 --- a/cmd/profiles.go +++ b/cmd/profiles.go @@ -10,8 +10,8 @@ import ( "os" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/profiles_test.go b/cmd/profiles_test.go index 3573197..3833924 100644 --- a/cmd/profiles_test.go +++ b/cmd/profiles_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/stretchr/testify/assert" ) diff --git a/cmd/proxies/common_test.go b/cmd/proxies/common_test.go index 0e4d607..9f815a6 100644 --- a/cmd/proxies/common_test.go +++ b/cmd/proxies/common_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" ) diff --git a/cmd/proxies/create.go b/cmd/proxies/create.go index 78aaf4b..633544e 100644 --- a/cmd/proxies/create.go +++ b/cmd/proxies/create.go @@ -6,7 +6,7 @@ import ( "github.com/kernel/cli/pkg/table" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/proxies/create_test.go b/cmd/proxies/create_test.go index 6669c55..cda254f 100644 --- a/cmd/proxies/create_test.go +++ b/cmd/proxies/create_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/stretchr/testify/assert" ) diff --git a/cmd/proxies/delete_test.go b/cmd/proxies/delete_test.go index 192e893..8edce63 100644 --- a/cmd/proxies/delete_test.go +++ b/cmd/proxies/delete_test.go @@ -6,8 +6,8 @@ import ( "net/http" "testing" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/stretchr/testify/assert" ) diff --git a/cmd/proxies/get.go b/cmd/proxies/get.go index 5a94661..97fdc21 100644 --- a/cmd/proxies/get.go +++ b/cmd/proxies/get.go @@ -6,7 +6,7 @@ import ( "github.com/kernel/cli/pkg/table" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/proxies/get_test.go b/cmd/proxies/get_test.go index 9f726c9..922abe3 100644 --- a/cmd/proxies/get_test.go +++ b/cmd/proxies/get_test.go @@ -6,8 +6,8 @@ import ( "net/http" "testing" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/stretchr/testify/assert" ) diff --git a/cmd/proxies/list.go b/cmd/proxies/list.go index e8dbc5a..b90781c 100644 --- a/cmd/proxies/list.go +++ b/cmd/proxies/list.go @@ -7,7 +7,7 @@ import ( "github.com/kernel/cli/pkg/table" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/cmd/proxies/list_test.go b/cmd/proxies/list_test.go index aada9d8..dcb6f71 100644 --- a/cmd/proxies/list_test.go +++ b/cmd/proxies/list_test.go @@ -5,8 +5,8 @@ import ( "errors" "testing" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/stretchr/testify/assert" ) diff --git a/cmd/proxies/types.go b/cmd/proxies/types.go index ae871b6..979f071 100644 --- a/cmd/proxies/types.go +++ b/cmd/proxies/types.go @@ -3,8 +3,8 @@ package proxies import ( "context" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" ) // ProxyService defines the subset of the Kernel SDK proxy client that we use. diff --git a/cmd/root.go b/cmd/root.go index cdbd4bb..6116d54 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -16,8 +16,8 @@ import ( "github.com/kernel/cli/pkg/auth" "github.com/kernel/cli/pkg/update" "github.com/kernel/cli/pkg/util" - "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) diff --git a/go.mod b/go.mod index 93b60fc..0042473 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1 github.com/golang-jwt/jwt/v5 v5.2.2 github.com/joho/godotenv v1.5.1 - github.com/onkernel/kernel-go-sdk v0.24.0 + github.com/kernel/kernel-go-sdk v0.25.0 github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/pterm/pterm v0.12.80 github.com/samber/lo v1.51.0 diff --git a/go.sum b/go.sum index 3172668..847e196 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/kernel/kernel-go-sdk v0.25.0 h1:I6EpQKcOasiuVi6gX8HcqEIxK9dAs6xMGSnlUW7AxXY= +github.com/kernel/kernel-go-sdk v0.25.0/go.mod h1:EeZzSuHZVeHKxKCPUzxou2bovNGhXaz0RXrSqKNf1AQ= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= @@ -91,8 +93,6 @@ github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0= github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8= github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig= -github.com/onkernel/kernel-go-sdk v0.24.0 h1:M5GdjmdASnpet9UezVEadPpzWyjBfoyqnLwHf/tFoVE= -github.com/onkernel/kernel-go-sdk v0.24.0/go.mod h1:t80buN1uCA/hwvm4D2SpjTJzZWcV7bWOFo9d7qdXD8M= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/pkg/auth/client.go b/pkg/auth/client.go index 58bf2c4..6446967 100644 --- a/pkg/auth/client.go +++ b/pkg/auth/client.go @@ -5,8 +5,8 @@ import ( "fmt" "os" - kernel "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + kernel "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" ) diff --git a/pkg/update/check.go b/pkg/update/check.go index 5eedd9f..e74b941 100644 --- a/pkg/update/check.go +++ b/pkg/update/check.go @@ -134,7 +134,7 @@ func printUpgradeMessage(current, latest, url string) { if url != "" { pterm.Info.Printf("Release notes: %s\n", url) } - if cmd := suggestUpgradeCommand(); cmd != "" { + if cmd := SuggestUpgradeCommand(); cmd != "" { pterm.Info.Printf("To upgrade, run: %s\n", cmd) } else { pterm.Info.Println("To upgrade, visit the release page above or use your package manager.") @@ -234,9 +234,9 @@ func saveCache(path string, c Cache) error { return os.WriteFile(path, b, 0o600) } -// suggestUpgradeCommand attempts to infer how the user installed kernel and +// SuggestUpgradeCommand attempts to infer how the user installed kernel and // returns a tailored upgrade command. Falls back to empty string on unknown. -func suggestUpgradeCommand() string { +func SuggestUpgradeCommand() string { // Collect candidate paths: current executable and shell-resolved binary candidates := []string{} if exe, err := os.Executable(); err == nil && exe != "" { @@ -272,7 +272,7 @@ func suggestUpgradeCommand() string { } rules := []rule{ - {hasHomebrew, nil, "brew upgrade onkernel/tap/kernel"}, + {hasHomebrew, nil, ""}, // Homebrew handled specially below {hasBun, []string{"BUN_INSTALL"}, "bun add -g @onkernel/cli@latest"}, {hasPNPM, []string{"PNPM_HOME"}, "pnpm add -g @onkernel/cli@latest"}, {hasNPM, []string{"NPM_CONFIG_PREFIX", "npm_config_prefix", "VOLTA_HOME"}, "npm i -g @onkernel/cli@latest"}, @@ -282,6 +282,10 @@ func suggestUpgradeCommand() string { for _, c := range candidates { for _, r := range rules { if r.check != nil && r.check(c) { + if r.cmd == "" { + // Homebrew detected, check which tap + return suggestHomebrewCommand(c) + } return r.cmd } } @@ -306,7 +310,50 @@ func suggestUpgradeCommand() string { } // Default suggestion when unknown - return "brew upgrade onkernel/tap/kernel" + return "brew upgrade kernel/tap/kernel" +} + +// suggestHomebrewCommand returns the appropriate brew command based on which tap +// the user has installed. If they have the old onkernel/tap, they need to uninstall +// and reinstall from the new kernel/tap. +func suggestHomebrewCommand(exePath string) string { + // Check if the executable path indicates the old tap by looking at version. + // The Cellar path format is: /opt/homebrew/Cellar/kernel//bin/kernel + // Versions before 0.13.0 were published to onkernel/tap, 0.13.0+ to kernel/tap. + if isOldTapVersion(exePath) { + return "brew uninstall kernel && brew install kernel/tap/kernel" + } + + return "brew upgrade kernel/tap/kernel" +} + +// isOldTapVersion checks if the Homebrew Cellar path contains a version < 0.13.0, +// which indicates it was installed from the old onkernel/tap. +func isOldTapVersion(exePath string) bool { + // Expected path format: .../Cellar/kernel//... + normPath := strings.ToLower(filepath.ToSlash(exePath)) + if !strings.Contains(normPath, "/cellar/kernel/") { + return false + } + + // Extract version from path + parts := strings.Split(normPath, "/cellar/kernel/") + if len(parts) < 2 { + return false + } + remainder := parts[1] // e.g., "0.12.4/bin/kernel" + versionPart := strings.Split(remainder, "/")[0] + if versionPart == "" { + return false + } + + // Parse and compare versions + installed, err := semver.NewVersion(versionPart) + if err != nil { + return false + } + threshold, _ := semver.NewVersion("0.13.0") + return installed.LessThan(threshold) } // invokedTrivialCommand returns true if the argv suggests a trivial invocation diff --git a/pkg/util/client.go b/pkg/util/client.go index 6b12f1d..20faf5f 100644 --- a/pkg/util/client.go +++ b/pkg/util/client.go @@ -9,8 +9,9 @@ import ( "os" "sync/atomic" - kernel "github.com/onkernel/kernel-go-sdk" - "github.com/onkernel/kernel-go-sdk/option" + "github.com/kernel/cli/pkg/update" + kernel "github.com/kernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk/option" "github.com/pterm/pterm" "github.com/spf13/cobra" ) @@ -76,7 +77,11 @@ func NewClient(opts ...option.RequestOption) kernel.Client { // is only displayed once per process. func showUpgradeMessage() { pterm.Error.Println("Your Kernel CLI is out of date and is not compatible with this API.") - pterm.Info.Println("Please upgrade by running: `brew upgrade onkernel/tap/kernel`") + if cmd := update.SuggestUpgradeCommand(); cmd != "" { + pterm.Info.Printf("Please upgrade by running: `%s`\n", cmd) + } else { + pterm.Info.Println("Please upgrade using your package manager.") + } } // IsNotFound returns true if the error is a Kernel API error with HTTP 404. diff --git a/pkg/util/errors.go b/pkg/util/errors.go index 45a4843..76fe233 100644 --- a/pkg/util/errors.go +++ b/pkg/util/errors.go @@ -6,7 +6,7 @@ import ( "fmt" "io" - "github.com/onkernel/kernel-go-sdk" + "github.com/kernel/kernel-go-sdk" ) // CleanedUpSdkError extracts a message field from the raw JSON resposne.