|
| 1 | +module Fastlane |
| 2 | + module Actions |
| 3 | + class AddDevelopmentCertificatesToProvisioningProfilesAction < Action |
| 4 | + def self.run(params) |
| 5 | + require 'spaceship' |
| 6 | + |
| 7 | + Spaceship.login |
| 8 | + Spaceship.select_team(team_id: params[:team_id]) |
| 9 | + |
| 10 | + all_certificates = Spaceship.certificate.all(mac: false).select { |certificate| |
| 11 | + certificate.owner_type == 'teamMember' |
| 12 | + } |
| 13 | + |
| 14 | + params[:app_identifier].each { |identifier| |
| 15 | + Spaceship.provisioning_profile.find_by_bundle_id(bundle_id: identifier) |
| 16 | + .select { |profile| |
| 17 | + profile.kind_of? Spaceship::Portal::ProvisioningProfile::Development |
| 18 | + } |
| 19 | + .tap { |profiles| |
| 20 | + UI.important "Warning: Unable to find any profiles associated with #{identifier}" unless profiles.length > 0 |
| 21 | + } |
| 22 | + .each { |profile| |
| 23 | + profile.certificates = all_certificates |
| 24 | + profile.update! |
| 25 | + UI.success "Applied #{all_certificates.length} certificates to #{profile.name}" |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + end |
| 30 | + |
| 31 | + ##################################################### |
| 32 | + # @!group Documentation |
| 33 | + ##################################################### |
| 34 | + |
| 35 | + def self.description |
| 36 | + "Add dev certificates to provisioning profiles" |
| 37 | + end |
| 38 | + |
| 39 | + def self.details |
| 40 | + "Add all team member's development certificates to profiles associated with the provided bundle identifiers" |
| 41 | + end |
| 42 | + |
| 43 | + def self.available_options |
| 44 | + [ |
| 45 | + FastlaneCore::ConfigItem.new(key: :app_identifier, |
| 46 | + description: "List of App Identifiers that should contain the new device identifier", |
| 47 | + is_string: false, |
| 48 | + verify_block: proc do |value| |
| 49 | + UI.user_error!("You must provide an array of bundle identifiers in `app_identifier`") unless not value.empty? |
| 50 | + end), |
| 51 | + FastlaneCore::ConfigItem.new(key: :team_id, |
| 52 | + description: "The team_id for the provisioning profiles", |
| 53 | + is_string: true, |
| 54 | + verify_block: proc do |value| |
| 55 | + UI.user_error!("You must provide a team ID in `team_id`") unless (value and not value.empty?) |
| 56 | + end), |
| 57 | + ] |
| 58 | + end |
| 59 | + |
| 60 | + def self.output |
| 61 | + # This lane doesn't provide variables that other lanes can consume. |
| 62 | + end |
| 63 | + |
| 64 | + def self.return_value |
| 65 | + # If your method provides a return value, you can describe here what it does |
| 66 | + end |
| 67 | + |
| 68 | + def self.authors |
| 69 | + # So no one will ever forget your contribution to fastlane :) You are awesome btw! |
| 70 | + ["jkmassel"] |
| 71 | + end |
| 72 | + |
| 73 | + def self.is_supported?(platform) |
| 74 | + platform == :ios |
| 75 | + end |
| 76 | + end |
| 77 | + end |
| 78 | +end |
0 commit comments