fastlane 2.73.0 → 2.74.0.beta.20180106010004

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/deliver/lib/assets/summary.html.erb +2 -1
  3. data/fastlane/lib/fastlane.rb +0 -2
  4. data/fastlane/lib/fastlane/commands_generator.rb +5 -2
  5. data/fastlane/lib/fastlane/lane_manager.rb +0 -45
  6. data/fastlane/lib/fastlane/lane_manager_base.rb +4 -4
  7. data/fastlane/lib/fastlane/runner.rb +4 -0
  8. data/fastlane/lib/fastlane/server/{command.rb → action_command.rb} +16 -25
  9. data/fastlane/lib/fastlane/server/action_command_return.rb +14 -0
  10. data/fastlane/lib/fastlane/server/command_executor.rb +0 -2
  11. data/fastlane/lib/fastlane/server/command_parser.rb +20 -0
  12. data/fastlane/lib/fastlane/server/control_command.rb +23 -0
  13. data/fastlane/lib/fastlane/server/json_return_value_processor.rb +71 -0
  14. data/fastlane/lib/fastlane/server/socket_server.rb +111 -112
  15. data/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb +4 -3
  16. data/fastlane/lib/fastlane/swift_lane_manager.rb +17 -6
  17. data/fastlane/lib/fastlane/version.rb +1 -1
  18. data/fastlane/swift/ControlCommand.swift +71 -0
  19. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +8 -0
  20. data/fastlane/swift/LaneFileProtocol.swift +55 -27
  21. data/fastlane/swift/RubyCommand.swift +3 -6
  22. data/fastlane/swift/RubyCommandable.swift +38 -0
  23. data/fastlane/swift/Runner.swift +6 -3
  24. data/fastlane/swift/SocketClient.swift +43 -27
  25. data/fastlane/swift/SocketResponse.swift +7 -2
  26. data/fastlane/swift/main.swift +5 -3
  27. metadata +24 -24
  28. data/fastlane/lib/.DS_Store +0 -0
  29. data/fastlane/lib/assets/.DS_Store +0 -0
  30. data/fastlane/lib/fastlane/.DS_Store +0 -0
  31. data/fastlane/lib/fastlane/actions/.DS_Store +0 -0
  32. data/fastlane/lib/fastlane/actions/docs/.DS_Store +0 -0
  33. data/fastlane/lib/fastlane/setup/.DS_Store +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a60f5fe37ddce7931d25079c7d083ebe840b42a6
4
- data.tar.gz: b6438be238ba86f59e014453052abb76423e7502
3
+ metadata.gz: 244eb914f52a52b8114ccf2b46476f43d44ed56e
4
+ data.tar.gz: fd4ddc091bb00205542592c5925a9eaa66ff5116
5
5
  SHA512:
6
- metadata.gz: 6fe03b54f9eb4ebe997e9195326e325d7cb73ee08ed68b53ef3aa10c290338238cd388de7827c458aef55657eb020edccff47091fdcd2810745b6d4b103e0301
7
- data.tar.gz: 7bbe34f2689363834606058664d2584036a389e139035d004f9c0b9de26832859f64c892f2071727489cc189a1b21cb2dfcc1e7a013a60356e6b9441125b6425
6
+ metadata.gz: ee764b619920b915d8b7bc4958b758d47599d0f0af067bf9265801a63b933f671a3fcc9f71b823f8bc8647f4dea31603d19f4bab540ebc15fb8cdd978f33a0e7
7
+ data.tar.gz: 5a5fc60562c8d5b48acb9f9b880fd484c503d3e1a4b1bd84cae6434cfe609acb232a1bf7a9bc90e0370f01441385bf70d58a4e60316fdf5f2fcfd0fbbc3f5133
@@ -261,7 +261,8 @@
261
261
  </div>
262
262
 
263
263
  <hr />
264
- <% end # end data %>
264
+ <% end # end data
265
+ %>
265
266
  <% if @options[:trade_representative_contact_information] %>
266
267
  <div class="app-minor-information">
267
268
  <div class="cat-headline">Trade Representative Contact Information</div>
@@ -20,8 +20,6 @@ require 'fastlane/supported_platforms'
20
20
  require 'fastlane/configuration_helper'
21
21
  require 'fastlane/one_off'
22
22
  require 'fastlane/server/socket_server_action_command_executor'
23
- require 'fastlane/server/command_executor'
24
- require 'fastlane/server/command'
25
23
  require 'fastlane/server/socket_server'
26
24
  require 'fastlane/command_line_handler'
27
25
  require 'fastlane/documentation/docs_generator'
@@ -43,7 +43,10 @@ module Fastlane
43
43
  ensure
44
44
  Fastlane::PluginUpdateManager.show_update_status
45
45
  if FastlaneCore::Globals.capture_output?
46
- FastlaneCore::Globals.captured_output = Helper.strip_ansi_colors($stdout.string)
46
+ if $stdout.respond_to?(:string)
47
+ # Sometimes you can get NoMethodError: undefined method `string' for #<IO:<STDOUT>> when runing with FastlaneRunner (swift)
48
+ FastlaneCore::Globals.captured_output = Helper.strip_ansi_colors($stdout.string)
49
+ end
47
50
  $stdout = STDOUT
48
51
  $stderr = STDERR
49
52
 
@@ -87,7 +90,7 @@ module Fastlane
87
90
 
88
91
  global_option('--verbose') { FastlaneCore::Globals.verbose = true }
89
92
  global_option('--capture_output', 'Captures the output of the current run, and generates a markdown issue template') do
90
- FastlaneCore::Globals.capture_output = true
93
+ FastlaneCore::Globals.capture_output = false
91
94
  FastlaneCore::Globals.verbose = true
92
95
  end
93
96
  global_option('--troubleshoot', 'Enables extended verbose mode. Use with caution, as this even includes ALL sensitive data. Cannot be used on CI.')
@@ -68,7 +68,6 @@ module Fastlane
68
68
  Fastlane::DocsGenerator.run(ff) unless skip_docs?
69
69
 
70
70
  duration = ((Time.now - started) / 60.0).round
71
-
72
71
  finish_fastlane(ff, duration, e)
73
72
 
74
73
  return ff
@@ -78,50 +77,6 @@ module Fastlane
78
77
  Helper.test? || FastlaneCore::Env.truthy?("FASTLANE_SKIP_DOCS")
79
78
  end
80
79
 
81
- # All the finishing up that needs to be done
82
- def self.finish_fastlane(ff, duration, error)
83
- # Finished with all the lanes
84
- Fastlane::JUnitGenerator.generate(Fastlane::Actions.executed_actions)
85
- print_table(Fastlane::Actions.executed_actions)
86
-
87
- Fastlane::PluginUpdateManager.show_update_status
88
-
89
- if error
90
- UI.error 'fastlane finished with errors'
91
- raise error
92
- elsif duration > 5
93
- UI.success "fastlane.tools just saved you #{duration} minutes! 🎉"
94
- else
95
- UI.success 'fastlane.tools finished successfully 🎉'
96
- end
97
- end
98
-
99
- # Print a table as summary of the executed actions
100
- def self.print_table(actions)
101
- return if actions.count == 0
102
-
103
- require 'terminal-table'
104
-
105
- rows = []
106
- actions.each_with_index do |current, i|
107
- is_error_step = !current[:error].to_s.empty?
108
-
109
- name = current[:name][0..60]
110
- name = name.red if is_error_step
111
- index = i + 1
112
- index = "💥" if is_error_step
113
- rows << [index, name, current[:time].to_i]
114
- end
115
-
116
- puts ""
117
- puts Terminal::Table.new(
118
- title: "fastlane summary".green,
119
- headings: ["Step", "Action", "Time (in s)"],
120
- rows: FastlaneCore::PrintTable.transform_output(rows)
121
- )
122
- puts ""
123
- end
124
-
125
80
  # Lane chooser if user didn't provide a lane
126
81
  # @param platform: is probably nil, but user might have called `fastlane android`, and only wants to list those actions
127
82
  def self.choose_lane(ff, platform)
@@ -7,7 +7,7 @@ module Fastlane
7
7
  end
8
8
 
9
9
  # All the finishing up that needs to be done
10
- def self.finish_fastlane(ff, duration, error)
10
+ def self.finish_fastlane(ff, duration, error, skip_message: false)
11
11
  # Sometimes we don't have a fastfile because we're using Fastfile.swift
12
12
  unless ff.nil?
13
13
  ff.runner.did_finish
@@ -20,12 +20,12 @@ module Fastlane
20
20
  Fastlane::PluginUpdateManager.show_update_status
21
21
 
22
22
  if error
23
- UI.error 'fastlane finished with errors'
23
+ UI.error 'fastlane finished with errors' unless skip_message
24
24
  raise error
25
25
  elsif duration > 5
26
- UI.success "fastlane.tools just saved you #{duration} minutes! 🎉"
26
+ UI.success "fastlane.tools just saved you #{duration} minutes! 🎉" unless skip_message
27
27
  else
28
- UI.success 'fastlane.tools finished successfully 🎉'
28
+ UI.success 'fastlane.tools finished successfully 🎉' unless skip_message
29
29
  end
30
30
  end
31
31
 
@@ -347,6 +347,10 @@ module Fastlane
347
347
  @lanes ||= {}
348
348
  end
349
349
 
350
+ def did_finish
351
+ # to maintain compatibility with other sibling classes that have this API
352
+ end
353
+
350
354
  def before_each_blocks
351
355
  @before_each ||= {}
352
356
  end
@@ -1,6 +1,5 @@
1
- require 'json'
2
-
3
1
  module Fastlane
2
+ # Represents an argument to the ActionCommand
4
3
  class Argument
5
4
  def initialize(json: nil)
6
5
  @name = json['name']
@@ -25,19 +24,28 @@ module Fastlane
25
24
  attr_reader :value_type
26
25
  end
27
26
 
28
- class Command
27
+ # Represents a command that is meant to execute an Action on the client's behalf
28
+ class ActionCommand
29
+ attr_reader :command_id # always present
30
+ attr_reader :args # always present
31
+ attr_reader :method_name # always present
32
+ attr_reader :class_name # only present when executing a class-method
33
+
29
34
  def initialize(json: nil)
30
- command_json = JSON.parse(json)
31
- @method_name = command_json['methodName']
32
- @class_name = command_json['className']
33
- @command_id = command_json['commandID']
35
+ @method_name = json['methodName']
36
+ @class_name = json['className']
37
+ @command_id = json['commandID']
34
38
 
35
- args_json = command_json['args'] ||= []
39
+ args_json = json['args'] ||= []
36
40
  @args = args_json.map do |arg|
37
41
  Argument.new(json: arg)
38
42
  end
39
43
  end
40
44
 
45
+ def cancel_signal?
46
+ return @command_id == "cancelFastlaneRun"
47
+ end
48
+
41
49
  def target_class
42
50
  unless class_name
43
51
  return nil
@@ -49,22 +57,5 @@ module Fastlane
49
57
  def is_class_method_command
50
58
  return class_name.to_s.length > 0
51
59
  end
52
-
53
- attr_reader :command_id # always present
54
- attr_reader :args # always present
55
- attr_reader :method_name # always present
56
- attr_reader :class_name # only present when executing a class-method
57
- end
58
-
59
- class CommandReturn
60
- attr_reader :return_value
61
- attr_reader :return_value_type
62
- attr_reader :closure_argument_value
63
-
64
- def initialize(return_value: nil, return_value_type: nil, closure_argument_value: nil)
65
- @return_value = return_value
66
- @closure_argument_value = closure_argument_value
67
- @return_value_type = return_value_type
68
- end
69
60
  end
70
61
  end
@@ -0,0 +1,14 @@
1
+ module Fastlane
2
+ # Encapsulates the result and description of a return object returned by an executed fastlane action
3
+ class ActionCommandReturn
4
+ attr_reader :return_value
5
+ attr_reader :return_value_type
6
+ attr_reader :closure_argument_value
7
+
8
+ def initialize(return_value: nil, return_value_type: nil, closure_argument_value: nil)
9
+ @return_value = return_value
10
+ @closure_argument_value = closure_argument_value
11
+ @return_value_type = return_value_type
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,3 @@
1
- require 'fastlane/server/command.rb'
2
-
3
1
  module Fastlane
4
2
  class CommandExecutor
5
3
  def execute(command: nil, target_object: nil)
@@ -0,0 +1,20 @@
1
+ require 'fastlane/server/action_command.rb'
2
+ require 'fastlane/server/control_command.rb'
3
+ require 'json'
4
+
5
+ module Fastlane
6
+ class CommandParser
7
+ def self.parse(json: nil)
8
+ command_json = JSON.parse(json)
9
+ command_type = command_json['commandType'].to_sym
10
+ command = command_json['command']
11
+
12
+ case command_type
13
+ when :action
14
+ return ActionCommand.new(json: command)
15
+ when :control
16
+ return ControlCommand.new(json: command)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ module Fastlane
2
+ # Represents a command that is meant to signal the server to do something on the client's behalf
3
+ # Examples are: :cancelFastlaneRune, and :done
4
+ class ControlCommand
5
+ attr_reader :command
6
+ attr_reader :user_message
7
+ attr_reader :reason
8
+
9
+ def initialize(json: nil)
10
+ @command = json['command'].to_sym
11
+ @user_message = json['userMessage']
12
+ @reason = json['reason'].to_sym if json['reason']
13
+ end
14
+
15
+ def cancel_signal?
16
+ return @command == :cancelFastlaneRun
17
+ end
18
+
19
+ def done_signal?
20
+ return @command == :done
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,71 @@
1
+ require 'json'
2
+
3
+ module Fastlane
4
+ class JSONReturnValueProcessor
5
+ def prepare_object(return_value: nil, return_value_type: nil)
6
+ case return_value_type
7
+ when nil
8
+ UI.verbose("return_value_type is nil value: #{return_value}")
9
+ return process_value_as_string(return_value: return_value)
10
+ when :string
11
+ return process_value_as_string(return_value: return_value)
12
+ when :int
13
+ return process_value_as_int(return_value: return_value)
14
+ when :bool
15
+ return process_value_as_bool(return_value: return_value)
16
+ when :array_of_strings
17
+ return process_value_as_array_of_strings(return_value: return_value)
18
+ when :hash_of_strings
19
+ return process_value_as_hash_of_strings(return_value: return_value)
20
+ else
21
+ UI.verbose("Unknown return type defined: #{return_value_type} for value: #{return_value}")
22
+ return process_value_as_string(return_value: return_value)
23
+ end
24
+ end
25
+
26
+ def process_value_as_string(return_value: nil)
27
+ if return_value.nil?
28
+ return_value = ""
29
+ end
30
+
31
+ # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
32
+ return JSON.generate(return_value.to_s, quirks_mode: true)
33
+ end
34
+
35
+ def process_value_as_array_of_strings(return_value: nil)
36
+ if return_value.nil?
37
+ return_value = []
38
+ end
39
+
40
+ # quirks_mode shouldn't be required for real objects
41
+ return JSON.generate(return_value)
42
+ end
43
+
44
+ def process_value_as_hash_of_strings(return_value: nil)
45
+ if return_value.nil?
46
+ return_value = {}
47
+ end
48
+
49
+ # quirks_mode shouldn't be required for real objects
50
+ return JSON.generate(return_value)
51
+ end
52
+
53
+ def process_value_as_bool(return_value: nil)
54
+ if return_value.nil?
55
+ return_value = false
56
+ end
57
+
58
+ # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
59
+ return JSON.generate(return_value.to_s, quirks_mode: true)
60
+ end
61
+
62
+ def process_value_as_int(return_value: nil)
63
+ if return_value.nil?
64
+ return_value = 0
65
+ end
66
+
67
+ # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
68
+ return JSON.generate(return_value.to_s, quirks_mode: true)
69
+ end
70
+ end
71
+ end
@@ -1,10 +1,17 @@
1
- require 'fastlane/server/command.rb'
2
1
  require 'fastlane/server/command_executor.rb'
2
+ require 'fastlane/server/command_parser.rb'
3
+ require 'fastlane/server/json_return_value_processor.rb'
3
4
  require 'socket'
4
5
  require 'json'
5
6
 
6
7
  module Fastlane
7
8
  class SocketServer
9
+ COMMAND_EXECUTION_STATE = {
10
+ ready: :ready,
11
+ already_shutdown: :already_shutdown,
12
+ error: :error
13
+ }
14
+
8
15
  attr_accessor :command_executor
9
16
  attr_accessor :return_value_processor
10
17
 
@@ -24,53 +31,112 @@ module Fastlane
24
31
  @stay_alive = stay_alive
25
32
  end
26
33
 
27
- # This is the public API, don't call anything else
34
+ # this is the public API, don't call anything else
28
35
  def start
29
- while listen
30
- # Loop for-ev-er
36
+ listen
37
+
38
+ while @stay_alive
39
+ UI.important("stay_alive is set to true, restarting server")
40
+ listen
31
41
  end
32
42
  end
33
43
 
34
44
  private
35
45
 
36
46
  def receive_and_process_commands
37
- # We'll break out of the infinite loop somehow, either error or 'done' message
38
- ended_loop_due_to_error = true
39
-
40
- loop do # No idea how many commands are coming, so we loop until an error or the done command is sent
41
- str = nil
47
+ loop do # no idea how many commands are coming, so we loop until an error or the done command is sent
48
+ execution_state = COMMAND_EXECUTION_STATE[:ready]
42
49
 
50
+ command_string = nil
43
51
  begin
44
- str = @client.recv(1_048_576) # 1024 * 1024
52
+ command_string = @client.recv(1_048_576) # 1024 * 1024
45
53
  rescue Errno::ECONNRESET => e
46
54
  UI.verbose(e)
47
- break
55
+ execution_state = COMMAND_EXECUTION_STATE[:error]
48
56
  end
49
57
 
50
- if str == 'done'
51
- time = Time.new
52
- UI.verbose("[#{time.usec}]: received done signal, shutting down")
53
- ended_loop_due_to_error = false
54
- break
58
+ if execution_state == COMMAND_EXECUTION_STATE[:ready]
59
+ # Ok, all is good, let's see what command we have
60
+ execution_state = parse_and_execute_command(command_string: command_string)
55
61
  end
56
- response_json = process_command(command_json: str)
57
62
 
58
- time = Time.new
59
- UI.verbose("[#{time.usec}]: sending #{response_json}")
60
- begin
61
- @client.puts(response_json) # Send some json to the client
62
- rescue Errno::EPIPE => e
63
- UI.verbose(e)
63
+ case execution_state
64
+ when COMMAND_EXECUTION_STATE[:ready]
65
+ # command executed successfully, let's setup for the next command
66
+ next
67
+ when COMMAND_EXECUTION_STATE[:already_shutdown]
68
+ # we shutdown in response to a command, nothing left to do but exit
69
+ break
70
+ when COMMAND_EXECUTION_STATE[:error]
71
+ # we got an error somewhere, let's shutdown and exit
72
+ handle_disconnect(error: true, exit_reason: :error)
64
73
  break
65
74
  end
66
75
  end
76
+ end
77
+
78
+ def parse_and_execute_command(command_string: nil)
79
+ command = CommandParser.parse(json: command_string)
80
+ case command
81
+ when ControlCommand
82
+ return handle_control_command(command)
83
+ when ActionCommand
84
+ return handle_action_command(command)
85
+ end
67
86
 
68
- return handle_disconnect(error: ended_loop_due_to_error)
87
+ # catch all
88
+ raise "Command #{command} not supported"
89
+ end
90
+
91
+ # we got a server control command from the client to do something like shutdown
92
+ def handle_control_command(command)
93
+ exit_reason = nil
94
+ if command.cancel_signal?
95
+ UI.verbose("received cancel signal shutting down, reason: #{command.reason}")
96
+
97
+ # send an ack to the client to let it know we're shutting down
98
+ cancel_response = '{"payload":{"status":"cancelled"}}'
99
+ send_response(cancel_response)
100
+
101
+ exit_reason = :cancelled
102
+ elsif command.done_signal?
103
+ UI.verbose("received done signal shutting down")
104
+
105
+ # client is already in the process of shutting down, no need to ack
106
+ exit_reason = :done
107
+ end
108
+
109
+ # if the command came in with a user-facing message, display it
110
+ if command.user_message
111
+ UI.important(command.user_message)
112
+ end
113
+
114
+ # currently all control commands should trigger a disconnect and shutdown
115
+ handle_disconnect(error: false, exit_reason: exit_reason)
116
+ return COMMAND_EXECUTION_STATE[:already_shutdown]
117
+ end
118
+
119
+ # execute and send back response to client
120
+ def handle_action_command(command)
121
+ response_json = process_action_command(command: command)
122
+ return send_response(response_json)
123
+ end
124
+
125
+ # send json back to client
126
+ def send_response(json)
127
+ UI.verbose("sending #{json}")
128
+ begin
129
+ @client.puts(json) # Send some json to the client
130
+ rescue Errno::EPIPE => e
131
+ UI.verbose(e)
132
+ return COMMAND_EXECUTION_STATE[:error]
133
+ end
134
+ return COMMAND_EXECUTION_STATE[:ready]
69
135
  end
70
136
 
71
137
  def listen
72
138
  @server = TCPServer.open('localhost', 2000) # Socket to listen on port 2000
73
- UI.message("Waiting for #{@connection_timeout} seconds for a connection from FastlaneRunner")
139
+ UI.verbose("Waiting for #{@connection_timeout} seconds for a connection from FastlaneRunner")
74
140
 
75
141
  # set thread local to ready so we can check it
76
142
  Thread.current[:ready] = true
@@ -84,34 +150,32 @@ module Fastlane
84
150
  rescue StandardError => e
85
151
  UI.user_error!("Something went wrong while waiting for a connection from the FastlaneRunner binary, shutting down\n#{e}")
86
152
  end
87
- UI.message("Client connected")
153
+ UI.verbose("Client connected")
88
154
 
155
+ # this loops forever
89
156
  receive_and_process_commands
90
157
  end
91
158
 
92
- def handle_disconnect(error: false)
93
- UI.important("Client disconnected, or a pipe broke") if error
94
- if @stay_alive
95
- UI.important("stay_alive is set to true, restarting server")
96
- # clean up before restart
97
- @client.close
98
- @client = nil
159
+ def handle_disconnect(error: false, exit_reason: :error)
160
+ Thread.current[:exit_reason] = exit_reason
99
161
 
100
- @server.close
101
- @server = nil
102
- return true # Restart server
103
- end
104
- return false # Don't restart server
162
+ UI.important("Client disconnected, a pipe broke, or received malformed data") if exit_reason == :error
163
+ # clean up
164
+ @client.close
165
+ @client = nil
166
+
167
+ @server.close
168
+ @server = nil
105
169
  end
