• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 16562138230

28 Jul 2025 06:48AM UTC coverage: 55.37%. First build
16562138230

Pull #3922

github

web-flow
Merge 50ce28b7b into b720b1240
Pull Request #3922: chore(deps): bump supabase/realtime from v2.41.7 to v2.41.8 in /pkg/config/templates

6192 of 11183 relevant lines covered (55.37%)

6.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/functions.go
1
package cmd
2

3
import (
4
        "fmt"
5

6
        "github.com/go-errors/errors"
7
        "github.com/spf13/afero"
8
        "github.com/spf13/cobra"
9
        "github.com/supabase/cli/internal/functions/delete"
10
        "github.com/supabase/cli/internal/functions/deploy"
11
        "github.com/supabase/cli/internal/functions/download"
12
        "github.com/supabase/cli/internal/functions/list"
13
        new_ "github.com/supabase/cli/internal/functions/new"
14
        "github.com/supabase/cli/internal/functions/serve"
15
        "github.com/supabase/cli/internal/utils"
16
        "github.com/supabase/cli/internal/utils/flags"
17
        "github.com/supabase/cli/pkg/cast"
18
)
19

20
var (
21
        functionsCmd = &cobra.Command{
22
                GroupID: groupManagementAPI,
23
                Use:     "functions",
24
                Short:   "Manage Supabase Edge functions",
25
        }
26

27
        functionsListCmd = &cobra.Command{
28
                Use:   "list",
29
                Short: "List all Functions in Supabase",
30
                Long:  "List all Functions in the linked Supabase project.",
31
                RunE: func(cmd *cobra.Command, args []string) error {
×
32
                        return list.Run(cmd.Context(), flags.ProjectRef, afero.NewOsFs())
×
33
                },
×
34
        }
35

36
        functionsDeleteCmd = &cobra.Command{
37
                Use:   "delete <Function name>",
38
                Short: "Delete a Function from Supabase",
39
                Long:  "Delete a Function from the linked Supabase project. This does NOT remove the Function locally.",
40
                Args:  cobra.ExactArgs(1),
41
                RunE: func(cmd *cobra.Command, args []string) error {
×
42
                        return delete.Run(cmd.Context(), args[0], flags.ProjectRef, afero.NewOsFs())
×
43
                },
×
44
        }
45

46
        functionsDownloadCmd = &cobra.Command{
47
                Use:   "download <Function name>",
48
                Short: "Download a Function from Supabase",
49
                Long:  "Download the source code for a Function from the linked Supabase project.",
50
                Args:  cobra.ExactArgs(1),
51
                RunE: func(cmd *cobra.Command, args []string) error {
×
52
                        return download.Run(cmd.Context(), args[0], flags.ProjectRef, useLegacyBundle, afero.NewOsFs())
×
53
                },
×
54
        }
55

56
        useApi          bool
57
        useDocker       bool
58
        useLegacyBundle bool
59
        noVerifyJWT     = new(bool)
60
        importMapPath   string
61
        prune           bool
62

63
        functionsDeployCmd = &cobra.Command{
64
                Use:   "deploy [Function name]",
65
                Short: "Deploy a Function to Supabase",
66
                Long:  "Deploy a Function to the linked Supabase project.",
67
                RunE: func(cmd *cobra.Command, args []string) error {
×
68
                        // Fallback to config if user did not set the flag.
×
69
                        if !cmd.Flags().Changed("no-verify-jwt") {
×
70
                                noVerifyJWT = nil
×
71
                        }
×
72
                        if useApi {
×
73
                                useDocker = false
×
74
                        } else if maxJobs > 1 {
×
75
                                return errors.New("--jobs must be used together with --use-api")
×
76
                        }
×
77
                        return deploy.Run(cmd.Context(), args, useDocker, noVerifyJWT, importMapPath, maxJobs, prune, afero.NewOsFs())
×
78
                },
79
        }
80

81
        functionsNewCmd = &cobra.Command{
82
                Use:   "new <Function name>",
83
                Short: "Create a new Function locally",
84
                Args:  cobra.ExactArgs(1),
85
                PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
×
86
                        cmd.GroupID = groupLocalDev
×
87
                        return cmd.Root().PersistentPreRunE(cmd, args)
×
88
                },
×
89
                RunE: func(cmd *cobra.Command, args []string) error {
×
90
                        return new_.Run(cmd.Context(), args[0], afero.NewOsFs())
×
91
                },
×
92
        }
93

94
        envFilePath string
95
        inspectBrk  bool
96
        inspectMode = utils.EnumFlag{
97
                Allowed: []string{
98
                        string(serve.InspectModeRun),
99
                        string(serve.InspectModeBrk),
100
                        string(serve.InspectModeWait),
101
                },
102
        }
