module Fastlane::Transporter

Constants

DEFAULT_TRANSPORTER_INSTALL_PATH

Default installation path.

DEFAULT_TRANSPORTER_SOURCE

Default source URL.

VERSION

Public Class Methods

add_root_ca( install_path: DEFAULT_TRANSPORTER_INSTALL_PATH, root_ca: ) click to toggle source

Add root CA to Transporter installation. @param install_path [String] Transporter install path. @param root_ca [String] Name or file path of Internal Root CA certificate to add to Transporter's Java certificate keystore.

# File lib/fastlane/plugin/transporter.rb, line 51
def self.add_root_ca(
  install_path: DEFAULT_TRANSPORTER_INSTALL_PATH,
  root_ca:
)
  check_install_path(install_path: install_path)

  root_ca_file = Helper::TransporterHelper.find_root_ca(root_ca)
  cert_alias = File.basename(root_ca_file)

  cmd = [
    "#{install_path}/java/bin/keytool",
    "-list",
    "-keystore #{install_path}/java/lib/security/cacerts",
    "-storepass changeit",
    "-alias #{cert_alias}"
  ].join(" ")
  cert_exists = system(cmd)
  if cert_exists
    FastlaneCore::UI.message("Transporter is already configured for this root CA.")
    return
  end

  # Patch the transporter with internal root CA.
  cmd = [
    "#{install_path}/java/bin/keytool",
    "-import",
    "-trustcacerts",
    "-alias #{cert_alias}",
    "-file #{root_ca_file}",
    "-keystore #{install_path}/java/lib/security/cacerts",
    "-storepass changeit",
    "-noprompt",
    "-v"
  ].join(" ")
  system(cmd)

  FastlaneCore::UI.success("Added root CA certificate to keystore")
end
all_classes() click to toggle source

Return all .rb files inside the “actions” and “helper” directory

# File lib/fastlane/plugin/transporter.rb, line 6
def self.all_classes
  Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
end
enable_basic_auth(install_path: DEFAULT_TRANSPORTER_INSTALL_PATH) click to toggle source

Enable basic authentication for Transporter installation. @param install_path [String] Transporter install path.

# File lib/fastlane/plugin/transporter.rb, line 92
def self.enable_basic_auth(install_path: DEFAULT_TRANSPORTER_INSTALL_PATH)
  check_install_path(install_path: install_path)
  properties_file = "#{install_path}/java/lib/net.properties"
  content = File.read(properties_file).gsub("=Basic", "")
  File.open(properties_file, "w") { |f| f.puts(content) }
  FastlaneCore::UI.success("Basic authentication is enabled")
end
install( source: DEFAULT_TRANSPORTER_SOURCE, install_path: DEFAULT_TRANSPORTER_INSTALL_PATH, overwrite: false ) click to toggle source

Install transporter. @param source [String] Transporter tarball URL or path; or path to existing Transporter directory. @param install_path [String] Transporter install path. @param overwrite [Boolean] Overwrite existing installation. Default is `false`.

# File lib/fastlane/plugin/transporter.rb, line 20
def self.install(
  source: DEFAULT_TRANSPORTER_SOURCE,
  install_path: DEFAULT_TRANSPORTER_INSTALL_PATH,
  overwrite: false
)
  if install_path.eql?(source)
    FastlaneCore::UI.message("Source and install path are the same")
    return
  end

  if File.exist?(install_path) && !overwrite
    FastlaneCore::UI.message("Transporter is already installed at path: #{install_path.green}")
    FastlaneCore::UI.message("Use 'overwrite:true' option to overwrite")
    return
  end

  FileUtils.rm_rf(install_path)
  FileUtils.mkdir_p(install_path)

  if File.directory?(source)
    FileUtils.cp_r(File.join(source, '.'), install_path)
  else
    tar_path = Helper::TransporterHelper.fetch_file(source)
    result = Helper::TransporterHelper.extract_tarball(tar_path, install_path)
    FastlaneCore::UI.user_error!("Failed to unpack tarball") unless result
  end
end
update_path(path: DEFAULT_TRANSPORTER_INSTALL_PATH) click to toggle source

Update Fastlane's Transporter path environment variable. @param path [String] Transporter path.

# File lib/fastlane/plugin/transporter.rb, line 102
def self.update_path(path: DEFAULT_TRANSPORTER_INSTALL_PATH)
  check_install_path(install_path: path)
  ENV["FASTLANE_ITUNES_TRANSPORTER_PATH"] = path
end

Private Class Methods

check_install_path(install_path:) click to toggle source

Check if Transporter is installed at given path. @param install_path [String] Transporter install path.

# File lib/fastlane/plugin/transporter.rb, line 109
def self.check_install_path(install_path:)
  FastlaneCore::UI.user_error!("No Transporter installation found at path: #{install_path.red}") unless File.exist?(install_path)
end