fastlane 2.183.2 → 2.184.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +88 -88
  3. data/cert/lib/cert/runner.rb +3 -7
  4. data/deliver/lib/deliver/commands_generator.rb +1 -1
  5. data/deliver/lib/deliver/detect_values.rb +5 -3
  6. data/deliver/lib/deliver/download_screenshots.rb +1 -1
  7. data/deliver/lib/deliver/html_generator.rb +2 -2
  8. data/deliver/lib/deliver/module.rb +6 -0
  9. data/deliver/lib/deliver/options.rb +36 -51
  10. data/deliver/lib/deliver/runner.rb +8 -11
  11. data/deliver/lib/deliver/setup.rb +1 -1
  12. data/deliver/lib/deliver/submit_for_review.rb +1 -1
  13. data/deliver/lib/deliver/upload_metadata.rb +19 -5
  14. data/deliver/lib/deliver/upload_price_tier.rb +1 -1
  15. data/deliver/lib/deliver/upload_screenshots.rb +1 -1
  16. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +7 -11
  17. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +12 -2
  18. data/fastlane/lib/fastlane/actions/check_app_store_metadata.rb +5 -1
  19. data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +32 -12
  20. data/fastlane/lib/fastlane/actions/get_certificates.rb +5 -1
  21. data/fastlane/lib/fastlane/actions/get_provisioning_profile.rb +5 -1
  22. data/fastlane/lib/fastlane/actions/register_device.rb +7 -10
  23. data/fastlane/lib/fastlane/actions/register_devices.rb +7 -10
  24. data/fastlane/lib/fastlane/actions/set_changelog.rb +7 -10
  25. data/fastlane/lib/fastlane/actions/swiftlint.rb +16 -4
  26. data/fastlane/lib/fastlane/actions/sync_code_signing.rb +6 -1
  27. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +5 -1
  28. data/fastlane/lib/fastlane/actions/upload_to_testflight.rb +2 -1
  29. data/fastlane/lib/fastlane/swift_fastlane_function.rb +6 -4
  30. data/fastlane/lib/fastlane/version.rb +1 -1
  31. data/fastlane/swift/Deliverfile.swift +1 -1
  32. data/fastlane/swift/DeliverfileProtocol.swift +20 -20
  33. data/fastlane/swift/Fastlane.swift +462 -240
  34. data/fastlane/swift/Gymfile.swift +1 -1
  35. data/fastlane/swift/GymfileProtocol.swift +1 -1
  36. data/fastlane/swift/Matchfile.swift +1 -1
  37. data/fastlane/swift/MatchfileProtocol.swift +1 -1
  38. data/fastlane/swift/OptionalConfigValue.swift +2 -32
  39. data/fastlane/swift/Precheckfile.swift +1 -1
  40. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  41. data/fastlane/swift/Scanfile.swift +1 -1
  42. data/fastlane/swift/ScanfileProtocol.swift +1 -1
  43. data/fastlane/swift/Screengrabfile.swift +1 -1
  44. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  45. data/fastlane/swift/Snapshotfile.swift +1 -1
  46. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  47. data/fastlane/swift/formatting/Brewfile.lock.json +2 -2
  48. data/fastlane_core/lib/fastlane_core/build_watcher.rb +24 -1
  49. data/fastlane_core/lib/fastlane_core/configuration/commander_generator.rb +5 -0
  50. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +2 -0
  51. data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +1 -1
  52. data/match/lib/match/importer.rb +6 -10
  53. data/match/lib/match/migrate.rb +2 -3
  54. data/match/lib/match/nuke.rb +3 -7
  55. data/match/lib/match/runner.rb +2 -3
  56. data/match/lib/match/spaceship_ensure.rb +3 -0
  57. data/match/lib/match/storage/google_cloud_storage.rb +2 -2
  58. data/match/lib/match/storage/s3_storage.rb +2 -2
  59. data/pilot/lib/pilot/build_manager.rb +2 -0
  60. data/pilot/lib/pilot/manager.rb +3 -7
  61. data/pilot/lib/pilot/options.rb +8 -0
  62. data/precheck/lib/precheck/runner.rb +8 -7
  63. data/sigh/lib/assets/resign.sh +77 -46
  64. data/sigh/lib/sigh/download_all.rb +4 -8
  65. data/sigh/lib/sigh/runner.rb +4 -8
  66. data/spaceship/lib/spaceship/connect_api/models/.age_rating_declaration.rb.swp +0 -0
  67. data/spaceship/lib/spaceship/connect_api/models/age_rating_declaration.rb +35 -4
  68. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +10 -0
  69. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +2 -3
  70. data/spaceship/lib/spaceship/connect_api/token.rb +6 -0
  71. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +4 -2
  72. metadata +19 -18
