-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathpush.go
35 lines (32 loc) · 942 Bytes
/
push.go
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
package push
import (
"context"
"fmt"
"os"
"github.com/spf13/afero"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/flags"
"github.com/supabase/cli/pkg/config"
)
func Run(ctx context.Context, ref string, fsys afero.Fs) error {
if err := flags.LoadConfig(fsys); err != nil {
return err
}
client := config.NewConfigUpdater(*utils.GetSupabase())
remote, err := utils.Config.GetRemoteByProjectRef(ref)
if err != nil {
// Use base config when no remote is declared
remote.ProjectId = ref
}
fmt.Fprintln(os.Stderr, "Pushing config to project:", remote.ProjectId)
console := utils.NewConsole()
keep := func(name string) bool {
title := fmt.Sprintf("Do you want to push %s config to remote?", name)
shouldPush, err := console.PromptYesNo(ctx, title, true)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
return shouldPush
}
return client.UpdateRemoteConfig(ctx, remote, keep)
}