106
170
 
107
- def process_command(command_json: nil)
108
- time = Time.new
109
- UI.verbose("[#{time.usec}]: received command:#{command_json}")
110
- return execute_command(command_json: command_json)
171
+ # record fastlane action command and then execute it
172
+ def process_action_command(command: nil)
173
+ UI.verbose("received command:#{command.inspect}")
174
+ return execute_action_command(command: command)
111
175
  end
112
176
 
113
- def execute_command(command_json: nil)
114
- command = Command.new(json: command_json)
177
+ # execute fastlane action command
178
+ def execute_action_command(command: nil)
115
179
  command_return = @command_executor.execute(command: command, target_object: nil)
116
180
  ## probably need to just return Strings, or ready_for_next with object isn't String
117
181
  return_object = command_return.return_value
@@ -133,8 +197,11 @@ module Fastlane
133
197
  closure_arg = ', "closure_argument_value": ' + closure_arg
134
198
  end
135
199
 
200
+ Thread.current[:exception] = nil
136
201
  return '{"payload":{"status":"ready_for_next", "return_object":' + return_object + closure_arg + '}}'
137
202
  rescue StandardError => e
203
+ Thread.current[:exception] = e
204
+
138
205
  exception_array = []
139
206
  exception_array << "#{e.class}:"
140
207
  exception_array << e.backtrace
@@ -146,72 +213,4 @@ module Fastlane
146
213
  return "{\"payload\":{\"status\":\"failure\",\"failure_information\":#{exception_array.flatten}}}"
147
214
  end
148
215
  end
149
-
150
- class JSONReturnValueProcessor
151
- def prepare_object(return_value: nil, return_value_type: nil)
152
- case return_value_type
153
- when nil
154
- UI.verbose("return_value_type is nil value: #{return_value}")
155
- return process_value_as_string(return_value: return_value)
156
- when :string
157
- return process_value_as_string(return_value: return_value)
158
- when :int
159
- return process_value_as_int(return_value: return_value)
160
- when :bool
161
- return process_value_as_bool(return_value: return_value)
162
- when :array_of_strings
163
- return process_value_as_array_of_strings(return_value: return_value)
164
- when :hash_of_strings
165
- return process_value_as_hash_of_strings(return_value: return_value)
166
- else
167
- UI.verbose("Unknown return type defined: #{return_value_type} for value: #{return_value}")
168
- return process_value_as_string(return_value: return_value)
169
- end
170
- end
171
-
172
- def process_value_as_string(return_value: nil)
173
- if return_value.nil?
174
- return_value = ""
175
- end
176
-
177
- # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
178
- return JSON.generate(return_value.to_s, quirks_mode: true)
179
- end
180
-
181
- def process_value_as_array_of_strings(return_value: nil)
182
- if return_value.nil?
183
- return_value = []
184
- end
185
-
186
- # quirks_mode shouldn't be required for real objects
187
- return JSON.generate(return_value)
188
- end
189
-
190
- def process_value_as_hash_of_strings(return_value: nil)
191
- if return_value.nil?
192
- return_value = {}
193
- end
194
-
195
- # quirks_mode shouldn't be required for real objects
196
- return JSON.generate(return_value)
197
- end
198
-
199
- def process_value_as_bool(return_value: nil)
200
- if return_value.nil?
201
- return_value = false
202
- end
203
-
204
- # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
205
- return JSON.generate(return_value.to_s, quirks_mode: true)
206
- end
207
-
208
- def process_value_as_int(return_value: nil)
209
- if return_value.nil?
210
- return_value = 0
211
- end
212
-
213
- # quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
214
- return JSON.generate(return_value.to_s, quirks_mode: true)
215
- end
216
- end
217
216
  end