fastlane 2.158.0 → 2.163.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +74 -74
  3. data/cert/lib/cert/options.rb +28 -1
  4. data/cert/lib/cert/runner.rb +50 -33
  5. data/deliver/lib/deliver/app_screenshot_iterator.rb +4 -4
  6. data/deliver/lib/deliver/module.rb +2 -0
  7. data/deliver/lib/deliver/options.rb +20 -4
  8. data/deliver/lib/deliver/runner.rb +36 -8
  9. data/deliver/lib/deliver/upload_metadata.rb +49 -9
  10. data/deliver/lib/deliver/upload_price_tier.rb +7 -2
  11. data/deliver/lib/deliver/upload_screenshots.rb +25 -8
  12. data/{pilot/lib/pilot/.manager.rb.swp → fastlane/lib/fastlane/.erb_template_helper.rb.swp} +0 -0
  13. data/fastlane/lib/fastlane/actions/{.slack.rb.swp → .git_commit.rb.swp} +0 -0
  14. data/fastlane/lib/fastlane/actions/.register_device.rb.swp +0 -0
  15. data/fastlane/lib/fastlane/actions/.register_devices.rb.swp +0 -0
  16. data/fastlane/lib/fastlane/actions/actions_helper.rb +20 -1
  17. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +39 -3
  18. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +15 -1
  19. data/fastlane/lib/fastlane/actions/check_app_store_metadata.rb +1 -0
  20. data/fastlane/lib/fastlane/actions/clean_build_artifacts.rb +1 -0
  21. data/fastlane/lib/fastlane/actions/docs/capture_android_screenshots.md +2 -2
  22. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
  23. data/fastlane/lib/fastlane/actions/docs/create_app_online.md +1 -1
  24. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +3 -2
  25. data/fastlane/lib/fastlane/actions/docs/run_tests.md +2 -2
  26. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +3 -3
  27. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +2 -2
  28. data/fastlane/lib/fastlane/actions/docs/upload_to_testflight.md +2 -2
  29. data/fastlane/lib/fastlane/actions/download_dsyms.rb +32 -7
  30. data/fastlane/lib/fastlane/actions/ensure_git_status_clean.rb +13 -2
  31. data/fastlane/lib/fastlane/actions/get_certificates.rb +1 -0
  32. data/fastlane/lib/fastlane/actions/get_provisioning_profile.rb +1 -0
  33. data/fastlane/lib/fastlane/actions/latest_testflight_build_number.rb +15 -0
  34. data/fastlane/lib/fastlane/actions/register_device.rb +46 -5
  35. data/fastlane/lib/fastlane/actions/register_devices.rb +46 -15
  36. data/fastlane/lib/fastlane/actions/sync_code_signing.rb +1 -0
  37. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +3 -2
  38. data/fastlane/lib/fastlane/helper/git_helper.rb +2 -0
  39. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +6 -4
  40. data/fastlane/lib/fastlane/swift_fastlane_function.rb +1 -1
  41. data/fastlane/lib/fastlane/version.rb +1 -1
  42. data/fastlane/swift/Actions.swift +2 -1
  43. data/fastlane/swift/Appfile.swift +2 -4
  44. data/fastlane/swift/ArgumentProcessor.swift +2 -6
  45. data/fastlane/swift/ControlCommand.swift +2 -5
  46. data/fastlane/swift/Deliverfile.swift +5 -2
  47. data/fastlane/swift/DeliverfileProtocol.swift +18 -7
  48. data/fastlane/swift/Fastfile.swift +5 -1
  49. data/fastlane/swift/Fastlane.swift +2368 -2251
  50. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +5 -5
  51. data/fastlane/swift/Gymfile.swift +5 -2
  52. data/fastlane/swift/GymfileProtocol.swift +6 -3
  53. data/fastlane/swift/LaneFileProtocol.swift +49 -40
  54. data/fastlane/swift/MainProcess.swift +77 -0
  55. data/fastlane/swift/Matchfile.swift +5 -2
  56. data/fastlane/swift/MatchfileProtocol.swift +21 -6
  57. data/fastlane/swift/Plugins.swift +2 -1
  58. data/fastlane/swift/Precheckfile.swift +5 -2
  59. data/fastlane/swift/PrecheckfileProtocol.swift +14 -3
  60. data/fastlane/swift/RubyCommand.swift +2 -6
  61. data/fastlane/swift/RubyCommandable.swift +2 -6
  62. data/fastlane/swift/Runner.swift +5 -9
  63. data/fastlane/swift/RunnerArgument.swift +2 -6
  64. data/fastlane/swift/Scanfile.swift +5 -2
  65. data/fastlane/swift/ScanfileProtocol.swift +6 -3
  66. data/fastlane/swift/Screengrabfile.swift +5 -2
  67. data/fastlane/swift/ScreengrabfileProtocol.swift +6 -3
  68. data/fastlane/swift/Snapshotfile.swift +5 -2
  69. data/fastlane/swift/SnapshotfileProtocol.swift +6 -3
  70. data/fastlane/swift/SocketClient.swift +3 -7
  71. data/fastlane/swift/SocketClientDelegateProtocol.swift +2 -6
  72. data/fastlane/swift/SocketResponse.swift +2 -6
  73. data/fastlane/swift/formatting/Brewfile.lock.json +18 -10
  74. data/fastlane/swift/main.swift +4 -8
  75. data/fastlane/swift/upgrade_manifest.json +1 -1
  76. data/fastlane_core/lib/fastlane_core/analytics/analytics_session.rb +6 -7
  77. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +2 -2
  78. data/frameit/lib/frameit/editor.rb +1 -0
  79. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +2 -2
  80. data/match/lib/match/generator.rb +6 -1
  81. data/match/lib/match/importer.rb +44 -8
  82. data/match/lib/match/migrate.rb +13 -2
  83. data/match/lib/match/nuke.rb +65 -22
  84. data/match/lib/match/options.rb +27 -2
  85. data/match/lib/match/runner.rb +38 -10
  86. data/match/lib/match/spaceship_ensure.rb +27 -21
  87. data/match/lib/match/storage/google_cloud_storage.rb +20 -3
  88. data/match/lib/match/storage/s3_storage.rb +19 -3
  89. data/pilot/lib/pilot/options.rb +2 -2
  90. data/precheck/lib/precheck/options.rb +16 -0
  91. data/precheck/lib/precheck/runner.rb +20 -1
  92. data/sigh/lib/sigh/download_all.rb +16 -4
  93. data/sigh/lib/sigh/options.rb +21 -0
  94. data/sigh/lib/sigh/runner.rb +80 -38
  95. data/snapshot/lib/assets/SnapshotHelper.swift +21 -2
  96. data/spaceship/README.md +1 -1
  97. data/spaceship/lib/spaceship/{connect_api/.DS_Store → .DS_Store} +0 -0
  98. data/spaceship/lib/spaceship/client.rb +9 -4
  99. data/spaceship/lib/spaceship/connect_api.rb +25 -0
  100. data/spaceship/lib/spaceship/connect_api/api_client.rb +12 -3
  101. data/spaceship/lib/spaceship/connect_api/client.rb +38 -15
  102. data/{fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp → spaceship/lib/spaceship/connect_api/models/.app_store_version_submission.rb.swp} +0 -0
  103. data/spaceship/lib/spaceship/connect_api/models/app.rb +17 -9
  104. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +1 -0
  105. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +3 -1
  106. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +2 -2
  107. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +3 -5
  108. data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +3 -5
  109. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +2 -1
  110. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +42 -0
  111. data/spaceship/lib/spaceship/connect_api/models/device.rb +5 -0
  112. data/spaceship/lib/spaceship/connect_api/models/profile.rb +7 -1
  113. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +59 -0
  114. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +45 -2
  115. data/spaceship/lib/spaceship/connect_api/spaceship.rb +3 -2
  116. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +13 -0
  117. data/spaceship/lib/spaceship/connect_api/token.rb +6 -1
  118. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +17 -9
  119. data/spaceship/lib/spaceship/connect_api/users/users.rb +40 -0
  120. data/spaceship/lib/spaceship/helper/net_http_generic_request.rb +11 -5
  121. metadata +27 -25
  122. data/fastlane/lib/fastlane/actions/.hockey.rb.swp +0 -0
  123. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -19,6 +19,8 @@ module Match
