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

supabase / cli / 9232878727

25 May 2024 04:23AM UTC coverage: 60.309% (-0.07%) from 60.378%
9232878727

push

github

web-flow
fix: timeout waiting for input from non-interactive prompt (#2318)

57 of 110 new or added lines in 19 files covered. (51.82%)

8 existing lines in 6 files now uncovered.

6865 of 11383 relevant lines covered (60.31%)

646.74 hits per line

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

10.53
/cmd/bootstrap.go
1
package cmd
2

3
import (
4
        "context"
5
        "fmt"
6
        "os"
7
        "os/signal"
8
        "strings"
9

10
        "github.com/go-errors/errors"
11
        "github.com/spf13/afero"
12
        "github.com/spf13/cobra"
13
        "github.com/spf13/viper"
14
        "github.com/supabase/cli/internal/bootstrap"
15
        "github.com/supabase/cli/internal/utils"
16
)
17

18
var (
19
        starter = bootstrap.StarterTemplate{
20
                Name:        "scratch",
21
                Description: "An empty project from scratch.",
22
                Start:       "supabase start",
23
        }
24

25
        bootstrapCmd = &cobra.Command{
26
                GroupID: groupQuickStart,
27
                Use:     "bootstrap [template]",
28
                Short:   "Bootstrap a Supabase project from a starter template",
29
                Args:    cobra.MaximumNArgs(1),
30
                RunE: func(cmd *cobra.Command, args []string) error {
×
NEW
31
                        ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt)
×
32
                        if !viper.IsSet("WORKDIR") {
×
33
                                title := fmt.Sprintf("Enter a directory to bootstrap your project (or leave blank to use %s): ", utils.Bold(utils.CurrentDirAbs))
×
NEW
34
                                if workdir, err := utils.NewConsole().PromptText(ctx, title); err != nil {
×
NEW
35
                                        return err
×
NEW
36
                                } else {
×
NEW
37
                                        viper.Set("WORKDIR", workdir)
×
NEW
38
                                }
×
39
                        }
40
                        client := utils.GetGtihubClient(ctx)
×
41
                        templates, err := bootstrap.ListSamples(ctx, client)
×
42
                        if err != nil {
×
43
                                return err
×
44
                        }
×
45
                        if len(args) > 0 {
×
46
                                name := strings.ToLower(args[0])
×
47
                                for _, t := range templates {
×
48
                                        if t.Name == name {
×
49
                                                starter = t
×
50
                                                break
×
51
                                        }
52
                                }
53
                                if name != starter.Name {
×
54
                                        return errors.New("Invalid template: " + args[0])
×
55
                                }
×
56
                        } else {
×
57
                                if err := promptStarterTemplate(ctx, templates); err != nil {
×
58
                                        return err
×
59
                                }
×
60
                        }
61
                        return bootstrap.Run(ctx, starter, afero.NewOsFs())
×
62
                },
63
        }
64
)
65

66
func init() {
87✔
67
        bootstrapFlags := bootstrapCmd.Flags()
87✔
68
        bootstrapFlags.StringP("password", "p", "", "Password to your remote Postgres database.")
87✔
69
        cobra.CheckErr(viper.BindPFlag("DB_PASSWORD", bootstrapFlags.Lookup("password")))
87✔
70
        rootCmd.AddCommand(bootstrapCmd)
87✔
71
}
87✔
72

73
func promptStarterTemplate(ctx context.Context, templates []bootstrap.StarterTemplate) error {
×
74
        items := make([]utils.PromptItem, len(templates))
×
75
        for i, t := range templates {
×
76
                items[i] = utils.PromptItem{
×
77
                        Index:   i,
×
78
                        Summary: t.Name,
×
79
                        Details: t.Description,
×
80
                }
×
81
        }
×
82
        items = append(items, utils.PromptItem{
×
83
                Index:   len(items),
×
84
                Summary: starter.Name,
×
85
                Details: starter.Description,
×
86
        })
×
87
        title := "Which starter template do you want to use?"
×
88
        choice, err := utils.PromptChoice(ctx, title, items)
×
89
        if err != nil {
×
90
                return err
×
91
        }
×
92
        if choice.Index < len(templates) {
×
93
                starter = templates[choice.Index]
×
94
        }
×
95
        return nil
×
96
}
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