forked from toolshed/abra
WIP: the beginning of catalogue generation
See coop-cloud/organising#159.
This commit is contained in:
41
cli/catalogue/generate.go
Normal file
41
cli/catalogue/generate.go
Normal file
@ -0,0 +1,41 @@
|
||||
package catalogue
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/git"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var catalogueGenerateCommand = &cli.Command{
|
||||
Name: "generate",
|
||||
Aliases: []string{"g"},
|
||||
Usage: "Generate a new copy of the catalogue",
|
||||
BashComplete: func(c *cli.Context) {},
|
||||
Action: func(c *cli.Context) error {
|
||||
catl, err := catalogue.ReadRecipeCatalogue()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
for recipeName, recipeMeta := range catl {
|
||||
recipeDir := path.Join(config.ABRA_DIR, "apps", strings.ToLower(recipeName))
|
||||
if err := git.Clone(recipeDir, recipeMeta.Repository); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := git.EnsureUpToDate(recipeDir); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// for reach app, build the recipemeta from parsing
|
||||
// spit out a JSON file
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user