33 lines
1020 B
Go
33 lines
1020 B
Go
package cli
|
|
|
|
import (
|
|
"gitea-mail-templates/tools/builder"
|
|
"gitea-mail-templates/tools/logging"
|
|
"gitea-mail-templates/tools/upstream"
|
|
"github.com/urfave/cli/v2"
|
|
"path/filepath"
|
|
)
|
|
|
|
func BuildCommand() *cli.Command {
|
|
return &cli.Command{Name: "build", Usage: "Generate installable themes from locked official inputs and shared controls", Flags: []cli.Flag{&cli.StringFlag{Name: "folder", Value: "../themes"}}, Action: func(c *cli.Context) error {
|
|
s, err := upstream.Prepare(c.Context, filepath.Dir(c.String("folder")))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
filter, err := builder.Filter(c.Args().Slice())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
packages, err := builder.BuildAll(c.String("folder"), s, filter)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
output := filepath.Join(filepath.Dir(c.String("folder")), "build", "themes")
|
|
if err := builder.Write(output, s, packages); err != nil {
|
|
return err
|
|
}
|
|
logging.Info("Builder", "Built %d themes for %s at %s", len(packages), s.Lock.Tag, output)
|
|
return nil
|
|
}}
|
|
}
|