103
        runtimeOption serve.RuntimeOption
104

105
        functionsServeCmd = &cobra.Command{
106
                Use:   "serve",
107
                Short: "Serve all Functions locally",
108
                PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
×
109
                        cmd.GroupID = groupLocalDev
×
110
                        return cmd.Root().PersistentPreRunE(cmd, args)
×
111
                },
×
112
                RunE: func(cmd *cobra.Command, args []string) error {
×
113
                        // Fallback to config if user did not set the flag.
×
114
                        if !cmd.Flags().Changed("no-verify-jwt") {
×
115
                                noVerifyJWT = nil
×
116
                        }
×
117

118
                        if len(inspectMode.Value) > 0 {
×
119
                                runtimeOption.InspectMode = cast.Ptr(serve.InspectMode(inspectMode.Value))
×
120
                        } else if inspectBrk {
×
121
                                runtimeOption.InspectMode = cast.Ptr(serve.InspectModeBrk)
×
122
                        }
×
123
                        if runtimeOption.InspectMode == nil && runtimeOption.InspectMain {
×
124
                                return fmt.Errorf("--inspect-main must be used together with one of these flags: [inspect inspect-mode]")
×
125
                        }
×
126

127
                        return serve.Run(cmd.Context(), envFilePath, noVerifyJWT, importMapPath, runtimeOption, afero.NewOsFs())
×
128
                },
129
        }
130
)
131

132
func init() {
×
133
        functionsListCmd.Flags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
×
134
        functionsDeleteCmd.Flags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
×
135
        deployFlags := functionsDeployCmd.Flags()
×
136
        deployFlags.BoolVar(&useApi, "use-api", false, "Use Management API to bundle functions.")
×
137
        deployFlags.BoolVar(&useDocker, "use-docker", true, "Use Docker to bundle functions.")
×
138
        deployFlags.BoolVar(&useLegacyBundle, "legacy-bundle", false, "Use legacy bundling mechanism.")
×
139
        functionsDeployCmd.MarkFlagsMutuallyExclusive("use-api", "use-docker", "legacy-bundle")
×
140
        cobra.CheckErr(deployFlags.MarkHidden("legacy-bundle"))
×
141
        deployFlags.UintVarP(&maxJobs, "jobs", "j", 1, "Maximum number of parallel jobs.")
×
142
        deployFlags.BoolVar(noVerifyJWT, "no-verify-jwt", false, "Disable JWT verification for the Function.")
×
143
        deployFlags.BoolVar(&prune, "prune", false, "Delete Functions that exist in Supabase project but not locally.")
×
144
        deployFlags.StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
×
145
        deployFlags.StringVar(&importMapPath, "import-map", "", "Path to import map file.")
×
146
        functionsServeCmd.Flags().BoolVar(noVerifyJWT, "no-verify-jwt", false, "Disable JWT verification for the Function.")
×
147
        functionsServeCmd.Flags().StringVar(&envFilePath, "env-file", "", "Path to an env file to be populated to the Function environment.")
×
148
        functionsServeCmd.Flags().StringVar(&importMapPath, "import-map", "", "Path to import map file.")
×
149
        functionsServeCmd.Flags().BoolVar(&inspectBrk, "inspect", false, "Alias of --inspect-mode brk.")
×
150
        functionsServeCmd.Flags().Var(&inspectMode, "inspect-mode", "Activate inspector capability for debugging.")
×
151
        functionsServeCmd.Flags().BoolVar(&runtimeOption.InspectMain, "inspect-main", false, "Allow inspecting the main worker.")
×
152
        functionsServeCmd.MarkFlagsMutuallyExclusive("inspect", "inspect-mode")
×
153
        functionsServeCmd.Flags().Bool("all", true, "Serve all Functions.")
×
154
        cobra.CheckErr(functionsServeCmd.Flags().MarkHidden("all"))
×
155
        functionsDownloadCmd.Flags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.")
×
156
        functionsDownloadCmd.Flags().BoolVar(&useLegacyBundle, "legacy-bundle", false, "Use legacy bundling mechanism.")
×
157
        functionsCmd.AddCommand(functionsListCmd)
×
158
        functionsCmd.AddCommand(functionsDeleteCmd)
×
159
        functionsCmd.AddCommand(functionsDeployCmd)
×
160
        functionsCmd.AddCommand(functionsNewCmd)
×
161
        functionsCmd.AddCommand(functionsServeCmd)
×
162
        functionsCmd.AddCommand(functionsDownloadCmd)
×
163
        rootCmd.AddCommand(functionsCmd)
×
164
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc