Class: Sigh::DownloadAll

Inherits:
Object
  • Object
show all
Defined in:
sigh/lib/sigh/download_all.rb

Instance Method Summary collapse

Instance Method Details

#download_all(download_xcode_profiles: false) ⇒ Object

Download all valid provisioning profiles



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'sigh/lib/sigh/download_all.rb', line 11

def download_all(download_xcode_profiles: false)
  UI.message("Starting login with user '#{Sigh.config[:username]}'")
  Spaceship.(Sigh.config[:username], nil)
  Spaceship.select_team
  UI.message("Successfully logged in")

  if download_xcode_profiles
    UI.deprecated("The App Store Connect API does not support querying for Xcode managed profiles: --download_code_profiles is deprecated")
  end

  case Sigh.config[:platform].to_s
  when 'ios'
    profile_types = [
      Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE,
      Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE,
      Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC,
      Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT
    ]
  when 'macos'
    profile_types = [
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE,
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT,
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT
    ]
  when 'catalyst'
    profile_types = [
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE,
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT,
      Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT
    ]
  when 'tvos'
    profile_types = [
      Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE,
      Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE,
      Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC,
      Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT
    ]
  end

  # Filtering on 'profileType' seems to be undocumented as of 2020-07-30
  # but works on both web session and official API
  profiles = Spaceship::ConnectAPI::Profile.all(filter: { profileType: profile_types.join(",") }, includes: "bundleId")
  download_profiles(profiles)
end

#download_profile(profile) ⇒ Object

Parameters:

  • profile (ProvisioningProfile)

    A profile we plan to download and store



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'sigh/lib/sigh/download_all.rb', line 75

def download_profile(profile)
  FileUtils.mkdir_p(Sigh.config[:output_path])

  type_name = pretty_type(profile.profile_type)
  profile_name = "#{type_name}_#{profile.uuid}_#{profile.bundle_id.identifier}"

  if Sigh.config[:platform].to_s == 'tvos'
    profile_name += "_tvos"
  end

  if ['macos', 'catalyst'].include?(Sigh.config[:platform].to_s)
    profile_name += '.provisionprofile'
  else
    profile_name += '.mobileprovision'
  end

  output_path = File.join(Sigh.config[:output_path], profile_name)
  File.open(output_path, "wb") do |f|
    content = Base64.decode64(profile.profile_content)
    f.write(content)
  end

  Manager.install_profile(output_path) unless Sigh.config[:skip_install]
end

#download_profiles(profiles) ⇒ Object

Parameters:

  • profiles (Array)

    Array of all the provisioning profiles we want to download



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

def download_profiles(profiles)
  UI.important("No profiles available for download") if profiles.empty?

  profiles.each do |profile|
    if profile.valid?
      UI.message("Downloading profile '#{profile.name}'...")
      download_profile(profile)
    else
      UI.important("Skipping invalid/expired profile '#{profile.name}'")
    end
  end
end

#pretty_type(profile_type) ⇒ Object



70
71
72
# File 'sigh/lib/sigh/download_all.rb', line 70

def pretty_type(profile_type)
  return Sigh.profile_pretty_type(profile_type)
end