b0VIM 8.1(e,_dvjoshJoshs-Mac-mini.local~josh/Projects/fastlane/fastlane/sigh/lib/sigh/runner.rbutf-8 3210#"! UtpM\ND\Pad8MvuiZ=<Y n ;  s r V  n = # Q | r q   zMB  ]\:)cq>ayc @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_DIRECT if Sigh.config[:developer_id] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT if Sigh.config[:development] @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE 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 [Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE, Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE].include?(profile_type) 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'adw !=( < end 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)adFDm5_$ u N 5 C R U l0#}qpQS^y3' z(Fw^ Spaceship::ConnectAPI::Device::DeviceClass::IPOD Spaceship::ConnectAPI::Device::DeviceClass::IPHONE, Spaceship::ConnectAPI::Device::DeviceClass::IPAD, Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH, [ when 'ios' device_class = case Sigh.config[:platform].to_s def devices_to_use 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::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT Spaceship.certificate.apple_distribution.all certificates = Spaceship.certificate.mac_app_distribution.all + elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.mac_development.all + if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_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::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_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::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE Spaceship.certificate.apple_development.all certificates = Spaceship.certificate.development.all + if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_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 profile ) device_ids: devices_to_use.map(&:id) certificate_ids: certificates_to_use.map(&:id), bundle_id_id: bundle_id.id, profile_type: profile_type, name: name, profile = Spaceship::ConnectAPI::Profile.create(adZ end return Spaceship::ConnectAPI::Device.all(filter: filter) filter = { deviceClass: device_class }ad\{zf^]X x w A  r f \ [ # { z L  V . 5  [%M0!sgfzrqH0g1 3)( 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.") UI.user_error!("The name '#{name}' is already taken, and fail_on_name_taken is true") if Sigh.config[:fail_on_name_taken] if profile profile = Spaceship::ConnectAPI::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] def create_profile! # Create a new profile and return it end return Sigh.profile_pretty_type(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 => error 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...") else true if current_profile.valid? || Sigh.config[:force] results = results.find_all do |current_profile| end profile.bundle_id.identifier == Sigh.config[:app_identifier] results = Spaceship::ConnectAPI::Profile.all(filter: { profileType: profile_type }, includes: "bundleId,certificates").select do |profile| # but works on both web session and official API # Filtering on 'profileType' seems to be undocumented as of 2020-07-30 UI.message("Fetching profiles...") def fetch_profiles # Fetches a profile matching the user's search requirements end @profile_type end @profile_type = Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT if Sigh.config[:developer_id]ad\ihT"A54' z R +   t j # t   rPHGba2h<1i.  F+> 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]) # always UNIVERSAL as of 2020-07-30 # We used to ensure by platform (IOS and MAC_OS) but now apps are # Only ensuring by app identifier 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 ['macos', 'catalyst'].include?(Sigh.config[:platform].to_s) end profile_name += "_catalyst" elsif Sigh.config[:platform].to_s == 'catalyst' 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] 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 certificates_to_use # Certificate to use based on the current distribution modeadoA end end Spaceship::ConnectAPI::Device::DeviceClass::MAC when 'macos', 'catalyst' Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV when 'tvos' ].join(",")