Sha256: 5bfff7c8e9e896f30340346050508c0ed7a0c3e482f2c7d38b9013d703e6dbe7

Contents?: true

Size: 1.51 KB

Versions: 352

Compression:

Stored size: 1.51 KB

Contents

require "digest/md5"

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) # http://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

352 entries across 352 versions & 1 rubygems

Version Path
fastlane-2.62.0.beta.20171010010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171009010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171008010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171007010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171006010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171005010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.61.0.beta.20171004010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.1 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20171003010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20171002010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20171001010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20170930010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20170929010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20170928010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20170927010003 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.60.0.beta.20170926010004 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.59.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.59.0.beta.20170925010002 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb