コード例 #1
0
ファイル: plugin.go プロジェクト: godrei/bitrise
func pluginInstall(c *cli.Context) error {
	// Input validation
	pluginSource := c.String("source")
	if pluginSource == "" {
		log.Fatal("Missing required input: source")
	}

	pluginBinary := c.String("bin-source")
	pluginVersionTag := c.String("version")

	// Install
	if pluginVersionTag == "" {
		log.Infof("=> Installing plugin from (%s) with latest version...", pluginSource)
	} else {
		log.Infof("=> Installing plugin (%s) with version (%s)...", pluginSource, pluginVersionTag)
	}

	plugin, version, err := plugins.InstallPlugin(pluginSource, pluginBinary, pluginVersionTag)
	if err != nil {
		log.Fatalf("Failed to install plugin from (%s), error: %s", pluginSource, err)
	}

	fmt.Println()
	log.Infoln(colorstring.Greenf("Plugin (%s) with version (%s) installed ", plugin.Name, version))

	if len(plugin.Description) > 0 {
		fmt.Println()
		fmt.Println(plugin.Description)
		fmt.Println()
	}

	return nil
}
コード例 #2
0
ファイル: audit.go プロジェクト: viktorbenei/stepman
func auditStepLibBeforeSharePullRequest(gitURI string) error {
	if exist, err := stepman.RootExistForCollection(gitURI); err != nil {
		return err
	} else if !exist {
		return fmt.Errorf("Missing routing for collection, call 'stepman setup -c %s' before audit.", gitURI)
	}

	collection, err := stepman.ReadStepSpec(gitURI)
	if err != nil {
		return err
	}

	for stepID, stepGroup := range collection.Steps {
		log.Debugf("Start audit StepGrup, with ID: (%s)", stepID)
		for version, step := range stepGroup.Versions {
			log.Debugf("Start audit Step (%s) (%s)", stepID, version)
			if err := auditStepModelBeforeSharePullRequest(step, stepID, version); err != nil {
				log.Errorf(" * "+colorstring.Redf("[FAILED] ")+"Failed audit (%s) (%s)", stepID, version)
				return fmt.Errorf("   Error: %s", err.Error())
			}
			log.Infof(" * "+colorstring.Greenf("[OK] ")+"Success audit (%s) (%s)", stepID, version)
		}
	}
	return nil
}
コード例 #3
0
ファイル: share_create.go プロジェクト: bitrise-io/stepman
func printFinishCreate(share ShareModel, stepDirInSteplib string, toolMode bool) {
	fmt.Println()
	log.Infof(" * "+colorstring.Green("[OK]")+" Your Step (%s) (%s) added to local StepLib (%s).", share.StepID, share.StepTag, stepDirInSteplib)
	log.Infoln(" *      You can find your Step's step.yml at: " + colorstring.Greenf("%s/step.yml", stepDirInSteplib))
	fmt.Println()
	fmt.Println("   " + GuideTextForShareFinish(toolMode))
}
コード例 #4
0
ファイル: plugin_install.go プロジェクト: birmacher/bitrise
func pluginInstall(c *cli.Context) {
	// Input validation
	pluginSource := c.String("source")
	if pluginSource == "" {
		log.Fatalln("Missing required input: source")
	}

	pluginName := c.String("name")
	if pluginName == "" {
		log.Fatalf("Missing required input: name")
	}

	pluginType := c.String("type")
	if pluginType == "" {
		pluginType = plugins.TypeGeneric
	}

	// Install
	log.Infof("=> Installing plugin (%s)...", plugins.PrintableName(pluginName, pluginType))
	printableName, err := plugins.InstallPlugin(c.App.Version, pluginSource, pluginName, pluginType)
	if err != nil {
		log.Fatalf("Failed to install plugin, err: %s", err)
	}
	fmt.Println()
	log.Infoln(colorstring.Greenf("Plugin (%s) installed", printableName))
}
コード例 #5
0
func createChangelog(c *cli.Context) {
	//
	// Build config
	config := releaseman.Config{}
	configPath := ""
	if c.IsSet("config") {
		configPath = c.String("config")
	} else {
		configPath = releaseman.DefaultConfigPth
	}

	if exist, err := pathutil.IsPathExists(configPath); err != nil {
		log.Warnf("Failed to check if path exist, error: %#v", err)
	} else if exist {
		config, err = releaseman.NewConfigFromFile(configPath)
		if err != nil {
			log.Fatalf("Failed to parse release config at (%s), error: %#v", configPath, err)
		}
	}

	config, err := collectChangelogConfigParams(config, c)
	if err != nil {
		log.Fatalf("Failed to collect config params, error: %#v", err)
	}

	//
	// Validate config
	config.Print(releaseman.ChangelogMode)

	if !releaseman.IsCIMode {
		ok, err := goinp.AskForBoolWithDefault("Are you ready for creating Changelog?", true)
		if err != nil {
			log.Fatalf("Failed to ask for input, error: %s", err)
		}
		if !ok {
			log.Fatal("Aborted create Changelog")
		}
	}

	//
	// Run set version script
	if c.IsSet(SetVersionScriptKey) {
		setVersionScript := c.String(SetVersionScriptKey)
		if err := runSetVersionScript(setVersionScript, config.Release.Version); err != nil {
			log.Fatalf("Failed to run set version script, error: %#v", err)
		}
	}

	//
	// Generate Changelog
	generateChangelog(config)

	fmt.Println()
	log.Infoln(colorstring.Greenf("v%s Changelog created (%s) 🚀", config.Release.Version, config.Changelog.Path))
}
コード例 #6
0
ファイル: setup.go プロジェクト: birmacher/bitrise
// PrintBitriseHeaderASCIIArt ...
func PrintBitriseHeaderASCIIArt(appVersion string) {
	// generated here: http://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Bitrise
	fmt.Println(`
  ██████╗ ██╗████████╗██████╗ ██╗███████╗███████╗
  ██╔══██╗██║╚══██╔══╝██╔══██╗██║██╔════╝██╔════╝
  ██████╔╝██║   ██║   ██████╔╝██║███████╗█████╗
  ██╔══██╗██║   ██║   ██╔══██╗██║╚════██║██╔══╝
  ██████╔╝██║   ██║   ██║  ██║██║███████║███████╗
  ╚═════╝ ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝╚══════╝╚══════╝`)
	fmt.Println()
	fmt.Println(colorstring.Greenf("Version: %s", appVersion))
	fmt.Println()
}
コード例 #7
0
ファイル: validate.go プロジェクト: birmacher/bitrise
func printRawValidation(validation ValidationModel) error {
	validConfig := true
	if validation.Config != nil {
		fmt.Println(colorstring.Blue("Config validation result:"))
		configValidation := *validation.Config
		if configValidation.IsValid {
			fmt.Printf("is valid: %s\n", colorstring.Greenf("%v", configValidation.IsValid))
		} else {
			fmt.Printf("is valid: %s\n", colorstring.Redf("%v", configValidation.IsValid))
			fmt.Printf("error: %s\n", colorstring.Red(configValidation.Error))

			validConfig = false
		}
		fmt.Println()
	}

	validSecrets := true
	if validation.Secrets != nil {
		fmt.Println(colorstring.Blue("Secret validation result:"))
		secretValidation := *validation.Secrets
		if secretValidation.IsValid {
			fmt.Printf("is valid: %s\n", colorstring.Greenf("%v", secretValidation.IsValid))
		} else {
			fmt.Printf("is valid: %s\n", colorstring.Redf("%v", secretValidation.IsValid))
			fmt.Printf("error: %s\n", colorstring.Red(secretValidation.Error))

			validSecrets = false
		}
	}

	if !validConfig && !validSecrets {
		return errors.New("Config and secrets are invalid")
	} else if !validConfig {
		return errors.New("Config is invalid")
	} else if !validSecrets {
		return errors.New("Secret is invalid")
	}
	return nil
}
コード例 #8
0
ファイル: validate.go プロジェクト: bitrise-io/bitrise
// String ...
func (v ValidationModel) String() string {
	msg := ""

	if v.Config != nil {
		config := *v.Config
		if config.IsValid {
			msg += fmt.Sprintf("Config is valid: %s", colorstring.Greenf("%v", true))
		} else {
			msg += fmt.Sprintf("Config is valid: %s", colorstring.Redf("%v", false))
			msg += fmt.Sprintf("\nError: %s", colorstring.Red(config.Error))
		}

		if len(config.Warnings) > 0 {
			msg += "\nWarning(s):\n"
			for i, warning := range config.Warnings {
				msg += fmt.Sprintf("- %s", warning)
				if i != len(config.Warnings)-1 {
					msg += "\n"
				}
			}
		}
	}

	if v.Secrets != nil {
		if v.Config != nil {
			msg += "\n"
		}

		secret := *v.Secrets
		if secret.IsValid {
			msg += fmt.Sprintf("Secret is valid: %s", colorstring.Greenf("%v", true))
		} else {
			msg += fmt.Sprintf("Secret is valid: %s", colorstring.Redf("%v", false))
			msg += fmt.Sprintf("\nError: %s", colorstring.Red(secret.Error))
		}
	}

	return msg
}
コード例 #9
0
ファイル: plugin.go プロジェクト: bitrise-io/bitrise
func pluginUpdate(c *cli.Context) error {
	// Input validation
	if len(c.Args()) == 0 {
		log.Fatal("Missing plugin name")
	}

	name := c.Args()[0]
	if name == "" {
		log.Fatal("Missing plugin name")
	}

	plugin, found, err := plugins.LoadPlugin(name)
	if err != nil {
		log.Fatalf("Failed to check if plugin (%s) installed, error: %s", name, err)
	} else if !found {
		log.Fatalf("Plugin (%s) is not installed", name)
	}

	// Check for new version
	if newVersion, err := plugins.CheckForNewVersion(plugin); err != nil {
		log.Fatalf("Failed to check for plugin (%s) new version, error: %s", plugin.Name, err)
	} else if newVersion != "" {
		log.Infof("Installing new version (%s) of plugin (%s)", newVersion, plugin.Name)

		route, found, err := plugins.ReadPluginRoute(plugin.Name)
		if err != nil {
			log.Fatalf("Failed to read plugin route, error: %s", err)
		}
		if !found {
			log.Fatalf("no route found for already loaded plugin (%s)", plugin.Name)
		}

		plugin, version, err := plugins.InstallPlugin(route.Source, newVersion)
		if err != nil {
			log.Fatalf("Failed to install plugin from (%s), error: %s", route.Source, err)
		}

		fmt.Println()
		log.Infoln(colorstring.Greenf("Plugin (%s) with version (%s) installed ", plugin.Name, version))

		if len(plugin.Description) > 0 {
			fmt.Println()
			fmt.Println(plugin.Description)
			fmt.Println()
		}
	} else {
		log.Info("No new version available")
	}

	return nil
}
コード例 #10
0
ファイル: audit.go プロジェクト: bitrise-io/stepman
func audit(c *cli.Context) error {
	// Input validation
	beforePR := c.Bool("before-pr")

	collectionURI := c.String("collection")
	if collectionURI != "" {
		if beforePR {
			log.Warnln("before-pr flag is used only for Step audit")
		}

		if err := auditStepLibBeforeSharePullRequest(collectionURI); err != nil {
			log.Fatalf("Audit Step Collection failed, err: %s", err)
		}
	} else {
		stepYMLPath := c.String("step-yml")
		if stepYMLPath != "" {
			if exist, err := pathutil.IsPathExists(stepYMLPath); err != nil {
				log.Fatalf("Failed to check path (%s), err: %s", stepYMLPath, err)
			} else if !exist {
				log.Fatalf("step.yml doesn't exist at: %s", stepYMLPath)
			}

			if beforePR {
				if err := auditStepBeforeSharePullRequest(stepYMLPath); err != nil {
					log.Fatalf("Step audit failed, err: %s", err)
				}
			} else {
				if err := auditStepBeforeShare(stepYMLPath); err != nil {
					log.Fatalf("Step audit failed, err: %s", err)
				}
			}

			log.Infof(" * "+colorstring.Greenf("[OK] ")+"Success audit (%s)", stepYMLPath)
		} else {
			log.Fatalln("'stepman audit' command needs --collection or --step-yml flag")
		}
	}

	return nil
}
コード例 #11
0
ファイル: plugin.go プロジェクト: bitrise-io/bitrise
func pluginDelete(c *cli.Context) error {
	// Input validation
	if len(c.Args()) == 0 {
		log.Fatal("Missing plugin name")
	}

	name := c.Args()[0]
	if name == "" {
		log.Fatal("Missing plugin name")
	}

	if _, found, err := plugins.LoadPlugin(name); err != nil {
		log.Fatalf("Failed to check if plugin (%s) installed, error: %s", name, err)
	} else if !found {
		log.Fatalf("Plugin (%s) is not installed", name)
	}

	versionPtr, err := plugins.GetPluginVersion(name)
	if err != nil {
		log.Fatalf("Failed to read plugin (%s) version, error: %s", name, err)
	}

	// Delete
	version := "local"
	if versionPtr != nil {
		version = versionPtr.String()
	}
	log.Infof("=> Deleting plugin (%s) with version (%s) ...", name, version)
	if err := plugins.DeletePlugin(name); err != nil {
		log.Fatalf("Failed to delete plugin (%s) with version (%s), error: %s", name, version, err)
	}

	fmt.Println()
	log.Infof(colorstring.Greenf("Plugin (%s) with version (%s) deleted", name, version))

	return nil
}
コード例 #12
0
func create(c *cli.Context) {
	//
	// Fail if git is not clean
	if err := ensureCleanGit(); err != nil {
		log.Fatalf("Ensure clean git failed, error: %#v", err)
	}

	//
	// Build config
	config := releaseman.Config{}
	configPath := ""
	if c.IsSet("config") {
		configPath = c.String("config")
	} else {
		configPath = releaseman.DefaultConfigPth
	}

	if exist, err := pathutil.IsPathExists(configPath); err != nil {
		log.Warnf("Failed to check if path exist, error: %#v", err)
	} else if exist {
		config, err = releaseman.NewConfigFromFile(configPath)
		if err != nil {
			log.Fatalf("Failed to parse release config at (%s), error: %#v", configPath, err)
		}
	}

	config, err := collectConfigParams(config, c)
	if err != nil {
		log.Fatalf("Failed to collect config params, error: %#v", err)
	}

	printRollBackMessage()

	//
	// Validate config
	config.Print(releaseman.FullMode)

	if !releaseman.IsCIMode {
		ok, err := goinp.AskForBoolWithDefault("Are you ready for release?", true)
		if err != nil {
			log.Fatalf("Failed to ask for input, error: %s", err)
		}
		if !ok {
			log.Fatal("Aborted release")
		}
	}

	//
	// Run set version script
	if c.IsSet(SetVersionScriptKey) {
		setVersionScript := c.String(SetVersionScriptKey)
		if err := runSetVersionScript(setVersionScript, config.Release.Version); err != nil {
			log.Fatalf("Failed to run set version script, error: %#v", err)
		}
	}

	//
	// Generate Changelog
	generateChangelog(config)

	//
	// Create release git changes
	generateRelease(config)

	fmt.Println()
	log.Infoln(colorstring.Greenf("v%s released 🚀", config.Release.Version))
	log.Infoln("Take a look at your git, and if you are happy with the release, push the changes.")
}