Sha256: e4fe28184facb9bef4fd14d1ee3b76fd658a264cb681063511981b7349e0c3e7

Contents?: true

Size: 1.16 KB

Versions: 486

Compression:

Stored size: 1.16 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.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

486 entries across 486 versions & 2 rubygems

Version Path
fastlane-2.65.0.beta.20171107010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171106010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171105010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171104010004 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171103010004 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171102010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.64.0.beta.20171101010004 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171031010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171030010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171029010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171028010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171027010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171026010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171025010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171024010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.62.1 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171023010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane-2.63.0.beta.20171022010003 fastlane_core/lib/fastlane_core/pkg_file_analyser.rb