Sha256: 0bf7a994c7a609143d22ebcd892bb29445622d08a089d5037f20e22fe592e1fe

Contents?: true

Size: 1.46 KB

Versions: 361

Compression:

Stored size: 1.46 KB

Contents

require 'digest/md5'

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) # 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?

      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

361 entries across 361 versions & 1 rubygems

Version Path
fastlane-2.65.0.beta.20171116010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171115010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171114010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.1 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171113010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171112010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171111010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171110010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171109010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171108010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.65.0.beta.20171107010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171106010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171105010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171104010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171103010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171102010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.64.0.beta.20171101010004 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.63.0 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane-2.63.0.beta.20171031010003 fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb