Sha256: 2cacc46994783fdd3e810c955d81d8eb1b1bf2e5025b782c4a1e1f8f87ae1f14

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

module Deliver
  class DetectValues
    def run!(options)
      find_app_identifier(options)
      find_app(options)
      find_folders(options)
      find_version(options)
    end

    def find_app_identifier(options)
      return if options[:app_identifier]

      if options[:ipa]
        identifier = FastlaneCore::IpaFileAnalyser.fetch_app_identifier(options[:ipa])
      elsif options[:pkg]
        identifier = FastlaneCore::PkgFileAnalyser.fetch_app_identifier(options[:pkg])
      end

      options[:app_identifier] = identifier if identifier.to_s.length > 0
      options[:app_identifier] ||= ask("The Bundle Identifier of your App: ")
    end

    def find_app(options)
      search_by = options[:app_identifier]
      search_by = options[:app] if search_by.to_s.length == 0
      app = Spaceship::Application.find(search_by)
      if app
        options[:app] = app
      else
        raise "Could not find app with app identifier '#{options[:app_identifier]}' in your iTunes Connect account (#{options[:username]} - Team: #{Spaceship::Tunes.client.team_id})".red
      end
    end

    def find_folders(options)
      containing = Helper.fastlane_enabled? ? './fastlane' : '.'
      options[:screenshots_path] ||= File.join(containing, 'screenshots')
      options[:metadata_path] ||= File.join(containing, 'metadata')

      FileUtils.mkdir_p(options[:screenshots_path])
      FileUtils.mkdir_p(options[:metadata_path])
    end

    def find_version(options)
      if options[:ipa]
        options[:app_version] ||= FastlaneCore::IpaFileAnalyser.fetch_app_version(options[:ipa])
      elsif options[:pkg]
        options[:app_version] ||= FastlaneCore::PkgFileAnalyser.fetch_app_version(options[:pkg])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deliver-1.9.0 lib/deliver/detect_values.rb
deliver-1.8.1 lib/deliver/detect_values.rb
deliver-1.8.0 lib/deliver/detect_values.rb