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



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'sigh/lib/sigh/download_all.rb', line 9

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")

  Spaceship.provisioning_profile.all(xcode: download_xcode_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

  if download_xcode_profiles
    UI.message("This run also included all Xcode managed provisioning profiles, as you used the `--download_xcode_profiles` flag")
  else
    UI.message("All Xcode managed provisioning profiles were ignored on this, to include them use the `--download_xcode_profiles` flag")
  end
end

#download_profile(profile) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'sigh/lib/sigh/download_all.rb', line 31

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

  type_name = profile.class.pretty_type
  type_name = "AdHoc" if profile.is_adhoc?

  profile_name = "#{type_name}_#{profile.uuid}_#{profile.app.bundle_id}.mobileprovision" # default name

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

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