b0VIM 8.1h^o=joshJoshs-MBP.localdomain~josh/Projects/fastlane/fastlane/sigh/lib/sigh/runner.rbutf-8 3210#"! UtpG DSXUnRN O adGvuiZ=<Y n ;  s r V  n = # Q | r q   \RQ*"!qAesJIx true if current_profile.val results = Spaceship::ConnectAPI::Profile.all(filter: {}, includes: "bundleId,certificates").select do |profile|# sub_platform: Sigh.config[:platform].to_s == 'tvos' ? 'tvOS' : nil)# mac: Sigh.config[:platform].to_s == 'macos',# results = profile_type.find_by_bundle_id(bundle_id: Sigh.config[:app_identifier], UI.message("Fetching profiles...") def fetch_profiles # Fetches a profile matching the user's search requirements end @profile_ty @profile_ when "macos" @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT if Sigh.config[:development] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC if Sigh.config[:adhoc] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE if Spaceship.client.in_house? @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE when "tvos" @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT if Sigh.config[:development] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC if Sigh.config[:adhoc] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE if Spaceship.client.in_house? @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE when "ios" case Sigh.config[:platform] return @profile_type if @profile_type def profile_type # The kind of provisioning profile we're interested in end return download_profile(profile) end ENV.delete("SIGH_PROFILE_ENTERPRISE") else ENV["SIGH_PROFILE_ENTERPRISE"] = "1" if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE UI.user_error!("Something went wrong fetching the latest profile") unless profile end profile = create_profile! ensure_app_exists! UI.important("No existing profiles found, that match the certificates you have installed locally! Creating a new provisioning profile for you") UI.user_error!("No matching provisioning profile found and can not create a new one because you enabled `readonly`") if Sigh.config[:readonly] else end profile = create_profile! profile.delete! UI.important("Recreating the profile") # Recreating the profile ensures it has all of the requested properties (cert, name, etc.) if Sigh.config[:force] profile = profiles.first UI.success("Found #{profiles.count} matching profile(s)") if profiles.count > 0 profiles ||= fetch_profiles # download the profile if it's there profiles = [] if Sigh.config[:skip_fetch_profiles] UI.message("Successfully logged in") Spaceship.select_team Spaceship.login(Sigh.config[:username], nil) UI.message("Starting login with user '#{Sigh.config[:username]}'") title: "Summary for sigh #{Fastlane::VERSION}") hide_keys: [:output_path], FastlaneCore::PrintTable.print_values(config: Sigh.config, def run # returns the path the newly created provisioning profile (in /tmp usually) # Uses the spaceship to create or download a provisioning profile attr_accessor :spaceship class Runnermodule Sighrequire_relative 'module'require 'fastlane_core/cert_checker'require 'fastlane_core/print_table'require 'base64'require 'spaceship'adN(D$  q  U W 7 - , c A  b X W ' R(ldcu=32A98Yu`t. eneend end end UI.message("") UI.mesend end end UI.messaend endend end end UIend end end UI.message("") UI.message("==========================================".yellow) UI.message("If the app should also be created on App Store Connect, remove the " + "--skip_itc".yellow + " from the command above") UI.message("You will be asked for any missing information, like the full name of your app") UI.message("") UI.message("fastlane produce -u #{config[:username]} -a #{config[:app_identifier]} --skip_itc".yellow) UI.message("") UI.message("You can easily generate a new App ID on the Developer Portal using 'produce':") UI.message("Could not find App ID with bundle identifier '#{config[:app_identifier]}'") UI.message("==========================================".yellow) UI.message("") def print_produce_command(config) end UI.user_error!("Could not find App with App Identifier '#{Sigh.config[:app_identifier]}'") print_produce_command(Sigh.config) return if Spaceship::ConnectAPI::BundleId.find(Sigh.config[:app_identifier], platform: platform) end platform = Spaceship::ConnectAPI::Platform::IOS else platform = Spaceship::ConnectAPI::Platform::MACOS if Sigh.config[:platform].to_s == 'macos' def ensure_app_exists! # Makes sure the current App ID exists. If not, it will show an appropriate error message end return output_path UI.success("Successfully downloaded provisioning profile...") end f.write(content) content = Base64.decode64(profile.profile_content) File.open(output_path, "wb") do |f| output_path = File.join(tmp_path, profile_name) tmp_path = Dir.mktmpdir("profile_download") end profile_name += '.mobileprovision' else profile_name += '.provisionprofile' if Sigh.config[:platform].to_s == 'macos' end profile_name += "_tvos" if Sigh.config[:platform].to_s == 'tvos' profile_name ||= "#{profile_type_pretty_type}_#{Sigh.config[:app_identifier]}" UI.important("Downloading provisioning profile...") def download_profile(profile) # Downloads and stores the provisioning profile end return certificates.first return certificates if Sigh.config[:development] # development profiles support multiple certificates end UI.user_error!(message) message += "If you don't want to do so, you can also use cert to generate a new one: https://fastlane.tools/cert" message += "It is recommended to use match to manage code signing for you, more information on https://codesigning.guide. " message = "Could not find a matching code signing identity for type '#{profile_type_pretty_type}'. " UI.important("No certificates for filter: #{filters}") if filters.length > 0 filters << "Certificate ID: '#{Sigh.config[:cert_id]}' " if Sigh.config[:cert_id] filters << "Owner Name: '#{Sigh.config[:cert_owner_name]}' " if Sigh.config[:cert_owner_name] filters = "" if certificates.count == 0 end end UI.message(str.green) str = ["\t- Name:", c.owner_name, "- ID:", c.id + " - Expires", c.expires.strftime("%d/%m/%Y")].join(" ") certificates.each do |c| UI.important("Available Code Signing Identities for current filters:") UI.important("Found more than one code signing identity. Choosing the first one. Check out `fastlane sigh --help` to see all available options.") if certificates.count > 1 && !Sigh.config[:development]ad2zA2 true if current_profile.valid? || Sigh.config[:force] results = results.find_all do |current_profile| end profile.bundle_id.identifier == Sigh.config[:app_identifier]ad2fef^VN+ g K $  x 2 g  j = ?N y3Lx=<(e N& end end end FastlaneCore::CertChecker.installed?(file.path) file.close file.write(c.download_raw) file = Tempfile.new('cert') certificates = certificates.find_all do |c| unless Sigh.config[:skip_certificate_verification] if Helper.mac? # verify certificates end true end next unless c.owner_name.strip == Sigh.config[:cert_owner_name].strip if Sigh.config[:cert_owner_name] end next unless c.id == Sigh.config[:cert_id].strip if Sigh.config[:cert_id] certificates = certificates.find_all do |c| # Filter them certificates = certificates_for_profile_and_platform def certificate_to_use # Certificate to use based on the current distribution mode end certificates end end Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.mac_app_distribution.all + else certificates = Spaceship.certificate.developer_id_application.all elsif profile_type == Spaceship.provisioning_profile.Direct Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.mac_app_distribution.all + elsif profile_type == Spaceship.provisioning_profile.AppStore Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.mac_development.all + if profile_type == Spaceship.provisioning_profile.Development when 'macos' end Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.production.all + # Ad hoc or App Store else certificates = Spaceship.certificate.in_house.all # Enterprise accounts don't have access to Apple Distribution certificates elsif profile_type == Spaceship.provisioning_profile.AdHoc && Spaceship.client && Spaceship.client.in_house? # for enterprise accounts, you get nothing back even if they exist. # the apple dev portal api has a weird quirk in it where if you query for distribution certificates # handles case where the desired certificate type is adhoc but the account is an enterprise account certificates = Spaceship.certificate.in_house.all # Enterprise accounts don't have access to Apple Distribution certificates elsif profile_type == Spaceship.provisioning_profile.InHouse Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.development.all + if profile_type == Spaceship.provisioning_profile.Development when 'ios', 'tvos' case Sigh.config[:platform].to_s def certificates_for_profile_and_platform end profiles end profiles = filtered elsif (filtered || []).count > 0 profiles = filtered if Sigh.config[:ignore_profiles_with_different_name] filtered = profiles.select { |p| p.name.strip == Sigh.config[:provisioning_name].strip } def filter_profil # # # # ## template_name: Sigh.config[:template_name])# sub_platform: Sigh.config[:platform].to_s == 'tvos' ? 'tvOS' : nil,# mac: Sigh.config[:platform].to_s == 'macos',# certificate: cert,# bundle_id: bundle_id,# profile = profile_type.create!(name: name,ad5 ymcb*S  ] 5 { R 9 + z D  l O @ N D < ;   ZGK57!p'[H>65 ED}WKA@ UI.important("Creating new provisioning profile for '#{Sigh.config[:app_identifier]}' with name '#{name}' for '#{Sigh.config[:platform]}' platform") end end name += " #{Time.now.to_i}" UI.error("The name '#{name}' is already taken, using another one.") if Spaceship.provisioning_profile.all.find { |p| p.name == name } unless Sigh.config[:skip_fetch_profiles] name = Sigh.config[:provisioning_name] || [bundle_id, profile_type_pretty_type].join(' ') bundle_id = Sigh.config[:app_identifier] cert = certificate_to_use def create_profile! # Create a new profile and return it end end "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT "InHouse" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE "AdHoc" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT "Direct" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT "InHouse" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE "AdHoc" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT case profile_type def profile_type_pretty_type end end installed && current_profile.certificate_valid? end end UI.message("Certificate for Provisioning Profile '#{current_profile.name}' not available locally: #{current_cert[:cert].id}, skipping this one...") else installed = true if FastlaneCore::CertChecker.installed?(file.path) file.close file.write(current_cert[:downloaded]) file = Tempfile.new('cert') next unless current_cert[:downloaded] # Skip certificates that failed to download raw_certs.each do |current_cert| # Makes sure we have the certificate installed on the local machine end { downloaded: raw_cert, cert: cert } end raw_cert = ni puts "RAW CERT: #{raw_cert}" raw_cert = Base64.decode64(cer raw_cert = Base64.decode64(cert.certificate_content) begin raw_certs = current_profile.certificates.map do |cert| # "member" and not an a "admin" # `cert.download_raw` can fail if the user is a # for checking if they are installed. # Attempts to download all certificates from this profile installed = false return results.find_all do |current_profile| UI.message("Verifying certificates...") return results if Sigh.config[:skip_certificate_verification] results = filter_profiles_by_name(results) if Sigh.config[:provisioning_name].to_s.length > 0 # Take the provisioning profile name into account end end false UI.message("Provisioning Profile '#{current_profile.name}' is not valid, skipping this one...") elseaduU|n?32W1 x V D : 2 1  P = A + z -  vf H,"W1%YON{gC pp profile. ) certificate_ids: [certificate_to_use.id] bundle_id_id: bundle_id.id, profile_type: profile_type, name: name, profile = Spaceship::ConnectAPI::Profile.create( UI.important("Creating new provisioning profile for '#{Sigh.config[:app_identifier]}' with name '#{name}' for '#{Sigh.config[:platform]}' platform") end UI.user_error!("Could not find App with App Identifier '#{Sigh.config[:app_identifier]}'") unless bundle_id bundle_id = Spaceship::ConnectAPI::BundleId.find(app_identifier) end end name += " #{Time.now.to_i}" UI.error("The name '#{name}' is already taken, using another one.") if Spaceship.provisioning_profile.all.find { |p| p.name == name } unless Sigh.config[:skip_fetch_profiles] name = Sigh.config[:provisioning_name] || [app_identifier, profile_type_pretty_type].join(' ') app_identifier = Sigh.config[:app_identifier] cert = certificate_to_use def create_profile! # Create a new profile and return it end end "AppStore Catalyst" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE "Development Catalyst" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT "InHouse" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE "AdHoc" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT "Direct" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT "InHouse" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE "AdHoc" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC "AppStore" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE "Development" when Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT case profile_type def profile_type_pretty_type end end installed # profile in the response # Don't need to check if certificate is valid because it comes with the end end UI.message("Certificate for Provisioning Profile '#{current_profile.name}' not available locally: #{current_cert[:cert].id}, skipping this one...") else installed = true if FastlaneCore::CertChecker.installed?(file.path) file.close file.write(current_cert[:downloaded]) file = Tempfile.new('cert') next unless current_cert[:downloaded] # Skip certificates that failed to download raw_certs.each do |current_cert| # Makes sure we have the certificate installed on the local machine end { downloaded: raw_cert, cert: cert } end raw_cert = nil UI.important("Cannot download cert #{cert.id} - #{error.message}") rescue => errorad8R`% vO6 j % ( p j ] = E u+UHE*MA@q6]OC98 end end end FastlaneCore::CertChecker.installed?(file.path) file.close file.write(c.download_raw) file = Tempfile.new('cert') certificates = certificates.find_all do |c| unless Sigh.config[:skip_certificate_verification] if Helper.mac? # verify certificates end true end next unless c.owner_name.strip == Sigh.config[:cert_owner_name].strip if Sigh.config[:cert_owner_name] end next unless c.id == Sigh.config[:cert_id].strip if Sigh.config[:cert_id] certificates = certificates.find_all do |c| # Filter them certificates = certificates_for_profile_and_platform def certificate_to_use # Certificate to use based on the current distribution mode end certificates end end Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.mac_app_distribution.all + else certificates = Spaceship.certificate.developer_id_application.all elsif profile_type == Spaceship.provisioning_profile.Direct Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.mac_app_distribution.all + elsif profile_type == Spaceship.provisioning_profile.AppStore Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.mac_development.all + if profile_type == Spaceship.provisioning_profile.Development when 'macos', 'catalyst' end Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.production.all + # Ad hoc or App Store else certificates = Spaceship.certificate.in_house.all # Enterprise accounts don't have access to Apple Distribution certificates elsif profile_type == Spaceship.provisioning_profile.AdHoc && Spaceship.client && Spaceship.client.in_house? # for enterprise accounts, you get nothing back even if they exist. # the apple dev portal api has a weird quirk in it where if you query for distribution certificates # handles case where the desired certificate type is adhoc but the account is an enterprise account certificates = Spaceship.certificate.in_house.all # Enterprise accounts don't have access to Apple Distribution certificates elsif profile_type == Spaceship.provisioning_profile.InHouse Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.development.all + if profile_type == Spaceship.provisioning_profile.Development when 'ios', 'tvos' case Sigh.config[:platform].to_s def certificates_for_profile_and_platform end profiles end profiles = filtered elsif (filtered || []).count > 0 profiles = filtered if Sigh.config[:ignore_profiles_with_different_name] filtered = profiles.select { |p| p.name.strip == Sigh.config[:provisioning_name].strip } def filter_profiles_by_name(profiles) end profilead= 7!F<; m V - , , p o [ results = Spac results = Spaceship::ConnectAPI::Profile.all(filter: {profileType: profile_type}, i results = Spaceship::ConnectAPI::Profile.all(filter: {profileType: profile_type}, includes: " results = Spaceship::ConnectAPI::Profile.all(filter: {profileType: profile_type}, includes: "bundleId,certi results = Spaceship::ConnectAPI::Profile.all(filter: {profileType: profile_type}, includes: "bundleId,certificates").select do |profile| UI.message("Fetching profiles...") def fetch_profiles # Fetches a profile matching the user's search requirements end @profile_type @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT if Sigh.config[:developer_id] end @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT if Sigh.config[:development] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE when "catalyst" @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT if Sigh.config[:development] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE