Sha256: 406b600eb550f3e7d69073e1adf58c36bb2cf509dc314060efd70cf970a5aec6

Contents?: true

Size: 1.18 KB

Versions: 530

Compression:

Stored size: 1.18 KB

Contents

require 'rexml/document'

require_relative 'helper'

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.shellescape} -xf #{path.shellescape}")

        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
            UI.error(ex)
            UI.error("Error parsing *.pkg distribution xml #{File.join(dir, file)}")
          end
        end

        nil
      end
    end
  end
end

Version data entries

530 entries across 530 versions & 2 rubygems

Version Path
fastlane-2.127.0.beta.20190705200056 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190704200049 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane_iac_publish-0.1.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190703200032 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190701200019 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190630200023 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190629200029 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190628200030 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190627200058 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190625200058 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.127.0.beta.20190624200045 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190623200100 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190622200100 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190621200104 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190620200055 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190619200046 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190618200051 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190617200114 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.126.0.beta.20190616200045 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb