(ctx context.Context, cmd *cli.Command)
| 83 | } |
| 84 | |
| 85 | func 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 | |
| 117 | func initInit(ps *clienv.PathStructure) error { |
| 118 | hasuraConf := map[string]any{"version": hasuraMetadataVersion} |
nothing calls this directly
no test coverage detected