fastlane-plugin-create_simulator_devices 0.0.5 → 0.0.6

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: 2fc01352add3412905b44f8168d0ce72b330e44ade2e34ff1040976d56ca3ee9
4
- data.tar.gz: 9195a8c5a3edcd6391b38b16407ad0e41d8a9e6b4ed05b20da069f6e55944e05
3
+ metadata.gz: a77a05dbf6d484a920978945f9e5941b67ec86f549dfeaa7d9add45d1e778174
4
+ data.tar.gz: '00961903381d91b9170c63bc51ebb2bbea55111511856eea951c854834d77b37'
5
5
  SHA512:
6
- metadata.gz: bc7bcbf613ac9e4839cf14993a53b9606d50ff39d6f9656bb03a3230814ecb78350d16655179e9836ca8fdf0ba1069212130b3f087589d19c1a93f850958607a
7
- data.tar.gz: 98860ea4b0a943ae9a734503c694181e04656e4b20bed4eb6c3ecde2144e63a90e1c5fd3389c960c912d8e46c996c86ef3d55d110374d027d6805cd31d3b1fe2
6
+ metadata.gz: be42b6fb3d60074b6b24c738c53cba15516c599b7f7ac80dce53a0a8dc7e845c2855de0ed9175487daae482c237af90a0b1d93954a4eded31387e4ea0359ed39
7
+ data.tar.gz: c0c89fe57b0992f5d2b1dbae8821e64f3719836500c01c7eaf5442c6bf5b5feba4c99ce59ef4d0b89b9950d2c44fd25a0e24d2db33f29f86e3de22dc2044558c
@@ -25,7 +25,7 @@ module Fastlane
25
25
  required_devices = params[:devices]
26
26
  UI.user_error!('No devices specified') if required_devices.nil? || required_devices.empty?
27
27
 
28
- shell_helper = CreateSimulatorDevices::ShellHelper.new(verbose:, action_context: self)
28
+ shell_helper = CreateSimulatorDevices::ShellHelper.new(print_command: params[:print_command], print_command_output: params[:print_command_output], action_context: self)
29
29
  runtime_helper = CreateSimulatorDevices::RuntimeHelper.new(cache_dir: params[:cache_dir], shell_helper:, verbose:)
30
30
 
31
31
  runner = CreateSimulatorDevices::Runner.new(
@@ -69,16 +69,26 @@ module Fastlane
69
69
  default_value: 'iPhone 16'),
70
70
  ::FastlaneCore::ConfigItem.new(key: :cache_dir,
71
71
  description: 'The directory to cache the simulator runtimes',
72
- is_string: true,
72
+ type: String,
73
73
  optional: true,
74
74
  default_value: "#{Dir.home}/.cache/create_simulator_devices"),
75
75
  ::FastlaneCore::ConfigItem.new(key: :verbose,
76
76
  env_name: 'VERBOSE',
77
77
  description: 'Verbose output',
78
- is_string: false,
78
+ type: Boolean,
79
79
  optional: true,
80
80
  default_value: ::FastlaneCore::Globals.verbose?,
81
- default_value_dynamic: true)
81
+ default_value_dynamic: true),
82
+ ::FastlaneCore::ConfigItem.new(key: :print_command,
83
+ description: 'Print xcrun simctl commands',
84
+ type: Boolean,
85
+ optional: true,
86
+ default_value: false),
87
+ ::FastlaneCore::ConfigItem.new(key: :print_command_output,
88
+ description: 'Print xcrun simctl commands output',
89
+ type: Boolean,
90
+ optional: true,
91
+ default_value: false)
82
92
  ]
83
93
  end
84
94
 
@@ -18,6 +18,8 @@ module Fastlane
18
18
  end
19
19
 
20
20
  def run(devices)
21
+ UI.message("Simulator devices to create: #{devices.join(', ')}")
22
+
21
23
  shell_helper.stop_core_simulator_services
22
24
 
23
25
  # Delete unusable runtimes and unavailable devices.
@@ -29,6 +31,11 @@ module Fastlane
29
31
  .filter_map { |device| required_device_for_device(device) }
30
32
  .uniq { |required_device| [required_device.device_type.name, required_device.required_runtime.product_version] }
31
33
 
34
+ if verbose
35
+ UI.message('Unique required devices:')
36
+ UI.message(" #{required_devices.map(&:description).join("\n ")}")
37
+ end
38
+
32
39
  # Install missing runtimes if needed.
33
40
  runtime_helper.install_missing_runtimes(required_devices)
34
41
 
@@ -39,12 +46,7 @@ module Fastlane
39
46
  matched_devices = required_devices
40
47
  .reject { |required_device| required_device.available_device.nil? }
41
48
 
42
- if verbose
43
- UI.message('Matched devices:')
44
- matched_devices.each do |matched_device|
45
- UI.message("\t#{matched_device.description}: #{matched_device.available_device.description}")
46
- end
47
- end
49
+ log_matched_devices
48
50
 
