Sha256: ac82e2ba4dd5d26bf99f88937422e0b49095ffd3441ddcb0fe66ac0a0c8754ab

Contents?: true

Size: 1.7 KB

Versions: 407

Compression:

Stored size: 1.7 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.file(ipa_path).hexdigest,
        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

    def unique_ipa_path(ipa_path)
      "#{Digest::SHA256.file(ipa_path).hexdigest}.ipa"
    end

    private

    def copy_ipa(ipa_path)
      ipa_file_name = unique_ipa_path(ipa_path)
      resulting_path = File.join(self.package_path, ipa_file_name)
      FileUtils.cp(ipa_path, resulting_path)

      return resulting_path
    end
  end
end

Version data entries

407 entries across 407 versions & 2 rubygems

Version Path
fastlane-2.132.0.beta.20190921200021 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190920200012 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190919200100 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190918200023 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190917200011 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190916200055 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190915200038 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190914200034 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190913200058 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.132.0.beta.20190912200052 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190911200010 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190910200104 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190909200058 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190908200041 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190907200030 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190906200026 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190905200113 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190904200040 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane-2.131.0.beta.20190903200013 fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb