Class: Produce::Service

Constant Summary

Constants included from Spaceship::ConnectAPI::BundleIdCapability::Options

Spaceship::ConnectAPI::BundleIdCapability::Options::COMPLETE_PROTECTION, Spaceship::ConnectAPI::BundleIdCapability::Options::GAME_CENTER_IOS, Spaceship::ConnectAPI::BundleIdCapability::Options::GAME_CENTER_MAC, Spaceship::ConnectAPI::BundleIdCapability::Options::PRIMARY_APP_CONSENT, Spaceship::ConnectAPI::BundleIdCapability::Options::PROTECTED_UNLESS_OPEN, Spaceship::ConnectAPI::BundleIdCapability::Options::PROTECTED_UNTIL_FIRST_USER_AUTH, Spaceship::ConnectAPI::BundleIdCapability::Options::XCODE_5, Spaceship::ConnectAPI::BundleIdCapability::Options::XCODE_6

Constants included from Spaceship::ConnectAPI::BundleIdCapability::Settings

Spaceship::ConnectAPI::BundleIdCapability::Settings::APPLE_ID_AUTH_APP_CONSENT, Spaceship::ConnectAPI::BundleIdCapability::Settings::DATA_PROTECTION_PERMISSION_LEVEL, Spaceship::ConnectAPI::BundleIdCapability::Settings::GAME_CENTER_SETTING, Spaceship::ConnectAPI::BundleIdCapability::Settings::ICLOUD_VERSION

Constants included from Spaceship::ConnectAPI::BundleIdCapability::Type

Spaceship::ConnectAPI::BundleIdCapability::Type::ACCESS_WIFI_INFORMATION, Spaceship::ConnectAPI::BundleIdCapability::Type::APPLE_ID_AUTH, Spaceship::ConnectAPI::BundleIdCapability::Type::APPLE_PAY, Spaceship::ConnectAPI::BundleIdCapability::Type::APP_ATTEST, Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS, Spaceship::ConnectAPI::BundleIdCapability::Type::ASSOCIATED_DOMAINS, Spaceship::ConnectAPI::BundleIdCapability::Type::AUTOFILL_CREDENTIAL_PROVIDER, Spaceship::ConnectAPI::BundleIdCapability::Type::CARPLAY_MESSAGING, Spaceship::ConnectAPI::BundleIdCapability::Type::CARPLAY_NAVIGATION, Spaceship::ConnectAPI::BundleIdCapability::Type::CARPLAY_PLAYABLE_CONTENT, Spaceship::ConnectAPI::BundleIdCapability::Type::CARPLAY_VOIP, Spaceship::ConnectAPI::BundleIdCapability::Type::CLASSKIT, Spaceship::ConnectAPI::BundleIdCapability::Type::COREMEDIA_HLS_LOW_LATENCY, Spaceship::ConnectAPI::BundleIdCapability::Type::CRITICAL_ALERTS, Spaceship::ConnectAPI::BundleIdCapability::Type::DATA_PROTECTION, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_ENDPOINT_SECURITY, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_HID, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_HID_DEVICE, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_HID_EVENT_SERVICE, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_NETWORKING, Spaceship::ConnectAPI::BundleIdCapability::Type::DRIVERKIT_SERIAL, Spaceship::ConnectAPI::BundleIdCapability::Type::EXTENDED_VIRTUAL_ADDRESSING, Spaceship::ConnectAPI::BundleIdCapability::Type::FAMILY_CONTROLS, Spaceship::ConnectAPI::BundleIdCapability::Type::FILEPROVIDER_TESTINGMODE, Spaceship::ConnectAPI::BundleIdCapability::Type::FONT_INSTALLATION, Spaceship::ConnectAPI::BundleIdCapability::Type::GAME_CENTER, Spaceship::ConnectAPI::BundleIdCapability::Type::GROUP_ACTIVITIES, Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT, Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT_RECALIBRATE_ESTIMATES, Spaceship::ConnectAPI::BundleIdCapability::Type::HLS_INTERSTITIAL_PREVIEW, Spaceship::ConnectAPI::BundleIdCapability::Type::HOMEKIT, Spaceship::ConnectAPI::BundleIdCapability::Type::HOTSPOT_HELPER_MANAGED, Spaceship::ConnectAPI::BundleIdCapability::Type::HOT_SPOT, Spaceship::ConnectAPI::BundleIdCapability::Type::ICLOUD, Spaceship::ConnectAPI::BundleIdCapability::Type::INTER_APP_AUDIO, Spaceship::ConnectAPI::BundleIdCapability::Type::IN_APP_PURCHASE, Spaceship::ConnectAPI::BundleIdCapability::Type::IPAD_CAMERA_MULTITASKING, Spaceship::ConnectAPI::BundleIdCapability::Type::MAPS, Spaceship::ConnectAPI::BundleIdCapability::Type::MARZIPAN, Spaceship::ConnectAPI::BundleIdCapability::Type::MDM_MANAGED_ASSOCIATED_DOMAINS, Spaceship::ConnectAPI::BundleIdCapability::Type::MULTIPATH, Spaceship::ConnectAPI::BundleIdCapability::Type::MUSIC_KIT, Spaceship::ConnectAPI::BundleIdCapability::Type::NETWORK_CUSTOM_PROTOCOL, Spaceship::ConnectAPI::BundleIdCapability::Type::NETWORK_EXTENSIONS, Spaceship::ConnectAPI::BundleIdCapability::Type::NFC_TAG_READING, Spaceship::ConnectAPI::BundleIdCapability::Type::PERSONAL_VPN, Spaceship::ConnectAPI::BundleIdCapability::Type::PUSH_NOTIFICATIONS, Spaceship::ConnectAPI::BundleIdCapability::Type::SFUNIVERSALLINK_API, Spaceship::ConnectAPI::BundleIdCapability::Type::SHAZAM_KIT, Spaceship::ConnectAPI::BundleIdCapability::Type::SIRIKIT, Spaceship::ConnectAPI::BundleIdCapability::Type::SYSTEM_EXTENSION_INSTALL, Spaceship::ConnectAPI::BundleIdCapability::Type::USERNOTIFICATIONS_COMMUNICATION, Spaceship::ConnectAPI::BundleIdCapability::Type::USERNOTIFICATIONS_TIMESENSITIVE, Spaceship::ConnectAPI::BundleIdCapability::Type::USER_MANAGEMENT, Spaceship::ConnectAPI::BundleIdCapability::Type::VP9_DECODER, Spaceship::ConnectAPI::BundleIdCapability::Type::WALLET, Spaceship::ConnectAPI::BundleIdCapability::Type::WIRELESS_ACCESSORY_CONFIGURATION

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_services(options, args) ⇒ Object



19
20
21
# File 'produce/lib/produce/service.rb', line 19

def self.available_services(options, args)
  self.new.available_services(options, args)
end

.disable(options, args) ⇒ Object



15
16
17
# File 'produce/lib/produce/service.rb', line 15

def self.disable(options, args)
  self.new.disable(options, args)
end

.enable(options, args) ⇒ Object



11
12
13
# File 'produce/lib/produce/service.rb', line 11

def self.enable(options, args)
  self.new.enable(options, args)
end

Instance Method Details

#available_services(options, _args) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'produce/lib/produce/service.rb', line 47

def available_services(options, _args)
  unless bundle_id
    UI.message("[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist")
    return
  end

  UI.success("[DevCenter] App found '#{bundle_id.name}'")
  UI.message("Fetching available services")
  return Spaceship::ConnectAPI::Capabilities.all
end

#build_settings_for(settings_key:, options_key:) ⇒ Hash

Returns Settings configuration for a key-settings combination.

Examples:

[{
   key: "DATA_PROTECTION_PERMISSION_LEVEL",
   options:
   [
     {
       key: "COMPLETE_PROTECTION"
     }
   ]
 }]

Returns:

  • (Hash)

    Settings configuration for a key-settings combination



81
82
83
84
85
86
87
88
# File 'produce/lib/produce/service.rb', line 81

def build_settings_for(settings_key:, options_key:)
  return [{
   key: settings_key,
   options: [ {
       key: options_key
     } ]
  }]
end

#bundle_idObject



416
417
418
419
420
421
422
423
# File 'produce/lib/produce/service.rb', line 416

def bundle_id
  return @bundle_id if @bundle_id
  UI.message("Starting login with user '#{Produce.config[:username]}'")
  Spaceship.(Produce.config[:username], nil)
  Spaceship.select_team
  UI.message("Successfully logged in")
  @bundle_id ||= Spaceship::ConnectAPI::BundleId.find(Produce.config[:app_identifier].to_s)
end

#disable(options, _args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'produce/lib/produce/service.rb', line 35

def disable(options, _args)
  unless bundle_id
    UI.message("[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist")
    return
  end

  UI.success("[DevCenter] App found '#{bundle_id.name}'")
  UI.message("Disabling services")
  disabled = update(false, options)
  UI.success("Done! Disabled #{disabled} services.")
end

#enable(options, _args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'produce/lib/produce/service.rb', line 23

def enable(options, _args)
  unless bundle_id
    UI.message("[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist")
    return
  end

  UI.success("[DevCenter] App found '#{bundle_id.name}'")
  UI.message("Enabling services")
  enabled = update(true, options)
  UI.success("Done! Enabled #{enabled} services.")
end

#update(on, options) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity rubocop:disable Require/MissingRequireStatement



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'produce/lib/produce/service.rb', line 92

def update(on, options)
  updated = valid_services_for(options).count

  if options.access_wifi
    UI.message("\tAccess WiFi")
    bundle_id.update_capability(ACCESS_WIFI_INFORMATION, enabled: on)
  end

  if options.app_attest
    UI.message("\tApp Attest")
    bundle_id.update_capability(APP_ATTEST, enabled: on)
  end

  if options.app_group
    UI.message("\tApp Groups")
    bundle_id.update_capability(APP_GROUPS, enabled: on)
  end

  if options.apple_pay
    UI.message("\tApple Pay")
    bundle_id.update_capability(APPLE_PAY, enabled: on)
  end

  if options.associated_domains
    UI.message("\tAssociated Domains")
    bundle_id.update_capability(ASSOCIATED_DOMAINS, enabled: on)
  end

  if options.auto_fill_credential
    UI.message("\tAutoFill Credential")
    bundle_id.update_capability(AUTOFILL_CREDENTIAL_PROVIDER, enabled: on)
  end

  if options.car_play_audio_app
    UI.message("\tCarPlay Audio App")
    bundle_id.update_capability(CARPLAY_PLAYABLE_CONTENT, enabled: on)
  end

  if options.car_play_messaging_app
    UI.message("\tCarPlay Messaging App")
    bundle_id.update_capability(CARPLAY_MESSAGING, enabled: on)
  end

  if options.car_play_navigation_app
    UI.message("\tCarPlay Navigation App")
    bundle_id.update_capability(CARPLAY_NAVIGATION, enabled: on)
  end

  if options.car_play_voip_calling_app
    UI.message("\tCarPlay Voip Calling App")
    bundle_id.update_capability(CARPLAY_VOIP, enabled: on)
  end

  if options.class_kit
    UI.message("\tClassKit")
    bundle_id.update_capability(CLASSKIT, enabled: on)
  end

  if options.critical_alerts
    UI.message("\tCritical Alerts")
    bundle_id.update_capability(CRITICAL_ALERTS, enabled: on)
  end

  if options.custom_network_protocol
    UI.message("\tCustom Network Protocol")
    bundle_id.update_capability(NETWORK_CUSTOM_PROTOCOL, enabled: on)
  end

  if options.data_protection
    UI.message("\tData Protection")

    settings = []
    case options.data_protection
    when "complete"
      settings = build_settings_for(settings_key: DATA_PROTECTION_PERMISSION_LEVEL, options_key: COMPLETE_PROTECTION)
    when "unlessopen"
      settings = build_settings_for(settings_key: DATA_PROTECTION_PERMISSION_LEVEL, options_key: PROTECTED_UNLESS_OPEN)
    when "untilfirstauth"
      settings = build_settings_for(settings_key: DATA_PROTECTION_PERMISSION_LEVEL, options_key: PROTECTED_UNTIL_FIRST_USER_AUTH)
    else
      UI.user_error!("Unknown service '#{options.data_protection}'. Valid values: 'complete', 'unlessopen', 'untilfirstauth'") unless options.data_protection == true || options.data_protection == false
    end
    bundle_id.update_capability(DATA_PROTECTION, enabled: on, settings: settings)
  end

  if options.extended_virtual_address_space
    UI.message("\tExtended Virtual Address Space")
    bundle_id.update_capability(EXTENDED_VIRTUAL_ADDRESSING, enabled: on)
  end

  if options.family_controls
    UI.message("\tFamily Controls")
    bundle_id.update_capability(FAMILY_CONTROLS, enabled: on)
  end

  if options.file_provider_testing_mode
    UI.message("\tFile Provider Testing Mode")
    bundle_id.update_capability(FILEPROVIDER_TESTINGMODE, enabled: on)
  end

  if options.fonts
    UI.message("\tFonts")
    bundle_id.update_capability(FONT_INSTALLATION, enabled: on)
  end

  if options.game_center
    UI.message("\tGame Center")

    settings = []
    case options.game_center
    when "mac"
      settings = build_settings_for(settings_key: GAME_CENTER_SETTING, options_key: GAME_CENTER_MAC)
    when "ios"
      settings = build_settings_for(settings_key: GAME_CENTER_SETTING, options_key: GAME_CENTER_IOS)
    else
      UI.user_error!("Unknown service '#{options.game_center}'. Valid values: 'ios', 'mac'") unless options.game_center == true || options.game_center == false
    end
    bundle_id.update_capability(GAME_CENTER, enabled: on, settings: settings)
  end

  if options.health_kit
    UI.message("\tHealthKit")
    bundle_id.update_capability(HEALTHKIT, enabled: on)
  end

  if options.hls_interstitial_preview
    UI.message("\tHLS Interstitial Preview")
    bundle_id.update_capability(HLS_INTERSTITIAL_PREVIEW, enabled: on)
  end

  if options.home_kit
    UI.message("\tHomeKit")
    bundle_id.update_capability(HOMEKIT, enabled: on)
  end

  if options.hotspot
    UI.message("\tHotspot")
    bundle_id.update_capability(HOT_SPOT, enabled: on)
  end

  if options.hotspot_helper
    UI.message("\tHotspot Helper")
    bundle_id.update_capability(HOTSPOT_HELPER_MANAGED, enabled: on)
  end

  if options.icloud
    UI.message("\tiCloud")

    settings = []
    case options.icloud
    when "xcode6_compatible"
      settings = build_settings_for(settings_key: ICLOUD_VERSION, options_key: XCODE_6)
    when "xcode5_compatible"
      settings = build_settings_for(settings_key: ICLOUD_VERSION, options_key: XCODE_5)
    else
      UI.user_error!("Unknown service '#{options.icloud}'. Valid values: 'xcode6_compatible', 'xcode5_compatible', 'off'") unless options.icloud == true || options.icloud == false
    end
    bundle_id.update_capability(ICLOUD, enabled: on, settings: settings)
  end

  if options.in_app_purchase
    UI.message("\tIn-App Purchase")
    bundle_id.update_capability(IN_APP_PURCHASE, enabled: on)
  end

  if options.inter_app_audio
    UI.message("\tInter-App Audio")
    bundle_id.update_capability(INTER_APP_AUDIO, enabled: on)
  end

  if options.low_latency_hls
    UI.message("\tLow Latency HLS")
    bundle_id.update_capability(COREMEDIA_HLS_LOW_LATENCY, enabled: on)
  end

  if options.managed_associated_domains
    UI.message("\tManaged Associated Domains")
    bundle_id.update_capability(MDM_MANAGED_ASSOCIATED_DOMAINS, enabled: on)
  end

  if options.maps
    UI.message("\tMaps")
    bundle_id.update_capability(MAPS, enabled: on)
  end

  if options.multipath
    UI.message("\tMultipath")
    bundle_id.update_capability(MULTIPATH, enabled: on)
  end

  if options.network_extension
    UI.message("\tNetwork Extension")
    bundle_id.update_capability(NETWORK_EXTENSIONS, enabled: on)
  end

  if options.nfc_tag_reading
    UI.message("\tNFC Tag Reading")
    bundle_id.update_capability(NFC_TAG_READING, enabled: on)
  end

  if options.personal_vpn
    UI.message("\tPersonal VPN")
    bundle_id.update_capability(PERSONAL_VPN, enabled: on)
  end

  if options.push_notification
    UI.message("\tPush Notifications")
    bundle_id.update_capability(PUSH_NOTIFICATIONS, enabled: on)
  end

  if options.
    UI.message("\tSign In With Apple")
    settings = build_settings_for(settings_key: APPLE_ID_AUTH_APP_CONSENT, options_key: PRIMARY_APP_CONSENT)
    bundle_id.update_capability(APPLE_ID_AUTH, enabled: on, settings: settings)
  end

  if options.siri_kit
    UI.message("\tSiriKit")
    bundle_id.update_capability(SIRIKIT, enabled: on)
  end

  if options.system_extension
    UI.message("\tSystem Extension")
    bundle_id.update_capability(SYSTEM_EXTENSION_INSTALL, enabled: on)
  end

  if options.user_management
    UI.message("\tUser Management")
    bundle_id.update_capability(USER_MANAGEMENT, enabled: on)
  end

  if options.wallet
    UI.message("\tWallet")
    bundle_id.update_capability(WALLET, enabled: on)
  end

  if options.wireless_accessory
    UI.message("\tWireless Accessory Configuration")
    bundle_id.update_capability(WIRELESS_ACCESSORY_CONFIGURATION, enabled: on)
  end

  if options.driver_kit
    UI.message("\tDriverKit")
    bundle_id.update_capability(DRIVERKIT, enabled: on)
  end

  if options.driver_kit_endpoint_security
    UI.message("\tDriverKit Endpoint Security")
    bundle_id.update_capability(DRIVERKIT_ENDPOINT_SECURITY, enabled: on)
  end

  if options.driver_kit_family_hid_device
    UI.message("\tDriverKit Family HID Device")
    bundle_id.update_capability(DRIVERKIT_HID_DEVICE, enabled: on)
  end

  if options.driver_kit_family_networking
    UI.message("\tDriverKit Family Networking")
    bundle_id.update_capability(DRIVERKIT_NETWORKING, enabled: on)
  end

  if options.driver_kit_family_serial
    UI.message("\tDriverKit Family Serial")
    bundle_id.update_capability(DRIVERKIT_SERIAL, enabled: on)
  end

  if options.driver_kit_hid_event_service
    UI.message("\tDriverKit HID EventService")
    bundle_id.update_capability(DRIVERKIT_HID_EVENT_SERVICE, enabled: on)
  end

  if options.driver_kit_transport_hid
    UI.message("\tDriverKit Transport HID")
    bundle_id.update_capability(DRIVERKIT_HID, enabled: on)
  end

  if options.multitasking_camera_access
    UI.message("\tMultitasking Camera Access")
    bundle_id.update_capability(IPAD_CAMERA_MULTITASKING, enabled: on)
  end

  if options.sf_universal_link_api
    UI.message("\tSFUniversalLink API")
    bundle_id.update_capability(SFUNIVERSALLINK_API, enabled: on)
  end

  if options.vp9_decoder
    UI.message("\tVP9 Decoder")
    bundle_id.update_capability(VP9_DECODER, enabled: on)
  end

  if options.music_kit
    UI.message("\tMusicKit")
    bundle_id.update_capability(MUSIC_KIT, enabled: on)
  end

  if options.shazam_kit
    UI.message("\tShazamKit")
    bundle_id.update_capability(SHAZAM_KIT, enabled: on)
  end

  if options.communication_notifications
    UI.message("\tCommunication Notifications")
    bundle_id.update_capability(USERNOTIFICATIONS_COMMUNICATION, enabled: on)
  end

  if options.group_activities
    UI.message("\tGroup Activities")
    bundle_id.update_capability(GROUP_ACTIVITIES, enabled: on)
  end

  if options.health_kit_estimate_recalibration
    UI.message("\tHealthKit Estimate Recalibration")
    bundle_id.update_capability(HEALTHKIT_RECALIBRATE_ESTIMATES, enabled: on)
  end

  if options.time_sensitive_notifications
    UI.message("\tTime Sensitive Notifications")
    bundle_id.update_capability(USERNOTIFICATIONS_TIMESENSITIVE, enabled: on)
  end

  updated
end

#valid_services_for(options) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'produce/lib/produce/service.rb', line 58

def valid_services_for(options)
  allowed_keys = [:access_wifi, :app_attest, :app_group, :apple_pay, :associated_domains, :auto_fill_credential, :car_play_audio_app, :car_play_messaging_app,
                  :car_play_navigation_app, :car_play_voip_calling_app, :class_kit, :icloud, :critical_alerts, :custom_network_protocol, :data_protection,
                  :extended_virtual_address_space, :file_provider_testing_mode, :family_controls, :fonts, :game_center, :health_kit, :hls_interstitial_preview, :home_kit, :hotspot,
                  :hotspot_helper, :in_app_purchase, :inter_app_audio, :low_latency_hls, :managed_associated_domains, :maps, :multipath, :network_extension,
                  :nfc_tag_reading, :passbook, :personal_vpn, :push_notification, :sign_in_with_apple, :siri_kit, :system_extension, :user_management, :vpn_configuration, :wallet,
                  :wireless_accessory, :driver_kit, :driver_kit_endpoint_security, :driver_kit_family_hid_device, :driver_kit_family_networking, :driver_kit_family_serial,
                  :driver_kit_hid_event_service, :driver_kit_transport_hid, :multitasking_camera_access, :sf_universal_link_api, :vp9_decoder, :music_kit, :shazam_kit,
                  :communication_notifications, :group_activities, :health_kit_estimate_recalibration, :time_sensitive_notifications]
  options.__hash__.select { |key, value| allowed_keys.include?(key) }
end