Skip to content

Commit 358a5ff

Browse files
feat: Add support for file-based snippets in Studio (#4656)
* Add SNIPPETS_MANAGEMENT_FOLDER env var and set it to snippets dir. * Remove duplicate lines. * Bind the snippets volume to the studio. * Fix whitespace. * Apply suggestion from @sweatybridge --------- Co-authored-by: Han Qiao <sweatybridge@gmail.com>
1 parent f386e44 commit 358a5ff

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

internal/start/start.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,11 @@ EOF
11431143
if err != nil {
11441144
return err
11451145
}
1146+
1147+
// Mount snippets directory for Studio to access
1148+
hostSnippetsPath := filepath.Join(workdir, utils.SnippetsDir)
1149+
binds = append(binds, fmt.Sprintf("%s:%s:rw", hostSnippetsPath, hostSnippetsPath))
1150+
binds = utils.RemoveDuplicates(binds)
11461151
if _, err := utils.DockerStart(
11471152
ctx,
11481153
container.Config{
@@ -1162,6 +1167,7 @@ EOF
11621167
fmt.Sprintf("NEXT_PUBLIC_ENABLE_LOGS=%v", utils.Config.Analytics.Enabled),
11631168
fmt.Sprintf("NEXT_ANALYTICS_BACKEND_PROVIDER=%v", utils.Config.Analytics.Backend),
11641169
"EDGE_FUNCTIONS_MANAGEMENT_FOLDER=" + filepath.Join(workdir, utils.FunctionsDir),
1170+
"SNIPPETS_MANAGEMENT_FOLDER=" + hostSnippetsPath,
11651171
// Ref: https://github.com/vercel/next.js/issues/51684#issuecomment-1612834913
11661172
"HOSTNAME=0.0.0.0",
11671173
},

internal/utils/misc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ var (
8080
SchemasDir = filepath.Join(SupabaseDirPath, "schemas")
8181
MigrationsDir = filepath.Join(SupabaseDirPath, "migrations")
8282
FunctionsDir = filepath.Join(SupabaseDirPath, "functions")
83+
SnippetsDir = filepath.Join(SupabaseDirPath, "snippets")
8384
FallbackImportMapPath = filepath.Join(FunctionsDir, "import_map.json")
8485
FallbackEnvFilePath = filepath.Join(FunctionsDir, ".env")
8586
DbTestsDir = filepath.Join(SupabaseDirPath, "tests")

0 commit comments

Comments
 (0)