Sha256: e5078137b9fe79caac0bde15cccf66322dd9d0d76d384c1a81607f31491c9d36

Contents?: true

Size: 1.63 KB

Versions: 111

Compression:

Stored size: 1.63 KB

Contents

require "digest/md5"

require_relative 'globals'
require_relative 'ui/ui'
require_relative 'module'

module FastlaneCore
  # Builds a package for the binary ready to be uploaded with the iTunes Transporter
  class IpaUploadPackageBuilder
    METADATA_FILE_NAME = "metadata.xml"

    attr_accessor :package_path

    def generate(app_id: nil, ipa_path: nil, package_path: nil, platform: nil)
      self.package_path = File.join(package_path, "#{app_id}.itmsp")
      FileUtils.rm_rf(self.package_path) if File.directory?(self.package_path)
      FileUtils.mkdir_p(self.package_path)

      ipa_path = copy_ipa(ipa_path)
      @data = {
        apple_id: app_id,
        file_size: File.size(ipa_path),
        ipa_path: File.basename(ipa_path), # this is only the base name as the ipa is inside the package
        md5: Digest::MD5.hexdigest(File.read(ipa_path)),
        archive_type: "bundle",
        platform: (platform || "ios") # pass "appletvos" for Apple TV's IPA
      }

      xml_path = File.join(FastlaneCore::ROOT, "lib/assets/XMLTemplate.xml.erb")
      xml = ERB.new(File.read(xml_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system

      File.write(File.join(self.package_path, METADATA_FILE_NAME), xml)
      UI.success("Wrote XML data to '#{self.package_path}'") if FastlaneCore::Globals.verbose?

      return package_path
    end

    private

    def copy_ipa(ipa_path)
      ipa_file_name = Digest::MD5.hexdigest(ipa_path)
      resulting_path = File.join(self.package_path, "#{ipa_file_name}.ipa")
      FileUtils.cp(ipa_path, resulting_path)

      return resulting_path
    end
  end
end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
fastlane-2.87.0.beta.20180323050014 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.87.0.beta.20180322050115 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.2 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.87.0.beta.20180321050017 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.1 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.87.0.beta.20180320050108 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180319050058 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180318050106 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180317050040 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180316050051 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180315050105 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180314050053 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180313050023 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180312050111 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180311050103 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180310050010 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.86.0.beta.20180309050025 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.85.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.85.0.beta.20180308050114 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb