示例#1
0
func upgradeAllCommand(c CommandLine) error {
	pluginsDir := c.PluginDirectory()

	localPlugins := s.GetLocalPlugins(pluginsDir)

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

	if err != nil {
		return err
	}

	pluginsToUpgrade := make([]m.InstalledPlugin, 0)

	for _, localPlugin := range localPlugins {
		for _, remotePlugin := range remotePlugins.Plugins {
			if localPlugin.Id == remotePlugin.Id {
				if ShouldUpgrade(localPlugin.Info.Version, remotePlugin) {
					pluginsToUpgrade = append(pluginsToUpgrade, localPlugin)
				}
			}
		}
	}

	for _, p := range pluginsToUpgrade {
		logger.Infof("Updating %v \n", p.Id)

		s.RemoveInstalledPlugin(pluginsDir, p.Id)
		InstallPlugin(p.Id, "", c)
	}

	return nil
}
示例#2
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
}
示例#3
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
}