Class: FastlaneCore::ShellScriptTransporterExecutor

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

Overview

Generates commands and executes the iTMSTransporter through the shell script it provides by the same name

Constant Summary

Constants inherited from TransporterExecutor

TransporterExecutor::ITMS_PROVIDER_REGEX

Instance Method Summary collapse

Methods inherited from TransporterExecutor

#displayable_errors, #execute, #parse_provider_info, #prepare

Instance Method Details

#build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) ⇒ Object



417
418
419
420
421
422
423
424
425
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 417

def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil)
  if !(username.nil? || password.nil?) && (jwt.nil? && api_key.nil?)
    "-u #{username.shellescape} -p #{shell_escaped_password(password)}"
  elsif !jwt.nil? && api_key.nil?
    "-jwt #{jwt}"
  elsif !api_key.nil?
    "-apiIssuer #{api_key[:issuer_id]} -apiKey #{api_key[:key_id]}"
  end
end

#build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) ⇒ Object



440
441
442
443
444
445
446
447
448
449
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 440

def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil)
  [
    '"' + Helper.transporter_path + '"',
    "-m lookupMetadata",
    build_credential_params(username, password, jwt),
    "-apple_id #{apple_id}",
    "-destination '#{destination}'",
    ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?)
  ].compact.join(' ')
end

#build_provider_ids_command(username, password, jwt = nil, api_key = nil) ⇒ Object



451
452
453
454
455
456
457
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 451

def build_provider_ids_command(username, password, jwt = nil, api_key = nil)
  [
    '"' + Helper.transporter_path + '"',
    '-m provider',
    build_credential_params(username, password, jwt, api_key)
  ].compact.join(' ')
end

#build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
438
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 427

def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil)
  [
    '"' + Helper.transporter_path + '"',
    "-m upload",
    build_credential_params(username, password, jwt, api_key),
    file_upload_option(source),
    additional_upload_parameters, # that's here, because the user might overwrite the -t option
    "-k 100000",
    ("-WONoPause true" if Helper.windows?), # Windows only: process instantly returns instead of waiting for key press
    ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?)
  ].compact.join(' ')
end

#build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs) ⇒ Object



459
460
461
462
463
464
465
466
467
468
469
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 459

def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs)
  jwt = kwargs[:jwt]
  [
    '"' + Helper.transporter_path + '"',
    '-m verify',
    build_credential_params(username, password, jwt),
    "-f #{source.shellescape}",
    ("-WONoPause true" if Helper.windows?), # Windows only: process instantly returns instead of waiting for key press
    ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?)
  ].compact.join(' ')
end

#file_upload_option(source) ⇒ Object



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 486

def file_upload_option(source)
  # uploading packages on non-macOS platforms requires AppStoreInfo.plist starting with Transporter >= 4.1
  if !Helper.is_mac? && File.directory?(source)
    asset_file = Dir.glob(File.join(source, "*.{#{allowed_package_extensions.join(',')}}")).first
    unless asset_file
      UI.user_error!("No package file (#{allowed_package_extensions.join(',')}) found in #{source}")
    end

    appstore_info_path = File.join(source, "AppStoreInfo.plist")
    unless File.file?(appstore_info_path)
      UI.error("AppStoreInfo.plist is required for uploading #{File.extname(asset_file)} files on non-macOS platforms.")
      UI.error("Expected AppStoreInfo.plist in the same directory as the #{File.extname(asset_file)} file.")
      UI.error("Generate it by running either 'fastlane gym [...] --generate_appstore_info'")
      UI.error("Or add '<key>generateAppStoreInformation</key><true/>' in an options.plist then run 'fastlane gym [...] --export_options options.plist'.")
      UI.user_error!("Missing required AppStoreInfo.plist file for iTMSTransporter upload")
    end

    UI.verbose("Using AppStoreInfo.plist for iTMSTransporter upload: #{appstore_info_path}")
    return "-assetFile #{asset_file.shellescape} -assetDescription #{appstore_info_path.shellescape}"
  end

  # use standard behavior for other file types or macOS platform
  super(source)
end

#handle_error(password) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 471

def handle_error(password)
  # rubocop:disable Style/CaseEquality
  # rubocop:disable Style/YodaCondition
  unless /^[0-9a-zA-Z\.\$\_\-]*$/ === password
    UI.error([
      "Password contains special characters, which may not be handled properly by iTMSTransporter.",
      "If you experience problems uploading to App Store Connect, please consider changing your password to something with only alphanumeric characters."
    ].join(' '))
  end
  # rubocop:enable Style/CaseEquality
  # rubocop:enable Style/YodaCondition

  UI.error("Could not download/upload from App Store Connect! It's probably related to your password or your internet connection.")
end