Ejemplo n.º 1
0
func InstallPlugin(pluginName, pluginFolder, version string) error {
	plugin, err := s.GetPlugin(pluginName)
	if err != nil {
		return err
	}

	v, err := SelectVersion(plugin, version)
	if err != nil {
		return err
	}

	url := v.Url
	commit := v.Commit

	downloadURL := url + "/archive/" + commit + ".zip"

	log.Infof("installing %v @ %v\n", plugin.Id, version)
	log.Infof("from url: %v\n", downloadURL)
	log.Infof("on commit: %v\n", commit)
	log.Infof("into: %v\n", pluginFolder)

	err = downloadFile(plugin.Id, pluginFolder, downloadURL)
	if err == nil {
		log.Infof("Installed %v successfully ✔\n", plugin.Id)
	}

	res, _ := s.ReadPlugin(pluginFolder, pluginName)

	for _, v := range res.Dependency.Plugins {
		InstallPlugin(v.Id, pluginFolder, "")
		log.Infof("Installed Dependency: %v ✔\n", v.Id)
	}

	return err
}
Ejemplo n.º 2
0
func listversionsCommand(c CommandLine) error {
	if err := validateVersionInput(c); err != nil {
		return err
	}

	pluginToList := c.Args().First()

	plugin, err := s.GetPlugin(pluginToList, c.GlobalString("repo"))
	if err != nil {
		return err
	}

	for _, i := range plugin.Versions {
		logger.Infof("%v\n", i.Version)
	}

	return nil
}
Ejemplo n.º 3
0
func InstallPlugin(pluginName, version string, c CommandLine) error {
	plugin, err := s.GetPlugin(pluginName, c.GlobalString("repo"))
	pluginFolder := c.GlobalString("pluginsDir")
	if err != nil {
		return err
	}

	v, err := SelectVersion(plugin, version)
	if err != nil {
		return err
	}

	if version == "" {
		version = v.Version
	}

	downloadURL := fmt.Sprintf("%s/%s/versions/%s/download",
		c.GlobalString("repo"),
		pluginName,
		version)

	log.Infof("installing %v @ %v\n", plugin.Id, version)
	log.Infof("from url: %v\n", downloadURL)
	log.Infof("into: %v\n", pluginFolder)
	log.Info("\n")

	err = downloadFile(plugin.Id, pluginFolder, downloadURL)
	if err != nil {
		return err
	}

	log.Infof("%s Installed %s successfully \n", color.GreenString("✔"), plugin.Id)

	/* Enable once we need support for downloading depedencies
	res, _ := s.ReadPlugin(pluginFolder, pluginName)
	for _, v := range res.Dependency.Plugins {
		InstallPlugin(v.Id, version, c)
		log.Infof("Installed dependency: %v ✔\n", v.Id)
	}
	*/
	return err
}
Ejemplo n.º 4
0
func upgradeCommand(c CommandLine) error {
	pluginsDir := c.GlobalString("pluginsDir")
	pluginName := c.Args().First()

	localPlugin, err := s.ReadPlugin(pluginsDir, pluginName)

	if err != nil {
		return err
	}

	v, err2 := s.GetPlugin(localPlugin.Id, c.GlobalString("repo"))

	if err2 != nil {
		return err2
	}

	if ShouldUpgrade(localPlugin.Info.Version, v) {
		s.RemoveInstalledPlugin(pluginsDir, pluginName)
		return InstallPlugin(localPlugin.Id, "", c)
	}

	log.Infof("%s %s is up to date \n", color.GreenString("✔"), localPlugin.Id)
	return nil
}