Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/cli-go/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"os/signal"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -184,6 +185,9 @@ func Execute() {
panic(err)
}
// Check upgrade last because --version flag is initialised after execute
if shouldSkipUpdateNotifier() {
return
}
Comment on lines +188 to +190

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve post-command suggestions when skipping updates

When SUPABASE_NO_UPDATE_NOTIFIER=1, this return exits Execute before the later utils.CmdSuggestion output, so successful commands that deliberately set an actionable follow-up—such as migration repair suggesting migration list—silently lose that output; the independent Claude plugin hint is also skipped. Scope the condition to the release check and upgrade message rather than returning from Execute.

Useful? React with 👍 / 👎.

ctx := rootCmd.Context()
if executedCmd != nil {
ctx = executedCmd.Context()
Expand All @@ -203,6 +207,15 @@ func Execute() {
}
}

func shouldSkipUpdateNotifier() bool {
val := os.Getenv("SUPABASE_NO_UPDATE_NOTIFIER")
if len(val) == 0 {
return false
}
enabled, err := strconv.ParseBool(val)
return err == nil && enabled
}

// ensureProjectGroupsCached populates the telemetry linked-project cache when
// a project ref is available but no cache exists. This ensures org/project
// PostHog groups are attached to all CLI events, not just those after `supabase link`.
Expand Down
23 changes: 23 additions & 0 deletions apps/cli-go/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,26 @@ func TestEnvSignals(t *testing.T) {
assert.Equal(t, strings.Repeat("x", 80), signals["TERM"])
assert.NotContains(t, signals, "AI_AGENT")
}

func TestShouldSkipUpdateNotifier(t *testing.T) {
t.Run("returns true when SUPABASE_NO_UPDATE_NOTIFIER is true", func(t *testing.T) {
t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "true")
assert.True(t, shouldSkipUpdateNotifier())
})

t.Run("returns true when SUPABASE_NO_UPDATE_NOTIFIER is 1", func(t *testing.T) {
t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "1")
assert.True(t, shouldSkipUpdateNotifier())
})

t.Run("returns false when SUPABASE_NO_UPDATE_NOTIFIER is false", func(t *testing.T) {
t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "false")
assert.False(t, shouldSkipUpdateNotifier())
})

t.Run("returns false when SUPABASE_NO_UPDATE_NOTIFIER is unset", func(t *testing.T) {
t.Setenv("SUPABASE_NO_UPDATE_NOTIFIER", "")
assert.False(t, shouldSkipUpdateNotifier())
})
}

Loading