Sha256: f95a033344ec13b19c9b49e9456127c44650ae69e9e3fb73cd3a8b3d86c43f05

Contents?: true

Size: 1.95 KB

Versions: 92

Compression:

Stored size: 1.95 KB

Contents

module Fastlane
  # Alert the user when updates for plugins are available
  class PluginUpdateManager
    def self.start_looking_for_updates
      return if FastlaneCore::Env.truthy?("FASTLANE_SKIP_UPDATE_CHECK")

      Thread.new do
        self.plugin_references.each do |plugin_name, current_plugin|
          begin
            self.server_results[plugin_name] = fetch_latest_version(plugin_name)
          rescue
          end
        end
      end
    end

    def self.show_update_status
      return if FastlaneCore::Env.truthy?("FASTLANE_SKIP_UPDATE_CHECK")

      # We set self.server_results to be nil
      # this way the table is not printed twice
      # (next to the summary table or when an exception happens)
      return unless self.server_results.count > 0

      rows = []
      self.plugin_references.each do |plugin_name, current_plugin|
        latest_version = self.server_results[plugin_name]
        next if latest_version.nil?
        current_version = Gem::Version.new(current_plugin[:version_number])
        next if current_version >= latest_version

        rows << [
          plugin_name.gsub(PluginManager.plugin_prefix, ''),
          current_version.to_s.red,
          latest_version.to_s.green
        ]
      end

      if rows.empty?
        UI.verbose("All plugins are up to date")
        return
      end

      puts Terminal::Table.new({
        rows: rows,
        title: "Plugin updates available".yellow,
        headings: ["Plugin", "Your Version", "Latest Version"]
      })
      UI.message "To update all plugins, just run"
      UI.command "fastlane update_plugins"
      puts ''
      @server_results = nil
    end

    def self.plugin_references
      Fastlane.plugin_manager.plugin_references
    end

    def self.fetch_latest_version(gem_name)
      Gem::Version.new(PluginManager.fetch_gem_info_from_rubygems(gem_name)["version"])
    rescue
      nil
    end

    def self.server_results
      @server_results ||= {}
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
fastlane-2.20.0.beta.20170307010029 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.2 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.20.0.beta.20170306010752 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.20.0.beta.20170305010057 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.20.0.beta.20170304010023 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.20.0.beta.20170303010054 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.20.0.beta.20170302010029 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.1 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170301010932 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170228010016 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170227010016 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170226010028 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170225010031 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170224010025 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.18.3 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170223010028 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.18.2 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.19.0.beta.20170222010016 fastlane/lib/fastlane/plugins/plugin_update_manager.rb
fastlane-2.18.1 fastlane/lib/fastlane/plugins/plugin_update_manager.rb