fastlane-plugin-create_simulator_devices 0.0.14 → 0.0.16

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: d67f3fc97805357d10286a81d1d7fcbf18ede6af69da32b176c6fcd73ab72a2f
4
- data.tar.gz: baf9ecd15c0dc7fbc66c413f61d48f44bf37a6ff32963fb4647cdcf9b586bdeb
3
+ metadata.gz: '028a321da872a819f1f84bfa2d7d8a33e39c489be64136c40cbb32636034e779'
4
+ data.tar.gz: a2b0bac0404220a52607287990e7b712c48919db6b0b06c6233ce07c2a134b78
5
5
  SHA512:
6
- metadata.gz: 8de8e706a371d863ee1646ca85c899ee96c42ce7f94a2c6bb97fabbc579b03af429ddc439356ea7a6d429507e0ccc4c21fda66007ffef6a16fd6925e99ef033f
7
- data.tar.gz: ddd40fb588c98656bae804668cc5ee899af6c09fc660a629edc6a6c443f431832375a0e3930dcb27ebc89153d325780386961dc8e4fececb877fb16b2488648a
6
+ metadata.gz: 9a8e2b2c8c7c42b4c7dac0e21ea6494e5ccd3c349b6be1c3ad36ee59ebeb08e179a68bd16bfde0cb1e7cf0241ffe9e0fbe7cddadd237f5c75dc32850b0100f0c
7
+ data.tar.gz: 81cfa75b45ad704d9a8ebdd221e7415ca0a48eb07ec9f4040369035ee434dc58325f88c615915356e498039f6e0c00afacf1235538951ee2abd4c8c737b1cf96
@@ -5,13 +5,15 @@ 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
9
9
 
10
- def initialize(name:, udid:, device_type_identifier:, available:)
10
+ def initialize(name:, udid:, device_type_identifier:, available:, data_path:, log_path:) # 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
15
17
  end
16
18
 
17
19
  def available?
@@ -27,7 +29,9 @@ module Fastlane
27
29
  name: hash[:name],
28
30
  udid: hash[:udid],
29
31
  device_type_identifier: hash[:deviceTypeIdentifier],
30
- available: hash[:isAvailable]
32
+ available: hash[:isAvailable],
33
+ data_path: hash[:dataPath],
34
+ log_path: hash[:logPath]
31
35
  )
32
36
  end
33
37
  end
@@ -44,7 +44,7 @@ module Fastlane
44
44
  end
45
45
 
46
46
  # Install missing runtimes if needed.
47
- runtime_helper.install_missing_runtimes(required_devices)
47
+ runtime_helper.install_missing_runtimes(required_devices, remove_cached_runtimes: remove_cached_runtimes)
48
48
 
49
49
  # Create missing devices for required devices.
50
50
  create_missing_devices(required_devices)
@@ -39,7 +39,7 @@ module Fastlane
39
39
  shell_helper.simctl_devices_for_runtimes(force: true)
40
40
  end
41
41
 
42
- def install_missing_runtimes(required_devices)
42
+ def install_missing_runtimes(required_devices, remove_cached_runtimes:)
43
43
  needed_runtimes = required_devices.filter_map(&:required_runtime).uniq
44
44
 
45
45
  missing_runtimes = missing_runtimes(needed_runtimes)
@@ -50,13 +50,17 @@ module Fastlane
50
50
  end
51
51
 
52
52
  # Return distinct matched devices strings
53
- matched_devices = create_simulator_devices_runner.find_runtime_and_device_for_required_devices(required_devices)
53
+ matched_simctl_devices = create_simulator_devices_runner.find_runtime_and_device_for_required_devices(required_devices)
54
54
  .reject { |required_device| required_device.simctl_device.nil? }
55
+ .map(&:simctl_device)
55
56
 
56
- matched_devices_udids = matched_devices.map { |matched_device| matched_device.simctl_device.udid }
57
+ matched_devices_udids = matched_simctl_devices.map(&:udid)
57
58
  UI.message("Available simulator devices: #{matched_devices_udids.join(', ')}")
58
59
 
59
- temp_output_dir = "#{File.expand_path(output_dir)}/simctl_diagnose_#{Time.now.strftime('%Y%m%d%H%M%S')}"
60
+ full_output_dir_path = File.expand_path(output_dir)
61
+ temp_output_dir = "#{full_output_dir_path}/simctl_diagnose"
62
+
63
+ FileUtils.mkdir_p(temp_output_dir)
60
64
 
61
65
  diagnose_args = matched_devices_udids.map { |udid| "--udid=#{udid}" }
62
66
  diagnose_args << '-b' # Do NOT show the resulting archive in a Finder window upon completion.
@@ -68,17 +72,42 @@ module Fastlane
68
72
 
69
73
  collect_diagnose_data_script_path = File.expand_path("#{__dir__}/scripts/collect_simctl_diagnose_data.sh")
70
74
 
75
+ UI.message("Collecting diagnose data to #{temp_output_dir}...")
71
76
  shell_helper.sh(
72
77
  command: "SIMCTL_DIAGNOSE_OUTPUT_FOLDER=#{temp_output_dir.shellescape} #{collect_diagnose_data_script_path.shellescape} #{cmd_args}",
73
- print_command: verbose,
78
+ print_command: true,
74
79
  print_command_output: verbose
75
80
  )
76
81
 
77
82
  archive_name = "#{temp_output_dir}.tar.gz"
78
83
  Actions.lane_context[Actions::SharedValues::GATHER_SIMCTL_DIAGNOSE_OUTPUT_FILE] = archive_name
79
84
 
85
+ copy_data_containers_and_logs(matched_simctl_devices, full_output_dir_path) if include_booted_device_data_directory || include_all_device_logs
86
+
80
87
  archive_name
81
88
  end
89
+
90
+ def copy_data_containers_and_logs(matched_simctl_devices, output_dir)
91
+ matched_simctl_devices.each do |simctl_device|
92
+ copy_data_container_and_logs(simctl_device, output_dir)
93
+ end
94
+ end
95
+
96
+ def copy_data_container_and_logs(simctl_device, output_dir)
97
+ if File.exist?(simctl_device.data_path)
98
+ UI.message("Copying data from #{simctl_device.data_path} to #{output_dir}...")
99
+ shell_helper.sh(
100
+ 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}"
101
+ )
102
+ end
103
+
104
+ return unless File.exist?(simctl_device.log_path)
105
+
106
+ UI.message("Copying logs from #{simctl_device.log_path} to #{output_dir}...")
107
+ shell_helper.sh(
108
+ 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}"
109
+ )
110
+ end
82
111
  end
83
112
  end
84
113
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module CreateSimulatorDevices
5
- VERSION = '0.0.14'
5
+ VERSION = '0.0.16'
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.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Budnik