19
19
  attr_reader :username
20
20
  attr_reader :team_id
21
21
  attr_reader :team_name
22
+ attr_reader :api_key_path
23
+ attr_reader :api_key
22
24
 
23
25
  def self.configure(params)
24
26
  s3_region = params[:s3_region]
@@ -43,7 +45,9 @@ module Match
43
45
  readonly: params[:readonly],
44
46
  username: params[:username],
45
47
  team_id: params[:team_id],
46
- team_name: params[:team_name]
48
+ team_name: params[:team_name],
49
+ api_key_path: params[:api_key_path],
50
+ api_key: params[:api_key]
47
51
  )
48
52
  end
49
53
 
@@ -55,7 +59,9 @@ module Match
55
59
  readonly: nil,
56
60
  username: nil,
57
61
  team_id: nil,
58
- team_name: nil)
62
+ team_name: nil,
63
+ api_key_path: nil,
64
+ api_key: nil)
59
65
  @s3_bucket = s3_bucket
60
66
  @s3_region = s3_region
61
67
  @s3_client = Fastlane::Helper::S3ClientHelper.new(access_key: s3_access_key, secret_access_key: s3_secret_access_key, region: s3_region)
@@ -64,6 +70,8 @@ module Match
64
70
  @username = username
65
71
  @team_id = team_id
66
72
  @team_name = team_name
73
+ @api_key_path = api_key_path
74
+ @api_key = api_key
67
75
  end
68
76
 
69
77
  # To make debugging easier, we have a custom exception here
@@ -180,10 +188,18 @@ module Match
180
188
  # see `prefixed_working_directory` comments for more details
181
189
  return self.team_id
182
190
  else
183
- spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name)
191
+ UI.user_error!("The `team_id` option is required. fastlane cannot automatically determine portal team id via the App Store Connect API (yet)") if self.team_id.to_s.empty?
192
+
193
+ spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name, api_token)
184
194
  return spaceship.team_id
185
195
  end
186
196
  end
197
+
198
+ def api_token
199
+ api_token ||= Spaceship::ConnectAPI::Token.create(self.api_key) if self.api_key
200
+ api_token ||= Spaceship::ConnectAPI::Token.from_json_file(self.api_key_path) if self.api_key_path
201
+ return api_token
202
+ end
187
203
  end
188
204
  end
189
205
  end
@@ -12,7 +12,7 @@ module Pilot
12
12
  [
13
13
  FastlaneCore::ConfigItem.new(key: :api_key_path,
14
14
  env_name: "PILOT_API_KEY_PATH",
15
- description: "Path to your App Store Connect API key JSON file",
15
+ description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
16
16
  optional: true,
17
17
  conflicting_options: [:username],
18
18
  verify_block: proc do |value|
@@ -20,7 +20,7 @@ module Pilot
20
20
  end),
21
21
  FastlaneCore::ConfigItem.new(key: :api_key,
22
22
  env_name: "PILOT_API_KEY",
23
- description: "Path to your App Store Connect API key JSON file",
23
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)",
24
24
  type: Hash,
25
25
  optional: true,
26
26
  sensitive: true,
@@ -25,6 +25,22 @@ module Precheck
25
25
  user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
26
26
 
27
27
  [
28
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
29
+ env_name: "PRECHECK_API_KEY_PATH",
30
+ description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
31
+ optional: true,
32
+ conflicting_options: [:username],
33
+ verify_block: proc do |value|
34
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
35
+ end),
36
+ FastlaneCore::ConfigItem.new(key: :api_key,
37
+ env_name: "PRECHECK_API_KEY",
38
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)",
39
+ type: Hash,
40
+ optional: true,
41
+ sensitive: true,
42
+ conflicting_options: [:api_key_path, :username]),
43
+
28
44
  FastlaneCore::ConfigItem.new(key: :app_identifier,
29
45
  short_option: "-a",
30
46
  env_name: "PRECHECK_APP_IDENTIFIER",
@@ -18,7 +18,20 @@ module Precheck
18
18
  hide_keys: [:output_path],
19
19
  title: "Summary for precheck #{Fastlane::VERSION}")
20
20
 
21
- unless Spaceship::Tunes.client
21
+ if api_token
22
+
23
+ # As of 2020-09-15, App Store Connect API does not have support for IAPs yet
24
+ # This means that API Key will fail if checking for IAPs.
25
+ #
26
+ # There is also a check in Deliver::Runner for this.
27
+ # Please remove check in Deliver when the API support IAPs.
28
+ if Precheck.config[:include_in_app_purchases]
29
+ UI.user_error!("Precheck cannot check In-app purchases with the App Store Connect API Key (yet). Exclude In-app purchases from precheck or use Apple ID login")
30
+ end
31
+
32
+ UI.message("Creating authorization token for App Store Connect API")
33
+ Spaceship::ConnectAPI.token = api_token
34
+ elsif Spaceship::Tunes.client.nil?
22
35
  # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
23
36
  # Prompts select team if multiple teams and none specified
24
37
  UI.message("Starting login with user '#{Precheck.config[:username]}'")
@@ -58,6 +71,12 @@ module Precheck
58
71
  return true
59
72
  end
60
73
 
74
+ def api_token
75
+ @api_token ||= Spaceship::ConnectAPI::Token.create(Precheck.config[:api_key]) if Precheck.config[:api_key]
76
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Precheck.config[:api_key_path]) if Precheck.config[:api_key_path]
77
+ return @api_token
78
+ end
79
+
61
80
  def print_items_not_checked(processor_result: nil)
62
81
  names = processor_result.items_not_checked.map(&:friendly_name)
63
82
  UI.message("😶 Metadata fields not checked by any rule: #{names.join(', ')}".yellow) if names.length > 0
@@ -9,10 +9,16 @@ module Sigh
9
9
  class DownloadAll
10
10
  # Download all valid provisioning profiles
11
11
  def download_all(download_xcode_profiles: false)
12
- UI.message("Starting login with user '#{Sigh.config[:username]}'")
13
- Spaceship.login(Sigh.config[:username], nil)
14
- Spaceship.select_team
15
- UI.message("Successfully logged in")
12
+ if (token = api_token)
13
+ UI.message("Creating authorization token for App Store Connect API")
14
+ Spaceship::ConnectAPI.token = token
15
+ else
16
+ # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
17
+ # Prompts select team if multiple teams and none specified
18
+ UI.message("Starting login with user '#{Sigh.config[:username]}'")
19
+ Spaceship::ConnectAPI.login(Sigh.config[:username], nil, use_portal: true, use_tunes: false)
20
+ UI.message("Successfully logged in")
21
+ end
16
22
 
17
23
  if download_xcode_profiles
18
24
  UI.deprecated("The App Store Connect API does not support querying for Xcode managed profiles: --download_code_profiles is deprecated")
@@ -53,6 +59,12 @@ module Sigh
53
59
  download_profiles(profiles)
54
60
  end
55
61
 
62
+ def api_token
63
+ api_token ||= Spaceship::ConnectAPI::Token.create(Sigh.config[:api_key]) if Sigh.config[:api_key]
64
+ api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Sigh.config[:api_key_path]) if Sigh.config[:api_key_path]
65
+ return api_token
66
+ end
67
+
56
68
  # @param profiles [Array] Array of all the provisioning profiles we want to download
57
69
  def download_profiles(profiles)
58
70
  UI.important("No profiles available for download") if profiles.empty?
@@ -54,6 +54,25 @@ module Sigh
54
54
  code_gen_sensitive: true,
55
55
  default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
56
56
  default_value_dynamic: true),
57
+
58
+ # App Store Connect API
59
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
60
+ env_name: "SIGH_API_KEY_PATH",
61
+ description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
62
+ optional: true,
63
+ conflicting_options: [:api_key],
64
+ verify_block: proc do |value|
65
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
66
+ end),
67
+ FastlaneCore::ConfigItem.new(key: :api_key,
68
+ env_name: "SIGH_API_KEY",
69
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)",
70
+ type: Hash,
71
+ optional: true,
72
+ sensitive: true,
73
+ conflicting_options: [:api_key_path]),
74
+
75
+ # Apple ID
57
76
  FastlaneCore::ConfigItem.new(key: :username,
58
77
  short_option: "-u",
59
78
  env_name: "SIGH_USERNAME",
@@ -82,6 +101,8 @@ module Sigh
82
101
  verify_block: proc do |value|
83
102
  ENV["FASTLANE_TEAM_NAME"] = value.to_s
84
103
  end),
