Sha256: afb3e95a3d3c21a4ffb259f3bc1241a593a2222ea48a6cd6229ed27e688bccc8

Contents?: true

Size: 1.42 KB

Versions: 28

Compression:

Stored size: 1.42 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)
      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

      lib_path = Helper.gem_path("fastlane_core")

      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))
      }

      xml_path = File.join(lib_path, "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)
      Helper.log.info "Wrote XML data to '#{self.package_path}'".green if $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

28 entries across 28 versions & 1 rubygems

Version Path
fastlane_core-0.29.1 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.29.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.28.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.27.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.6 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.5 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.4 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.3 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.2 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.1 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.26.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.25.4 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.25.3 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.25.2 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.25.1 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.25.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.24.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.23.0 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.22.3 lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core-0.22.2 lib/fastlane_core/ipa_upload_package_builder.rb