Sha256: 4bb2bd7ecaa11177ceb3ddcb6003ef365d49e9a0600412c6634759242d56480f

Contents?: true

Size: 1.58 KB

Versions: 578

Compression:

Stored size: 1.58 KB

Contents

require 'digest/md5'

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

module FastlaneCore
  # Builds a package for the pkg ready to be uploaded with the iTunes Transporter
  class PkgUploadPackageBuilder
    METADATA_FILE_NAME = 'metadata.xml'

    attr_accessor :package_path

    def generate(app_id: nil, pkg_path: nil, package_path: nil, platform: "osx")
      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)

      pkg_path = copy_pkg(pkg_path)
      @data = {
        apple_id: app_id,
        file_size: File.size(pkg_path),
        ipa_path: File.basename(pkg_path), # this is only the base name as the ipa is inside the package
        md5: Digest::MD5.hexdigest(File.read(pkg_path)),
        archive_type: 'product-archive',
        platform: platform
      }

      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?

      package_path
    end

    private

    def copy_pkg(pkg_path)
      ipa_file_name = Digest::MD5.hexdigest(pkg_path)
      resulting_path = File.join(self.package_path, "#{ipa_file_name}.pkg")
      FileUtils.cp(pkg_path, resulting_path)

      resulting_path
    end
  end
end

Version data entries

578 entries across 578 versions & 2 rubygems

Version Path
fastlane-2.131.0.beta.20190902200022 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.131.0.beta.20190901200035 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.131.0.beta.20190831200041 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.131.0.beta.20190830200038 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190829200051 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190828200015 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190827200051 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190826200016 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190825200030 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190824200021 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190823200017 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190822200101 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190821200034 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190820200024 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190819200109 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190818200034 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190817200018 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190816200015 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.130.0.beta.20190815200057 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb