Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3148eba
feat: add db postgres settings to config (#2787)
avallete Oct 23, 2024
aaa0d7f
chore: refactor use cast ptr (#2793)
avallete Oct 23, 2024
56c2cc4
fix(config): default value for seed remote (#2797)
avallete Oct 24, 2024
78bc7f7
feat(config): allow local postgres configuration (#2796)
avallete Oct 24, 2024
8611ace
feat(config): experimental config webhooks (#2794)
avallete Oct 25, 2024
2fe2da6
chore: upgrade keyring use package DeleteAll method (#2800)
avallete Oct 25, 2024
b322db7
fix: node-fetch hanging issue when fetching checksum after fetching b…
xmliszt Oct 26, 2024
813d6a7
fix: Bump studio to the latest image version 20241029 (#2815)
ivasilov Oct 29, 2024
25fd4e7
feat(auth): add mfa webauthn config variables (#2812)
J0 Oct 29, 2024
1250951
fix(auth): support email otp length and expiry (#2810)
sweatybridge Oct 29, 2024
074cbb6
chore: generate openapi client
sweatybridge Oct 29, 2024
bf9f40e
fix(config): resolve objects path when loading buckets config
sweatybridge Oct 29, 2024
398b7b7
feat(functions): allow custom functions entrypoint path (#2813)
sweatybridge Oct 30, 2024
4d2e5c3
chore(deps): bump github.com/Netflix/go-env from 0.1.0 to 0.1.2 (#2809)
dependabot[bot] Oct 30, 2024
0109975
feat(config): implement storage config update (#2817)
sweatybridge Oct 30, 2024
cf2136a
fix: bump edge-runtime to 1.59.1 (#2819)
nyannyacha Oct 31, 2024
68f9c56
feat(inspect): add role-configs command to list db roles with custom …
encima Oct 31, 2024
9aec8f2
chore: update generated v1 api client (#2825)
sweatybridge Nov 2, 2024
fefeebd
fix: bump edge-runtime to 1.60.1 (#2820)
nyannyacha Nov 2, 2024
4cf189a
feat(config): load local deno.json file as import map (#2824)
jgoux Nov 3, 2024
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
563 changes: 332 additions & 231 deletions api/beta.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions cmd/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/supabase/cli/internal/functions/serve"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/flags"
"github.com/supabase/cli/pkg/cast"
)

var (
Expand Down Expand Up @@ -106,9 +107,9 @@ var (
}

if len(inspectMode.Value) > 0 {
runtimeOption.InspectMode = utils.Ptr(serve.InspectMode(inspectMode.Value))
runtimeOption.InspectMode = cast.Ptr(serve.InspectMode(inspectMode.Value))
} else if inspectBrk {
runtimeOption.InspectMode = utils.Ptr(serve.InspectModeBrk)
runtimeOption.InspectMode = cast.Ptr(serve.InspectModeBrk)
}
if runtimeOption.InspectMode == nil && runtimeOption.InspectMain {
return fmt.Errorf("--inspect-main must be used together with one of these flags: [inspect inspect-mode]")
Expand Down
10 changes: 10 additions & 0 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/supabase/cli/internal/inspect/long_running_queries"
"github.com/supabase/cli/internal/inspect/outliers"
"github.com/supabase/cli/internal/inspect/replication_slots"
"github.com/supabase/cli/internal/inspect/role_configs"
"github.com/supabase/cli/internal/inspect/role_connections"
"github.com/supabase/cli/internal/inspect/seq_scans"
"github.com/supabase/cli/internal/inspect/table_index_sizes"
Expand Down Expand Up @@ -194,6 +195,14 @@ var (
},
}

inspectRoleConfigsCmd = &cobra.Command{
Use: "role-configs",
Short: "Show configuration settings for database roles when they have been modified",
RunE: func(cmd *cobra.Command, args []string) error {
return role_configs.Run(cmd.Context(), flags.DbConfig, afero.NewOsFs())
},
}

inspectRoleConnectionsCmd = &cobra.Command{
Use: "role-connections",
Short: "Show number of active connections for all database roles",
Expand Down Expand Up @@ -247,6 +256,7 @@ func init() {
inspectDBCmd.AddCommand(inspectTableRecordCountsCmd)
inspectDBCmd.AddCommand(inspectBloatCmd)
inspectDBCmd.AddCommand(inspectVacuumStatsCmd)
inspectDBCmd.AddCommand(inspectRoleConfigsCmd)
inspectDBCmd.AddCommand(inspectRoleConnectionsCmd)
inspectCmd.AddCommand(inspectDBCmd)
reportCmd.Flags().StringVar(&outputDir, "output-dir", "", "Path to save CSV files in")
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module github.com/supabase/cli

go 1.22.4
go 1.23.2

require (
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
github.com/Netflix/go-env v0.1.0
github.com/Netflix/go-env v0.1.2
github.com/andybalholm/brotli v1.1.1
github.com/cenkalti/backoff/v4 v4.3.0
github.com/charmbracelet/bubbles v0.18.0
github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/glamour v0.7.0
github.com/charmbracelet/lipgloss v0.12.1
github.com/containers/common v0.60.4
github.com/danieljoos/wincred v1.2.2
github.com/deepmap/oapi-codegen/v2 v2.2.0
github.com/docker/cli v27.3.1+incompatible
github.com/docker/docker v27.3.1+incompatible
Expand All @@ -25,6 +24,7 @@ require (
github.com/go-xmlfmt/xmlfmt v1.1.2
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golangci/golangci-lint v1.61.0
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v62 v62.0.0
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.6.0
Expand All @@ -48,7 +48,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/stripe/pg-schema-diff v0.7.0
github.com/withfig/autocomplete-tools/packages/cobra v1.2.0
github.com/zalando/go-keyring v0.2.5
github.com/zalando/go-keyring v0.2.6
go.opentelemetry.io/otel v1.31.0
golang.org/x/mod v0.21.0
golang.org/x/oauth2 v0.23.0
Expand All @@ -61,6 +61,7 @@ require (
require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
al.essio.dev/pkg/shellescape v1.5.1 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/4meepo/tagalign v1.3.4 // indirect
github.com/Abirdcfly/dupword v0.1.1 // indirect
Expand All @@ -77,7 +78,6 @@ require (
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/alecthomas/chroma/v2 v2.8.0 // indirect
github.com/alecthomas/go-check-sumtype v0.1.4 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/alexkohler/nakedret/v2 v2.0.4 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
Expand Down Expand Up @@ -115,6 +115,7 @@ require (
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/cyphar/filepath-securejoin v0.3.1 // indirect
github.com/daixiang0/gci v0.13.5 // indirect
github.com/danieljoos/wincred v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
Expand Down Expand Up @@ -169,7 +170,6 @@ require (
github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/revgrep v0.5.3 // indirect
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
4d63.com/gocheckcompilerdirectives v1.2.1/go.mod h1:yjDJSxmDTtIHHCqX0ufRYZDL6vQtMG7tJdKVeWwsqvs=
4d63.com/gochecknoglobals v0.2.1 h1:1eiorGsgHOFOuoOiJDy2psSrQbRdIHrlge0IJIkUgDc=
4d63.com/gochecknoglobals v0.2.1/go.mod h1:KRE8wtJB3CXCsb1xy421JfTHIIbmT3U5ruxw2Qu8fSU=
al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho=
al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down Expand Up @@ -65,8 +67,8 @@ github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lpr
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/Netflix/go-env v0.1.0 h1:qSMk2A4D6urE/YqOKpLeOkaATGmFmMLo56E7kNNKypk=
github.com/Netflix/go-env v0.1.0/go.mod h1:9IRTAm+pQDPMpUtMLR26JOrjHnAWz3KUbhaegqTdhfY=
github.com/Netflix/go-env v0.1.2 h1:0DRoLR9lECQ9Zqvkswuebm3jJ/2enaDX6Ei8/Z+EnK0=
github.com/Netflix/go-env v0.1.2/go.mod h1:WlIhYi++8FlKNJtrop1mjXYAJMzv1f43K4MqCoh0yGE=
github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA=
github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
Expand All @@ -87,8 +89,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0=
github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30=
github.com/alexkohler/nakedret/v2 v2.0.4 h1:yZuKmjqGi0pSmjGpOC016LtPJysIL0WEUiaXW5SUnNg=
github.com/alexkohler/nakedret/v2 v2.0.4/go.mod h1:bF5i0zF2Wo2o4X4USt9ntUWve6JbFv02Ff4vlkmS/VU=
github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw=
Expand Down Expand Up @@ -1012,8 +1012,8 @@ github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s=
github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY=
github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8=
github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk=
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo=
gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8=
Expand Down
7 changes: 4 additions & 3 deletions internal/branches/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/flags"
"github.com/supabase/cli/pkg/api"
"github.com/supabase/cli/pkg/cast"
)

func TestCreateCommand(t *testing.T) {
Expand All @@ -36,7 +37,7 @@ func TestCreateCommand(t *testing.T) {
})
// Run test
err := Run(context.Background(), api.CreateBranchBody{
Region: utils.Ptr("sin"),
Region: cast.Ptr("sin"),
}, fsys)
// Check error
assert.NoError(t, err)
Expand All @@ -53,7 +54,7 @@ func TestCreateCommand(t *testing.T) {
ReplyError(net.ErrClosed)
// Run test
err := Run(context.Background(), api.CreateBranchBody{
Region: utils.Ptr("sin"),
Region: cast.Ptr("sin"),
}, fsys)
// Check error
assert.ErrorIs(t, err, net.ErrClosed)
Expand All @@ -70,7 +71,7 @@ func TestCreateCommand(t *testing.T) {
Reply(http.StatusServiceUnavailable)
// Run test
err := Run(context.Background(), api.CreateBranchBody{
Region: utils.Ptr("sin"),
Region: cast.Ptr("sin"),
}, fsys)
// Check error
assert.ErrorContains(t, err, "Unexpected error creating preview branch:")
Expand Down
18 changes: 12 additions & 6 deletions internal/db/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func NewContainerConfig() container.Config {
env := []string{
"POSTGRES_PASSWORD=" + utils.Config.Db.Password,
"POSTGRES_HOST=/var/run/postgresql",
"POSTGRES_INITDB_ARGS=--lc-ctype=C.UTF-8",
"JWT_SECRET=" + utils.Config.Auth.JwtSecret,
fmt.Sprintf("JWT_EXP=%d", utils.Config.Auth.JwtExpiry),
}
Expand All @@ -81,13 +80,18 @@ func NewContainerConfig() container.Config {
Timeout: 2 * time.Second,
Retries: 3,
},
Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && docker-entrypoint.sh postgres -D /etc/postgresql
Entrypoint: []string{"sh", "-c", `
cat <<'EOF' > /etc/postgresql.schema.sql && \
cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && \
cat <<'EOF' >> /etc/postgresql/postgresql.conf && \
docker-entrypoint.sh postgres -D /etc/postgresql
` + initialSchema + `
` + _supabaseSchema + `
EOF
` + utils.Config.Db.RootKey + `
EOF
`},
` + utils.Config.Db.Settings.ToPostgresConfig() + `
EOF`},
}
if utils.Config.Db.MajorVersion >= 14 {
config.Cmd = []string{"postgres",
Expand Down Expand Up @@ -124,11 +128,13 @@ func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f
}
if utils.Config.Db.MajorVersion <= 14 {
config.Entrypoint = []string{"sh", "-c", `
cat <<'EOF' > /docker-entrypoint-initdb.d/supabase_schema.sql
cat <<'EOF' > /docker-entrypoint-initdb.d/supabase_schema.sql && \
cat <<'EOF' >> /etc/postgresql/postgresql.conf && \
docker-entrypoint.sh postgres -D /etc/postgresql
` + _supabaseSchema + `
EOF
docker-entrypoint.sh postgres -D /etc/postgresql
`}
` + utils.Config.Db.Settings.ToPostgresConfig() + `
EOF`}
hostConfig.Tmpfs = map[string]string{"/docker-entrypoint-initdb.d": ""}
}
// Creating volume will not override existing volume, so we must inspect explicitly
Expand Down
53 changes: 53 additions & 0 deletions internal/db/start/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/supabase/cli/internal/testing/apitest"
"github.com/supabase/cli/internal/testing/fstest"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/pkg/cast"
"github.com/supabase/cli/pkg/pgtest"
)

Expand Down Expand Up @@ -308,3 +309,55 @@ func TestSetupDatabase(t *testing.T) {
assert.Empty(t, apitest.ListUnmatchedRequests())
})
}
func TestStartDatabaseWithCustomSettings(t *testing.T) {
t.Run("starts database with custom MaxConnections", func(t *testing.T) {
// Setup
utils.Config.Db.MajorVersion = 15
utils.DbId = "supabase_db_test"
utils.ConfigId = "supabase_config_test"
utils.Config.Db.Port = 5432
utils.Config.Db.Settings.MaxConnections = cast.Ptr(uint(50))

// Setup in-memory fs
fsys := afero.NewMemMapFs()

// Setup mock docker
require.NoError(t, apitest.MockDocker(utils.Docker))
defer gock.OffAll()
gock.New(utils.Docker.DaemonHost()).
Get("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.DbId).
Reply(http.StatusNotFound).
JSON(volume.Volume{})
apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Db.Image), utils.DbId)
gock.New(utils.Docker.DaemonHost()).
Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json").
Reply(http.StatusOK).
JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{
State: &types.ContainerState{
Running: true,
Health: &types.Health{Status: types.Healthy},
},
}})

apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-realtime")
require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-realtime", ""))
apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Storage.Image), "test-storage")
require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-storage", ""))
apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Auth.Image), "test-auth")
require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-auth", ""))
// Setup mock postgres
conn := pgtest.NewConn()
defer conn.Close(t)

// Run test
err := StartDatabase(context.Background(), fsys, io.Discard, conn.Intercept)

// Check error
assert.NoError(t, err)
assert.Empty(t, apitest.ListUnmatchedRequests())

// Check if the custom MaxConnections setting was applied
config := NewContainerConfig()
assert.Contains(t, config.Entrypoint[2], "max_connections = 50")
})
}
6 changes: 3 additions & 3 deletions internal/functions/deploy/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap
}
}()
// Create bind mounts
hostEntrypointDir := filepath.Dir(entrypoint)
binds, err := GetBindMounts(cwd, utils.FunctionsDir, hostOutputDir, hostEntrypointDir, importMap, b.fsys)
binds, err := GetBindMounts(cwd, utils.FunctionsDir, hostOutputDir, entrypoint, importMap, b.fsys)
if err != nil {
return err
}
Expand Down Expand Up @@ -86,7 +85,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap
return function.Compress(eszipBytes, output)
}

func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImportMapPath string, fsys afero.Fs) ([]string, error) {
func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointPath, hostImportMapPath string, fsys afero.Fs) ([]string, error) {
sep := string(filepath.Separator)
// Docker requires all host paths to be absolute
if !filepath.IsAbs(hostFuncDir) {
Expand Down Expand Up @@ -116,6 +115,7 @@ func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImpor
}
}
// Allow entrypoints outside the functions directory
hostEntrypointDir := filepath.Dir(hostEntrypointPath)
if len(hostEntrypointDir) > 0 {
if !filepath.IsAbs(hostEntrypointDir) {
hostEntrypointDir = filepath.Join(cwd, hostEntrypointDir)
Expand Down
7 changes: 6 additions & 1 deletion internal/functions/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/go-errors/errors"
"github.com/spf13/afero"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/pkg/cast"
"github.com/supabase/cli/pkg/config"
"github.com/supabase/cli/pkg/function"
)
Expand Down Expand Up @@ -57,6 +58,10 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) {
slugs = append(slugs, slug)
}
}
// Add all function slugs declared in config file
for slug := range utils.Config.Functions {
slugs = append(slugs, slug)
}
return slugs, nil
}

Expand Down Expand Up @@ -86,7 +91,7 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
function.ImportMap = utils.FallbackImportMapPath
}
if noVerifyJWT != nil {
function.VerifyJWT = utils.Ptr(!*noVerifyJWT)
function.VerifyJWT = cast.Ptr(!*noVerifyJWT)
}
functionConfig[name] = function
}
Expand Down
9 changes: 7 additions & 2 deletions internal/functions/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/supabase/cli/internal/testing/apitest"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/pkg/api"
"github.com/supabase/cli/pkg/cast"
"github.com/supabase/cli/pkg/config"
)

Expand Down Expand Up @@ -321,12 +322,16 @@ func TestImportMapPath(t *testing.T) {
}
// Setup in-memory fs
fsys := afero.NewMemMapFs()
// Custom global import map loaded via cli flag
customImportMapPath := filepath.Join(utils.FunctionsDir, "custom_import_map.json")
require.NoError(t, afero.WriteFile(fsys, customImportMapPath, []byte("{}"), 0644))
// Create fallback import map to test precedence order
require.NoError(t, afero.WriteFile(fsys, utils.FallbackImportMapPath, []byte("{}"), 0644))
// Run test
fc, err := GetFunctionConfig([]string{slug}, utils.FallbackImportMapPath, utils.Ptr(false), fsys)
fc, err := GetFunctionConfig([]string{slug}, customImportMapPath, cast.Ptr(false), fsys)
// Check error
assert.NoError(t, err)
assert.Equal(t, utils.FallbackImportMapPath, fc[slug].ImportMap)
assert.Equal(t, customImportMapPath, fc[slug].ImportMap)
})

t.Run("returns empty string if no fallback", func(t *testing.T) {
Expand Down
Loading
Loading