WIP: another step further into app new command

This commit is contained in:
decentral1se 2021-07-30 20:14:17 +02:00
parent ac6b8ab147
commit f56ddef6c8
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -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