Exemple #1
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
	}

	remotePlugins, err2 := s.ListAllPlugins(c.GlobalString("repo"))

	if err2 != nil {
		return err2
	}

	for _, v := range remotePlugins.Plugins {
		if localPlugin.Id == v.Id {
			if ShouldUpgrade(localPlugin.Info.Version, v) {
				s.RemoveInstalledPlugin(pluginsDir, pluginName)
				return InstallPlugin(localPlugin.Id, "", c)
			}
		}
	}

	return nil
}
Exemple #2
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
}
func InstallPlugin(pluginName, version string, c CommandLine) error {
	plugin, err := s.GetPlugin(pluginName, c.RepoDirectory())
	pluginFolder := c.PluginDirectory()
	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)

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

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

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

	res, _ := s.ReadPlugin(pluginFolder, pluginName)
	for _, v := range res.Dependencies.Plugins {
		InstallPlugin(v.Id, version, c)
		logger.Infof("Installed dependency: %v ✔\n", v.Id)
	}

	return err
}
Exemple #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
}