Sha256: b93412c0f9ef429557c4891eb8fc475bdcfd01d82938f397dda5f2fe0b11e6a7

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

require 'rexml/document'

module FastlaneCore
  class PkgFileAnalyser
    def self.fetch_app_identifier(path)
      xml = self.fetch_distribution_xml_file(path)
      return xml.elements['installer-gui-script/product'].attributes['id'] if xml
      return nil
    end

    # Fetches the app version from the given pkg file.
    def self.fetch_app_version(path)
      xml = self.fetch_distribution_xml_file(path)
      return xml.elements['installer-gui-script/product'].attributes['version'] if xml
      return nil
    end

    def self.fetch_distribution_xml_file(path)
      Dir.mktmpdir do |dir|
        Helper.backticks("xar -C #{dir} -xf #{path}")

        Dir.foreach(dir) do |file|
          next unless file.include? 'Distribution'

          begin
            content = File.open(File.join(dir, file))
            xml = REXML::Document.new(content)

            if xml.elements['installer-gui-script/product']
              return xml
            end
          rescue => ex
            Helper.log.error ex
            Helper.log.error "Error parsing *.pkg distribution xml #{File.join(dir, file)}".red
          end
        end

        nil
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fastlane_core-0.39.1 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.39.0 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.38.0 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.37.0 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.9 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.8 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.7 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.6 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.5 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.4 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.3 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.2 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.1 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.36.0 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.35.1 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.35.0 lib/fastlane_core/pkg_file_analyser.rb
fastlane_core-0.34.0 lib/fastlane_core/pkg_file_analyser.rb