fastlane-plugin-create_simulator_devices 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b2c73d26a678b6c2871d2749da24233ff2d889d4b089eee2cbf25edf5b8de4d
4
- data.tar.gz: 16a9a49267d3820cac3ca95ee16160657f589d785bf56b040d37ae9b92b8c865
3
+ metadata.gz: 8bf78a070d8cc87783033a6d6dfb1c778a2cacc388cf0e5f691308955e94f848
4
+ data.tar.gz: 1a4fae00d92ff2e0c1f2a15a3f0804cb519fc9e2cedafa98e183ab0da6d39b74
5
5
  SHA512:
6
- metadata.gz: ca21d83129049ad9a69689ed417bf4b333b55b3a08facc8c09d2992bf475da42818b53367a28a56423c8887073c5922f883d433c36688f79f44165c744e6a072
7
- data.tar.gz: 145a144f2da681665e846dfdc7a348ef52883df996f64c6498d17a08edb6fe86c9959e119a5bb16d51b6ae2c8f64cb21831db666603eb9bc2fbb5567939a063a
6
+ metadata.gz: b47dc812e54c36acd0a95131838b5f45b0ab2fc9422965c961b4002acfdaf275ac9e1a870336a778043908cb62da3e6656ae3feb29c657bee6b80200dc320a24
7
+ data.tar.gz: e21033bc755e645677f98e54ddb553cafbaf674ac01e6d34bd07dce967b17a2f1c5459c0928d0edf06de002abae337940e122bff507c63850a85101d749d2771
@@ -46,7 +46,8 @@ module Fastlane
46
46
  output_dir: params[:output_dir],
47
47
  timeout: params[:timeout],
48
48
  include_all_device_logs: params[:include_all_device_logs],
49
- include_booted_device_data_directory: params[:include_booted_device_data_directory]
49
+ include_booted_device_data_directory: params[:include_booted_device_data_directory],
50
+ include_nonbooted_device_data_directory: params[:include_nonbooted_device_data_directory]
50
51
  )
51
52
 
52
53
  runner.run(required_devices)
@@ -127,6 +128,12 @@ module Fastlane
127
128
  description: 'Include booted device data directory. Warning: May include private information, app data containers, and increases the size of the archive! Default is NOT to collect the data container',
128
129
  type: Boolean,
129
130
  optional: true,
131
+ default_value: false),
132
+ ::FastlaneCore::ConfigItem.new(key: :include_nonbooted_device_data_directory,
133
+ env_name: 'GATHER_SIMCTL_DIAGNOSE_INCLUDE_NONBOOTED_DEVICE_DATA_DIRECTORY',
134
+ description: 'Include non-booted device data directory. Warning: May include private information, app data containers, and increases the size of the archive! Default is NOT to collect the data container',
135
+ type: Boolean,
136
+ optional: true,
130
137
  default_value: false)
131
138
  ]
132
139
  end
@@ -5,13 +5,16 @@ module Fastlane
5
5
  module SimCTL
6
6
  # Represents a device.
7
7
  class Device
8
- attr_accessor :udid, :name, :device_type_identifier, :available
8
+ attr_accessor :udid, :name, :device_type_identifier, :available, :data_path, :log_path, :state
9
9
 
10
- def initialize(name:, udid:, device_type_identifier:, available:)
10
+ def initialize(name:, udid:, device_type_identifier:, available:, data_path:, log_path:, state:) # rubocop:disable Metrics/ParameterLists
11
11
  self.name = name
12
12
  self.udid = udid
13
13
  self.device_type_identifier = device_type_identifier
14
14
  self.available = available
15
+ self.data_path = data_path
16
+ self.log_path = log_path
17
+ self.state = state
15
18
  end
16
19
 
17
20
  def available?
@@ -27,7 +30,10 @@ module Fastlane
27
30
  name: hash[:name],
28
31
  udid: hash[:udid],
29
32
  device_type_identifier: hash[:deviceTypeIdentifier],
30
- available: hash[:isAvailable]
33
+ available: hash[:isAvailable],
34
+ data_path: hash[:dataPath],
35
+ log_path: hash[:logPath],
36
+ state: hash[:state]
31
37
  )
32
38
  end
33
39
  end
@@ -12,7 +12,8 @@ module Fastlane
12
12
  class Runner
13
13
  UI = ::Fastlane::UI unless defined?(UI)
14
14
 
15
- attr_accessor :shell_helper, :verbose, :runtime_helper, :device_naming_style, :create_simulator_devices_runner, :output_dir, :timeout, :include_all_device_logs, :include_booted_device_data_directory, :print_command, :print_command_output
15
+ attr_accessor :shell_helper, :verbose, :runtime_helper, :device_naming_style, :create_simulator_devices_runner, :output_dir, :timeout, :include_all_device_logs, :include_booted_device_data_directory, :print_command, :print_command_output,
16
+ :include_nonbooted_device_data_directory
16
17
 
17
18
  def initialize( # rubocop:disable Metrics/ParameterLists
18
19
  runtime_helper:,
@@ -23,7 +24,8 @@ module Fastlane
23
24
  output_dir:,
24
25
  timeout:,
25
26
  include_all_device_logs:,
26
- include_booted_device_data_directory:
27
+ include_booted_device_data_directory:,
28
+ include_nonbooted_device_data_directory:
27
29
  )
28
30
  self.shell_helper = shell_helper
29
31
  self.verbose = verbose
@@ -34,6 +36,7 @@ module Fastlane
34
36
  self.timeout = timeout
35
37
  self.include_all_device_logs = include_all_device_logs
36
38
  self.include_booted_device_data_directory = include_booted_device_data_directory
39
+ self.include_nonbooted_device_data_directory = include_nonbooted_device_data_directory
37
40
  end
38
41
 
39
42
  def run(devices) # rubocop:disable Metrics/AbcSize
@@ -50,13 +53,17 @@ module Fastlane
50
53
  end
51
54
 
52
55
  # Return distinct matched devices strings
53
- matched_devices = create_simulator_devices_runner.find_runtime_and_device_for_required_devices(required_devices)
56
+ matched_simctl_devices = create_simulator_devices_runner.find_runtime_and_device_for_required_devices(required_devices)
54
57
  .reject { |required_device| required_device.simctl_device.nil? }
58
+ .map(&:simctl_device)
55
59
 
56
- matched_devices_udids = matched_devices.map { |matched_device| matched_device.simctl_device.udid }
60
+ matched_devices_udids = matched_simctl_devices.map(&:udid)
57
61
  UI.message("Available simulator devices: #{matched_devices_udids.join(', ')}")
58
62
 
59
- temp_output_dir = "#{File.expand_path(output_dir)}/simctl_diagnose_#{Time.now.strftime('%Y%m%d%H%M%S')}"
63
+ full_output_dir_path = File.expand_path(output_dir)
64
+ temp_output_dir = "#{full_output_dir_path}/simctl_diagnose"
65
+
66
+ FileUtils.mkdir_p(temp_output_dir)
60
67
 
61
68
  diagnose_args = matched_devices_udids.map { |udid| "--udid=#{udid}" }
62
69
  diagnose_args << '-b' # Do NOT show the resulting archive in a Finder window upon completion.
@@ -68,17 +75,44 @@ module Fastlane
68
75
 
69
76
  collect_diagnose_data_script_path = File.expand_path("#{__dir__}/scripts/collect_simctl_diagnose_data.sh")
70
77
 
78
+ UI.message("Collecting diagnose data to #{temp_output_dir}...")
71
79
  shell_helper.sh(
72
80
  command: "SIMCTL_DIAGNOSE_OUTPUT_FOLDER=#{temp_output_dir.shellescape} #{collect_diagnose_data_script_path.shellescape} #{cmd_args}",
73
- print_command: verbose,
81
+ print_command: true,
74
82
  print_command_output: verbose
75
83
  )
76
84
 
77
85
  archive_name = "#{temp_output_dir}.tar.gz"
78
86
  Actions.lane_context[Actions::SharedValues::GATHER_SIMCTL_DIAGNOSE_OUTPUT_FILE] = archive_name
79
87
 
88
+ copy_data_containers_and_logs(matched_simctl_devices, full_output_dir_path) if include_nonbooted_device_data_directory
89
+
80
90
  archive_name
81
91
  end
92
+
93
+ def copy_data_containers_and_logs(matched_simctl_devices, output_dir)
94
+ matched_simctl_devices
95
+ .reject { |simctl_device| simctl_device.state == 'Booted' }
96
+ .each do |simctl_device|
97
+ copy_data_container_and_logs(simctl_device, output_dir)
98
+ end
99
+ end
100
+
101
+ def copy_data_container_and_logs(simctl_device, output_dir)
102
+ if File.exist?(simctl_device.data_path)
103
+ UI.message("Copying data from #{simctl_device.data_path} to #{output_dir}...")
104
+ shell_helper.sh(
105
+ command: "tar -czf #{output_dir}/#{simctl_device.name.shellescape}_#{simctl_device.udid.shellescape}_data.tar.gz --cd #{File.dirname(simctl_device.data_path).shellescape} #{File.basename(simctl_device.data_path).shellescape}"
106
+ )
107
+ end
108
+
109
+ return unless File.exist?(simctl_device.log_path)
110
+
111
+ UI.message("Copying logs from #{simctl_device.log_path} to #{output_dir}...")
112
+ shell_helper.sh(
113
+ command: "tar -czf #{output_dir}/#{simctl_device.name.shellescape}_#{simctl_device.udid.shellescape}_logs.tar.gz --cd #{File.dirname(simctl_device.log_path).shellescape} #{File.basename(simctl_device.log_path).shellescape}"
114
+ )
115
+ end
82
116
  end
83
117
  end
84
118
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module CreateSimulatorDevices
5
- VERSION = '0.0.15'
5
+ VERSION = '0.0.17'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-create_simulator_devices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Budnik