49
51
  matched_devices.map!(&:description)
50
52
 
@@ -53,6 +55,18 @@ module Fastlane
53
55
  matched_devices
54
56
  end
55
57
 
58
+ def log_matched_devices
59
+ UI.message('Matched devices:')
60
+ matched_devices.each do |matched_device|
61
+ device_info = ''
62
+ if verbose
63
+ device_info = shell_helper.device_info_by_udid(matched_device.available_device.udid)
64
+ device_info = "\n#{device_info}"
65
+ end
66
+ UI.message(" #{matched_device.description}: #{matched_device.available_device.description}#{device_info}")
67
+ end
68
+ end
69
+
56
70
  def delete_unavailable_devices
57
71
  return unless shell_helper.available_devices_for_runtimes.values.flatten.any?(&:available?)
58
72
 
@@ -82,7 +96,10 @@ module Fastlane
82
96
  missing_devices = required_devices
83
97
  .select { |required_device| required_device.available_device.nil? }
84
98
 
85
- return if missing_devices.empty?
99
+ if missing_devices.empty?
100
+ UI.message('All required devices are present. Skipping device creation...') if verbose
101
+ return
102
+ end
86
103
 
87
104
  UI.message('Creating missing devices')
88
105
  missing_devices.each do |missing_device|
@@ -118,9 +135,11 @@ module Fastlane
118
135
  def required_device_for_device(device)
119
136
  available_device_types = shell_helper.available_device_types
120
137
 
138
+ device_os_version = device[/ \(([\d.]*?)\)$/, 1]
139
+ device_name = device.delete_suffix(" (#{device_os_version})").strip unless device_os_version.nil?
140
+
121
141
  device_type = available_device_types.detect do |available_device_type|
122
- # Avoid matching "iPhone 16" for the "iPhone 16e" device.
123
- "#{device} ".start_with?("#{available_device_type.name} ")
142
+ device_name == available_device_type.name
124
143
  end
125
144
 
126
145
  unless device_type
@@ -131,8 +150,6 @@ module Fastlane
131
150
  product_family = device_type.product_family
132
151
 
133
152
  os_name = PRODUCT_FAMILY_TO_OS_NAME[product_family]
134
- device_os_version = device.delete_prefix(device_type.name).strip
135
- device_os_version = device_os_version[/\(([\d.]*?)\)/, 1]
136
153
 
137
154
  runtime_version = nil
138
155
  unless device_os_version.nil? || device_os_version.empty?
@@ -43,7 +43,10 @@ module Fastlane
43
43
 
44
44
  missing_runtimes = missing_runtimes(needed_runtimes)
45
45
 
46
- return if missing_runtimes.empty?
46
+ if missing_runtimes.empty?
47
+ UI.message('All required runtimes are present. Skipping runtime installation...') if verbose
48
+ return
49
+ end
47
50
 
48
51
  missing_runtimes.each do |missing_runtime|
49
52
  download_and_install_missing_runtime(missing_runtime)
@@ -10,16 +10,17 @@ module Fastlane
10
10
  UI = ::Fastlane::UI unless defined?(UI)
11
11
 
12
12
  # Proprty verbose
13
- attr_accessor :verbose, :action_context
13
+ attr_accessor :print_command, :print_command_output, :action_context
14
14
 
15
- def initialize(verbose: false, action_context: nil)
16
- self.verbose = verbose
15
+ def initialize(print_command: false, print_command_output: false, action_context: nil)
16
+ self.print_command = print_command
17
+ self.print_command_output = print_command_output
17
18
  self.action_context = action_context
18
19
  end
19
20
 
20
- def sh(command:, print_command: verbose, print_command_output: verbose)
21
+ def sh(command:, print_command: self.print_command, print_command_output: self.print_command_output)
21
22
  if action_context
22
- action_context.sh(command, print_command:, print_command_output:)
23
+ action_context.sh(command, print_command: print_command, print_command_output: print_command_output)
23
24
  else
24
25
  # Fallback for testing or direct usage
25
26
  require 'open3'
@@ -163,6 +164,14 @@ module Fastlane
163
164
  UI.important("Failed to import runtime #{runtime_name} with '#{import_platform_command}' :\n#{e}")
164
165
  end
165
166
  end
167
+
168
+ def device_info_by_udid(udid)
169
+ sh(
170
+ command: "xcrun simctl list devices --json | jq '.devices | to_entries[].value[] | select(.udid==\"#{udid.shellescape}\")'",
171
+ print_command: false,
172
+ print_command_output: false
173
+ )
174
+ end
166
175
  end
167
176
  end
168
177
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module CreateSimulatorDevices
5
- VERSION = '0.0.5'
5
+ VERSION = '0.0.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Budnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-17 00:00:00.000000000 Z
11
+ date: 2025-08-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: developers@setapp.com