build

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:    "build",
	Usage:   "Builds the current project",
	Aliases: []string{"b"},
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "config", Aliases: []string{"c"}, Value: ".rain.yml", Usage: "Load configuration from file"},
		&cli.IntFlag{Name: "parallelism", Value: 2, Usage: "number of tasks running concurrently"},
		&cli.DurationFlag{Name: "timeout", Value: 10 * time.Minute, Usage: "timeout to the entire push process", DefaultText: "10 minutes"},
		&cli.BoolFlag{Name: "rm-dist", Value: false, Usage: "remove the dist folder before build"},
	},
	Action: func(c *cli.Context) error {
		start := time.Now()
		log.Infof(color.New(color.Bold).Sprint("building..."))

		conf := c.String("config")
		cfg, err := config.Load(conf)
		if err != nil {
			return err
		}
		ctx, cancel := context.NewWithTimeout(cfg, c.Duration("timeout"))
		defer cancel()
		setupPushContext(ctx, c)
		err = ctrlc.Default.Run(ctx, func() error {
			for _, pipe := range pipeline.BuildPipeline {
				if err := middleware.Log(
					pipe.String(),
					middleware.ErrHandler(pipe.Run),
					middleware.DefaultInitialPadding,
				)(ctx); err != nil {
					return err
				}
			}
			return nil
		})
		if err != nil {
			return errors.Wrap(err, color.New(color.Bold).Sprintf("build failed after %0.2fs", time.Since(start).Seconds()))
		}

		log.Infof(color.New(color.Bold).Sprintf("build succeeded after %0.2fs", time.Since(start).Seconds()))
		return nil
	},
}

Command build

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL