fastlane 2.34.0.beta.20170524010028 → 2.34.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a981dabe599f6c33b7f167decb24f85fe11dac5
4
- data.tar.gz: dc67db8fa80f2d37fb6bd689c217ccbbb014b20c
3
+ metadata.gz: 476b447650ec03fab7e9903ca3bee62d3f42bfde
4
+ data.tar.gz: 86a6d8fa75d294749c345b5c074099cd13805209
5
5
  SHA512:
6
- metadata.gz: e79043dd42b1d821f39d6a81fd693bc5ea8eec44c077d710e42956f375d5cfba541b4d6fc738760abf4da0a43b23ccdf083e7368d3f76d4d9e069bdbd6e0d3ba
7
- data.tar.gz: bf0c1038c7efb8a8cc2eec5562b7605ff042c80d5d1c778644b5a6477355d8a8d14fbb943e36994252ac904305c22c25085e559a626f38b5076743c38e66dfcf
6
+ metadata.gz: 2b707014f17a86db8c73206c69a3eb2db15253fef2249815ce4feb73ab3ce1457c1ea28ba8c4e0d1253ef4be4403dcebe48a45406e0bf1f9f3d3138dbc54d470
7
+ data.tar.gz: 541aedfd64deceb114b1f472a477fefa2e8bf5626bf8c2a9192c75ab88b259a826994292b3e65e600d5b33358efb242c51127950b1e218f9955b3d971fc9612d
Binary file
Binary file
@@ -48,7 +48,7 @@ module Fastlane
48
48
 
49
49
  options_to_client = lambda do |options|
50
50
  options.map do |option|
51
- case option
51
+ case option.to_sym
52
52
  when :shake, :anonymous
53
53
  option.to_s
54
54
  when :video_only_wifi
@@ -8,9 +8,7 @@ module Fastlane
8
8
  ALL_TOOLS = ["fastlane"]
9
9
 
10
10
  def self.run(options)
11
- if options[:no_update]
12
- return
13
- end
11
+ return if options[:no_update] # this is used to update itself
14
12
 
15
13
  tools_to_update = options[:tools].split ',' unless options[:tools].nil?
16
14
  tools_to_update ||= all_installed_tools
@@ -23,14 +21,16 @@ module Fastlane
23
21
  UI.message("Looking for updates for #{tools_to_update.join(', ')}...")
24
22
 
25
23
  updater = Gem::CommandManager.instance[:update]
24
+ updater.options[:prerelease] = true if options[:nightly]
26
25
  cleaner = Gem::CommandManager.instance[:cleanup]
27
26
 
28
27
  sudo_needed = !File.writable?(Gem.dir)
29
28
 
30
29
  if sudo_needed
31
30
  UI.important("It seems that your Gem directory is not writable by your current User.")
32
- UI.important("Fastlane would need sudo rights to update itself, however, running 'sudo fastlane' is not recommended.")
33
- UI.important("If you still want to use this action, please read the Actions.md documentation on a guide how to set this up.")
31
+ UI.important("fastlane would need sudo rights to update itself, however, running 'sudo fastlane' is not recommended.")
32
+ UI.important("If you still want to use this action, please read the documentation on a guide how to set this up:")
33
+ UI.important("https://docs.fastlane.tools/actions/#update_fastlane")
34
34
  return
35
35
  end
36
36
 
@@ -43,11 +43,12 @@ module Fastlane
43
43
  return
44
44
  end
45
45
 
46
- highest_versions = updater.highest_installed_gems.keep_if { |key| tools_to_update.include? key }
46
+ highest_versions = updater.highest_installed_gems.keep_if { |key| tools_to_update.include?(key) }
47
47
  update_needed = updater.which_to_update(highest_versions, tools_to_update)
48
48
 
49
49
  if update_needed.count == 0
50
50
  UI.success("Nothing to update ✅")
51
+ show_information_about_nightly_builds unless options[:nightly]
51
52
  return
52
53
  end
53
54
 
@@ -56,31 +57,49 @@ module Fastlane
56
57
 
57
58
  update_needed.each do |tool_info|
58
59
  tool = tool_info[0]
60
+ gem_version = tool_info[1]
59
61
  local_version = Gem::Version.new(highest_versions[tool].version)
60
- latest_version = FastlaneCore::UpdateChecker.fetch_latest(tool)
61
- UI.message("Updating #{tool} from #{local_version} to #{latest_version} ... 🚀")
62
+ latest_official_version = FastlaneCore::UpdateChecker.fetch_latest(tool)
63
+
64
+ if options[:nightly]
65
+ UI.message("Updating #{tool} from #{local_version.to_s.yellow} to nightly build #{gem_version.to_s.yellow}... (last official release #{latest_official_version.to_s.yellow}) 🚀")
66
+ else
67
+ UI.message("Updating #{tool} from #{local_version.to_s.yellow} to #{latest_official_version.to_s.yellow}... 🚀")
68
+ end
62
69
 
63
70
  # Approximate_recommendation will create a string like "~> 0.10" from a version 0.10.0, e.g. one that is valid for versions >= 0.10 and <1.0
64
- updater.update_gem tool, Gem::Requirement.new(local_version.approximate_recommendation)
71
+ requirement_version = options[:nightly] ? gem_version : local_version.approximate_recommendation
72
+ updater.update_gem(tool, Gem::Requirement.new(requirement_version))
65
73
 
66
- UI.message("Finished updating #{tool}")
74
+ UI.success("Finished updating #{tool}")
67
75
  end
68
76
 
69
- all_updated_tools = updater.installer.installed_gems.select do |updated_tool|
70
- updated_tool.version > highest_versions[updated_tool.name].version if highest_versions[updated_tool.name]
71
- end
77
+ UI.message("Cleaning up old versions...")
78
+ cleaner.options[:args] = tools_to_update
79
+ cleaner.execute
72
80
 
73
- if all_updated_tools.empty?
74
- UI.message("All fastlane tools are up-to-date!")
81
+ if options[:nightly]
82
+ UI.success("Thanks for using fastlane's nightly builds! This makes it easier for everyone to detect regressions earlier.")
83
+ UI.success("Please submit an issue on GitHub if anything behaves differently than it should 🍪")
75
84
  else
76
- UI.message("Cleaning up old versions...")
77
- cleaner.options[:args] = all_updated_tools.map(&:name)
78
- cleaner.execute
79
- UI.message("fastlane.tools successfully updated! I will now restart myself... 😴")
80
-
81
- # Set no_update to true so we don't try to update again
82
- exec "FL_NO_UPDATE=true #{$PROGRAM_NAME} #{ARGV.join ' '}"
85
+ show_information_about_nightly_builds
83
86
  end
87
+
88
+ UI.message("fastlane.tools successfully updated! I will now restart myself... 😴")
89
+
90
+ # Set no_update to true so we don't try to update again
91
+ exec "FL_NO_UPDATE=true #{$PROGRAM_NAME} #{ARGV.join ' '}"
92
+ end
93
+
94
+ def self.show_information_about_nightly_builds
95
+ UI.message("")
96
+ UI.message("Please help us test early releases of fastlane by opting into nightly builds 🌃")
97
+ UI.message("Just replace your `update_fastlane` call with")
98
+ UI.message("")
99
+ UI.command_output("update_fastlane(nightly: true)")
100
+ UI.message("")
101
+ UI.message("Nightly builds are reviewed and tested just like the public releases 🚂")
102
+ UI.message("")
84
103
  end
85
104
 
86
105
  def self.all_installed_tools
@@ -93,7 +112,7 @@ module Fastlane
93
112
 
94
113
  def self.details
95
114
  [
96
- "This action will look at all installed fastlane tools and update them to the next available minor version - major version updates will not be performed automatically, as they might include breaking changes. If an update was performed, fastlane will be restarted before the run continues.",
115
+ "This action will update fastlane to the most recent version - major version updates will not be performed automatically, as they might include breaking changes. If an update was performed, fastlane will be restarted before the run continues.",
97
116
  "If you are using rbenv or rvm, everything should be good to go. However, if you are using the system's default ruby, some additional setup is needed for this action to work correctly. In short, fastlane needs to be able to access your gem library without running in `sudo` mode.",
98
117
  "The simplest possible fix for this is putting the following lines into your `~/.bashrc` or `~/.zshrc` file:",
99
118
  "```bash",
@@ -101,26 +120,32 @@ module Fastlane
101
120
  "export PATH=$PATH:~/.gems/bin",
102
121
  "```",
103
122
  "After the above changes, restart your terminal, then run `mkdir $GEM_HOME` to create the new gem directory. After this, you're good to go!",
104
- "Recommended usage of the `update_fastlane` action is at the top of the `before_all` block, before running any other action"
123
+ "Recommended usage of the `update_fastlane` action is at the top inside of the `before_all` block, before running any other action"
105
124
  ].join("\n\n")
106
125
  end
107
126
 
108
127
  def self.available_options
109
128
  [
110
- FastlaneCore::ConfigItem.new(key: :tools,
111
- env_name: "FL_TOOLS_TO_UPDATE",
112
- 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",
113
- optional: true),
129
+ FastlaneCore::ConfigItem.new(key: :nightly,
130
+ env_name: "FL_UPDATE_FASTLANE_NIGHTLY",
131
+ description: "Opt-in to install and use nightly fastlane builds",
132
+ is_string: false,
133
+ default_value: false),
114
134
  FastlaneCore::ConfigItem.new(key: :no_update,
115
135
  env_name: "FL_NO_UPDATE",
116
- description: "Don't update during this run. Defaults to false",
136
+ description: "Don't update during this run. Defaults to false. This is used internally",
117
137
  is_string: false,
118
- default_value: false)
138
+ default_value: false),
139
+ FastlaneCore::ConfigItem.new(key: :tools,
140
+ env_name: "FL_TOOLS_TO_UPDATE",
141
+ description: "Comma separated list of fastlane tools to update (e.g. fastlane,deliver,sigh)",
142
+ deprecated: true,
143
+ optional: true)
119
144
  ]
120
145
  end
121
146
 
122
- def self.author
123
- "milch"
147
+ def self.authors
148
+ ["milch", "KrauseFx"]
124
149
  end
125
150
 
126
151
  def self.is_supported?(platform)
@@ -89,6 +89,10 @@ module Fastlane
89
89
  unless plugin_is_added_as_dependency?(plugin_name)
90
90
  content = pluginfile_content || AUTOGENERATED_LINE
91
91
 
92
+ unless content.end_with?("\n")
93
+ content += "\n"
94
+ end
95
+
92
96
  line_to_add = "gem '#{plugin_name}'"
93
97
  line_to_add += gem_dependency_suffix(plugin_name)
94
98
  UI.verbose("Adding line: #{line_to_add}")
@@ -1,4 +1,4 @@
1
1
  module Fastlane
2
- VERSION = '2.34.0.beta.20170524010028'.freeze
2
+ VERSION = '2.34.0'.freeze
3
3
  DESCRIPTION = "The easiest way to automate beta deployments and releases for your iOS and Android apps".freeze
4
4
  end
@@ -24,12 +24,18 @@ module FastlaneCore
24
24
  # a crash report), unless we have explictly turned on the crash reporter because
25
25
  # we want to test it
26
26
  return if Helper.test? && !@explitly_enabled_for_testing
27
-
28
- payload = CrashReportGenerator.generate(exception: exception, action: action)
29
- send_report(payload: payload)
30
- save_file(payload: payload)
31
- show_message unless did_show_message?
32
- @did_report_crash = true
27
+ begin
28
+ payload = CrashReportGenerator.generate(exception: exception, action: action)
29
+ send_report(payload: payload)
30
+ save_file(payload: payload)
31
+ show_message unless did_show_message?
32
+ @did_report_crash = true
33
+ rescue
34
+ if FastlaneCore::Globals.verbose?
35
+ UI.error("Unable to send the crash report.")
36
+ UI.error("Please open an issue on GitHub if you need help!")
37
+ end
38
+ end
33
39
  end
34
40
 
35
41
  def reset_crash_reporter_for_testing
data/scan/lib/scan.rb CHANGED
@@ -3,8 +3,8 @@ require 'scan/manager'
3
3
  require 'scan/options'
4
4
  require 'scan/runner'
5
5
  require 'scan/detect_values'
6
- require 'scan/report_collector'
7
6
  require 'scan/test_command_generator'
7
+ require 'scan/xcpretty_reporter_options_generator.rb'
8
8
  require 'scan/test_result_parser'
9
9
  require 'scan/error_handler'
10
10
  require 'scan/slack_poster'
@@ -113,8 +113,14 @@ module Scan
113
113
  FastlaneCore::ConfigItem.new(key: :output_types,
114
114
  short_option: "-f",
115
115
  env_name: "SCAN_OUTPUT_TYPES",
116
- description: "Comma separated list of the output types (e.g. html, junit)",
116
+ description: "Comma separated list of the output types (e.g. html, junit, json-compilation-database)",
117
117
  default_value: "html,junit"),
118
+ FastlaneCore::ConfigItem.new(key: :output_files,
119
+ env_name: "SCAN_OUTPUT_FILES",
120
+ description: "Comma separated list of the output files, corresponding to the types provided by :output_types (order should match). If specifying an output type of json-compilation-database with :use_clang_report_name enabled, that option will take precedence",
121
+ conflicting_options: [:custom_report_file_name],
122
+ optional: true,
123
+ default_value: nil),
118
124
  FastlaneCore::ConfigItem.new(key: :buildlog_path,
119
125
  short_option: "-l",
120
126
  env_name: "SCAN_BUILDLOG_PATH",
@@ -251,7 +257,9 @@ module Scan
251
257
  default_value: false),
252
258
  FastlaneCore::ConfigItem.new(key: :custom_report_file_name,
253
259
  env_name: "SCAN_CUSTOM_REPORT_FILE_NAME",
254
- description: "Sets custom full report file name",
260
+ description: "Sets custom full report file name when generating a single report",
261
+ deprecated: "Use --output_files",
262
+ conflicting_options: [:output_files],
255
263
  optional: true,
256
264
  is_string: true)
257
265
  ]
@@ -46,22 +46,7 @@ module Scan
46
46
  end
47
47
 
48
48
  def handle_results(tests_exit_status)
49
- # First, generate a JUnit report to get the number of tests
50
- require 'tempfile'
51
- output_file = Tempfile.new("junit_report")
52
-
53
- report_collector = ReportCollector.new(Scan.config[:open_report],
54
- Scan.config[:output_types],
55
- Scan.config[:output_directory],
56
- Scan.config[:use_clang_report_name],
57
- Scan.config[:custom_report_file_name])
58
-
59
- cmd = report_collector.generate_commands(TestCommandGenerator.xcodebuild_log_path,
60
- types: 'junit',
61
- output_file_name: output_file.path).values.last
62
- system(cmd)
63
-
64
- result = TestResultParser.new.parse_result(output_file.read)
49
+ result = TestResultParser.new.parse_result(test_results)
65
50
  SlackPoster.new.run(result)
66
51
 
67
52
  if result[:failures] > 0
@@ -81,8 +66,6 @@ module Scan
81
66
 
82
67
  copy_simulator_logs
83
68
 
84
- report_collector.parse_raw_file(TestCommandGenerator.xcodebuild_log_path)
85
-
86
69
  if result[:failures] > 0
87
70
  UI.test_failure!("Tests have failed")
88
71
  end
@@ -90,6 +73,15 @@ module Scan
90
73
  unless tests_exit_status == 0
91
74
  UI.test_failure!("Test execution failed. Exit status: #{tests_exit_status}")
92
75
  end
76
+
77
+ if !Helper.is_ci? && Scan.cache[:open_html_report_path]
78
+ `open --hide '#{Scan.cache[:open_html_report_path]}'`
79
+ end
80
+ end
81
+
82
+ def test_results
83
+ return "" unless Scan.cache[:temp_junit_report]
84
+ File.read(Scan.cache[:temp_junit_report])
93
85
  end
94
86
 
95
87
  def copy_simulator_logs
@@ -75,8 +75,6 @@ module Scan
75
75
  end
76
76
 
77
77
  def pipe
78
- # During building we just show the output in the terminal
79
- # Check out the ReportCollector class for more xcpretty things
80
78
  pipe = ["| tee '#{xcodebuild_log_path}'"]
81
79
 
82
80
  if Scan.config[:output_style] == 'raw'
@@ -103,7 +101,13 @@ module Scan
103
101
  formatter << "--test"
104
102
  end
105
103
 
106
- return pipe << ["| xcpretty #{formatter.join(' ')}"]
104
+ reporter_options_generator = XCPrettyReporterOptionsGenerator.new(Scan.config[:open_report],
105
+ Scan.config[:output_types],
106
+ Scan.config[:output_files] || Scan.config[:custom_report_file_name],
107
+ Scan.config[:output_directory],
108
+ Scan.config[:use_clang_report_name])
109
+ reporter_options = reporter_options_generator.generate_reporter_options
110
+ return pipe << "| xcpretty #{formatter.join(' ')} #{reporter_options.join(' ')}"
107
111
  end
108
112
 
109
113
  # Store the raw file
@@ -0,0 +1,76 @@
1
+ module Scan
2
+ class XCPrettyReporterOptionsGenerator
3
+ SUPPORTED_REPORT_TYPES = %w(html junit json-compilation-database)
4
+
5
+ def self.generate_from_scan_config
6
+ self.new(Scan.config[:open_report],
7
+ Scan.config[:output_types],
8
+ Scan.config[:output_files] || Scan.config[:custom_report_file_name],
9
+ Scan.config[:output_directory],
10
+ Scan.config[:use_clang_report_name])
11
+ end
12
+
13
+ # Intialize with values from Scan.config matching these param names
14
+ def initialize(open_report, output_types, output_files, output_directory, use_clang_report_name)
15
+ @open_report = open_report
16
+ @output_types = output_types
17
+ @output_files = output_files
18
+ @output_directory = output_directory
19
+ @use_clang_report_name = use_clang_report_name
20
+
21
+ # might already be an array when passed via fastlane
22
+ @output_types = @output_types.split(',') if @output_types.kind_of?(String)
23
+
24
+ if @output_files.nil?
25
+ @output_files = @output_types.map { |type| "report.#{type}" }
26
+ elsif @output_files.kind_of?(String)
27
+ # might already be an array when passed via fastlane
28
+ @output_files = @output_files.split(',')
29
+ end
30
+
31
+ unless @output_types.length == @output_files.length
32
+ UI.important("WARNING: output_types and output_files do not have the same number of items. Default values will be substituted as needed.")
33
+ end
34
+
35
+ (@output_types - SUPPORTED_REPORT_TYPES).each do |type|
36
+ UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED_REPORT_TYPES.join(', ')}")
37
+ end
38
+ end
39
+
40
+ def generate_reporter_options
41
+ reporter = []
42
+
43
+ valid_types = @output_types & SUPPORTED_REPORT_TYPES
44
+ valid_types.each do |raw_type|
45
+ type = raw_type.strip
46
+ output_path = File.join(File.expand_path(@output_directory), determine_output_file_name(type))
47
+ reporter << "--report #{type}"
48
+ reporter << "--output #{output_path}"
49
+
50
+ if type == "html" && @open_report
51
+ Scan.cache[:open_html_report_path] = output_path
52
+ end
53
+ end
54
+
55
+ # adds another junit reporter in case the user does not specify one
56
+ # this will be used to generate a results table and then discarded
57
+ require 'tempfile'
58
+ Scan.cache[:temp_junit_report] = Tempfile.new("junit_report").path
59
+ reporter << "--report junit"
60
+ reporter << "--output #{Scan.cache[:temp_junit_report]}"
61
+ return reporter
62
+ end
63
+
64
+ private
65
+
66
+ def determine_output_file_name(type)
67
+ if @use_clang_report_name && type == "json-compilation-database"
68
+ return "compile_commands.json"
69
+ end
70
+
71
+ index = @output_types.index(type)
72
+ file = @output_files[index]
73
+ file || "report.#{type}"
74
+ end
75
+ end
76
+ end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.34.0.beta.20170524010028
4
+ version: 2.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -802,6 +802,7 @@ files:
802
802
  - deliver/lib/deliver/upload_price_tier.rb
803
803
  - deliver/lib/deliver/upload_screenshots.rb
804
804
  - fastlane/README.md
805
+ - fastlane/lib/.DS_Store
805
806
  - fastlane/lib/assets/Actions.md.erb
806
807
  - fastlane/lib/assets/AppfileTemplate
807
808
  - fastlane/lib/assets/AppfileTemplateAndroid
@@ -818,6 +819,7 @@ files:
818
819
  - fastlane/lib/assets/s3_plist_template.erb
819
820
  - fastlane/lib/assets/s3_version_template.erb
820
821
  - fastlane/lib/fastlane.rb
822
+ - fastlane/lib/fastlane/.DS_Store
821
823
  - fastlane/lib/fastlane/action.rb
822
824
  - fastlane/lib/fastlane/action_collector.rb
823
825
  - fastlane/lib/fastlane/actions/README.md
@@ -1212,11 +1214,11 @@ files:
1212
1214
  - scan/lib/scan/error_handler.rb
1213
1215
  - scan/lib/scan/manager.rb
1214
1216
  - scan/lib/scan/options.rb
1215
- - scan/lib/scan/report_collector.rb
1216
1217
  - scan/lib/scan/runner.rb
1217
1218
  - scan/lib/scan/slack_poster.rb
1218
1219
  - scan/lib/scan/test_command_generator.rb
1219
1220
  - scan/lib/scan/test_result_parser.rb
1221
+ - scan/lib/scan/xcpretty_reporter_options_generator.rb
1220
1222
  - screengrab/README.md
1221
1223
  - screengrab/lib/assets/ScreengrabfileTemplate
1222
1224
  - screengrab/lib/screengrab.rb
@@ -1264,6 +1266,7 @@ files:
1264
1266
  - snapshot/lib/snapshot/test_command_generator.rb
1265
1267
  - snapshot/lib/snapshot/update.rb
1266
1268
  - spaceship/README.md
1269
+ - spaceship/lib/.DS_Store
1267
1270
  - spaceship/lib/assets/languageMapping.json
1268
1271
  - spaceship/lib/assets/languageMappingReadable.json
1269
1272
  - spaceship/lib/spaceship.rb
@@ -1368,23 +1371,23 @@ metadata:
1368
1371
  post_install_message:
1369
1372
  rdoc_options: []
1370
1373
  require_paths:
1371
- - pem/lib
1372
- - spaceship/lib
1373
- - match/lib
1374
- - pilot/lib
1375
- - screengrab/lib
1376
- - produce/lib
1377
- - deliver/lib
1378
1374
  - cert/lib
1379
- - frameit/lib
1375
+ - credentials_manager/lib
1376
+ - deliver/lib
1380
1377
  - fastlane/lib
