Sha256: fa80734c1bf7bccb9cbd4e68df950282f3f7ed1ca3739c7e942e8dfbef4813e8

Contents?: true

Size: 1.18 KB

Versions: 658

Compression:

Stored size: 1.18 KB

Contents

require 'fastlane/server/action_command.rb'
require 'fastlane/server/control_command.rb'
require 'json'

module Fastlane
  class CommandParser
    def self.parse(json: nil)
      if json.strip == "done"
        return intercept_old_done_command
      end

      command_json = JSON.parse(json)
      command_type_json = command_json['commandType']

      if command_type_json.nil?
        # Old Swift style (needs upgrade)
        return handle_old_style_action_command(command_json: command_json)
      else
        # New Swift command style
        return handle_new_style_commands(command_json: command_json)
      end
    end

    def self.handle_new_style_commands(command_json: nil)
      command_type = command_json['commandType'].to_sym
      command = command_json['command']

      case command_type
      when :action
        return ActionCommand.new(json: command)
      when :control
        return ControlCommand.new(json: command)
      end
    end

    def self.handle_old_style_action_command(command_json: nil)
      return ActionCommand.new(json: command_json)
    end

    def self.intercept_old_done_command
      return ControlCommand.new(json: '{"command":"done"}')
    end
  end
end

Version data entries

658 entries across 658 versions & 5 rubygems

Version Path
fastlane-2.226.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.225.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.224.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.223.1 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.223.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.222.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.221.1 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.221.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.220.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.219.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.218.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-security-patched-2.216.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.217.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.216.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.215.1 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.215.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-mercafacil-2.214.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.214.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.213.0 fastlane/lib/fastlane/server/command_parser.rb
fastlane-2.212.2 fastlane/lib/fastlane/server/command_parser.rb