Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
cli/cmd/functions.go at develop · AskJoe/cli · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
AskJoe
cli
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
develop
Breadcrumbs
cli
/
cmd
/
functions.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
162 lines (148 loc) · 6.48 KB
develop
Breadcrumbs
cli
/
cmd
/
functions.go
Copy path
Top
File metadata and controls
Code
Blame
162 lines (148 loc) · 6.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package
cmd
import
(
"fmt"
"github.com/go-errors/errors"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/supabase/cli/internal/functions/delete"
"github.com/supabase/cli/internal/functions/deploy"
"github.com/supabase/cli/internal/functions/download"
"github.com/supabase/cli/internal/functions/list"
new_
"github.com/supabase/cli/internal/functions/new"
"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
(
functionsCmd
=
&
cobra.
Command
{
GroupID
:
groupManagementAPI
,
Use
:
"functions"
,
Short
:
"Manage Supabase Edge functions"
,
}
functionsListCmd
=
&
cobra.
Command
{
Use
:
"list"
,
Short
:
"List all Functions in Supabase"
,
Long
:
"List all Functions in the linked Supabase project."
,
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
return
list
.
Run
(
cmd
.
Context
(),
flags
.
ProjectRef
,
afero
.
NewOsFs
())
},
}
functionsDeleteCmd
=
&
cobra.
Command
{
Use
:
"delete <Function name>"
,
Short
:
"Delete a Function from Supabase"
,
Long
:
"Delete a Function from the linked Supabase project. This does NOT remove the Function locally."
,
Args
:
cobra
.
ExactArgs
(
1
),
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
return
delete
.
Run
(
cmd
.
Context
(),
args
[
0
],
flags
.
ProjectRef
,
afero
.
NewOsFs
())
},
}
functionsDownloadCmd
=
&
cobra.
Command
{
Use
:
"download <Function name>"
,
Short
:
"Download a Function from Supabase"
,
Long
:
"Download the source code for a Function from the linked Supabase project."
,
Args
:
cobra
.
ExactArgs
(
1
),
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
return
download
.
Run
(
cmd
.
Context
(),
args
[
0
],
flags
.
ProjectRef
,
useLegacyBundle
,
afero
.
NewOsFs
())
},
}
useApi
bool
useDocker
bool
useLegacyBundle
bool
noVerifyJWT
=
new
(
bool
)
importMapPath
string
functionsDeployCmd
=
&
cobra.
Command
{
Use
:
"deploy [Function name]"
,
Short
:
"Deploy a Function to Supabase"
,
Long
:
"Deploy a Function to the linked Supabase project."
,
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
// Fallback to config if user did not set the flag.
if
!
cmd
.
Flags
().
Changed
(
"no-verify-jwt"
) {
noVerifyJWT
=
nil
}
if
useApi
{
useDocker
=
false
}
else
if
maxJobs
>
1
{
return
errors
.
New
(
"--jobs must be used together with --use-api"
)
}
return
deploy
.
Run
(
cmd
.
Context
(),
args
,
useDocker
,
noVerifyJWT
,
importMapPath
,
maxJobs
,
afero
.
NewOsFs
())
},
}
functionsNewCmd
=
&
cobra.
Command
{
Use
:
"new <Function name>"
,
Short
:
"Create a new Function locally"
,
Args
:
cobra
.
ExactArgs
(
1
),
PersistentPreRunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
cmd
.
GroupID
=
groupLocalDev
return
cmd
.
Root
().
PersistentPreRunE
(
cmd
,
args
)
},
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
return
new_
.
Run
(
cmd
.
Context
(),
args
[
0
],
afero
.
NewOsFs
())
},
}
envFilePath
string
inspectBrk
bool
inspectMode
=
utils.
EnumFlag
{
Allowed
: []
string
{
string
(
serve
.
InspectModeRun
),
string
(
serve
.
InspectModeBrk
),
string
(
serve
.
InspectModeWait
),
},
}
runtimeOption
serve.
RuntimeOption
functionsServeCmd
=
&
cobra.
Command
{
Use
:
"serve"
,
Short
:
"Serve all Functions locally"
,
PersistentPreRunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
cmd
.
GroupID
=
groupLocalDev
return
cmd
.
Root
().
PersistentPreRunE
(
cmd
,
args
)
},
RunE
:
func
(
cmd
*
cobra.
Command
,
args
[]
string
)
error
{
// Fallback to config if user did not set the flag.
if
!
cmd
.
Flags
().
Changed
(
"no-verify-jwt"
) {
noVerifyJWT
=
nil
}
if
len
(
inspectMode
.
Value
)
>
0
{
runtimeOption
.
InspectMode
=
cast
.
Ptr
(
serve
.
InspectMode
(
inspectMode
.
Value
))
}
else
if
inspectBrk
{
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]"
)
}
return
serve
.
Run
(
cmd
.
Context
(),
envFilePath
,
noVerifyJWT
,
importMapPath
,
runtimeOption
,
afero
.
NewOsFs
())
},
}
)
func
init
() {
functionsListCmd
.
Flags
().
StringVar
(
&
flags
.
ProjectRef
,
"project-ref"
,
""
,
"Project ref of the Supabase project."
)
functionsDeleteCmd
.
Flags
().
StringVar
(
&
flags
.
ProjectRef
,
"project-ref"
,
""
,
"Project ref of the Supabase project."
)
deployFlags
:=
functionsDeployCmd
.
Flags
()
deployFlags
.
BoolVar
(
&
useApi
,
"use-api"
,
false
,
"Use Management API to bundle functions."
)
deployFlags
.
BoolVar
(
&
useDocker
,
"use-docker"
,
true
,
"Use Docker to bundle functions."
)
deployFlags
.
BoolVar
(
&
useLegacyBundle
,
"legacy-bundle"
,
false
,
"Use legacy bundling mechanism."
)
functionsDeployCmd
.
MarkFlagsMutuallyExclusive
(
"use-api"
,
"use-docker"
,
"legacy-bundle"
)
cobra
.
CheckErr
(
deployFlags
.
MarkHidden
(
"legacy-bundle"
))
deployFlags
.
UintVarP
(
&
maxJobs
,
"jobs"
,
"j"
,
1
,
"Maximum number of parallel jobs."
)
deployFlags
.
BoolVar
(
noVerifyJWT
,
"no-verify-jwt"
,
false
,
"Disable JWT verification for the Function."
)
deployFlags
.
StringVar
(
&
flags
.
ProjectRef
,
"project-ref"
,
""
,
"Project ref of the Supabase project."
)
deployFlags
.
StringVar
(
&
importMapPath
,
"import-map"
,
""
,
"Path to import map file."
)
functionsServeCmd
.
Flags
().
BoolVar
(
noVerifyJWT
,
"no-verify-jwt"
,
false
,
"Disable JWT verification for the Function."
)
functionsServeCmd
.
Flags
().
StringVar
(
&
envFilePath
,
"env-file"
,
""
,
"Path to an env file to be populated to the Function environment."
)
functionsServeCmd
.
Flags
().
StringVar
(
&
importMapPath
,
"import-map"
,
""
,
"Path to import map file."
)
functionsServeCmd
.
Flags
().
BoolVar
(
&
inspectBrk
,
"inspect"
,
false
,
"Alias of --inspect-mode brk."
)
functionsServeCmd
.
Flags
().
Var
(
&
inspectMode
,
"inspect-mode"
,
"Activate inspector capability for debugging."
)
functionsServeCmd
.
Flags
().
BoolVar
(
&
runtimeOption
.
InspectMain
,
"inspect-main"
,
false
,
"Allow inspecting the main worker."
)
functionsServeCmd
.
MarkFlagsMutuallyExclusive
(
"inspect"
,
"inspect-mode"
)
functionsServeCmd
.
Flags
().
Bool
(
"all"
,
true
,
"Serve all Functions."
)
cobra
.
CheckErr
(
functionsServeCmd
.
Flags
().
MarkHidden
(
"all"
))
functionsDownloadCmd
.
Flags
().
StringVar
(
&
flags
.
ProjectRef
,
"project-ref"
,
""
,
"Project ref of the Supabase project."
)
functionsDownloadCmd
.
Flags
().
BoolVar
(
&
useLegacyBundle
,
"legacy-bundle"
,
false
,
"Use legacy bundling mechanism."
)
functionsCmd
.
AddCommand
(
functionsListCmd
)
functionsCmd
.
AddCommand
(
functionsDeleteCmd
)
functionsCmd
.
AddCommand
(
functionsDeployCmd
)
functionsCmd
.
AddCommand
(
functionsNewCmd
)
functionsCmd
.
AddCommand
(
functionsServeCmd
)
functionsCmd
.
AddCommand
(
functionsDownloadCmd
)
rootCmd
.
AddCommand
(
functionsCmd
)
}
You can’t perform that action at this time.