fix: docs and fix for new recipes
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Closes coop-cloud/organising#228.
This commit is contained in:
parent
c76bd25c1d
commit
7022f42711
@ -1,6 +1,7 @@
|
|||||||
package recipe
|
package recipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -18,10 +19,27 @@ var recipeNewCommand = &cli.Command{
|
|||||||
Usage: "Create a new recipe",
|
Usage: "Create a new recipe",
|
||||||
Aliases: []string{"n"},
|
Aliases: []string{"n"},
|
||||||
ArgsUsage: "<recipe>",
|
ArgsUsage: "<recipe>",
|
||||||
Action: func(c *cli.Context) error {
|
Description: `
|
||||||
recipe := internal.ValidateRecipe(c)
|
This command creates a new recipe.
|
||||||
|
|
||||||
directory := path.Join(config.APPS_DIR, recipe.Name)
|
Abra uses our built-in example repository which is available here:
|
||||||
|
|
||||||
|
https://git.coopcloud.tech/coop-cloud/example
|
||||||
|
|
||||||
|
Files within the example repository make use of the Golang templating system
|
||||||
|
which Abra uses to inject values into the generated recipe folder (e.g. name of
|
||||||
|
recipe and domain in the sample environment config).
|
||||||
|
|
||||||
|
The new example repository is cloned to ~/.abra/apps/<recipe>.
|
||||||
|
`,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
recipeName := c.Args().First()
|
||||||
|
|
||||||
|
if recipeName == "" {
|
||||||
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
|
}
|
||||||
|
|
||||||
|
directory := path.Join(config.APPS_DIR, recipeName)
|
||||||
if _, err := os.Stat(directory); !os.IsNotExist(err) {
|
if _, err := os.Stat(directory); !os.IsNotExist(err) {
|
||||||
logrus.Fatalf("'%s' recipe directory already exists?", directory)
|
logrus.Fatalf("'%s' recipe directory already exists?", directory)
|
||||||
}
|
}
|
||||||
@ -31,16 +49,16 @@ var recipeNewCommand = &cli.Command{
|
|||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gitRepo := path.Join(config.APPS_DIR, recipe.Name, ".git")
|
gitRepo := path.Join(config.APPS_DIR, recipeName, ".git")
|
||||||
if err := os.RemoveAll(gitRepo); err != nil {
|
if err := os.RemoveAll(gitRepo); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
logrus.Debugf("removed git repo in '%s'", gitRepo)
|
logrus.Debugf("removed git repo in '%s'", gitRepo)
|
||||||
|
|
||||||
toParse := []string{
|
toParse := []string{
|
||||||
path.Join(config.APPS_DIR, recipe.Name, "README.md"),
|
path.Join(config.APPS_DIR, recipeName, "README.md"),
|
||||||
path.Join(config.APPS_DIR, recipe.Name, ".env.sample"),
|
path.Join(config.APPS_DIR, recipeName, ".env.sample"),
|
||||||
path.Join(config.APPS_DIR, recipe.Name, ".drone.yml"),
|
path.Join(config.APPS_DIR, recipeName, ".drone.yml"),
|
||||||
}
|
}
|
||||||
for _, path := range toParse {
|
for _, path := range toParse {
|
||||||
file, err := os.OpenFile(path, os.O_RDWR, 0755)
|
file, err := os.OpenFile(path, os.O_RDWR, 0755)
|
||||||
@ -59,14 +77,14 @@ var recipeNewCommand = &cli.Command{
|
|||||||
if err := tpl.Execute(file, struct {
|
if err := tpl.Execute(file, struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
}{recipe.Name, "TODO"}); err != nil {
|
}{recipeName, "TODO"}); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof(
|
logrus.Infof(
|
||||||
"new recipe '%s' created in %s, happy hacking!\n",
|
"new recipe '%s' created in %s, happy hacking!\n",
|
||||||
recipe.Name, path.Join(config.APPS_DIR, recipe.Name),
|
recipeName, path.Join(config.APPS_DIR, recipeName),
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user