|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"path"
|
|
|
|
|
"slices"
|
|
|
|
|
|
|
|
|
|
"coopcloud.tech/abra/cli/internal"
|
|
|
|
|
"coopcloud.tech/abra/pkg/autocomplete"
|
|
|
|
@ -61,52 +62,48 @@ keys configured on your account.`,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
repos, err := recipe.ReadReposMetadata()
|
|
|
|
|
repos, err := recipe.ReadReposMetadata(internal.Debug)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var barLength int
|
|
|
|
|
var logMsg string
|
|
|
|
|
barLength := len(repos)
|
|
|
|
|
if recipeName != "" {
|
|
|
|
|
barLength = 1
|
|
|
|
|
logMsg = fmt.Sprintf("ensuring %v recipe is cloned & up-to-date", barLength)
|
|
|
|
|
} else {
|
|
|
|
|
barLength = len(repos)
|
|
|
|
|
logMsg = fmt.Sprintf("ensuring %v recipes are cloned & up-to-date, this could take some time...", barLength)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !skipUpdates {
|
|
|
|
|
log.Warn(logMsg)
|
|
|
|
|
if err := recipe.UpdateRepositories(repos, recipeName); err != nil {
|
|
|
|
|
if err := recipe.UpdateRepositories(repos, recipeName, internal.Debug); err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var warnings []string
|
|
|
|
|
catl := make(recipe.RecipeCatalogue)
|
|
|
|
|
catlBar := formatter.CreateProgressbar(barLength, "generating catalogue metadata...")
|
|
|
|
|
catlBar := formatter.CreateProgressbar(barLength, "collecting catalogue metadata")
|
|
|
|
|
for _, recipeMeta := range repos {
|
|
|
|
|
if recipeName != "" && recipeName != recipeMeta.Name {
|
|
|
|
|
catlBar.Add(1)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NOTE(d1): the "example" recipe is a temporary special case
|
|
|
|
|
// https://git.coopcloud.tech/toolshed/organising/issues/666
|
|
|
|
|
if recipeMeta.Name == "example" {
|
|
|
|
|
catlBar.Add(1)
|
|
|
|
|
if !internal.Debug {
|
|
|
|
|
catlBar.Add(1)
|
|
|
|
|
}
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r := recipe.Get(recipeMeta.Name)
|
|
|
|
|
versions, err := r.GetRecipeVersions()
|
|
|
|
|
versions, warnMsgs, err := r.GetRecipeVersions()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Warn(err)
|
|
|
|
|
warnings = append(warnings, err.Error())
|
|
|
|
|
}
|
|
|
|
|
if len(warnMsgs) > 0 {
|
|
|
|
|
warnings = append(warnings, warnMsgs...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
features, category, err := recipe.GetRecipeFeaturesAndCategory(r)
|
|
|
|
|
features, category, warnMsgs, err := recipe.GetRecipeFeaturesAndCategory(r)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Warn(err)
|
|
|
|
|
warnings = append(warnings, err.Error())
|
|
|
|
|
}
|
|
|
|
|
if len(warnMsgs) > 0 {
|
|
|
|
|
warnings = append(warnings, warnMsgs...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catl[recipeMeta.Name] = recipe.RecipeMeta{
|
|
|
|
@ -122,7 +119,24 @@ keys configured on your account.`,
|
|
|
|
|
Features: features,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catlBar.Add(1)
|
|
|
|
|
if !internal.Debug {
|
|
|
|
|
catlBar.Add(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := catlBar.Close(); err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var uniqueWarnings []string
|
|
|
|
|
for _, w := range warnings {
|
|
|
|
|
if !slices.Contains(uniqueWarnings, w) {
|
|
|
|
|
uniqueWarnings = append(uniqueWarnings, w)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, warnMsg := range uniqueWarnings {
|
|
|
|
|
log.Warn(warnMsg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recipesJSON, err := json.MarshalIndent(catl, "", " ")
|
|
|
|
@ -152,7 +166,7 @@ keys configured on your account.`,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Infof("generated new recipe catalogue in %s", config.RECIPES_JSON)
|
|
|
|
|
log.Infof("generated recipe catalogue: %s", config.RECIPES_JSON)
|
|
|
|
|
|
|
|
|
|
cataloguePath := path.Join(config.ABRA_DIR, "catalogue")
|
|
|
|
|
if publishChanges {
|
|
|
|
|