1378
+ - fastlane_core/lib
1379
+ - frameit/lib
1381
1380
  - gym/lib
1381
+ - match/lib
1382
+ - pem/lib
1383
+ - pilot/lib
1384
+ - produce/lib
1385
+ - scan/lib
1386
+ - screengrab/lib
1382
1387
  - sigh/lib
1383
1388
  - snapshot/lib
1389
+ - spaceship/lib
1384
1390
  - supply/lib
1385
- - fastlane_core/lib
1386
- - credentials_manager/lib
1387
- - scan/lib
1388
1391
  required_ruby_version: !ruby/object:Gem::Requirement
1389
1392
  requirements:
1390
1393
  - - ">="
@@ -1392,14 +1395,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
1392
1395
  version: 2.0.0
1393
1396
  required_rubygems_version: !ruby/object:Gem::Requirement
1394
1397
  requirements:
1395
- - - ">"
1398
+ - - ">="
1396
1399
  - !ruby/object:Gem::Version
1397
- version: 1.3.1
1400
+ version: '0'
1398
1401
  requirements: []
1399
1402
  rubyforge_project:
1400
- rubygems_version: 2.4.5.2
1403
+ rubygems_version: 2.6.10
1401
1404
  signing_key:
1402
1405
  specification_version: 4
1403
1406
  summary: The easiest way to automate beta deployments and releases for your iOS and
1404
1407
  Android apps
1405
1408
  test_files: []
1409
+ has_rdoc:
@@ -1,70 +0,0 @@
1
- module Scan
2
- class ReportCollector
3
- SUPPORTED = %w(html junit json-compilation-database)
4
-
5
- # Intialize with values from Scan.config matching these param names
6
- def initialize(open_report, output_types, output_directory, use_clang_report_name, custom_report_file_name = nil)
7
- @open_report = open_report
8
- @output_types = output_types
9
- @output_directory = output_directory
10
- @use_clang_report_name = use_clang_report_name
11
- @custom_report_file_name = custom_report_file_name
12
- end
13
-
14
- def parse_raw_file(path)
15
- UI.user_error!("Couldn't find file at path '#{path}'") unless File.exist?(path)
16
-
17
- commands = generate_commands(path)
18
- commands.each do |output_path, command|
19
- if system(command)
20
- UI.success("Successfully generated report at '#{output_path}'")
21
- else
22
- UI.user_error!("Failed to generate report at '#{output_path}'")
23
- end
24
-
25
- if @open_report and output_path.end_with?(".html")
26
- # Open the HTML file
27
- `open --hide '#{output_path}'`
28
- end
29
- end
30
- end
31
-
32
- # Returns a hash containing the resulting path as key and the command as value
33
- def generate_commands(path, types: nil, output_file_name: nil)
34
- types ||= @output_types
35
- types = types.split(",") if types.kind_of?(String) # might already be an array when passed via fastlane
36
- commands = {}
37
-
38
- types.each do |raw|
39
- type = raw.strip
40
-
41
- unless SUPPORTED.include?(type)
42
- UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED.join(', ')}")
43
- next
44
- end
45
-
46
- output_path = output_file_name || File.join(File.expand_path(@output_directory), determine_output_file_name(type))
47
-
48
- parts = ["cat '#{path}' | "]
49
- parts << "xcpretty"
50
- parts << "--report #{type}"
51
- parts << "--output '#{output_path}'"
52
- parts << "&> /dev/null "
53
-
54
- commands[output_path] = parts.join(" ")
55
- end
56
-
57
- return commands
58
- end
59
-
60
- def determine_output_file_name(type)
61
- if @use_clang_report_name && type == "json-compilation-database"
62
- "compile_commands.json"
63
- elsif !@custom_report_file_name.nil?
64
- @custom_report_file_name
65
- else
66
- "report.#{type}"
67
- end
68
- end
69
- end
70
- end