Skip to content

Commit f43b957

Browse files
committed
fix: defaults to json import map
1 parent 888c236 commit f43b957

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

internal/functions/deploy/deploy.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,22 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
113113
functionConfig[name] = function
114114
}
115115
if len(functionsUsingDeprecatedImportMap) > 0 {
116-
fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using deprecated import_map.json (please migrate to deno.jsonc):", utils.Aqua(strings.Join(functionsUsingDeprecatedImportMap, ", ")))
116+
fmt.Fprintln(os.Stderr,
117+
utils.Yellow("WARNING:"),
118+
"Functions using deprecated import_map.json (please migrate to deno.json):",
119+
utils.Aqua(strings.Join(functionsUsingDeprecatedImportMap, ", ")),
120+
)
117121
}
118122
if len(functionsUsingDeprecatedGlobalFallback) > 0 {
119-
fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using fallback import map:", utils.Aqua(strings.Join(functionsUsingDeprecatedGlobalFallback, ", ")))
120-
fmt.Fprintln(os.Stderr, "Please use recommended per function dependency declaration ", utils.Aqua("https://supabase.com/docs/guides/functions/import-maps"))
123+
fmt.Fprintln(os.Stderr,
124+
utils.Yellow("WARNING:"),
125+
"Functions using fallback import map:",
126+
utils.Aqua(strings.Join(functionsUsingDeprecatedGlobalFallback, ", ")),
127+
)
128+
fmt.Fprintln(os.Stderr,
129+
"Please use recommended per function dependency declaration ",
130+
utils.Aqua("https://supabase.com/docs/guides/functions/import-maps"),
131+
)
121132
}
122133
return functionConfig, nil
123134
}

internal/functions/new/new.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
var (
1818
//go:embed templates/index.ts
1919
indexEmbed string
20-
//go:embed templates/deno.jsonc
20+
//go:embed templates/deno.json
2121
denoEmbed string
2222
//go:embed templates/.npmrc
2323
npmrcEmbed string
@@ -57,8 +57,8 @@ func Run(ctx context.Context, slug string, fsys afero.Fs) error {
5757
return errors.Errorf("failed to create function entrypoint: %w", err)
5858
}
5959

60-
if err := afero.WriteFile(fsys, filepath.Join(funcDir, "deno.jsonc"), []byte(denoEmbed), 0644); err != nil {
61-
return errors.Errorf("failed to create deno.jsonc config: %w", err)
60+
if err := afero.WriteFile(fsys, filepath.Join(funcDir, "deno.json"), []byte(denoEmbed), 0644); err != nil {
61+
return errors.Errorf("failed to create deno.json config: %w", err)
6262
}
6363

6464
if err := afero.WriteFile(fsys, filepath.Join(funcDir, ".npmrc"), []byte(npmrcEmbed), 0644); err != nil {

internal/functions/new/new_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ func TestNewCommand(t *testing.T) {
2525
"curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/test-func'",
2626
)
2727

28-
// Verify deno.jsonc exists
29-
denoPath := filepath.Join(utils.FunctionsDir, "test-func", "deno.jsonc")
28+
// Verify deno.json exists
29+
denoPath := filepath.Join(utils.FunctionsDir, "test-func", "deno.json")
3030
_, err = afero.ReadFile(fsys, denoPath)
31-
assert.NoError(t, err, "deno.jsonc should be created")
31+
assert.NoError(t, err, "deno.json should be created")
3232

3333
// Verify .npmrc exists
3434
npmrcPath := filepath.Join(utils.FunctionsDir, "test-func", ".npmrc")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"imports": {}
3+
}

internal/functions/new/templates/deno.jsonc

Lines changed: 0 additions & 6 deletions
This file was deleted.

pkg/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ func TestLoadFunctionImportMap(t *testing.T) {
410410
}
411411
// Run test
412412
assert.NoError(t, config.Load("", fsys))
413-
// Check that deno.json was set as import map
413+
// Check that deno.jsonc was set as import map
414414
assert.Equal(t, "supabase/functions/hello/deno.jsonc", config.Functions["hello"].ImportMap)
415415
})
416416

0 commit comments

Comments
 (0)