コード例 #1
0
ファイル: clone.go プロジェクト: dyweb/Ayi
// Clone clones a remote git repo
func Clone(r Remote) (Repo, error) {
	// log.Info("git clone " + r.GetSSH() + " " + GetCloneDirectory(r))
	repo := Repo{Remote: r, LocalPath: GetCloneDirectory(r)}
	cmdStr := "git clone " + r.GetSSH() + " " + repo.LocalPath
	log.Info(cmdStr)
	err := util.RunCommand(cmdStr)
	if err != nil {
		// TODO: may wrap the error
		return repo, err
	}
	return repo, nil
}
コード例 #2
0
ファイル: runner.go プロジェクト: dyweb/Ayi
// ExecuteCommand look for configured command(s) and execute
// TODO: return value can have name, if my memory is correct
func ExecuteCommand(cmdName string) (int, error) {
	commands, err := LookUpCommands(cmdName)
	if err != nil {
		log.Warnf(err.Error())
		return 0, errors.Wrap(err, "Runner can't find commands")
	}
	success := 0
	for _, cmd := range commands {
		log.Infof("executing: %s \n", cmd)
		err := util.RunCommand(cmd)

		if err != nil {
			_, ok := err.(*util.DryRunError)
			if !ok {
				return success, errors.Errorf("%s failed due to: %s", cmdName, err.Error())
			}
		}
		success++
	}
	// TODO: may need to return dry run error here
	return len(commands), nil
}
コード例 #3
0
ファイル: update.go プロジェクト: dyweb/Ayi
import (
	"github.com/spf13/cobra"
	"github.com/spf13/viper"

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

var updateCmd = &cobra.Command{
	Use:   "update",
	Short: "update dependencies configured in .ayi.yml",
	Long:  "update required libraries and runtimes, auto detect composer.json package.json",
	Run: func(cmd *cobra.Command, args []string) {
		hasupdate := viper.IsSet("update")
		if !hasupdate {
			log.Warn("update configuration not found!")
			log.Errorf("TODO: looking for available commands")
			return
		}
		commands := viper.GetStringSlice("update")
		for _, cmd := range commands {
			log.Infof("executing: %s \n", cmd)
			util.RunCommand(cmd)
		}
	},
}

func init() {
	RootCmd.AddCommand(updateCmd)

}