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
64
65
66
67
68
# 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 iTunesConnect"
  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 iTunesConnect.".green
  else
    # rubocop:disable Style/CaseEquality
    unless /^[0-9a-zA-Z\.\$\_]*$/ === @password
      Helper.log.error "Password contains special characters, which may not be handled properly by iTMSTransporter. If you experience problems uploading to iTunes Connect, please consider changing your password to something with only alphanumeric characters."
    end
    # rubocop:enable Style/CaseEquality
    Helper.log.fatal "Could not download metadata from iTunes Connect! It's probably related to your password or your internet connection."
  end

  result
end

#upload(app_id, dir) ⇒ Bool

Uploads the modified package back to iTunesConnect

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



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

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

  Helper.log.info "Going to upload updated app to iTunesConnect"
  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 iTunesConnect. 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
  end

  result
end