Example #1
0
File: run.go Project: dyweb/Ayi
	Use:   "run",
	Short: "run user defined commands in scripts block",
	Long:  "run user defined commands in .ayi.yml's scripts block. ie: Ayi run build",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 1 {
			log.Error("Must specify command to run! ie: Ayi run build")
			listAllScripts()
			os.Exit(1)
		}
		hasScripts := viper.IsSet("scripts")
		if !hasScripts {
			log.Error("run configuration not found!")
			os.Exit(1)
		}
		scriptName := args[0]
		_, err := runner.ExecuteCommand(scriptName)
		if err != nil {
			log.Error(err.Error())
			log.Error("script failed")
			os.Exit(1)
		}
		log.Info("script finished")
	},
}

func listAllScripts() {
	scripts := viper.GetStringMapString("scripts")
	log.Info("all avaliable scripts are listed below")
	for name := range scripts {
		fmt.Println(name)
	}
Example #2
0
package cmd

import (
	"os"

	"github.com/spf13/cobra"

	"github.com/dyweb/Ayi/util/runner"
)

var depInstallCmd = &cobra.Command{
	Use:   "dep-install",
	Short: "install dependencies configured in .ayi.yml",
	Long:  "install required libraries and runtimes, auto detect composer.json package.json",
	Run: func(cmd *cobra.Command, args []string) {
		count, err := runner.ExecuteCommand("dep-install")
		if err != nil {
			log.Error(err.Error())
			log.Error("install failed")
			os.Exit(1)
		}
		log.Infof("All %d dependency install commands finished", count)
	},
}

func init() {
	RootCmd.AddCommand(depInstallCmd)

}
Example #3
0
File: install.go Project: dyweb/Ayi
package cmd

import (
	"os"

	"github.com/spf13/cobra"

	"github.com/dyweb/Ayi/util/runner"
)

var installCmd = &cobra.Command{
	Use:   "install",
	Short: "build and install binary",
	Long:  "build and install binary following commands defined in install block in .ayi.yml",
	Run: func(cmd *cobra.Command, args []string) {
		_, err := runner.ExecuteCommand("install")
		if err != nil {
			log.Error(err.Error())
			log.Error("install failed")
			os.Exit(1)
		}
	},
}

func init() {
	RootCmd.AddCommand(installCmd)

}
Example #4
0
File: test.go Project: dyweb/Ayi
package cmd

import (
	"os"

	"github.com/spf13/cobra"

	"github.com/dyweb/Ayi/util/runner"
)

var testCmd = &cobra.Command{
	Use:   "test",
	Short: "run test configured in .ayi.yml",
	Long:  "run user defined test commands in .ayi.yml",
	Run: func(cmd *cobra.Command, args []string) {
		count, err := runner.ExecuteCommand("test")
		if err != nil {
			log.Error(err.Error())
			log.Error("test failed")
			os.Exit(1)
		}
		log.Infof("All %d test commands have passed", count)
	},
}

func init() {
	RootCmd.AddCommand(testCmd)

}