104
+
105
+ # Other options
85
106
  FastlaneCore::ConfigItem.new(key: :provisioning_name,
86
107
  short_option: "-n",
87
108
  env_name: "SIGH_PROVISIONING_PROFILE_NAME",
@@ -17,11 +17,16 @@ module Sigh
17
17
  hide_keys: [:output_path],
18
18
  title: "Summary for sigh #{Fastlane::VERSION}")
19
19
 
20
- # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
21
- # Prompts select team if multiple teams and none specified
22
- UI.message("Starting login with user '#{Sigh.config[:username]}'")
23
- Spaceship::ConnectAPI.login(Sigh.config[:username], nil, use_portal: true, use_tunes: false)
24
- UI.message("Successfully logged in")
20
+ if api_token
21
+ UI.message("Creating authorization token for App Store Connect API")
22
+ Spaceship::ConnectAPI.token = api_token
23
+ else
24
+ # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
25
+ # Prompts select team if multiple teams and none specified
26
+ UI.message("Starting login with user '#{Sigh.config[:username]}'")
27
+ Spaceship::ConnectAPI.login(Sigh.config[:username], nil, use_portal: true, use_tunes: false)
28
+ UI.message("Successfully logged in")
29
+ end
25
30
 
26
31
  profiles = [] if Sigh.config[:skip_fetch_profiles]
27
32
  profiles ||= fetch_profiles # download the profile if it's there
@@ -54,6 +59,12 @@ module Sigh
54
59
  return download_profile(profile)
55
60
  end
56
61
 
62
+ def api_token
63
+ @api_token ||= Spaceship::ConnectAPI::Token.create(Sigh.config[:api_key]) if Sigh.config[:api_key]
64
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Sigh.config[:api_key_path]) if Sigh.config[:api_key_path]
65
+ return @api_token
66
+ end
67
+
57
68
  # The kind of provisioning profile we're interested in
58
69
  def profile_type
59
70
  return @profile_type if @profile_type
@@ -190,65 +201,95 @@ module Sigh
190
201
  profiles
191
202
  end
192
203
 
204
+ def fetch_certificates(certificate_types)
205
+ filter = {
206
+ certificateType: certificate_types.join(',')
207
+ }
208
+ return Spaceship::ConnectAPI::Certificate.all(filter: filter)
209
+ end
210
+
193
211
  def certificates_for_profile_and_platform
212
+ types = []
213
+
194
214
  case Sigh.config[:platform].to_s
195
215
  when 'ios', 'tvos'
196
216
  if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT
197
- certificates = Spaceship.certificate.development.all +
198
- Spaceship.certificate.apple_development.all
217
+ types = [
218
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT,
219
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DEVELOPMENT
220
+ ]
199
221
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE
200
222
  # Enterprise accounts don't have access to Apple Distribution certificates
201
- certificates = Spaceship.certificate.in_house.all
223
+ types = [
224
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
225
+ ]
202
226
  # handles case where the desired certificate type is adhoc but the account is an enterprise account
203
227
  # the apple dev portal api has a weird quirk in it where if you query for distribution certificates
204
228
  # for enterprise accounts, you get nothing back even if they exist.
205
- elsif (profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC) && Spaceship.client && Spaceship.client.in_house?
229
+ elsif (profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC) && Spaceship::ConnectAPI.client && Spaceship::ConnectAPI.client.in_house?
206
230
  # Enterprise accounts don't have access to Apple Distribution certificates
207
- certificates = Spaceship.certificate.in_house.all
231
+ types = [
232
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
233
+ ]
208
234
  else
209
- # Ad hoc or App Store
210
- certificates = Spaceship.certificate.production.all +
211
- Spaceship.certificate.apple_distribution.all
235
+ types = [
236
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
237
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
238
+ ]
212
239
  end
213
240
 
214
241
  when 'macos', 'catalyst'
215
242
  if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT
216
- certificates = Spaceship.certificate.mac_development.all +
217
- Spaceship.certificate.apple_development.all
243
+ types = [
244
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT,
245
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DEVELOPMENT
246
+ ]
218
247
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE
219
- certificates = Spaceship.certificate.mac_app_distribution.all +
220
- Spaceship.certificate.apple_distribution.all
248
+ types = [
249
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
250
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION
251
+ ]
221
252
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT
222
- certificates = Spaceship.certificate.developer_id_application.all
253
+ types = [
254
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPER_ID_APPLICATION
255
+ ]
223
256
  else
224
- certificates = Spaceship.certificate.mac_app_distribution.all +
225
- Spaceship.certificate.apple_distribution.all
257
+ types = [
258
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
259
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION
260
+ ]
226
261
  end
227
262
  end
228
263
 
229
- certificates
264
+ fetch_certificates(types)
230
265
  end
231
266
 
232
267
  def devices_to_use
233
268
  # Only use devices if development or adhoc
234
269
  return [] if !Sigh.config[:development] && !Sigh.config[:adhoc]
235
270
 
236
- device_class = case Sigh.config[:platform].to_s
237
- when 'ios'
238
- [
239
- Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH,
240
- Spaceship::ConnectAPI::Device::DeviceClass::IPAD,
241
- Spaceship::ConnectAPI::Device::DeviceClass::IPHONE,
242
- Spaceship::ConnectAPI::Device::DeviceClass::IPOD
243
- ].join(",")
244
- when 'tvos'
245
- Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV
246
- when 'macos', 'catalyst'
247
- Spaceship::ConnectAPI::Device::DeviceClass::MAC
248
- end
249
-
250
- filter = { deviceClass: device_class }
251
- return Spaceship::ConnectAPI::Device.all(filter: filter)
271
+ device_classes = case Sigh.config[:platform].to_s
272
+ when 'ios'
273
+ [
274
+ Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH,
275
+ Spaceship::ConnectAPI::Device::DeviceClass::IPAD,
276
+ Spaceship::ConnectAPI::Device::DeviceClass::IPHONE,
277
+ Spaceship::ConnectAPI::Device::DeviceClass::IPOD
278
+ ]
279
+ when 'tvos'
280
+ [Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV]
281
+ when 'macos', 'catalyst'
282
+ [Spaceship::ConnectAPI::Device::DeviceClass::MAC]
283
+ end
284
+
285
+ if api_token
286
+ return Spaceship::ConnectAPI::Device.all.select do |device|
287
+ device_classes.include?(device.device_class)
288
+ end
289
+ else
290
+ filter = { deviceClass: device_classes.join(",") }
291
+ return Spaceship::ConnectAPI::Device.all(filter: filter)
292
+ end
252
293
  end
253
294
 
254
295
  # Certificate to use based on the current distribution mode
@@ -273,7 +314,8 @@ module Sigh
273
314
  unless Sigh.config[:skip_certificate_verification]
274
315
  certificates = certificates.find_all do |c|
275
316
  file = Tempfile.new('cert')
276
- file.write(c.download_raw)
317
+ raw_data = Base64.decode64(c.certificate_content)
318
+ file.write(raw_data)
277
319
  file.close
278
320
 
279
321
  FastlaneCore::CertChecker.installed?(file.path)
@@ -165,6 +165,12 @@ open class Snapshot: NSObject {
165
165
  }
166
166
 
167
167
  let screenshot = XCUIScreen.main.screenshot()
168
+ #if os(iOS)
169
+ let image = XCUIDevice.shared.orientation.isLandscape ? fixLandscapeOrientation(image: screenshot.image) : screenshot.image
170
+ #else
171
+ let image = screenshot.image
172
+ #endif
173
+
168
174
  guard var simulator = ProcessInfo().environment["SIMULATOR_DEVICE_NAME"], let screenshotsDir = screenshotsDirectory else { return }
169
175
 
170
176
  do {
@@ -174,7 +180,7 @@ open class Snapshot: NSObject {
174
180
  simulator = regex.stringByReplacingMatches(in: simulator, range: range, withTemplate: "")
175
181
 
176
182
  let path = screenshotsDir.appendingPathComponent("\(simulator)-\(name).png")
177
- try screenshot.pngRepresentation.write(to: path)
183
+ try image.pngData()?.write(to: path, options: .atomic)
178
184
  } catch let error {
179
185
  NSLog("Problem writing screenshot: \(name) to \(screenshotsDir)/\(simulator)-\(name).png")
180
186
  NSLog(error.localizedDescription)
@@ -182,6 +188,19 @@ open class Snapshot: NSObject {
182
188
  #endif
183
189
  }
184
190
 
191
+ class func fixLandscapeOrientation(image: UIImage) -> UIImage {
192
+ if #available(iOS 10.0, *) {
193
+ let format = UIGraphicsImageRendererFormat()
194
+ format.scale = image.scale
195
+ let renderer = UIGraphicsImageRenderer(size: image.size, format: format)
196
+ return renderer.image { context in
197
+ image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
198
+ }
199
+ } else {
200
+ return image
201
+ }
202
+ }
203
+
185
204
  class func waitForLoadingIndicatorToDisappear(within timeout: TimeInterval) {
186
205
  #if os(tvOS)
187
206
  return
@@ -279,4 +298,4 @@ private extension CGFloat {
279
298
 
280
299
  // Please don't remove the lines below
281
300
  // They are used to detect outdated configuration files
282
- // SnapshotHelperVersion [1.23]
301
+ // SnapshotHelperVersion [1.24]
@@ -167,7 +167,7 @@ _spaceship_ uses all those API points to offer this seamless experience.
167
167
  _spaceship_ does a lot of magic to get everything working so neatly:
168
168
 
169
169
  - **Sensible Defaults**: You only have to provide the mandatory information (e.g. new provisioning profiles contain all devices by default)
170
- - **Local Validation**: When pushing changes back to the Apple Dev Portal _spaceship_ will make sure only valid data is sent to Apple (e.g. automatic repairing of provisioning profiles)
170
+ - **Local Validation**: When pushing changes back to the Apple Developer Portal _spaceship_ will make sure only valid data is sent to Apple (e.g. automatic repairing of provisioning profiles)
171
171
  - **Various request/response types**: When working with the different API endpoints, _spaceship_ has to deal with `JSON`, `XML`, `txt`, `plist` and sometimes even `HTML` responses and requests.
172
172
  - **Automatic Pagination**: Even if you have thousands of apps, profiles or certificates, _spaceship_ **can** handle your scale. It was heavily tested by first using _spaceship_ to create hundreds of profiles and then accessing them using _spaceship_.
173
173
  - **Session, Cookie and CSRF token**: All the security aspects are handled by _spaceship_.
@@ -196,7 +196,7 @@ module Spaceship
196
196
  self.new(cookie: another_client.instance_variable_get(:@cookie), current_team_id: another_client.team_id)
197
197
  end
198
198
 
199
- def initialize(cookie: nil, current_team_id: nil, timeout: nil)
199
+ def initialize(cookie: nil, current_team_id: nil, csrf_tokens: nil, timeout: nil)
200
200
  options = {
201
201
  request: {
202
202
  timeout: (ENV["SPACESHIP_TIMEOUT"] || timeout || 300).to_i,
@@ -204,6 +204,7 @@ module Spaceship
204
204
  }
205
205
  }
206
206
  @current_team_id = current_team_id
207
+ @csrf_tokens = csrf_tokens
207
208
  @cookie = cookie || HTTP::CookieJar.new
208
209
 
209
210
  @client = Faraday.new(self.class.hostname, options) do |c|
@@ -857,9 +858,7 @@ module Spaceship
857
858
 
858
859
  resp_hash = response.to_hash
859
860
  if resp_hash[:status] == 401
860
- msg = "Auth lost"
861
- logger.warn(msg)
862
- raise UnauthorizedAccessError.new, "Unauthorized Access"
861
+ handle_401(response)
863
862
  end
864
863
 
865
864
  if response.body.to_s.include?("<title>302 Found</title>")
@@ -880,6 +879,12 @@ module Spaceship
880
879
  end
881
880
  end
882
881
 
882
+ def handle_401(response)
883
+ msg = "Auth lost"
884
+ logger.warn(msg)
885
+ raise UnauthorizedAccessError.new, "Unauthorized Access"
886
+ end
887
+
883
888
  def send_request_auto_paginate(method, url_or_path, params, headers, &block)
884
889
  response = send_request(method, url_or_path, params, headers, &block)
885
890
  return response unless should_process_next_rel?(response)