Class: FastlaneCore::ItunesTransporter

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane_core/itunes_transporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user = nil, password = nil) ⇒ ItunesTransporter

Returns a new instance of the iTunesTransporter. If no username or password given, it will be taken from the #CredentialsManager::AccountManager



34
35
36
37
38
# File 'lib/fastlane_core/itunes_transporter.rb', line 34

def initialize(user = nil, password = nil)
  data = CredentialsManager::AccountManager.new(user: user, password: password)
  @user = data.user
  @password = data.password
end

Class Method Details

.hide_transporter_outputObject

This will be called from the Deliverfile, and disables the logging of the transporter output



25
26
27
28
29
# File 'lib/fastlane_core/itunes_transporter.rb', line 25

def self.hide_transporter_output
  @hide_transporter_output = true

  @hide_transporter_output = false if $verbose
end

Instance Method Details

#download(app_id, dir = nil) ⇒ Bool

Downloads the latest version of the app metadata package from iTC.

Parameters:

  • app_id (Integer)

    The unique App ID

  • dir (String) (defaults to: nil)

    the path in which the package file should be stored

Returns:

  • (Bool)

    True if everything worked fine

Raises:

  • (Deliver::TransporterTransferError)

    when something went wrong when transfering



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fastlane_core/itunes_transporter.rb', line 46

def download(app_id, dir = nil)
  dir ||= "/tmp"

  Helper.log.info "Going to download app metadata from iTunes Connect"
  command = build_download_command(@user, @password, app_id, dir)
  Helper.log.debug build_download_command(@user, 'YourPassword', app_id, dir) if $verbose

  result = execute_transporter(command)

  itmsp_path = File.join(dir, "#{app_id}.itmsp")
  if result and File.directory? itmsp_path
    Helper.log.info "Successfully downloaded the latest package from iTunes Connect.".green
  else
    handle_error(@password)
  end

  result
end

#upload(app_id, dir) ⇒ Bool

Uploads the modified package back to iTunes Connect

Parameters:

  • app_id (Integer)

    The unique App ID

  • dir (String)

    the path in which the package file is located

Returns:

  • (Bool)

    True if everything worked fine

Raises:

  • (Deliver::TransporterTransferError)

    when something went wrong when transfering



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/fastlane_core/itunes_transporter.rb', line 71

def upload(app_id, dir)
  dir = File.join(dir, "#{app_id}.itmsp")

  Helper.log.info "Going to upload updated app to iTunes Connect"
  Helper.log.info "This might take a few minutes, please don't interrupt the script".green

  command = build_upload_command(@user, @password, dir)
  Helper.log.debug build_upload_command(@user, 'YourPassword', dir) if $verbose

  result = execute_transporter(command)

  if result
    Helper.log.info(("-" * 102).green)
    Helper.log.info("Successfully uploaded package to iTunes Connect. It might take a few minutes until it's visible online.".green)
    Helper.log.info(("-" * 102).green)

    FileUtils.rm_rf(dir) unless Helper.is_test? # we don't need the package any more, since the upload was successful
  else
    handle_error(@password)
  end

  result
end