MCPcopy Create free account
hub / github.com/nhost/nhost / commandInit

Function commandInit

cli/cmd/project/init.go:85–115  ·  view source on GitHub ↗
(ctx context.Context, cmd *cli.Command)

Source from the content-addressed store, hash-verified

83}
84
85func commandInit(ctx context.Context, cmd *cli.Command) error {
86 ce := clienv.FromCLI(cmd)
87
88 if clienv.PathExists(ce.Path.NhostFolder()) {
89 return errors.New("nhost folder already exists") //nolint:err113
90 }
91
92 if err := os.MkdirAll(ce.Path.NhostFolder(), 0o755); err != nil { //nolint:mnd
93 return fmt.Errorf("failed to create nhost folder: %w", err)
94 }
95
96 ce.Infoln("Initializing Nhost project")
97
98 if err := config.InitConfigAndSecrets(ce); err != nil {
99 return fmt.Errorf("failed to initialize configuration: %w", err)
100 }
101
102 if cmd.Bool(flagRemote) {
103 if err := InitRemote(ctx, ce); err != nil {
104 return fmt.Errorf("failed to initialize remote project: %w", err)
105 }
106 } else {
107 if err := initInit(ce.Path); err != nil {
108 return fmt.Errorf("failed to initialize project: %w", err)
109 }
110 }
111
112 ce.Infoln("Successfully initialized Nhost project, run `nhost up` to start development")
113
114 return nil
115}
116
117func initInit(ps *clienv.PathStructure) error {
118 hasuraConf := map[string]any{"version": hasuraMetadataVersion}

Callers

nothing calls this directly

Calls 8

FromCLIFunction · 0.92
PathExistsFunction · 0.92
InitConfigAndSecretsFunction · 0.92
InitRemoteFunction · 0.85
initInitFunction · 0.85
NhostFolderMethod · 0.80
ErrorfMethod · 0.80
InfolnMethod · 0.80

Tested by

no test coverage detected