@@ -75,6 +75,9 @@
75
75
  # new features August 2020
76
76
  # 1. fixes usage for users with GNU-sed in their $PATH
77
77
  #
78
+ # new features May 2021
79
+ # 1. fix entitlements merging when changing team
80
+ #
78
81
 
79
82
  # Logging functions
80
83
 
@@ -346,7 +349,7 @@ function provision_for_bundle_id {
346
349
  }
347
350
 
348
351
  # Find the bundle identifier contained inside a provisioning profile
349
- function bundle_id_for_provison {
352
+ function bundle_id_for_provision {
350
353
 
351
354
  local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(security cms -D -i "$1")")
352
355
  checkStatus
@@ -384,7 +387,7 @@ function add_provision {
384
387
  error "Provisioning profile '$PROVISION' file does not exist"
385
388
  fi
386
389
 
387
- local BUNDLE_ID=$(bundle_id_for_provison "$PROVISION")
390
+ local BUNDLE_ID=$(bundle_id_for_provision "$PROVISION")
388
391
  add_provision_for_bundle_id "$PROVISION" "$BUNDLE_ID"
389
392
  }
390
393
 
@@ -434,7 +437,7 @@ function resign {
434
437
  error "Use the -p option (example: -p com.example.app=xxxx.mobileprovision)"
435
438
  fi
436
439
 
437
- local PROVISION_BUNDLE_IDENTIFIER=$(bundle_id_for_provison "$NEW_PROVISION")
440
+ local PROVISION_BUNDLE_IDENTIFIER=$(bundle_id_for_provision "$NEW_PROVISION")
438
441
 
439
442
  # Use provisioning profile's bundle identifier
440
443
  if [ "$BUNDLE_IDENTIFIER" == "" ]; then
@@ -580,7 +583,7 @@ function resign {
580
583
  # Found a reference bundle id, now get the corresponding provisioning profile for this bundle id
581
584
  REF_PROVISION=$(provision_for_bundle_id "$REF_BUNDLE_ID")
582
585
  # Map to the new bundle id
583
- NEW_REF_BUNDLE_ID=$(bundle_id_for_provison "$REF_PROVISION")
586
+ NEW_REF_BUNDLE_ID=$(bundle_id_for_provision "$REF_PROVISION")
584
587
  # Change if not the same and if doesn't contain wildcard
585
588
  # shellcheck disable=SC2049
586
589
  if [[ "$REF_BUNDLE_ID" != "$NEW_REF_BUNDLE_ID" ]] && ! [[ "$NEW_REF_BUNDLE_ID" =~ \* ]]; then
@@ -636,6 +639,20 @@ function resign {
636
639
  log "\nApp entitlements for ${APP_PATH}:"
637
640
  log "$(cat "$APP_ENTITLEMENTS")"
638
641
 
642
+ # Get the old and new app identifier (prefix)
643
+ APP_ID_KEY="application-identifier"
644
+ # Extract just the identifier from the value
645
+ # Use the fact that we are after some identifer, which is always at the start of the string
646
+ OLD_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$APP_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
647
+ NEW_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
648
+
649
+ # Get the old and the new team ID
650
+ # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
651
+ security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
652
+ OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist")
653
+ # New team ID is part of profile entitlements
654
+ NEW_TEAM_ID=$(PlistBuddy -c "Print com.apple.developer.team-identifier" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
655
+
639
656
  log "Patching profile entitlements with values from app entitlements"
640
657
  PATCHED_ENTITLEMENTS="$TEMP_DIR/patchedEntitlements"
641
658
  # Start with using what comes in provisioning profile entitlements before patching
@@ -654,20 +671,14 @@ function resign {
654
671
  "com.apple.developer.icloud-container-development-container-identifiers" \
655
672
  # This key has an invalid generic value in PP (actual value is set by Xcode during export), see dedicated processing a few blocks below
656
673
  "com.apple.developer.icloud-container-environment" \
657
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
658
- "com.apple.developer.icloud-container-identifiers" \
659
674
  # PP enable all available services and not app-defined ones, must use App entitlements value
660
675
  "com.apple.developer.icloud-services" \
661
676
  # Was already denylisted in previous version, but has someone ever seen this key in a PP?
662
677
  "com.apple.developer.restricted-resource-mode" \
663
678
  # If actually used by the App, this value will be set in its entitlements
664
679
  "com.apple.developer.nfc.readersession.formats" \
665
- # PP list a single TeamID.* identifier and not app-defined ones, must use App entitlements value
666
- "com.apple.developer.pass-type-identifiers" \
667
680
  # If actually used by the App, this value will be set in its entitlements
668
681
  "com.apple.developer.siri" \
669
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
670
- "com.apple.developer.ubiquity-container-identifiers" \
671
682
  # PP define a generic TeamID.* identifier and not the app-defined one, must use App entitlements value
672
683
  "com.apple.developer.ubiquity-kvstore-identifier" \
673
684
  # If actually used by the App, this value will be set in its entitlements
@@ -680,8 +691,6 @@ function resign {
680
691
  "com.apple.developer.healthkit" \
681
692
  # If actually used by the App, this value will be set in its entitlements
682
693
  "com.apple.developer.healthkit.access" \
683
- # PP list identifiers inconsistent with app-defined ones, must use App entitlements value
684
- "com.apple.developer.in-app-payments" \
685
694
  # If actually used by the App, this value will be set in its entitlements
686
695
  "com.apple.developer.networking.vpn.api" \
687
696
  # If actually used by the App, this value will be set in its entitlements
@@ -694,40 +703,45 @@ function resign {
694
703
  "com.apple.developer.associated-domains" \
695
704
  # If actually used by the App, this value will be set in its entitlements
696
705
  "com.apple.developer.default-data-protection" \
697
- # PP seem to list the same groups as the App, but use App entitlements value to be sure
698
- "com.apple.security.application-groups" \
699
706
  # Was already denylisted in previous version, seems to be an artifact from an old Xcode release
700
707
  "com.apple.developer.maps" \
701
708
  # If actually used by the App, this value will be set in its entitlements
702
709
  "com.apple.external-accessory.wireless-configuration"
703
710
  )
704
711
 
712
+ # If we change team while resigning, we have no other choice than to use the following entitlements from the PP instead of the App
713
+ # because they are based on unique identifiers (defined in the developer portal) that can't be shared between teams
714
+ if [[ "$OLD_TEAM_ID" != "$NEW_TEAM_ID" ]]; then
715
+ warning "WARNING: Changing team while resigning"
716
+ warning "WARNING: Using these entitlements from the provisioning profile instead of the existing app:"
717
+ warning "WARNING: App Groups, Merchant IDs (Apple Pay In-App Payments), iCloud Containers, Pass Type IDs (Wallet)"
718
+ warning "WARNING: If these capabilities are enabled, make sure AppID and provisioning profile are properly configured"
719
+ # For Pass Types, PP only list a single TeamID.* identifier and not the potential restricted list defined in the existing App
720
+ # but we can't guess the new identifiers to be used, so this generic value is better than nothing and should be fine for most apps
721
+ warning "WARNING: Resigned app will allow all pass types from the new team, even if old app only allowed a restricted list"
722
+ else
723
+ DENYLISTED_KEYS+=(\
724
+ "com.apple.security.application-groups" \
725
+ "com.apple.developer.in-app-payments" \
726
+ "com.apple.developer.ubiquity-container-identifiers" \
727
+ "com.apple.developer.icloud-container-identifiers" \
728
+ "com.apple.developer.pass-type-identifiers" \
729
+ )
730
+ fi
731
+
705
732
  # Denylisted keys must not be included into new profile, so remove them from patched profile
706
733
  for KEY in "${DENYLISTED_KEYS[@]}"; do
707
734
  log "Removing denylisted key: $KEY"
708
735
  PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
709
736
  done
710
737
 
711
- # Get the old and new app identifier (prefix)
712
- APP_ID_KEY="application-identifier"
713
- # Extract just the identifier from the value
714
- # Use the fact that we are after some identifier, which is always at the start of the string
715
- OLD_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$APP_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
716
- NEW_APP_ID=$(PlistBuddy -c "Print $APP_ID_KEY" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
717
-
718
- # Get the old and the new team ID
719
- # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
720
- security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
721
- OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist")
722
- # New team ID is part of profile entitlements
723
- NEW_TEAM_ID=$(PlistBuddy -c "Print com.apple.developer.team-identifier" "$PROFILE_ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
724
-
725
738
  # List of rules for transferring entitlements from app to profile plist
726
739
  # The format for each enty is "KEY[|ID_TYPE]"
727
740
  # Where KEY is the plist key, e.g. "keychain-access-groups"
728
741
  # and ID_TYPE is optional part separated by '|' that specifies what value to patch:
729
742
  # TEAM_ID - patch the TeamIdentifierPrefix
730
743
  # APP_ID - patch the AppIdentifierPrefix
744
+ # ICLOUD_ENV - patch the target iCloud Environment
731
745
  # Patching means replacing old value from app entitlements with new value from provisioning profile
732
746
  # For example, for KEY=keychain-access-groups the ID_TYPE=APP_ID
733
747
  # Which means that old app ID prefix in keychain-access-groups will be replaced with new app ID prefix
@@ -740,23 +754,32 @@ function resign {
740
754
  "com.apple.developer.healthkit" \
741
755
  "com.apple.developer.healthkit.access" \
742
756
  "com.apple.developer.homekit" \
743
- "com.apple.developer.icloud-container-environment" \
744
- "com.apple.developer.icloud-container-identifiers" \
757
+ "com.apple.developer.icloud-container-environment|ICLOUD_ENV" \
745
758
  "com.apple.developer.icloud-services" \
746
- "com.apple.developer.in-app-payments" \
747
759
  "com.apple.developer.networking.HotspotConfiguration" \
748
760
  "com.apple.developer.networking.multipath" \
749
761
  "com.apple.developer.networking.networkextension" \
750
762
  "com.apple.developer.networking.vpn.api" \
751
763
  "com.apple.developer.nfc.readersession.formats" \
752
- "com.apple.developer.pass-type-identifiers|TEAM_ID" \
753
764
  "com.apple.developer.siri" \
754
- "com.apple.developer.ubiquity-container-identifiers" \
755
765
  "com.apple.developer.ubiquity-kvstore-identifier|TEAM_ID" \
756
766
  "com.apple.external-accessory.wireless-configuration" \
757
- "com.apple.security.application-groups" \
758
767
  "inter-app-audio" \
759
- "keychain-access-groups|APP_ID")
768
+ "keychain-access-groups|APP_ID" \
769
+ )
770
+
771
+ # If we change team while resigning, we have no other choice than to use the following entitlements from the PP instead of the App
772
+ # because they are based on unique identifiers (defined in the developer portal) that can't be shared between teams
773
+ # If we don't change team while resigning, we should use the following entitlements from the existing App and not from the PP
774
+ if [[ "$OLD_TEAM_ID" == "$NEW_TEAM_ID" ]]; then
775
+ ENTITLEMENTS_TRANSFER_RULES+=(\
776
+ "com.apple.security.application-groups" \
777
+ "com.apple.developer.in-app-payments" \
778
+ "com.apple.developer.ubiquity-container-identifiers" \
779
+ "com.apple.developer.icloud-container-identifiers" \
780
+ "com.apple.developer.pass-type-identifiers|TEAM_ID" \
781
+ )
782
+ fi
760
783
 
761
784
  # Loop over all the entitlement keys that need to be transferred from app entitlements
762
785
  for RULE in "${ENTITLEMENTS_TRANSFER_RULES[@]}"; do
@@ -771,7 +794,19 @@ function resign {
771
794
  continue
772
795
  fi
773
796
 
774
- if [[ "$KEY" == "com.apple.developer.icloud-container-environment" ]]; then
797
+ log "App entitlements value for key '$KEY':"
798
+ log "$ENTITLEMENTS_VALUE"
799
+
800
+ # Patch the ID value if specified
801
+ if [[ "$ID_TYPE" == "APP_ID" ]]; then
802
+ # Replace old value with new value in patched entitlements
803
+ log "Replacing old app ID '$OLD_APP_ID' with new app ID '$NEW_APP_ID'"
804
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | sed "s/$OLD_APP_ID/$NEW_APP_ID/g")
805
+ elif [[ "$ID_TYPE" == "TEAM_ID" ]]; then
806
+ # Replace old team identifier with new value
807
+ log "Replacing old team ID '$OLD_TEAM_ID' with new team ID '$NEW_TEAM_ID'"
808
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | sed "s/$OLD_TEAM_ID/$NEW_TEAM_ID/g")
809
+ elif [[ "$ID_TYPE" == "ICLOUD_ENV" ]]; then
775
810
  # Add specific iCloud Environment key to patched entitlements
776
811
  # This value is set by Xcode during export (manually selected for Development and AdHoc, automatically set to Production for Store)
777
812
  # Would need an additional dedicated option to specify the iCloud environment to be used (Development or Production)
@@ -788,20 +823,16 @@ function resign {
788
823
  fi
789
824
  fi
790
825
 
826
+ OLD_ICLOUD_ENV=$(echo "$ENTITLEMENTS_VALUE" | sed -e 's,<string>\(.*\)</string>,\1,g')
791
827
  if [[ "$certificate_name" =~ "Distribution:" ]]; then
792
- ICLOUD_ENV="Production"
828
+ NEW_ICLOUD_ENV="Production"
793
829
  else
794
- ICLOUD_ENV="Development"
830
+ NEW_ICLOUD_ENV="Development"
795
831
  fi
796
- log "Overriding value for $KEY"
797
- log "Old value: $ENTITLEMENTS_VALUE"
798
- log "New value: $ICLOUD_ENV"
799
- ENTITLEMENTS_VALUE="$ICLOUD_ENV"
832
+ log "Replacing iCloud environment '$OLD_ICLOUD_ENV' with '$NEW_ICLOUD_ENV'"
833
+ ENTITLEMENTS_VALUE=$(echo "$ENTITLEMENTS_VALUE" | sed "s/$OLD_ICLOUD_ENV/$NEW_ICLOUD_ENV/g")
800
834
  fi
801
835
 
802
- log "App entitlements value for key '$KEY':"
803
- log "$ENTITLEMENTS_VALUE"
804
-
805
836
  # Remove the entry for current key from profisioning profile entitlements (if exists)
806
837
  PlistBuddy -c "Delete $KEY" "$PATCHED_ENTITLEMENTS" 2>/dev/null
807
838
 
@@ -830,7 +861,7 @@ function resign {
830
861
  # Replace old bundle ID with new bundle ID in patched entitlements
831
862
  # Read old bundle ID from the old Info.plist which was saved for this purpose
832
863
  OLD_BUNDLE_ID="$(PlistBuddy -c "Print :CFBundleIdentifier" "$TEMP_DIR/oldInfo.plist")"
833
- NEW_BUNDLE_ID="$(bundle_id_for_provison "$NEW_PROVISION")"
864
+ NEW_BUNDLE_ID="$(bundle_id_for_provision "$NEW_PROVISION")"
834
865
  log "Replacing old bundle ID '$OLD_BUNDLE_ID' with new bundle ID '$NEW_BUNDLE_ID' in patched entitlements"
835
866
  # Note: ideally we'd match against the opening <string> tag too, but this isn't possible
836
867
  # because $OLD_BUNDLE_ID and $NEW_BUNDLE_ID do not include the team ID prefix which is
@@ -9,9 +9,11 @@ module Sigh
9
9
  class DownloadAll
10
10
  # Download all valid provisioning profiles
11
11
  def download_all(download_xcode_profiles: false)
12
- if (token = api_token)
12
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: Sigh.config[:api_key], filepath: Sigh.config[:api_key_path]))
13
13
  UI.message("Creating authorization token for App Store Connect API")
14
- Spaceship::ConnectAPI.token = token
14
+ Spaceship::ConnectAPI.token = api_token
15
+ elsif !Spaceship::ConnectAPI.token.nil?
16
+ UI.message("Using existing authorization token for App Store Connect API")
15
17
  else
16
18
  # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
17
19
  # Prompts select team if multiple teams and none specified
@@ -59,12 +61,6 @@ module Sigh
59
61
  download_profiles(profiles)
60
62
  end
61
63
 
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
-
68
64
  # @param profiles [Array] Array of all the provisioning profiles we want to download
69
65
  def download_profiles(profiles)
70
66
  UI.important("No profiles available for download") if profiles.empty?
@@ -17,9 +17,11 @@ module Sigh
17
17
  hide_keys: [:output_path],
18
18
  title: "Summary for sigh #{Fastlane::VERSION}")
19
19
 
20
- if api_token
20
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: Sigh.config[:api_key], filepath: Sigh.config[:api_key_path]))
21
21
  UI.message("Creating authorization token for App Store Connect API")
22
22
  Spaceship::ConnectAPI.token = api_token
23
+ elsif !Spaceship::ConnectAPI.token.nil?
24
+ UI.message("Using existing authorization token for App Store Connect API")
23
25
  else
24
26
  # Username is now optional since addition of App Store Connect API Key
25
27
  # Force asking for username to prompt user if not already set
@@ -63,12 +65,6 @@ module Sigh
63
65
  return download_profile(profile)
64
66
  end
65
67
 
66
- def api_token
67
- @api_token ||= Spaceship::ConnectAPI::Token.create(**Sigh.config[:api_key]) if Sigh.config[:api_key]
68
- @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Sigh.config[:api_key_path]) if Sigh.config[:api_key_path]
69
- return @api_token
70
- end
71
-
72
68
  # The kind of provisioning profile we're interested in
73
69
  def profile_type
74
70
  return @profile_type if @profile_type
@@ -286,7 +282,7 @@ module Sigh
286
282
  [Spaceship::ConnectAPI::Device::DeviceClass::MAC]
287
283
  end
288
284
 
289
- if api_token
285
+ if Spaceship::ConnectAPI.token
290
286
  return Spaceship::ConnectAPI::Device.all.select do |device|
291
287
  device_classes.include?(device.device_class)
292
288
  end
@@ -6,6 +6,8 @@ module Spaceship
6
6
 
7
7
  # Rating
8
8
  attr_accessor :alcohol_tobacco_or_drug_use_or_references
9
+ attr_accessor :contests
10
+ attr_accessor :gambling
9
11
  attr_accessor :gambling_simulated
10
12
  attr_accessor :medical_or_treatment_information
11
13
  attr_accessor :profanity_or_crude_humor
@@ -16,13 +18,16 @@ module Spaceship
16
18
  attr_accessor :violence_realistic_prolonged_graphic_or_sadistic
17
19
  attr_accessor :violence_realistic
18
20
 
19
- # boolean
20
- attr_accessor :gambling_and_contests
21
+ # Boolean
22
+ attr_accessor :seventeen_plus
21
23
  attr_accessor :unrestricted_web_access
22
24
 
23
25
  # KidsAge
24
26
  attr_accessor :kids_age_band
25
27
 
28
+ # Deprecated as of App Store Connect API 1.3
29
+ attr_accessor :gambling_and_contests
30
+
26
31
  module Rating
27
32
  NONE = "NONE"
28
33
  INFREQUENT_OR_MILD = "INFREQUENT_OR_MILD"
@@ -37,10 +42,12 @@ module Spaceship
37
42
 
38
43
  attr_mapping({
39
44
  "alcoholTobaccoOrDrugUseOrReferences" => "alcohol_tobacco_or_drug_use_or_references",
40
- "gamblingAndContests" => "gambling_and_contests",
45
+ "contests" => "contests",
46
+ "gambling" => "gambling",
41
47
  "gamblingSimulated" => "gambling_simulated",
42
48
  "medicalOrTreatmentInformation" => "medical_or_treatment_information",
43
49
  "profanityOrCrudeHumor" => "profanity_or_crude_humor",
50
+ "seventeenPlus" => "seventeen_plus",
44
51
  "sexualContentGraphicAndNudity" => "sexual_content_graphic_and_nudity",
45
52
  "sexualContentOrNudity" => "sexual_content_or_nudity",
46
53
  "horrorOrFearThemes" => "horror_or_fear_themes",
@@ -49,7 +56,10 @@ module Spaceship
49
56
  "violenceCartoonOrFantasy" => "violence_cartoon_or_fantasy",
50
57
  "violenceRealisticProlongedGraphicOrSadistic" => "violence_realistic_prolonged_graphic_or_sadistic",
51
58
  "violenceRealistic" => "violence_realistic",
52
- "kidsAgeBand" => "kids_age_band"
59
+ "kidsAgeBand" => "kids_age_band",
60
+
61
+ # Deprecated as of App Store Connect API 1.3
62
+ "gamblingAndContests" => "gambling_and_contests",
53
63
  })
54
64
 
55
65
  def self.type
@@ -83,6 +93,27 @@ module Spaceship
83
93
  1 => true
84
94
  }
85
95
 
96
+ def self.map_deprecation_if_possible(attributes)
97
+ attributes = attributes.dup
98
+ messages = []
99
+ errors = []
100
+
101
+ value = attributes.delete('gamblingAndContests')
102
+ return attributes, messages, errors if value.nil?
103
+
104
+ messages << "Age Rating 'gamblingAndContests' has been deprecated and split into 'gambling' and 'contests'"
105
+
106
+ attributes['gambling'] = value
107
+ if value == true
108
+ errors << "'gamblingAndContests' could not be mapped to 'contests' - 'contests' requires a value of 'NONE', 'INFREQUENT_OR_MILD', or 'FREQUENT_OR_INTENSE'"
109
+ attributes['contests'] = value
110
+ else
111
+ attributes['contests'] = 'NONE'
112
+ end
113
+
114
+ return attributes, messages, errors
115
+ end
116
+
86
117
  def self.map_key_from_itc(key)
87
118
  key = key.gsub("MZGenre.", "")
88
119
  return nil if key.empty?
@@ -81,6 +81,16 @@ module Spaceship
81
81
  client.delete_app_info(app_info_id: id)
82
82
  end
83
83
 
84
+ #
85
+ # Age Rating Declaration
86
+ #
87
+
88
+ def fetch_age_rating_declaration(client: nil)
89
+ client ||= Spaceship::ConnectAPI
90
+ resp = client.get_age_rating_declaration(app_info_id: id)
91
+ return resp.to_models.first
92
+ end
93
+
84
94
  #
85
95
  # App Info Localizations
86
96
  #
@@ -110,10 +110,9 @@ module Spaceship
110
110
  # Age Rating Declaration
111
111
  #
112
112
 
113
+ # @deprecated
113
114
  def fetch_age_rating_declaration(client: nil)
114
- client ||= Spaceship::ConnectAPI
115
- resp = client.get_age_rating_declaration(app_store_version_id: id)
116
- return resp.to_models.first
115
+ raise 'AppStoreVersion no longer as AgeRatingDelcaration as of App Store Connect API 1.3 - Use AppInfo instead'
117
116
  end
118
117
 
119
118
  #
@@ -25,6 +25,12 @@ module Spaceship
25
25
  # key is for App Store or Enterprise so this is the temporary workaround
26
26
  attr_accessor :in_house
27
27
 
28
+ def self.from(hash: nil, filepath: nil)
29
+ api_token ||= self.create(**hash) if hash
30
+ api_token ||= self.from_json_file(filepath) if filepath
31
+ return api_token
32
+ end
33
+
28
34
  def self.from_json_file(filepath)
29
35
  json = JSON.parse(File.read(filepath), { symbolize_names: true })
30
36
 
@@ -17,9 +17,11 @@ module Spaceship
17
17
  # ageRatingDeclarations
18
18
  #
19
19
 
20
- def get_age_rating_declaration(app_store_version_id: nil)
20
+ def get_age_rating_declaration(app_info_id: nil, app_store_version_id: nil)
21
+ raise "Keyword 'app_store_version_id' is deprecated and 'app_info_id' is required" if app_store_version_id || app_info_id.nil?
22
+
21
23
  params = tunes_request_client.build_params(filter: nil, includes: nil, limit: nil, sort: nil)
22
- tunes_request_client.get("appStoreVersions/#{app_store_version_id}/ageRatingDeclaration", params)
24
+ tunes_request_client.get("appInfos/#{app_info_id}/ageRatingDeclaration", params)
23
25
  end
24
26
 
25
27
  def patch_age_rating_declaration(age_rating_declaration_id: nil, attributes: nil)