<commit_before>require 'rubygems/spec_fetcher'
require 'rubygems/commands/update_command'

module Fastlane
  module Actions
    # Makes sure fastlane tools are up-to-date when running fastlane 
    class UpdateFastlaneAction < Action

      ALL_TOOLS = [
        "fastlane",
        "fastlane_core",
        "deliver",
        "snapshot",
        "frameit",
        "pem",
        "sigh",
        "produce",
        "cert",
        "codes",
        "credentials_manager"
      ]

      def self.run(options)

        tools_to_update = options[:tools]
        tools_to_update ||= all_installed_tools

        updater = Gem::Commands::UpdateCommand.new

        puts Fastlane::VERSION

        sudo_needed = !File.writable?(Gem.dir)

        if sudo_needed
          # TODO: Think up how to do this properly
          #Helper.log.info "Fastlane needs your password to update the fastlane-tools."
          #Action.sh "sudo gem update " + tools_to_update.join(" ")
        else
          highest_versions = updater.highest_installed_gems

          #suppress updater output - very noisy
          Gem::DefaultUserInteraction.ui = Gem::SilentUI.new

          tools_to_update.each do |tool| 
            updater.update_gem tool
          end

          any_updates = updater.updated.any? do |updated_tool|
            updated_tool.version > highest_versions[updated_tool.name].version
          end

          if any_updates
            Helper.log.info "fastlane.tools succesfully updated! I will now restart myself... 😴"
            exec "fastlane #{ARGV.join ' '}"
          else 
            Helper.log.info "All fastlane tools are up-to-date!"
          end
        end
      end

      def self.all_installed_tools
        Gem::Specification.select { |s| ALL_TOOLS.include? s.name }.map {|s| s.name}.uniq
      end

      def self.description
        "Makes sure fastlane-tools are up-to-date when running fastlane"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :tools,
                                       env_name: "FL_TOOLS_TO_UPDATE",
                                       description: "An array of the fastlane-tools to update. If not specified, all installed fastlane-tools will be updated",
                                       optional: true),
        ]
      end

      def self.author
        "milch"
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end
<commit_msg>Update available options to include FL_NO_UPDATE<commit_after>require 'rubygems/spec_fetcher'
require 'rubygems/commands/update_command'

module Fastlane
  module Actions
    # Makes sure fastlane tools are up-to-date when running fastlane 
    class UpdateFastlaneAction < Action

      ALL_TOOLS = [
        "fastlane",
        "fastlane_core",
        "deliver",
        "snapshot",
        "frameit",
        "pem",
        "sigh",
        "produce",
        "cert",
        "codes",
        "credentials_manager"
      ]

      def self.run(options)

        tools_to_update = options[:tools]
        tools_to_update ||= all_installed_tools

        updater = Gem::Commands::UpdateCommand.new

        puts Fastlane::VERSION

        sudo_needed = !File.writable?(Gem.dir)

        if sudo_needed
          # TODO: Think up how to do this properly
          #Helper.log.info "Fastlane needs your password to update the fastlane-tools."
          #Action.sh "sudo gem update " + tools_to_update.join(" ")
        else
          highest_versions = updater.highest_installed_gems

          #suppress updater output - very noisy
          Gem::DefaultUserInteraction.ui = Gem::SilentUI.new

          tools_to_update.each do |tool| 
            updater.update_gem tool
          end

          any_updates = updater.updated.any? do |updated_tool|
            updated_tool.version > highest_versions[updated_tool.name].version
          end

          if any_updates
            Helper.log.info "fastlane.tools succesfully updated! I will now restart myself... 😴"
            exec "fastlane #{ARGV.join ' '}"
          else 
            Helper.log.info "All fastlane tools are up-to-date!"
          end
        end
      end

      def self.all_installed_tools
        Gem::Specification.select { |s| ALL_TOOLS.include? s.name }.map {|s| s.name}.uniq
      end

      def self.description
        "Makes sure fastlane-tools are up-to-date when running fastlane"
      end

      def self.available_options
        [
          FastlaneCore::ConfigItem.new(key: :tools,
                                       env_name: "FL_TOOLS_TO_UPDATE",
                                       description: "Comma separated list of fastlane tools to update (e.g. fastlane,deliver,sigh). If not specified, all currently installed fastlane-tools will be updated",
                                       optional: true),
         FastlaneCore::ConfigItem.new(key: :no_update,
                                      env_name: "FL_NO_UPDATE",
                                      description: "Don't update during this run. Defaults to false",
                                      is_string: false,
                                      default_value: false),
        ]
      end

      def self.author
        "milch"
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07997762863534676, 'fraction_numerical': 0.0, 'mean_word_length': 1.7247333671914677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4214783', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1461, 'n_words': 374}