diff --git a/cli/app.go b/cli/app.go index 95ceaeeb..28792bc6 100644 --- a/cli/app.go +++ b/cli/app.go @@ -3,6 +3,8 @@ package cli import ( "context" "fmt" + "io/ioutil" + "path" "sort" "strings" @@ -100,17 +102,38 @@ locally in a pass store (see passwordstore.org for more). if AppName == "" { prompt := &survey.Input{ Message: "Specify app name:", + Default: strings.ReplaceAll(Domain, ".", "_"), } if err := survey.AskOne(prompt, &AppName); err != nil { logrus.Fatal(err) } } - // convert name and truncate or error out if needed + sanitisedAppName := strings.ReplaceAll(AppName, ".", "_") + if len(sanitisedAppName) > 45 { + logrus.Fatal(fmt.Errorf("'%s' cannot be longer than 45 characters", sanitisedAppName)) + } + + envSamplePath := path.Join(config.ABRA_DIR, "apps", appType, ".env.sample") + envSample, err := ioutil.ReadFile(envSamplePath) + if err != nil { + logrus.Fatal(err) + } + + appEnvPath := path.Join(config.ABRA_DIR, "servers", Server, fmt.Sprintf("%s.env", sanitisedAppName)) + err = ioutil.WriteFile(appEnvPath, envSample, 0755) + if err != nil { + logrus.Fatal(err) + } - // cp over env.sample and do some sed/replacing // generate secrets if asked to do so + if Secrets { + } + // save them in a pass store if asked to do so + if Pass { + } + // Output some instructions on how to deploy this thing return nil