repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/group.rb
spaceship/lib/spaceship/test_flight/group.rb
require_relative 'base' require_relative 'build' module Spaceship::TestFlight class Group < Base attr_accessor :id attr_accessor :name attr_accessor :is_default_external_group attr_accessor :is_internal_group attr_accessor :provider_id attr_accessor :is_active attr_accessor :created attr_accessor :app_id attr_mapping({ 'id' => :id, 'name' => :name, 'isInternalGroup' => :is_internal_group, 'appAdamId' => :app_id, 'isDefaultExternalGroup' => :is_default_external_group, 'providerId' => :provider_id, 'active' => :is_active, 'created' => :created }) def self.create!(app_id: nil, group_name: nil) group = self.find(app_id: app_id, group_name: group_name) return group unless group.nil? data = client.create_group_for_app(app_id: app_id, group_name: group_name) self.new(data) end def self.delete!(app_id: nil, group_name: nil) group = self.find(app_id: app_id, group_name: group_name) client.delete_group_for_app(app_id: app_id, group_id: group.id) end def self.all(app_id: nil) groups = client.get_groups(app_id: app_id) groups.map { |g| self.new(g) } end def self.find(app_id: nil, group_name: nil) groups = self.all(app_id: app_id) groups.find { |g| g.name == group_name } end def self.default_external_group(app_id: nil) groups = self.all(app_id: app_id) groups.find(&:default_external_group?) end def self.filter_groups(app_id: nil, &block) groups = self.all(app_id: app_id) groups.select(&block) end def self.internal_group(app_id: nil) groups = self.all(app_id: app_id) groups.find(&:internal_group?) end # First we need to add the tester to the app # It's ok if the tester already exists, we just have to do this... don't ask # This will enable testing for the tester for a given app, as just creating the tester on an account-level # is not enough to add the tester to a group. If this isn't done the next request would fail. # This is a bug we reported to the App Store Connect team, as it also happens on the App Store Connect UI on 18. April 2017 def add_tester!(tester) # This post request creates an account-level tester and then makes it available to the app, or just makes # it available to the app if it already exists client.create_app_level_tester(app_id: self.app_id, first_name: tester.first_name, last_name: tester.last_name, email: tester.email) # This put request adds the tester to the group client.post_tester_to_group(group_id: self.id, email: tester.email, first_name: tester.first_name, last_name: tester.last_name, app_id: self.app_id) end def remove_tester!(tester) client.delete_tester_from_group(group_id: self.id, tester_id: tester.tester_id, app_id: self.app_id) end def self.add_tester_to_groups!(tester: nil, app: nil, groups: nil) self.perform_for_groups_in_app(app: app, groups: groups) { |group| group.add_tester!(tester) } end def self.remove_tester_from_groups!(tester: nil, app: nil, groups: nil) self.perform_for_groups_in_app(app: app, groups: groups) { |group| group.remove_tester!(tester) } end def default_external_group? is_default_external_group end def internal_group? is_internal_group end def active? is_active end def builds builds = client.builds_for_group(app_id: self.app_id, group_id: self.id) builds.map { |b| Spaceship::TestFlight::Build.new(b) } end def self.perform_for_groups_in_app(app: nil, groups: nil, &block) if groups.nil? default_external_group = app.default_external_group if default_external_group.nil? raise "The app #{app.name} does not have a default external group. Please make sure to pass group names to the `:groups` option." end test_flight_groups = [default_external_group] else test_flight_groups = self.filter_groups(app_id: app.apple_id) do |group| groups.include?(group.name) end raise "There are no groups available matching the names passed to the `:groups` option." if test_flight_groups.empty? end test_flight_groups.each(&block) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/build.rb
spaceship/lib/spaceship/test_flight/build.rb
require 'time' require_relative 'base' require_relative 'test_info' require_relative 'export_compliance' require_relative 'beta_review_info' require_relative 'build_trains' require_relative '../connect_api' module Spaceship module TestFlight class Build < Base # @example # "com.sample.app" attr_accessor :bundle_id # @example # "testflight.build.state.testing.active" # @example # "testflight.build.state.processing" attr_accessor :internal_state # @example # "testflight.build.state.submit.ready" # @example # "testflight.build.state.processing" attr_accessor :external_state # Internal build ID (int) # @example # 19285309 attr_accessor :id # @example # "1.0" attr_accessor :train_version # @example # "152" attr_accessor :build_version attr_accessor :beta_review_info attr_accessor :export_compliance attr_accessor :test_info attr_accessor :install_count attr_accessor :invite_count attr_accessor :crash_count attr_accessor :auto_notify_enabled attr_accessor :did_notify attr_accessor :upload_date attr_accessor :dsym_url attr_accessor :build_sdk attr_accessor :include_symbols attr_accessor :number_of_asset_packs attr_accessor :contains_odr attr_accessor :file_name attr_mapping({ 'appAdamId' => :app_id, 'providerId' => :provider_id, 'bundleId' => :bundle_id, 'trainVersion' => :train_version, 'buildVersion' => :build_version, 'betaReviewInfo' => :beta_review_info, 'exportCompliance' => :export_compliance, 'internalState' => :internal_state, 'externalState' => :external_state, 'testInfo' => :test_info, 'installCount' => :install_count, 'inviteCount' => :invite_count, 'crashCount' => :crash_count, 'autoNotifyEnabled' => :auto_notify_enabled, 'didNotify' => :did_notify, 'uploadDate' => :upload_date, 'id' => :id, 'dSYMUrl' => :dsym_url, 'buildSdk' => :build_sdk, 'includesSymbols' => :include_symbols, 'numberOfAssetPacks' => :number_of_asset_packs, 'containsODR' => :contains_odr, 'fileName' => :file_name }) BUILD_STATES = { processing: 'testflight.build.state.processing', active: 'testflight.build.state.testing.active', ready_to_submit: 'testflight.build.state.submit.ready', ready_to_test: 'testflight.build.state.testing.ready', export_compliance_missing: 'testflight.build.state.export.compliance.missing', review_rejected: 'testflight.build.state.review.rejected', approved: 'testflight.build.state.review.approved' } # Find a Build by `build_id`. # # @return (Spaceship::TestFlight::Build) def self.find(app_id: nil, build_id: nil) attrs = client.get_build(app_id: app_id, build_id: build_id) self.new(attrs) end def self.all(app_id: nil, platform: nil, retry_count: 0) trains = BuildTrains.all(app_id: app_id, platform: platform, retry_count: retry_count) trains.values.flatten end def self.builds_for_train(app_id: nil, platform: nil, train_version: nil, retry_count: 3) builds_data = client.get_builds_for_train(app_id: app_id, platform: platform, train_version: train_version, retry_count: retry_count) builds_data.map { |data| self.new(data) } end # Just the builds, as a flat array, that are still processing def self.all_processing_builds(app_id: nil, platform: nil, retry_count: 0) all(app_id: app_id, platform: platform, retry_count: retry_count).find_all(&:processing?) end # Just the builds, as a flat array, that are waiting for beta review def self.all_waiting_for_review(app_id: nil, platform: nil, retry_count: 0) all(app_id: app_id, platform: platform, retry_count: retry_count).select { |app| app.external_state == 'testflight.build.state.review.waiting' } end def self.latest(app_id: nil, platform: nil) all(app_id: app_id, platform: platform).sort_by(&:upload_date).last end # reload the raw_data resource for this build. # This is useful when we start with a partial build response as returned by the BuildTrains, # but then need to look up some attributes on the full build representation. # # Note: this will overwrite any non-saved changes to the object # # @return (Spaceship::Base::DataHash) the raw_data of the build. def reload self.raw_data = self.class.find(app_id: app_id, build_id: id).raw_data end def ready_to_submit? external_state == BUILD_STATES[:ready_to_submit] end def ready_to_test? external_state == BUILD_STATES[:ready_to_test] end def active? external_state == BUILD_STATES[:active] end def processing? external_state == BUILD_STATES[:processing] end def export_compliance_missing? external_state == BUILD_STATES[:export_compliance_missing] end def review_rejected? external_state == BUILD_STATES[:review_rejected] end def approved? external_state == BUILD_STATES[:approved] end def processed? active? || ready_to_submit? || export_compliance_missing? || review_rejected? end # Getting builds from BuildTrains only gets a partial Build object # We are then requesting the full build from iTC when we need to access # any of the variables below, because they are not included in the partial Build objects # # `super` here calls `beta_review_info` as defined by the `attr_mapping` above. # @return (Spaceship::TestFlight::BetaReviewInfo) def beta_review_info super || reload BetaReviewInfo.new(super) end # @return (Spaceship::TestFlight::ExportCompliance) def export_compliance super || reload ExportCompliance.new(super) end # @return (Spaceship::TestFlight::TestInfo) def test_info super || reload TestInfo.new(super) end # @return (Time) an parsed Time value for the upload_date def upload_date Time.parse(super) end # saves the changes to the Build object to TestFlight def save! client.put_build(app_id: app_id, build_id: id, build: self) end def update_build_information!(description: nil, feedback_email: nil, whats_new: nil) test_info.description = description if description test_info.feedback_email = feedback_email if feedback_email test_info.whats_new = whats_new if whats_new save! end def submit_for_testflight_review! return if ready_to_test? return if approved? Spaceship::ConnectAPI.post_beta_app_review_submissions(build_id: id) end def expire! client.expire_build(app_id: app_id, build_id: id, build: self) end def add_group!(group) client.add_group_to_build(app_id: app_id, group_id: group.id, build_id: id) end # Bridges the TestFlight::Build to the App Store Connect API build def find_app_store_connect_build builds = Spaceship::ConnectAPI::Build.all( app_id: app_id, version: self.train_version, build_number: self.build_version ) return builds.find { |build| build.id == id } end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/app_test_info.rb
spaceship/lib/spaceship/test_flight/app_test_info.rb
require_relative 'base' require_relative 'test_info' require_relative 'beta_review_info' module Spaceship::TestFlight class AppTestInfo < Base # AppTestInfo wraps a test_info and beta_review_info in the format required to manage test_info # for an application. Note that this structure, although looking similar to build test_info # is test information about the application attr_accessor :test_info attr_accessor :beta_review_info def self.find(app_id: nil) raw_app_test_info = client.get_app_test_info(app_id: app_id) self.new(raw_app_test_info) end def test_info Spaceship::TestFlight::TestInfo.new(raw_data['details']) end def test_info=(value) raw_data.set(['details'], value.raw_data) end def beta_review_info Spaceship::TestFlight::BetaReviewInfo.new(raw_data['betaReviewInfo']) end def beta_review_info=(value) raw_data.set(['betaReviewInfo'], value.raw_data) end # saves the changes to the App Test Info object to TestFlight def save_for_app!(app_id: nil) client.put_app_test_info(app_id: app_id, app_test_info: self) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/beta_review_info.rb
spaceship/lib/spaceship/test_flight/beta_review_info.rb
require_relative 'base' module Spaceship::TestFlight class BetaReviewInfo < Base attr_accessor :contact_first_name, :contact_last_name, :contact_phone, :contact_email attr_accessor :demo_account_name, :demo_account_password, :demo_account_required, :notes attr_mapping({ 'contactFirstName' => :contact_first_name, 'contactLastName' => :contact_last_name, 'contactPhone' => :contact_phone, 'contactEmail' => :contact_email, 'demoAccountName' => :demo_account_name, 'demoAccountPassword' => :demo_account_password, 'demoAccountRequired' => :demo_account_required, 'notes' => :notes }) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/base.rb
spaceship/lib/spaceship/test_flight/base.rb
require_relative '../base' require_relative '../tunes/tunes_client' module Spaceship module TestFlight class Base < Spaceship::Base def self.client # Verify there is a client that can be used if Spaceship::Tunes.client # Initialize new client if new or if team changed if @client.nil? || @client.team_id != Spaceship::Tunes.client.team_id @client = Client.client_with_authorization_from(Spaceship::Tunes.client) end end # Need to handle not having a client but this shouldn't ever happen raise "Please login using `Spaceship::Tunes.login('user', 'password')`" unless @client @client end ## # Have subclasses inherit the client from their superclass # # Essentially, we are making a class-inheritable-accessor as described here: # https://apidock.com/rails/v4.2.7/Class/class_attribute def self.inherited(subclass) this_class = self subclass.define_singleton_method(:client) do this_class.client end end def to_json raw_data.to_json end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/export_compliance.rb
spaceship/lib/spaceship/test_flight/export_compliance.rb
require_relative 'base' module Spaceship::TestFlight class ExportCompliance < Base attr_accessor :uses_encryption, :encryption_updated attr_mapping({ 'usesEncryption' => :uses_encryption, 'encryptionUpdated' => :encryption_updated }) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/client.rb
spaceship/lib/spaceship/test_flight/client.rb
require_relative '../client' module Spaceship module TestFlight class Client < Spaceship::Client ## # Spaceship HTTP client for the testflight API. # # This client is solely responsible for the making HTTP requests and # parsing their responses. Parameters should be either named parameters, or # for large request data bodies, pass in anything that can respond to # `to_json`. # # Each request method should validate the required parameters. A required parameter is one that would result in 400-range response if it is not supplied. # Each request method should make only one request. For more high-level logic, put code in the data models. def self.hostname 'https://appstoreconnect.apple.com/testflight/v2/' end ## # @!group Build trains API ## # Returns an array of all available build trains (not the builds they include) def get_build_trains(app_id: nil, platform: "ios") assert_required_params(__method__, binding) response = request(:get, "providers/#{team_id}/apps/#{app_id}/platforms/#{platform}/trains") handle_response(response) end def get_builds_for_train(app_id: nil, platform: "ios", train_version: nil, retry_count: 3) assert_required_params(__method__, binding) with_retry(retry_count) do response = request(:get, "providers/#{team_id}/apps/#{app_id}/platforms/#{platform}/trains/#{train_version}/builds", nil, {}, true) handle_response(response) end end ## # @!group Builds API ## def get_build(app_id: nil, build_id: nil) assert_required_params(__method__, binding) response = request(:get, "providers/#{team_id}/apps/#{app_id}/builds/#{build_id}") handle_response(response) end def put_build(app_id: nil, build_id: nil, build: nil) assert_required_params(__method__, binding) response = request(:put) do |req| req.url("providers/#{team_id}/apps/#{app_id}/builds/#{build_id}") req.body = build.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end def expire_build(app_id: nil, build_id: nil, build: nil) assert_required_params(__method__, binding) response = request(:post) do |req| req.url("providers/#{team_id}/apps/#{app_id}/builds/#{build_id}/expire") req.body = build.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end ## # @!group Groups API ## # Returns a list of available testing groups # e.g. # {"b6f65dbd-c845-4d91-bc39-0b661d608970" => "Boarding", # "70402368-9deb-409f-9a26-bb3f215dfee3" => "Automatic"} def get_groups(app_id: nil) @cached_groups = {} unless @cached_groups return @cached_groups[app_id] if @cached_groups[app_id] assert_required_params(__method__, binding) response = request(:get, "/testflight/v2/providers/#{provider_id}/apps/#{app_id}/groups") @cached_groups[app_id] = handle_response(response) end def create_group_for_app(app_id: nil, group_name: nil) assert_required_params(__method__, binding) body = { 'name' => group_name } response = request(:post) do |req| req.url("providers/#{team_id}/apps/#{app_id}/groups") req.body = body.to_json req.headers['Content-Type'] = 'application/json' end # This is invalid now. @cached_groups.delete(app_id) if @cached_groups handle_response(response) end def delete_group_for_app(app_id: nil, group_id: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}" response = request(:delete, url) handle_response(response) end def add_group_to_build(app_id: nil, group_id: nil, build_id: nil) assert_required_params(__method__, binding) body = { 'groupId' => group_id, 'buildId' => build_id } response = request(:put) do |req| req.url("providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/builds/#{build_id}") req.body = body.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end ##################################################### # @!group Testers ##################################################### def testers(tester) url = tester.url[:index] r = request(:get, url) parse_response(r, 'data')['users'] end def testers_by_app(tester, app_id, group_id: nil) if group_id.nil? group_ids = get_groups(app_id: app_id).map do |group| group['id'] end end group_ids ||= [group_id] testers = [] group_ids.each do |json_group_id| url = tester.url(app_id, provider_id, json_group_id)[:index_by_app] r = request(:get, url) testers += parse_response(r, 'data')['users'] end testers end ##################################################### # @!Internal Testers ##################################################### def internal_users(app_id: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/internalUsers" r = request(:get, url) parse_response(r, 'data') end ## # @!group Testers API ## def testers_for_app(app_id: nil) assert_required_params(__method__, binding) page_size = 40 # that's enforced by the iTC servers resulting_array = [] # Sort order is set to `default` instead of `email`, because any other sort order breaks pagination # when dealing with lots of anonymous (public link) testers: https://github.com/fastlane/fastlane/pull/13778 initial_url = "providers/#{team_id}/apps/#{app_id}/testers?limit=#{page_size}&sort=default&order=asc" response = request(:get, initial_url) link_from_response = proc do |r| # I weep for Swift nil chaining (l = r.headers['link']) && (m = l.match(/<(.*)>/)) && m.captures.first end next_link = link_from_response.call(response) result = Array(handle_response(response)) resulting_array += result return resulting_array if result.count == 0 until next_link.nil? response = request(:get, next_link) result = Array(handle_response(response)) next_link = link_from_response.call(response) break if result.count == 0 resulting_array += result end return resulting_array.uniq end def delete_tester_from_app(app_id: nil, tester_id: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/testers/#{tester_id}" response = request(:delete, url) handle_response(response) end def remove_testers_from_testflight(app_id: nil, tester_ids: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/deleteTesters" response = request(:post) do |req| req.url(url) req.body = tester_ids.map { |i| { "id" => i } }.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end def search_for_tester_in_app(app_id: nil, text: nil) assert_required_params(__method__, binding) text = CGI.escape(text) url = "providers/#{team_id}/apps/#{app_id}/testers?order=asc&search=#{text}&sort=status" response = request(:get, url) handle_response(response) end def resend_invite_to_external_tester(app_id: nil, tester_id: nil) assert_required_params(__method__, binding) url = "/testflight/v1/invites/#{app_id}/resend?testerId=#{tester_id}" response = request(:post, url) handle_response(response) end def create_app_level_tester(app_id: nil, first_name: nil, last_name: nil, email: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/testers" response = request(:post) do |req| req.url(url) req.body = { "email" => email, "firstName" => first_name, "lastName" => last_name }.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end def post_tester_to_group(app_id: nil, email: nil, first_name: nil, last_name: nil, group_id: nil) assert_required_params(__method__, binding) # Then we can add the tester to the group that allows the app to test # This is easy enough, we already have all this data. We don't need any response from the previous request url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/testers" response = request(:post) do |req| req.url(url) req.body = [{ "email" => email, "firstName" => first_name, "lastName" => last_name }].to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end def delete_tester_from_group(group_id: nil, tester_id: nil, app_id: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/testers/#{tester_id}" response = request(:delete) do |req| req.url(url) req.headers['Content-Type'] = 'application/json' end handle_response(response) end def builds_for_group(app_id: nil, group_id: nil) assert_required_params(__method__, binding) url = "providers/#{team_id}/apps/#{app_id}/groups/#{group_id}/builds" response = request(:get, url) handle_response(response) end ## # @!group AppTestInfo ## def get_app_test_info(app_id: nil) assert_required_params(__method__, binding) response = request(:get, "providers/#{team_id}/apps/#{app_id}/testInfo") handle_response(response) end def put_app_test_info(app_id: nil, app_test_info: nil) assert_required_params(__method__, binding) response = request(:put) do |req| req.url("providers/#{team_id}/apps/#{app_id}/testInfo") req.body = app_test_info.to_json req.headers['Content-Type'] = 'application/json' end handle_response(response) end protected def handle_response(response) if (200...300).cover?(response.status) && (response.body.nil? || response.body.empty?) return end raise InternalServerError, "Server error got #{response.status}" if (500...600).cover?(response.status) unless response.body.kind_of?(Hash) raise UnexpectedResponse, response.body end raise UnexpectedResponse, response.body['error'] if response.body['error'] raise UnexpectedResponse, "Temporary App Store Connect error: #{response.body}" if response.body['statusCode'] == 'ERROR' return response.body['data'] if response.body['data'] return response.body end private # used to assert all of the named parameters are supplied values # # @raises NameError if the values are nil def assert_required_params(method_name, binding) parameter_names = method(method_name).parameters.map { |k, v| v } parameter_names.each do |name| if local_variable_get(binding, name).nil? raise NameError, "`#{name}' is a required parameter" end end end def local_variable_get(binding, name) if binding.respond_to?(:local_variable_get) binding.local_variable_get(name) else binding.eval(name.to_s) end end def provider_id return team_id if self.provider.nil? self.provider.provider_id end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/test_info.rb
spaceship/lib/spaceship/test_flight/test_info.rb
require_relative 'base' module Spaceship::TestFlight class TestInfo < Base # TestInfo Contains a collection of info for testers. There is one "testInfo" for each locale. # # For now, when we set a value it sets the same value for all locales # When getting a value, we return the first locale values attr_accessor :description, :feedback_email, :whats_new, :privacy_policy_url, :marketing_url def description raw_data.first['description'] end def description=(value) raw_data.each { |locale| locale['description'] = value } end def feedback_email raw_data.first['feedbackEmail'] end def feedback_email=(value) raw_data.each { |locale| locale['feedbackEmail'] = value } end def privacy_policy_url raw_data.first['privacyPolicyUrl'] end def privacy_policy_url=(value) raw_data.each { |locale| locale['privacyPolicyUrl'] = value } end def marketing_url raw_data.first['marketingUrl'] end def marketing_url=(value) raw_data.each { |locale| locale['marketingUrl'] = value } end def whats_new raw_data.first['whatsNew'] end def whats_new=(value) raw_data.each { |locale| locale['whatsNew'] = value } end def deep_copy TestInfo.new(raw_data.map(&:dup)) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/lib/spaceship/test_flight/tester.rb
spaceship/lib/spaceship/test_flight/tester.rb
require_relative 'base' module Spaceship module TestFlight class Tester < Base # @return (String) The identifier of this tester, provided by App Store Connect # @example # "60f858b4-60a8-428a-963a-f943a3d68d17" attr_accessor :tester_id # @return (String) The email of this tester # @example # "tester@spaceship.com" attr_accessor :email # @return (String) The first name of this tester # @example # "Cary" attr_accessor :first_name # @return (String) The last name of this tester # @example # "Bennett" attr_accessor :last_name # @return (String) # @example # "invited" # "installed" # attr_accessor :status # @return (Integer) Date of the last modification of the status (e.g. invite sent) attr_accessor :status_mod_time # @return (Hash) # @example # { # "latestInstalledAppAdamId": "1222374686", # "latestInstalledBuildId": "20739770", # "latestInstalledDate": "1496866405755", # "latestInstalledShortVersion": "1.0", # "latestInstalledVersion": "68" # } attr_accessor :latest_install_info attr_accessor :latest_installed_date # @return (Integer) Number of sessions attr_accessor :session_count attr_accessor :groups attr_mapping( 'id' => :tester_id, 'email' => :email, 'status' => :status, 'statusModTime' => :status_mod_time, 'latestInstallInfo' => :latest_install_info, 'sessionCount' => :session_count, 'firstName' => :first_name, 'lastName' => :last_name, 'groups' => :groups ) def latest_installed_date return nil unless latest_install_info latest_installed_date_value = latest_install_info["latestInstalledDate"] return nil unless latest_installed_date_value return latest_installed_date_value.to_i end def pretty_install_date return nil unless latest_installed_date Time.at((latest_installed_date / 1000)).strftime("%Y-%m-%d %H:%M") end # @return (Array) Returns all beta testers available for this account def self.all(app_id: nil) client.testers_for_app(app_id: app_id).map { |data| self.new(data) } end # *DEPRECATED: Use `Spaceship::TestFlight::Tester.search` method instead* def self.find(app_id: nil, email: nil) testers = self.search(app_id: app_id, text: email, is_email_exact_match: true) return testers.first end def status_mod_time Time.parse(super) if super.to_s.length > 0 end # @return (Spaceship::TestFlight::Tester) Returns the testers matching the parameter. # ITC searches all fields, and is full text. The search results are the union of all words in the search text # @param text (String) (required): Value used to filter the tester, case-insensitive def self.search(app_id: nil, text: nil, is_email_exact_match: false) text = text.strip testers_matching_text = client.search_for_tester_in_app(app_id: app_id, text: text).map { |data| self.new(data) } testers_matching_text ||= [] if is_email_exact_match text = text.downcase testers_matching_text = testers_matching_text.select do |tester| tester.email.downcase == text end end return testers_matching_text end def self.remove_testers_from_testflight(app_id: nil, tester_ids: nil) client.remove_testers_from_testflight(app_id: app_id, tester_ids: tester_ids) end def self.create_app_level_tester(app_id: nil, first_name: nil, last_name: nil, email: nil) client.create_app_level_tester(app_id: app_id, first_name: first_name, last_name: last_name, email: email) end def remove_from_app!(app_id: nil) client.delete_tester_from_app(app_id: app_id, tester_id: self.tester_id) end def remove_from_testflight!(app_id: nil) client.remove_testers_from_testflight(app_id: app_id, tester_ids: [self.tester_id]) end def resend_invite(app_id: nil) client.resend_invite_to_external_tester(app_id: app_id, tester_id: self.tester_id) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/help_formatter_spec.rb
fastlane_core/spec/help_formatter_spec.rb
describe FastlaneCore::HelpFormatter do class MockCommand attr_accessor :name, :summary, :description, :options, :examples def initialize(name, summary, description, options, examples) @name = name @summary = summary @description = description @options = options @examples = examples end end class MockCommanderRunner attr_accessor :commands, :program, :options, :aliases, :default_command def initialize @commands = {} @program = {} @options = [] @aliases = {} @default_command = nil end def program(key) @program[key] end def alias?(name) @aliases.include?(name) end end let(:commander) { MockCommanderRunner.new } before do commander.program = { name: 'foo_bar_test', description: 'This is a mock CLI app for testing' } default_command_options = [ { switches: ['-v', '--verbose'], description: 'Output verbose logs' } ] commander.commands = { foo: MockCommand.new('foo', 'Print foo', 'Print foo description', [], []), bar: MockCommand.new('bar', 'Print bar', 'Print bar description', [], []), foo_bar: MockCommand.new('foo_bar', 'Print foo bar', 'Print foo bar description', default_command_options, []) } end it 'should indicate default command with default_command setting' do commander.default_command = :foo_bar help = described_class.new(commander).render expect(help).to match(/\(\* default\)/) expect(help).to match(/\* Print foo bar/) end it 'should not mention default command with without default_command setting' do help = described_class.new(commander).render expect(help).not_to match(/\(\* default\)/) expect(help).not_to match(/\* Print foo bar/) end it 'should still renders a subcommand with super class\'s template' do command = commander.commands[:foo] help = described_class.new(commander).render_command(command) expect(help).to match(/#{command.description}/) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/ios_app_identifier_guesser_spec.rb
fastlane_core/spec/ios_app_identifier_guesser_spec.rb
require 'spec_helper' require 'fastlane_core/ios_app_identifier_guesser' describe FastlaneCore::IOSAppIdentifierGuesser do it 'returns nil if no clues' do # this might also fail if the environment or config files are not clean expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to be_nil end describe 'guessing from command line args' do it 'returns iOS app_identifier if specified with -a' do args = ["-a", "com.krausefx.app"] expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier(args)).to eq("com.krausefx.app") end it 'returns iOS app_identifier if specified with --app_identifier' do args = ["--app_identifier", "com.krausefx.app"] expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier(args)).to eq("com.krausefx.app") end end describe 'guessing from environment' do it 'returns iOS app_identifier present in environment' do ["FASTLANE", "DELIVER", "PILOT", "PRODUCE", "PEM", "SIGH", "SNAPSHOT", "MATCH"].each do |current| env_var_name = "#{current}_APP_IDENTIFIER" app_identifier = "#{current}.bundle.id" ENV[env_var_name] = app_identifier expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq(app_identifier) ENV.delete(env_var_name) end end end describe 'guessing from Appfile' do it 'returns iOS app_identifier found in Appfile' do expect(CredentialsManager::AppfileConfig).to receive(:try_fetch_value).with(:app_identifier).and_return("Appfile.bundle.id") expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq("Appfile.bundle.id") end end describe 'guessing from configuration files' do def allow_non_target_configuration_file(file_name) allow_any_instance_of(FastlaneCore::Configuration).to receive(:load_configuration_file).with(file_name, any_args) do |configuration, config_file_name| nil end end def allow_target_configuration_file(file_name) allow_any_instance_of(FastlaneCore::Configuration).to receive(:load_configuration_file).with(file_name, any_args) do |configuration, config_file_name| configuration[:app_identifier] = "#{config_file_name}.bundle.id" end end it 'returns iOS app_identifier found in Deliverfile' do allow_target_configuration_file("Deliverfile") allow_non_target_configuration_file("Gymfile") allow_non_target_configuration_file("Matchfile") allow_non_target_configuration_file("Snapfile") expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq("Deliverfile.bundle.id") end it 'catches common permutations of application id with swift matcher' do expected_app_ids = [ "a.c.b", "a.c.b", "a.c.b", "a.c.b", "a.c.b", "a.c.b", "a-c-b", "a", "ad", "a--.--.b" ] valid_id_strings = [ "var appIdentifier: String { return \"a.c.b\" }", "var appIdentifier: String? { return \"a.c.b\" }", "var appIdentifier: String[] { return [\"a.c.b\"] }", "var appIdentifier: String {return \"a.c.b\"}", "var appIdentifier: String {return \"a.c.b\"} ", "var appIdentifier: String { return \"a.c.b \" }", "var appIdentifier: String { return \"a-c-b\" }", "var appIdentifier: String { return \"a\" }", "var appIdentifier: String { return \"ad\" }", "var appIdentifier: String { return \"a--.--.b\" }" ] valid_id_strings.zip(expected_app_ids).each do |line, expected_app_id| app_id = FastlaneCore::IOSAppIdentifierGuesser.match_swift_application_id(text_line: line) expect(app_id).to eq(expected_app_id) end end it 'ignores non-application ids with swift matcher' do valid_id_strings = [ "var appIdentifier: String { return \"\" }", "var appIdentifier: String", "var appIdentifier: String { get }", "var appIdentifier: String? { return nil }", "var appIdentifier: String? { get }", "var appIdentifier: String[] { return [] }", "var appIdentifier: String[] { get }", "var appIdentifier: String [ ] {get }", "var appId: String { return \"\" }", "var appId: String { get }" ] valid_id_strings.each do |line| expect(FastlaneCore::IOSAppIdentifierGuesser.match_swift_application_id(text_line: line)).to be_nil end end it 'returns iOS app_identifier found in Gymfile' do allow_target_configuration_file("Gymfile") allow_non_target_configuration_file("Deliverfile") allow_non_target_configuration_file("Matchfile") allow_non_target_configuration_file("Snapfile") expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq("Gymfile.bundle.id") end it 'returns iOS app_identifier found in Snapfile' do allow_target_configuration_file("Snapfile") allow_non_target_configuration_file("Deliverfile") allow_non_target_configuration_file("Gymfile") allow_non_target_configuration_file("Matchfile") expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq("Snapfile.bundle.id") end it 'returns iOS app_identifier found in Matchfile' do allow_target_configuration_file("Matchfile") allow_non_target_configuration_file("Deliverfile") allow_non_target_configuration_file("Gymfile") allow_non_target_configuration_file("Snapfile") expect(FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier([])).to eq("Matchfile.bundle.id") end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/print_table_spec.rb
fastlane_core/spec/print_table_spec.rb
describe FastlaneCore do describe FastlaneCore::PrintTable do before do @options = [ FastlaneCore::ConfigItem.new(key: :cert_name, env_name: "SIGH_PROVISIONING_PROFILE_NAME", description: "Set the profile name", verify_block: nil), FastlaneCore::ConfigItem.new(key: :output, env_name: "SIGH_OUTPUT_PATH", description: "Directory in which the profile should be stored", default_value: ".", verify_block: proc do |value| UI.user_error!("Could not find output directory '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :a_bool, description: "Metadata: A bool", optional: true, is_string: false, default_value: true), FastlaneCore::ConfigItem.new(key: :a_sensitive, description: "Metadata: A sensitive option", optional: true, sensitive: true, is_string: true, default_value: "Some secret"), FastlaneCore::ConfigItem.new(key: :a_hash, description: "Metadata: A hash", optional: true, is_string: false) ] @values = { cert_name: "asdf", output: "..", a_bool: true, a_hash: {} } @config = FastlaneCore::Configuration.create(@options, @values) end it "supports nil config" do value = FastlaneCore::PrintTable.print_values expect(value).to eq({ rows: [] }) end it "prints out all the information in a nice table" do title = "Custom Title" value = FastlaneCore::PrintTable.print_values(config: @config, title: title, hide_keys: [:a_sensitive]) expect(value[:title]).to eq(title.green) expect(value[:rows]).to eq([["cert_name", "asdf"], ["output", ".."], ["a_bool", true]]) end it "automatically masks sensitive options" do value = FastlaneCore::PrintTable.print_values(config: @config) expect(value[:rows]).to eq([["cert_name", "asdf"], ["output", ".."], ["a_bool", true], ["a_sensitive", "********"]]) end it "supports mask_keys property with symbols and strings" do value = FastlaneCore::PrintTable.print_values(config: @config, mask_keys: [:cert_name, 'a_bool']) expect(value[:rows]).to eq([["cert_name", "********"], ["output", ".."], ["a_bool", "********"], ["a_sensitive", "********"]]) end it "supports hide_keys property with symbols and strings" do value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:cert_name, "a_bool", :a_sensitive]) expect(value[:rows]).to eq([['output', '..']]) end it "recurses over hashes" do @config[:a_hash][:foo] = 'bar' @config[:a_hash][:bar] = { foo: 'bar' } value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:cert_name, :a_bool]) expect(value[:rows]).to eq([["output", ".."], ["a_hash.foo", "bar"], ["a_hash.bar.foo", "bar"], ["a_sensitive", "********"]]) end it "supports hide_keys property in hashes" do @config[:a_hash][:foo] = 'bar' @config[:a_hash][:bar] = { foo: 'bar' } value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:cert_name, :a_bool, 'a_hash.foo', 'a_hash.bar.foo']) expect(value[:rows]).to eq([["output", ".."], ["a_sensitive", "********"]]) end it "supports printing default values and ignores missing unset ones " do @config[:cert_name] = nil # compulsory without default @config[:output] = nil # compulsory with default value = FastlaneCore::PrintTable.print_values(config: @config) expect(value[:rows]).to eq([["output", "."], ["a_bool", true], ["a_sensitive", "********"]]) end describe "Breaks down lines" do let(:long_breakable_text) { 'bar ' * 400 } before do @config[:cert_name] = long_breakable_text allow(TTY::Screen).to receive(:width).and_return(200) end it "middle truncate" do expect(FastlaneCore::PrintTable).to receive(:should_transform?).and_return(true) value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:output, :a_bool, :a_sensitive], transform: :truncate_middle) expect(value[:rows].count).to eq(1) expect(value[:rows][0][1]).to include("...") expect(value[:rows][0][1].length).to be < long_breakable_text.length end it "newline" do expect(FastlaneCore::PrintTable).to receive(:should_transform?).and_return(true) value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:output, :a_bool, :a_sensitive], transform: :newline) expect(value[:rows].count).to eq(1) expect(value[:rows][0][1]).to include("\n") expect(value[:rows][0][1].length).to be > long_breakable_text.length end it "no change for `nil`" do value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:output, :a_bool, :a_sensitive], transform: nil) expect(value[:rows].count).to eq(1) expect(value[:rows][0][1].length).to eq(long_breakable_text.length) end it "doesn't break with long strings with no space" do rows = [[:git_url, "https" * 100]] value = FastlaneCore::PrintTable.print_values(config: rows, hide_keys: [], transform: :newline) expect(value[:rows].count).to eq(1) expect(value[:rows].first.first).to eq("git_url") expect(value[:rows].first.last).to include("httpshttps") end it "doesn't transform if the env variable is set" do FastlaneSpec::Env.with_env_values("FL_SKIP_TABLE_TRANSFORM" => "1") do value = FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [:output, :a_bool, :a_sensitive], transform: :truncate_middle) expect(value[:rows][0][1]).to_not(include("...")) end end it "raises an exception for invalid transform" do expect(FastlaneCore::PrintTable).to receive(:should_transform?).and_return(true) expect do FastlaneCore::PrintTable.print_values(config: @config, hide_keys: [], transform: :something_random) end.to raise_error("Unknown transform value 'something_random'") end end it "supports non-Configuration prints" do value = FastlaneCore::PrintTable.print_values(config: { key: "value" }, title: "title") expect(value[:rows]).to eq([["key", "value"]]) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/helper_spec.rb
fastlane_core/spec/helper_spec.rb
describe FastlaneCore do describe FastlaneCore::Helper do describe "#bundler?" do it "returns false when not in a bundler environment" do stub_const('ENV', {}) expect(FastlaneCore::Helper.bundler?).to be(false) end it "returns true BUNDLE_BIN_PATH is defined" do stub_const('ENV', { 'BUNDLE_BIN_PATH' => '/fake/elsewhere' }) expect(FastlaneCore::Helper.bundler?).to be(true) end it "returns true BUNDLE_GEMFILE is defined" do stub_const('ENV', { 'BUNDLE_GEMFILE' => '/fake/elsewhere/myFile' }) expect(FastlaneCore::Helper.bundler?).to be(true) end end describe "#xcode_at_least?" do ["15.2", "15.2.3", 15, 15.3].each do |check_version| ["15.3", "16"].each do |xcode_version| it "Xcode #{xcode_version} is at least #{check_version}" do allow(FastlaneCore::Helper).to receive(:xcode_version).and_return(xcode_version) expect(FastlaneCore::Helper.xcode_at_least?(check_version)).to be(true) end end ["14", "14.99.99"].each do |xcode_version| it "Xcode #{xcode_version} is less than #{check_version}" do allow(FastlaneCore::Helper).to receive(:xcode_version).and_return(xcode_version) expect(FastlaneCore::Helper.xcode_at_least?(check_version)).to be(false) end end end end describe '#colors_disabled?' do it "should return false if no environment variables set" do stub_const('ENV', {}) expect(FastlaneCore::Helper.colors_disabled?).to be(false) end it "should return true if FASTLANE_DISABLE_COLORS" do stub_const('ENV', { "FASTLANE_DISABLE_COLORS" => "true" }) expect(FastlaneCore::Helper.colors_disabled?).to be(true) end it "should return true if NO_COLORS" do stub_const('ENV', { "NO_COLOR" => 1 }) expect(FastlaneCore::Helper.colors_disabled?).to be(true) end end describe '#json_file?' do it "should return false on invalid json file" do expect(FastlaneCore::Helper.json_file?("./fastlane_core/spec/fixtures/json_file/broken")).to be(false) end it "should return true on valid json file" do expect(FastlaneCore::Helper.json_file?("./fastlane_core/spec/fixtures/json_file/valid")).to be(true) end end describe "#ci?" do it "returns false when not building in a known CI environment" do stub_const('ENV', {}) expect(FastlaneCore::Helper.ci?).to be(false) end it "returns true when building in CircleCI" do stub_const('ENV', { 'CIRCLECI' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in Jenkins" do stub_const('ENV', { 'JENKINS_URL' => 'http://fake.jenkins.url' }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in Jenkins Slave" do stub_const('ENV', { 'JENKINS_HOME' => '/fake/jenkins/home' }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in Travis CI" do stub_const('ENV', { 'TRAVIS' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in gitlab-ci" do stub_const('ENV', { 'GITLAB_CI' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in AppCenter" do stub_const('ENV', { 'APPCENTER_BUILD_ID' => '185' }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in GitHub Actions" do stub_const('ENV', { 'GITHUB_ACTION' => 'FAKE_ACTION' }) expect(FastlaneCore::Helper.ci?).to be(true) stub_const('ENV', { 'GITHUB_ACTIONS' => 'true' }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in Xcode Server" do stub_const('ENV', { 'XCS' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns true when building in Azure DevOps (VSTS) " do stub_const('ENV', { 'TF_BUILD' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end end describe "#is_circle_ci?" do it "returns true when building in CircleCI" do stub_const('ENV', { 'CIRCLECI' => true }) expect(FastlaneCore::Helper.ci?).to be(true) end it "returns false when not building in a known CI environment" do stub_const('ENV', {}) expect(FastlaneCore::Helper.ci?).to be(false) end end describe "#keychain_path" do it "finds file in current directory" do allow(File).to receive(:file?).and_return(false) found = File.expand_path("test.keychain") allow(File).to receive(:file?).with(found).and_return(true) expect(FastlaneCore::Helper.keychain_path("test.keychain")).to eq(File.expand_path(found)) end it "finds file in current directory with -db" do allow(File).to receive(:file?).and_return(false) found = File.expand_path("test-db") allow(File).to receive(:file?).with(found).and_return(true) expect(FastlaneCore::Helper.keychain_path("test.keychain")).to eq(File.expand_path(found)) end it "finds file in current directory with spaces and \"" do allow(File).to receive(:file?).and_return(false) found = File.expand_path('\\"\\ test\\ \\".keychain') allow(File).to receive(:file?).with(found).and_return(true) expect(FastlaneCore::Helper.keychain_path('\\"\\ test\\ \\".keychain')).to eq(File.expand_path(found)) end end describe "Xcode" do # Those tests also work when using a beta version of Xcode it "#xcode_path", requires_xcode: true do expect(FastlaneCore::Helper.xcode_path[-1]).to eq('/') expect(FastlaneCore::Helper.xcode_path).to match(%r{/Applications/Xcode.*.app/Contents/Developer/}) end it "#transporter_path", requires_xcode: true do unless FastlaneCore::Helper.xcode_at_least?("14") expect(FastlaneCore::Helper.transporter_path).to match(%r{/Applications/Xcode.*.app/Contents/Applications/Application Loader.app/Contents/itms/bin/iTMSTransporter|/Applications/Xcode.*.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms/bin/iTMSTransporter}) end end it "#xcode_version", requires_xcode: true do expect(FastlaneCore::Helper.xcode_version).to match(/^\d[\.\d]+$/) end context "#user_defined_itms_path?" do it "not defined", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => nil }) expect(FastlaneCore::Helper.user_defined_itms_path?).to be(false) end it "is defined", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => '/some/path/to/something' }) expect(FastlaneCore::Helper.user_defined_itms_path?).to be(true) end end context "#user_defined_itms_path" do it "not defined", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => nil }) expect(FastlaneCore::Helper.user_defined_itms_path).to be(nil) end it "is defined", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => '/some/path/to/something' }) expect(FastlaneCore::Helper.user_defined_itms_path).to eq('/some/path/to/something') end end context "#itms_path" do it "default", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => nil }) if FastlaneCore::Helper.xcode_at_least?("14") expect(FastlaneCore::UI).to receive(:user_error!).with(/Could not find transporter/) expect { FastlaneCore::Helper.itms_path }.not_to raise_error else expect(FastlaneCore::Helper.itms_path).to match(/itms/) end end it "uses FASTLANE_ITUNES_TRANSPORTER_PATH", requires_xcode: true do stub_const('ENV', { 'FASTLANE_ITUNES_TRANSPORTER_PATH' => '/some/path/to/something' }) expect(FastlaneCore::Helper.itms_path).to eq('/some/path/to/something') end end end describe "#zip_directory" do let(:directory) { File.absolute_path('/tmp/directory') } let(:directory_to_zip) { File.absolute_path('/tmp/directory/to_zip') } let(:the_zip) { File.absolute_path('/tmp/thezip.zip') } it "creates correct zip command with contents_only set to false with default print option (true)" do expect(FastlaneCore::Helper).to receive(:backticks) .with("cd '#{directory}' && zip -r '#{the_zip}' 'to_zip'", print: true) .exactly(1).times FastlaneCore::Helper.zip_directory(directory_to_zip, the_zip, contents_only: false) end it "creates correct zip command with contents_only set to true with print set to false" do expect(FastlaneCore::Helper).to receive(:backticks) .with("cd '#{directory_to_zip}' && zip -r '#{the_zip}' *", print: false) .exactly(1).times expect(FastlaneCore::UI).to receive(:command).exactly(1).times FastlaneCore::Helper.zip_directory(directory_to_zip, the_zip, contents_only: true, print: false) end end describe "#fastlane_enabled?" do it "returns false when FastlaneCore::FastlaneFolder.path is nil" do expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil) expect(FastlaneCore::Helper.fastlane_enabled?).to be(false) end it "returns true when FastlaneCore::FastlaneFolder.path is not nil" do expect(FastlaneCore::FastlaneFolder).to receive(:path).and_return('./fastlane') expect(FastlaneCore::Helper.fastlane_enabled?).to be(true) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/interface_spec.rb
fastlane_core/spec/interface_spec.rb
describe FastlaneCore::Interface do describe "Abort helper methods" do describe "#abort_with_message!" do it "raises FastlaneCommonException" do expect do FastlaneCore::Interface.new.abort_with_message!("Yup") end.to raise_error(FastlaneCore::Interface::FastlaneCommonException, "Yup") end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/tag_version_spec.rb
fastlane_core/spec/tag_version_spec.rb
describe FastlaneCore::TagVersion do describe "version_number_from_tag" do # This is the style generated by rake release. it "removes any initial v" do tag = "v0.1.0-beta.3" version_number = FastlaneCore::TagVersion.version_number_from_tag(tag) expect(version_number).to eq("0.1.0-beta.3") end it "returns any tag that does not start with v" do tag = "0.1.0-beta.3" version_number = FastlaneCore::TagVersion.version_number_from_tag(tag) expect(version_number).to eq("0.1.0-beta.3") end end describe "correct?" do it "returns true for versions supported by Gem::Version" do tag = "1.2.3" expect(FastlaneCore::TagVersion.correct?(tag)).to be(true) end it "returns true for tags that can be converted to a Gem::Version using version_number_from_tag" do tag = "v1.2.3" expect(FastlaneCore::TagVersion.correct?(tag)).to be(true) end it "returns false for tags that are not versions" do tag = "finished-refactoring" expect(FastlaneCore::TagVersion.correct?(tag)).to be(false) end end context "initialization" do it "accepts tags starting with v" do version = FastlaneCore::TagVersion.new("v1.2.3.4.5") gem_version = Gem::Version.new("1.2.3.4.5") expect(version).to eq(gem_version) end it "accepts versions accepted by Gem::Version" do version = FastlaneCore::TagVersion.new("1.2.3.4.5") gem_version = Gem::Version.new("1.2.3.4.5") expect(version).to eq(gem_version) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/project_spec.rb
fastlane_core/spec/project_spec.rb
describe FastlaneCore do describe FastlaneCore::Project do describe 'project and workspace detection' do def within_a_temp_dir Dir.mktmpdir do |dir| FileUtils.cd(dir) do yield(dir) if block_given? end end end let(:options) do [ FastlaneCore::ConfigItem.new(key: :project, description: "Project", optional: true), FastlaneCore::ConfigItem.new(key: :workspace, description: "Workspace", optional: true) ] end it 'raises if both project and workspace are specified' do expect do config = FastlaneCore::Configuration.new(options, { project: 'yup', workspace: 'yeah' }) FastlaneCore::Project.detect_projects(config) end.to raise_error(FastlaneCore::Interface::FastlaneError, "You can only pass either a workspace or a project path, not both") end it 'keeps the specified project' do config = FastlaneCore::Configuration.new(options, { project: 'yup' }) FastlaneCore::Project.detect_projects(config) expect(config[:project]).to eq('yup') expect(config[:workspace]).to be_nil end it 'keeps the specified workspace' do config = FastlaneCore::Configuration.new(options, { workspace: 'yeah' }) FastlaneCore::Project.detect_projects(config) expect(config[:project]).to be_nil expect(config[:workspace]).to eq('yeah') end it 'picks the only workspace file present' do within_a_temp_dir do |dir| workspace = './Something.xcworkspace' FileUtils.mkdir_p(workspace) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:workspace]).to eq(workspace) end end it 'picks the only project file present' do within_a_temp_dir do |dir| project = './Something.xcodeproj' FileUtils.mkdir_p(project) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:project]).to eq(project) end end it 'prompts to select among multiple workspace files' do within_a_temp_dir do |dir| workspaces = ['./Something.xcworkspace', './SomethingElse.xcworkspace'] FileUtils.mkdir_p(workspaces) expect(FastlaneCore::Project).to receive(:choose).and_return(workspaces.last) expect(FastlaneCore::Project).not_to(receive(:select_project)) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:workspace]).to eq(workspaces.last) end end it 'prompts to select among multiple project files' do within_a_temp_dir do |dir| projects = ['./Something.xcodeproj', './SomethingElse.xcodeproj'] FileUtils.mkdir_p(projects) expect(FastlaneCore::Project).to receive(:choose).and_return(projects.last) expect(FastlaneCore::Project).not_to(receive(:select_project)) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:project]).to eq(projects.last) end end it 'asks the user to specify a project when none are found' do within_a_temp_dir do |dir| project = './subdir/Something.xcodeproj' FileUtils.mkdir_p(project) expect(FastlaneCore::UI).to receive(:input).and_return(project) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:project]).to eq(project) end end it 'asks the user to specify a workspace when none are found' do within_a_temp_dir do |dir| workspace = './subdir/Something.xcworkspace' FileUtils.mkdir_p(workspace) expect(FastlaneCore::UI).to receive(:input).and_return(workspace) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:workspace]).to eq(workspace) end end it 'explains when a provided path is not found' do within_a_temp_dir do |dir| workspace = './subdir/Something.xcworkspace' FileUtils.mkdir_p(workspace) expect(FastlaneCore::UI).to receive(:input).and_return("something wrong") expect(FastlaneCore::UI).to receive(:error).with(/Couldn't find/) expect(FastlaneCore::UI).to receive(:input).and_return(workspace) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:workspace]).to eq(workspace) end end it 'explains when a provided path is not valid' do within_a_temp_dir do |dir| workspace = './subdir/Something.xcworkspace' FileUtils.mkdir_p(workspace) FileUtils.mkdir_p('other-directory') expect(FastlaneCore::UI).to receive(:input).and_return('other-directory') expect(FastlaneCore::UI).to receive(:error).with(/Path must end with/) expect(FastlaneCore::UI).to receive(:input).and_return(workspace) config = FastlaneCore::Configuration.new(options, {}) FastlaneCore::Project.detect_projects(config) expect(config[:workspace]).to eq(workspace) end end end it "raises an exception if path was not found" do tmp_path = Dir.mktmpdir path = "#{tmp_path}/notHere123" expect do FastlaneCore::Project.new(project: path) end.to raise_error("Could not find project at path '#{path}'") end describe "Valid Standard Project" do before do options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" } @project = FastlaneCore::Project.new(options) end it "#path" do expect(@project.path).to eq(File.expand_path("./fastlane_core/spec/fixtures/projects/Example.xcodeproj")) end it "#is_workspace" do expect(@project.is_workspace).to eq(false) end it "#workspace" do expect(@project.workspace).to be_nil end it "#project" do expect(@project.project).to_not(be_nil) end it "#project_name" do expect(@project.project_name).to eq("Example") end it "#schemes returns all available schemes" do expect(@project.schemes).to eq(["Example"]) end it "#configurations returns all available configurations" do expect(@project.configurations).to eq(["Debug", "Release", "SpecialConfiguration"]) end it "#app_name", requires_xcode: true do expect(@project.app_name).to eq("ExampleProductName") end it "#mac?", requires_xcode: true do expect(@project.mac?).to eq(false) end it "#ios?", requires_xcode: true do expect(@project.ios?).to eq(true) end it "#multiplatform?", requires_xcode: true do expect(@project.multiplatform?).to eq(false) end it "#tvos?", requires_xcode: true do expect(@project.tvos?).to eq(false) end end describe "Valid CocoaPods Project" do before do options = { workspace: "./fastlane_core/spec/fixtures/projects/cocoapods/Example.xcworkspace", scheme: "Example" } @workspace = FastlaneCore::Project.new(options) end it "#schemes returns all schemes" do expect(@workspace.schemes).to eq(["Example"]) end it "#schemes returns all configurations" do expect(@workspace.configurations).to eq([]) end end describe "Mac Project" do before do options = { project: "./fastlane_core/spec/fixtures/projects/Mac.xcodeproj" } @project = FastlaneCore::Project.new(options) end it "#mac?", requires_xcode: true do expect(@project.mac?).to eq(true) end it "#ios?", requires_xcode: true do expect(@project.ios?).to eq(false) end it "#tvos?", requires_xcode: true do expect(@project.tvos?).to eq(false) end it "#multiplatform?", requires_xcode: true do expect(@project.multiplatform?).to eq(false) end it "schemes", requires_xcodebuild: true do expect(@project.schemes).to eq(["Mac"]) end end describe "TVOS Project" do before do options = { project: "./fastlane_core/spec/fixtures/projects/ExampleTVOS.xcodeproj" } @project = FastlaneCore::Project.new(options) end it "#mac?", requires_xcode: true do expect(@project.mac?).to eq(false) end it "#ios?", requires_xcode: true do expect(@project.ios?).to eq(false) end it "#tvos?", requires_xcode: true do expect(@project.tvos?).to eq(true) end it "#multiplatform?", requires_xcode: true do expect(@project.multiplatform?).to eq(false) end it "schemes", requires_xcodebuild: true do expect(@project.schemes).to eq(["ExampleTVOS"]) end end describe "Cross-Platform Project" do before do options = { project: "./fastlane_core/spec/fixtures/projects/Cross-Platform.xcodeproj" } @project = FastlaneCore::Project.new(options) end it "supported_platforms", requires_xcode: true do expect(@project.supported_platforms).to eq([:macOS, :iOS, :tvOS, :watchOS]) end it "#mac?", requires_xcode: true do expect(@project.mac?).to eq(true) end it "#ios?", requires_xcode: true do expect(@project.ios?).to eq(true) end it "#tvos?", requires_xcode: true do expect(@project.tvos?).to eq(true) end it "#multiplatform?", requires_xcode: true do expect(@project.multiplatform?).to eq(true) end it "schemes", requires_xcodebuild: true do expect(@project.schemes).to eq(["CrossPlatformFramework"]) end end describe "Valid Workspace with workspace contained schemes" do before do options = { workspace: "./fastlane_core/spec/fixtures/projects/workspace_schemes/WorkspaceSchemes.xcworkspace", scheme: "WorkspaceSchemesScheme" } @workspace = FastlaneCore::Project.new(options) end it "#schemes returns all schemes" do expect(@workspace.schemes).to eq(["WorkspaceSchemesFramework", "WorkspaceSchemesApp", "WorkspaceSchemesScheme"]) end it "#schemes returns all configurations" do expect(@workspace.configurations).to eq([]) end end describe "build_settings() can handle empty lines" do it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos on Xcode >= 8.3" do options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" } @project = FastlaneCore::Project.new(options) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("11.0").and_return(false) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("13").and_return(false) expect(FastlaneCore::Helper).to receive(:xcode_at_least?).with("8.3").and_return(true) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(FastlaneCore::Project).to receive(:run_command).with(command, { timeout: 3, retries: 3, print: true }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains")) expect(@project.build_settings(key: "SUPPORTED_PLATFORMS")).to eq("iphonesimulator iphoneos") end it "SUPPORTED_PLATFORMS should be iphonesimulator iphoneos on Xcode < 8.3" do options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" } @project = FastlaneCore::Project.new(options) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("11.0").and_return(false) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("13").and_return(false) expect(FastlaneCore::Helper).to receive(:xcode_at_least?).with("8.3").and_return(false) command = "xcodebuild clean -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(FastlaneCore::Project).to receive(:run_command).with(command, { timeout: 3, retries: 3, print: true }).and_return(File.read("./fastlane_core/spec/fixtures/projects/build_settings_with_toolchains")) expect(@project.build_settings(key: "SUPPORTED_PLATFORMS")).to eq("iphonesimulator iphoneos") end end describe "Build Settings with default configuration" do before do options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" } @project = FastlaneCore::Project.new(options) end it "IPHONEOS_DEPLOYMENT_TARGET should be 9.0", requires_xcode: true do expect(@project.build_settings(key: "IPHONEOS_DEPLOYMENT_TARGET")).to eq("9.0") end it "PRODUCT_BUNDLE_IDENTIFIER should be tools.fastlane.app", requires_xcode: true do expect(@project.build_settings(key: "PRODUCT_BUNDLE_IDENTIFIER")).to eq("tools.fastlane.app") end end describe "Build Settings with specific configuration" do before do options = { project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", configuration: "SpecialConfiguration" } @project = FastlaneCore::Project.new(options) end it "IPHONEOS_DEPLOYMENT_TARGET should be 9.0", requires_xcode: true do expect(@project.build_settings(key: "IPHONEOS_DEPLOYMENT_TARGET")).to eq("9.0") end it "PRODUCT_BUNDLE_IDENTIFIER should be tools.fastlane.app.special", requires_xcode: true do expect(@project.build_settings(key: "PRODUCT_BUNDLE_IDENTIFIER")).to eq("tools.fastlane.app.special") end end describe 'Project.xcode_build_settings_timeout' do before do ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] = nil end it "returns default value" do expect(FastlaneCore::Project.xcode_build_settings_timeout).to eq(3) end it "returns specified value" do ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] = '5' expect(FastlaneCore::Project.xcode_build_settings_timeout).to eq(5) end it "returns 0 if empty" do ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] = '' expect(FastlaneCore::Project.xcode_build_settings_timeout).to eq(0) end it "returns 0 if garbage" do ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] = 'hiho' expect(FastlaneCore::Project.xcode_build_settings_timeout).to eq(0) end end describe 'Project.xcode_build_settings_retries' do before do ENV['FASTLANE_XCODEBUILD_SETTINGS_RETRIES'] = nil end it "returns default value" do expect(FastlaneCore::Project.xcode_build_settings_retries).to eq(3) end it "returns specified value" do ENV['FASTLANE_XCODEBUILD_SETTINGS_RETRIES'] = '5' expect(FastlaneCore::Project.xcode_build_settings_retries).to eq(5) end it "returns 0 if empty" do ENV['FASTLANE_XCODEBUILD_SETTINGS_RETRIES'] = '' expect(FastlaneCore::Project.xcode_build_settings_retries).to eq(0) end it "returns 0 if garbage" do ENV['FASTLANE_XCODEBUILD_SETTINGS_RETRIES'] = 'hiho' expect(FastlaneCore::Project.xcode_build_settings_retries).to eq(0) end end describe "Project.run_command" do def count_processes(text) `ps -aef | grep #{text} | grep -v grep | wc -l`.to_i end it "runs simple commands" do cmd = 'echo HO' # note: this command is deliberately not using `"` around `HO` as `echo` would echo those back on Windows expect(FastlaneCore::Project.run_command(cmd)).to eq("HO\n") end it "runs more complicated commands" do cmd = "ruby -e 'sleep 0.1; puts \"HI\"'" expect(FastlaneCore::Project.run_command(cmd)).to eq("HI\n") end it "should timeouts and kills" do text = "FOOBAR" # random text count = count_processes(text) cmd = "ruby -e 'sleep 3; puts \"#{text}\"'" expect do FastlaneCore::Project.run_command(cmd, timeout: 1) end.to raise_error(Timeout::Error) # on mac this before only partially works as expected if FastlaneCore::Helper.mac? # this shows the current implementation issue # Timeout doesn't kill the running process # i.e. see fastlane/fastlane_core#102 expect(count_processes(text)).to eq(count + 1) sleep(5) expect(count_processes(text)).to eq(count) # you would be expected to be able to see the number of processes go back to count right away. end end it "retries and kills" do text = "NEEDSRETRY" cmd = "ruby -e 'sleep 3; puts \"#{text}\"'" expect(FastlaneCore::Project).to receive(:`).and_call_original.exactly(4).times expect do FastlaneCore::Project.run_command(cmd, timeout: 0.2, retries: 3) end.to raise_error(Timeout::Error) end end describe "xcodebuild derived_data_path" do it 'generates an xcodebuild -showBuildSettings command that includes derived_data_path if provided in options', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", derived_data_path: "./special/path/DerivedData" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -derivedDataPath ./special/path/DerivedData 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end end describe "xcodebuild disable_package_automatic_updates" do it 'generates xcodebuild -showBuildSettings command with disabled automatic package resolution' do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(true) project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", disable_package_automatic_updates: true }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -disableAutomaticPackageResolution 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end end describe "xcodebuild package_authorization_provider" do it 'generates an xcodebuild -showBuildSettings command that includes package_authorization_provider if provided in options', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", package_authorization_provider: "keychain" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -packageAuthorizationProvider keychain 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end end describe 'xcodebuild_xcconfig option', requires_xcode: true do it 'generates an xcodebuild -showBuildSettings command without xcconfig by default' do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -showBuildSettings command that includes xcconfig if provided in options', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", xcconfig: "/path/to/some.xcconfig" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -xcconfig /path/to/some.xcconfig 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end end describe "xcodebuild use_system_scm" do it 'generates an xcodebuild -showBuildSettings command that includes scmProvider if provided in options', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", use_system_scm: true }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -scmProvider system 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -showBuildSettings command that does not include scmProvider when not provided in options', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -showBuildSettings command that does not include scmProvider when the option provided is false', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", use_system_scm: false }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end end describe 'xcodebuild command for SwiftPM', requires_xcode: true do it 'generates an xcodebuild -resolvePackageDependencies command with Xcode >= 11' do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(true) project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end it 'generates an xcodebuild -resolvePackageDependencies command with custom resolving paths with Xcode >= 11' do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(true) project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", cloned_source_packages_path: "./path/to/cloned_source_packages", package_cache_path: "./path/to/package_cache" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -clonedSourcePackagesDirPath ./path/to/cloned_source_packages -packageCachePath ./path/to/package_cache" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end it 'generates nil if skip_package_dependencies_resolution is true' do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).and_return(true) project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", skip_package_dependencies_resolution: true }) expect(project.build_xcodebuild_resolvepackagedependencies_command).to be_nil end it 'build_settings() should not add SPM path if Xcode < 11' do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("8.3").and_return(true) expect(FastlaneCore::Helper).to receive(:xcode_at_least?).with("11.0").and_return(false) expect(FastlaneCore::Helper).to receive(:xcode_at_least?).with("13").and_return(false) project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", cloned_source_packages_path: "./path/to/resolve" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates even if given options do not support skip_package_dependencies_resolution' do config = FastlaneCore::Configuration.create( [ FastlaneCore::ConfigItem.new(key: :workspace, optional: true), FastlaneCore::ConfigItem.new(key: :project, optional: true) ], { project: './fastlane_core/spec/fixtures/projects/Example.xcodeproj' } ) project = FastlaneCore::Project.new(config) expect(project.build_xcodebuild_resolvepackagedependencies_command).to_not(be_nil) expect { project.build_xcodebuild_resolvepackagedependencies_command }.to_not(raise_error) end end describe "xcodebuild destination parameter" do context "when xcode version is at_least 13" do before(:each) do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("8.3").and_return(true) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("11.0").and_return(true) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("13").and_return(true) end context "when destination parameter is provided in options" do it 'generates an xcodebuild -showBuildSettings command that includes destination', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", destination: "FakeDestination" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -destination FakeDestination 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -resolvePackageDependencies command that includes destination' do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", destination: "FakeDestination" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj -destination FakeDestination" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end end context "when destination parameter is not provided in options" do it 'generates an xcodebuild -showBuildSettings command that does not include destination', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -resolvePackageDependencies command that does not include destination' do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end end end context "when xcode version is less than 13" do before(:each) do allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("8.3").and_return(true) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("11.0").and_return(true) allow(FastlaneCore::Helper).to receive(:xcode_at_least?).with("13").and_return(false) end context "when destination parameter is provided in options" do it 'generates an xcodebuild -showBuildSettings command that does not include destination', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", destination: "FakeDestination" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -resolvePackageDependencies command that does not include destination' do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj", destination: "FakeDestination" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end end context "when destination parameter is not provided in options" do it 'generates an xcodebuild -showBuildSettings command that does not include destination', requires_xcode: true do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -showBuildSettings -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj 2>&1" expect(project.build_xcodebuild_showbuildsettings_command).to eq(command) end it 'generates an xcodebuild -resolvePackageDependencies command that does not include destination' do project = FastlaneCore::Project.new({ project: "./fastlane_core/spec/fixtures/projects/Example.xcodeproj" }) command = "xcodebuild -resolvePackageDependencies -project ./fastlane_core/spec/fixtures/projects/Example.xcodeproj" expect(project.build_xcodebuild_resolvepackagedependencies_command).to eq(command) end end end end describe "#project_paths" do it "works with basic projects" do project = FastlaneCore::Project.new({ project: "gym/lib" }) expect(project.project_paths).to be_an(Array) expect(project.project_paths).to eq([File.expand_path("gym/lib")]) end it "works with workspaces containing projects referenced relative by group" do workspace_path = "fastlane_core/spec/fixtures/projects/project_paths/groups/FooBar.xcworkspace" project = FastlaneCore::Project.new({ workspace: workspace_path }) expect(project.project_paths).to eq([ File.expand_path(workspace_path.gsub("FooBar.xcworkspace", "FooBar/FooBar.xcodeproj")) ]) end it "works with workspaces containing projects referenced relative by workspace" do workspace_path = "fastlane_core/spec/fixtures/projects/project_paths/containers/FooBar.xcworkspace" project = FastlaneCore::Project.new({ workspace: workspace_path }) expect(project.project_paths).to eq([ File.expand_path(workspace_path.gsub("FooBar.xcworkspace", "FooBar/FooBar.xcodeproj")) ]) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/languages_spec.rb
fastlane_core/spec/languages_spec.rb
describe FastlaneCore do describe FastlaneCore::Languages do it "all languages are available" do expect(FastlaneCore::Languages::ALL_LANGUAGES.count).to be >= 27 end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/wordwrap_spec.rb
fastlane_core/spec/wordwrap_spec.rb
require 'fastlane_core/string_filters' describe WordWrap do context 'wordwrapping will return an array of strings' do let(:test_string) { 'some big long string with lots of characters I think there should be more than eighty characters here!' } it 'will return an empty array if the length is zero' do result = test_string.wordwrap(0) expect(result).to eq([]) end it 'will return an array of strings, each being <= the length passed to wordwrap' do wrap_length = 5 result = test_string.wordwrap(wrap_length) string_lengths = result.map(&:length) expect(result).to all(be_a(String)) expect(string_lengths).to all(be <= wrap_length + 1) # The +1 is to consider spaces end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/command_executor_spec.rb
fastlane_core/spec/command_executor_spec.rb
describe FastlaneCore do describe FastlaneCore::CommandExecutor do describe "execute" do let(:failing_command) { FastlaneCore::Helper.windows? ? 'echo log && exit 42' : 'echo log; exit 42' } let(:failing_command_output) { FastlaneCore::Helper.windows? ? "log \n" : "log\n" } let(:failing_command_error_input) { FastlaneCore::Helper.windows? ? "log " : "log" } it 'executes a simple command successfully' do unless FastlaneCore::Helper.windows? expect(Process).to receive(:wait) end result = FastlaneSpec::Env.with_env_values('FASTLANE_EXEC_FLUSH_PTY_WORKAROUND' => '1') do FastlaneCore::CommandExecutor.execute(command: 'echo foo') end expect(result).to eq('foo') end it 'handles reading which throws a EIO exception', requires_pty: true do fake_std_in_lines = [ "a_filename\n" ] fake_std_in = double("stdin") expect(fake_std_in).to receive(:each).and_yield(*fake_std_in_lines).and_raise(Errno::EIO) fake_std_out = double("stdout") expect(fake_std_in).to receive(:close) expect(fake_std_out).to receive(:close) # Make a fake child process so we have a valid PID and $? is set correctly expect(PTY).to receive(:spawn) do |command, &block| expect(command).to eq('ls') # PTY uses "$?" to get exitcode, which is filled in by Process.wait(), # so we have to spawn a real process unless we want to mock methods # on nil. child_process_id = Process.spawn('echo foo', out: File::NULL) expect(Process).to receive(:wait).with(child_process_id) block.yield(fake_std_in, fake_std_out, child_process_id) end result = FastlaneCore::CommandExecutor.execute(command: 'ls') # We are implicitly also checking that the error was not rethrown because that would # have crashed the test expect(result).to eq('a_filename') end it 'chomps but does not strip output lines', requires_pty: true do fake_std_in = [ "Shopping list:\n", " - Milk\n", "\r - Bread\n", " - Muffins\n" ] fake_std_out = 'not_really_std_out' expect(fake_std_in).to receive(:close) expect(fake_std_out).to receive(:close) expect(PTY).to receive(:spawn) do |command, &block| expect(command).to eq('echo foo') # PTY uses "$?" to get exitcode, which is filled in by Process.wait(), # so we have to spawn a real process unless we want to mock methods # on nil. child_process_id = Process.spawn('echo foo', out: File::NULL) expect(Process).to receive(:wait).with(child_process_id) block.yield(fake_std_in, fake_std_out, child_process_id) end result = FastlaneCore::CommandExecutor.execute(command: 'echo foo') # We are implicitly also checking that the error was not rethrown because that would # have crashed the test expect(result).to eq(<<-LIST.chomp) Shopping list: - Milk - Bread - Muffins LIST end it "does not print output to stdout when status != 0 and output was already printed" do unless FastlaneCore::Helper.windows? expect(Process).to receive(:wait) end expect do FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: true, error: proc do |_error_output| end ) end.not_to output(failing_command_output).to_stdout end it "prints output to stdout only once when status != 0 and output was not already printed" do unless FastlaneCore::Helper.windows? expect(Process).to receive(:wait).exactly(3) end expect do FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: false, error: nil ) end.to output(failing_command_output).to_stdout.and(raise_error(FastlaneCore::Interface::FastlaneError) do |error| expect(error.to_s).to eq("Exit status: 42") end) expect do FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: false, error: proc do |_error_output| end ) end.to output(failing_command_output).to_stdout expect do FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: true, suppress_output: true, error: proc do |_error_output| end ) end.to output(failing_command_output).to_stdout end it "calls error block with output argument" do unless FastlaneCore::Helper.windows? expect(Process).to receive(:wait).twice end error_block_input = nil result = FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: true, error: proc do |error_output| error_block_input = error_output end ) expect(error_block_input).to eq(failing_command_error_input) error_block_input = nil result = FastlaneCore::CommandExecutor.execute( command: failing_command, print_all: false, error: proc do |error_output| error_block_input = error_output end ) expect(error_block_input).to eq(failing_command_error_input) end end describe "which" do require 'tempfile' it "does not find commands which are not on the PATH" do expect(FastlaneCore::CommandExecutor.which('not_a_real_command')).to be_nil end it "finds commands without extensions which are on the PATH" do allow(FastlaneCore::Helper).to receive(:windows?).and_return(false) Tempfile.open('foobarbaz') do |f| File.chmod(0777, f) temp_dir = File.dirname(f) temp_cmd = File.basename(f) FastlaneSpec::Env.with_env_values('PATH' => temp_dir) do expect(FastlaneCore::CommandExecutor.which(temp_cmd)).to eq(f.path) end end end it "finds commands without extensions which are on the PATH on Windows", if: FastlaneCore::Helper.windows? do Tempfile.open('foobarbaz') do |f| File.chmod(0777, f) temp_dir = File.dirname(f) temp_cmd = File.basename(f) FastlaneSpec::Env.with_env_values('PATH' => temp_dir) do expect(FastlaneCore::CommandExecutor.which(temp_cmd)).to eq(f.path.gsub('/', '\\')) end end end it "finds commands with known extensions which are on the PATH", if: FastlaneCore::Helper.windows? do allow(FastlaneCore::Helper).to receive(:windows?).and_return(true) Tempfile.open(['foobarbaz', '.exe']) do |f| File.chmod(0777, f) temp_dir = File.dirname(f) temp_cmd = File.basename(f, '.exe') FastlaneCore::CommandExecutor.which(temp_cmd) FastlaneSpec::Env.with_env_values('PATH' => temp_dir, 'PATHEXT' => '.exe') do expect(FastlaneCore::CommandExecutor.which(temp_cmd)).to eq(f.path.gsub('/', '\\')) end end end it "does not find commands with unknown extensions which are on the PATH" do allow(FastlaneCore::Helper).to receive(:windows?).and_return(true) Tempfile.open(['foobarbaz', '.exe']) do |f| File.chmod(0777, f) temp_dir = File.dirname(f) temp_cmd = File.basename(f, '.exe') FastlaneSpec::Env.with_env_values('PATH' => temp_dir, 'PATHEXT' => '') do expect(FastlaneCore::CommandExecutor.which(temp_cmd)).to be_nil end end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/test_commander_program.rb
fastlane_core/spec/test_commander_program.rb
# Helper class that encapsulates the setup of a do-nothing Commander # program that captures the results of parsing command line options class TestCommanderProgram include Commander::Methods attr_accessor :args attr_accessor :options def self.run(config_items) new(config_items).tap(&:run!) end def initialize(config_items) # Sets up the global options in Commander whose behavior we want # to be testing. FastlaneCore::CommanderGenerator.new.generate(config_items) program :version, '1.0' program :description, 'Testing' command :test do |c| c.action do |args, options| @args = args.dup @options = options.__hash__.dup end end default_command(:test) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/fastlane_pty_spec.rb
fastlane_core/spec/fastlane_pty_spec.rb
describe FastlaneCore do describe FastlaneCore::FastlanePty do describe "spawn" do it 'executes a simple command successfully' do @all_lines = [] exit_status = FastlaneCore::FastlanePty.spawn('echo foo') do |command_stdout, command_stdin, pid| command_stdout.each do |line| @all_lines << line.chomp end end expect(exit_status).to eq(0) expect(@all_lines).to eq(["foo"]) end it 'doesn t return -1 if an exception was raised in the block in PTY.spawn' do status = double("ProcessStatus") allow(status).to receive(:exitstatus) { 0 } expect(FastlaneCore::FastlanePty).to receive(:require).with("pty").and_return(nil) allow(FastlaneCore::FastlanePty).to receive(:process_status).and_return(status) exception = StandardError.new expect { exit_status = FastlaneCore::FastlanePty.spawn('a path of a working exec') do |command_stdout, command_stdin, pid| raise exception end }.to raise_error(FastlaneCore::FastlanePtyError) { |error| expect(error.exit_status).to eq(0) # command was success but output handling failed } end it 'doesn t return -1 if an exception was raised in the block in Open3.popen2e' do expect(FastlaneCore::FastlanePty).to receive(:require).with("pty").and_raise(LoadError) allow(FastlaneCore::FastlanePty).to receive(:require).with("open3").and_call_original allow(FastlaneCore::FastlanePty).to receive(:open3) exception = StandardError.new expect { exit_status = FastlaneCore::FastlanePty.spawn('echo foo') do |command_stdout, command_stdin, pid| raise exception end }.to raise_error(FastlaneCore::FastlanePtyError) { |error| expect(error.exit_status).to eq(0) # command was success but output handling failed } end # could be used to test # let(:crasher_path) { File.expand_path("./fastlane_core/spec/crasher/crasher") } it 'raises an error if the program crashes through PTY.spawn' do status = double("ProcessStatus") allow(status).to receive(:exitstatus) { nil } allow(status).to receive(:signaled?) { true } expect(FastlaneCore::FastlanePty).to receive(:require).with("pty").and_return(nil) allow(FastlaneCore::FastlanePty).to receive(:process_status).and_return(status) expect { exit_status = FastlaneCore::FastlanePty.spawn("a path of a crasher exec") do |command_stdout, command_stdin, pid| end }.to raise_error(FastlaneCore::FastlanePtyError) { |error| expect(error.exit_status).to eq(-1) # command was forced to -1 } end it 'raises an error if the program crashes through PTY.popen' do stdin = double("stdin") allow(stdin).to receive(:close) stdout = double("stdout") allow(stdout).to receive(:close) status = double("ProcessStatus") allow(status).to receive(:exitstatus) { nil } allow(status).to receive(:signaled?) { true } allow(status).to receive(:pid) { 12_345 } process = double("process") allow(process).to receive(:value) { status } expect(FastlaneCore::FastlanePty).to receive(:require).with("pty").and_raise(LoadError) allow(FastlaneCore::FastlanePty).to receive(:require).with("open3").and_return(nil) allow(Open3).to receive(:popen2e).and_yield(stdin, stdout, process) expect { exit_status = FastlaneCore::FastlanePty.spawn("a path of a crasher exec") do |command_stdout, command_stdin, pid| end }.to raise_error(FastlaneCore::FastlanePtyError) { |error| expect(error.exit_status).to eq(-1) # command was forced to -1 } end end describe "spawn_with_pty" do it 'passes the command to Pty when FASTLANE_EXEC_FLUSH_PTY_WORKAROUND is not set', requires_pty: true do allow(PTY).to receive(:spawn).with("echo foo") FastlaneSpec::Env.with_env_values('FASTLANE_EXEC_FLUSH_PTY_WORKAROUND' => nil) do FastlaneCore::FastlanePty.spawn_with_pty('echo foo') do |command_stdout, command_stdin, pid| end end end it 'wraps the command with a workaround when FASTLANE_EXEC_FLUSH_PTY_WORKAROUND is set', requires_pty: true do allow(PTY).to receive(:spawn).with("echo foo;") FastlaneSpec::Env.with_env_values('FASTLANE_EXEC_FLUSH_PTY_WORKAROUND' => '1') do FastlaneCore::FastlanePty.spawn_with_pty('echo foo') do |command_stdout, command_stdin, pid| end end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/fastlane_user_dir_spec.rb
fastlane_core/spec/fastlane_user_dir_spec.rb
describe FastlaneCore do it "returns the path to the user's directory" do expected_path = File.join(ENV["HOME"], ".fastlane") expect(File).to receive(:directory?).and_return(false) expect(FileUtils).to receive(:mkdir_p).with(expected_path) expect(FastlaneCore.fastlane_user_dir).to eq(expected_path) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/fastlane_folder_spec.rb
fastlane_core/spec/fastlane_folder_spec.rb
describe FastlaneCore::FastlaneFolder do let(:fastfile_name) { "Fastfile" } describe "#path" do it "returns the fastlane path if it exists" do expect(FastlaneCore::FastlaneFolder.path).to eq("./fastlane/") end it "returns nil if the fastlane path isn't available" do Dir.chdir("/") do expect(FastlaneCore::FastlaneFolder.path).to eq(nil) end end it "returns the path if fastlane is being executed from the fastlane directory" do Dir.chdir("fastlane") do expect(FastlaneCore::FastlaneFolder.path).to eq('./') end end end describe "#fastfile_path" do it "uses a Fastfile that's inside a fastlane directory" do expect(FastlaneCore::FastlaneFolder.fastfile_path).to eq(File.join(".", "fastlane", fastfile_name)) end it "uses a Fastfile that's inside a fastlane directory if cd is inside a fastlane dir" do Dir.chdir("fastlane") do expect(FastlaneCore::FastlaneFolder.fastfile_path).to eq(File.join(".", fastfile_name)) end end it "doesn't try to use a Fastfile if it's not inside a fastlane folder" do Dir.chdir("sigh") do File.write(fastfile_name, "") begin expect(FastlaneCore::FastlaneFolder.fastfile_path).to eq(nil) rescue RSpec::Expectations::ExpectationNotMetError => ex raise ex ensure File.delete(fastfile_name) end end end end describe "#swift?" do it "returns false if nil fastfile_path" do allow(FastlaneCore::FastlaneFolder).to receive(:fastfile_path).and_return(nil) expect(FastlaneCore::FastlaneFolder.swift?).to eq(false) end it "returns false if not Fastfile" do allow(FastlaneCore::FastlaneFolder).to receive(:fastfile_path).and_return("Fastfile") expect(FastlaneCore::FastlaneFolder.swift?).to eq(false) end it "returns true if Fastfile.swift" do allow(FastlaneCore::FastlaneFolder).to receive(:fastfile_path).and_return("Fastfile.swift") expect(FastlaneCore::FastlaneFolder.swift?).to eq(true) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/configuration_spec.rb
fastlane_core/spec/configuration_spec.rb
describe FastlaneCore do describe FastlaneCore::Configuration do describe "Create a new Configuration Manager" do it "raises an error if no hash is given" do expect do FastlaneCore::Configuration.create([], "string") end.to raise_error("values parameter must be a hash") end it "raises an error if no array is given" do expect do FastlaneCore::Configuration.create("string", {}) end.to raise_error("available_options parameter must be an array of ConfigItems but is String") end it "raises an error if array contains invalid elements" do expect do FastlaneCore::Configuration.create(["string"], {}) end.to raise_error("available_options parameter must be an array of ConfigItems. Found String.") end it "raises an error if the option of a given value is not available" do expect do FastlaneCore::Configuration.create([], { cert_name: "value" }) end.to raise_error("Could not find option 'cert_name' in the list of available options: ") end it "raises an error if a description ends with a ." do expect do FastlaneCore::Configuration.create([FastlaneCore::ConfigItem.new( key: :cert_name, env_name: "asdf", description: "Set the profile name." )], {}) end.to raise_error("Do not let descriptions end with a '.', since it's used for user inputs as well for key :cert_name") end describe "config conflicts" do it "raises an error if a key was used twice" do expect do FastlaneCore::Configuration.create([FastlaneCore::ConfigItem.new( key: :cert_name, env_name: "asdf" ), FastlaneCore::ConfigItem.new( key: :cert_name, env_name: "asdf" )], {}) end.to raise_error("Multiple entries for configuration key 'cert_name' found!") end it "raises an error if a short_option was used twice" do conflicting_options = [ FastlaneCore::ConfigItem.new(key: :foo, short_option: "-f", description: "foo"), FastlaneCore::ConfigItem.new(key: :bar, short_option: "-f", description: "bar") ] expect do FastlaneCore::Configuration.create(conflicting_options, {}) end.to raise_error("Multiple entries for short_option '-f' found!") end it "raises an error for unresolved conflict between options" do conflicting_options = [ FastlaneCore::ConfigItem.new(key: :foo, conflicting_options: [:bar, :oof]), FastlaneCore::ConfigItem.new(key: :bar), FastlaneCore::ConfigItem.new(key: :oof) ] values = { foo: "", bar: "" } expect do FastlaneCore::Configuration.create(conflicting_options, values) end.to raise_error("Unresolved conflict between options: 'foo' and 'bar'") end it "calls custom conflict handler when conflict happens between two options" do conflicting_options = [ FastlaneCore::ConfigItem.new(key: :foo, conflicting_options: [:bar, :oof], conflict_block: proc do |value| UI.user_error!("You can't use option '#{value.key}' along with 'foo'") end), FastlaneCore::ConfigItem.new(key: :bar), FastlaneCore::ConfigItem.new(key: :oof, conflict_block: proc do |value| UI.user_error!("You can't use option '#{value.key}' along with 'oof'") end) ] values = { foo: "", bar: "" } expect do FastlaneCore::Configuration.create(conflicting_options, values) end.to raise_error("You can't use option 'bar' along with 'foo'") end end describe "data_type" do it "sets the data type correctly if `is_string` is not set but type is specified" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Array) expect(config_item.data_type).to eq(Array) end it "sets the data type correctly if `is_string` is set but the type is specified" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', is_string: true, type: Array) expect(config_item.data_type).to eq(Array) end it "sets the data type correctly if `is_string` is set but the type is not specified" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', is_string: true) expect(config_item.data_type).to eq(String) end end describe "#sensitive flag" do before(:each) do allow(FastlaneCore::Helper).to receive(:test?).and_return(false) allow(FastlaneCore::UI).to receive(:interactive?).and_return(true) allow(FastlaneCore::Helper).to receive(:ci?).and_return(false) end it "should set the sensitive flag" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Array, optional: true, sensitive: true, default_value: ['5', '4', '3', '2', '1']) expect(config_item.sensitive).to eq(true) end it "should ask using asterisks" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: String, is_string: true, optional: false, sensitive: true) config = FastlaneCore::Configuration.create([config_item], {}) expect(FastlaneCore::UI).to receive(:password).and_return("password") expect(config[:foo]).to eq("password") end it "should ask using plaintext" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: String, is_string: false, optional: false, sensitive: false) config = FastlaneCore::Configuration.create([config_item], {}) expect(FastlaneCore::UI).to receive(:input).and_return("plaintext") expect(config[:foo]).to eq("plaintext") end end describe "arrays" do it "returns Array default values correctly" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Array, optional: true, default_value: ['5', '4', '3', '2', '1']) config = FastlaneCore::Configuration.create([config_item], {}) expect(config[:foo]).to eq(['5', '4', '3', '2', '1']) end it "returns Array input values correctly" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Array) config = FastlaneCore::Configuration.create([config_item], { foo: ['5', '4', '3', '2', '1'] }) expect(config[:foo]).to eq(['5', '4', '3', '2', '1']) end it "returns Array environment variable values correctly" do ENV["FOO"] = '5,4,3,2,1' config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', env_name: 'FOO', type: Array) config = FastlaneCore::Configuration.create([config_item], {}) expect(config[:foo]).to eq(['5', '4', '3', '2', '1']) ENV.delete("FOO") end end describe "auto_convert_value" do it "auto converts string values to Integers" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Integer) value = config_item.auto_convert_value('987') expect(value).to eq(987) end it "auto converts string values to Floats" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Float) value = config_item.auto_convert_value('9.91') expect(value).to eq(9.91) end it "auto converts Array values to Strings if allowed" do config_item = FastlaneCore::ConfigItem.new(key: :xcargs, description: 'xcargs', type: :shell_string) array = ['a b', 'c d', :e] value = config_item.auto_convert_value(array) expect(value).to eq(array.shelljoin) end it "auto converts Hash values to Strings if allowed" do config_item = FastlaneCore::ConfigItem.new(key: :xcargs, description: 'xcargs', type: :shell_string) hash = { 'FOO BAR' => 'I\'m foo bar', :BAZ => 'And I\'m baz' } value = config_item.auto_convert_value(hash) expected = 'FOO\\ BAR=I\\\'m\\ foo\\ bar BAZ=And\\ I\\\'m\\ baz' expected = "\"FOO BAR\"=\"I'm foo bar\" BAZ=\"And I'm baz\"" if FastlaneCore::Helper.windows? expect(value).to eq(expected) end it "does not auto convert Array values to Strings if not allowed" do config_item = FastlaneCore::ConfigItem.new(key: :xcargs, description: 'xcargs', type: String) array = ['a b', 'c d', :e] value = config_item.auto_convert_value(array) expect(value).to eq(array) end it "does not auto convert Hash values to Strings if not allowed" do config_item = FastlaneCore::ConfigItem.new(key: :xcargs, description: 'xcargs', type: String) hash = { 'FOO BAR' => 'I\'m foo bar', :BAZ => 'And I\'m baz' } value = config_item.auto_convert_value(hash) expect(value).to eq(hash) end it "auto converts nil to nil when type is not specified" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo') value = config_item.auto_convert_value(nil) expect(value).to eq(nil) end it "auto converts nil to nil when type is Integer" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Integer) value = config_item.auto_convert_value(nil) expect(value).to eq(nil) end it "auto converts nil to nil when type is Float" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Float) value = config_item.auto_convert_value(nil) expect(value).to eq(nil) end it "auto converts booleans as strings to booleans" do c = [ FastlaneCore::ConfigItem.new(key: :true_value, is_string: false), FastlaneCore::ConfigItem.new(key: :true_value2, is_string: false), FastlaneCore::ConfigItem.new(key: :false_value, is_string: false), FastlaneCore::ConfigItem.new(key: :false_value2, is_string: false) ] config = FastlaneCore::Configuration.create(c, { true_value: "true", true_value2: "YES", false_value: "false", false_value2: "NO" }) expect(config[:true_value]).to eq(true) expect(config[:true_value2]).to eq(true) expect(config[:false_value]).to eq(false) expect(config[:false_value2]).to eq(false) end it "doesn't auto convert booleans as strings to booleans if type is explicitly set to String" do c = [ FastlaneCore::ConfigItem.new(key: :true_value, type: String), FastlaneCore::ConfigItem.new(key: :true_value2, type: String), FastlaneCore::ConfigItem.new(key: :false_value, type: String), FastlaneCore::ConfigItem.new(key: :false_value2, type: String) ] config = FastlaneCore::Configuration.create(c, { true_value: "true", true_value2: "YES", false_value: "false", false_value2: "NO" }) expect(config[:true_value]).to eq("true") expect(config[:true_value2]).to eq("YES") expect(config[:false_value]).to eq("false") expect(config[:false_value2]).to eq("NO") end it "auto converts strings to integers" do c = [ FastlaneCore::ConfigItem.new(key: :int_value, type: Integer) ] config = FastlaneCore::Configuration.create(c, { int_value: "10" }) expect(config[:int_value]).to eq(10) end it "auto converts '0' to the integer 0" do c = [ FastlaneCore::ConfigItem.new(key: :int_value, type: Integer) ] config = FastlaneCore::Configuration.create(c, { int_value: "0" }) expect(config[:int_value]).to eq(0) end end describe "validation" do it "raises an exception if the data type is not as expected" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', type: Float) expect do config_item.valid?('ABC') end.to raise_error(FastlaneCore::Interface::FastlaneError, "'foo' value must be a Float! Found String instead.") end it "verifies the default value as well" do c = FastlaneCore::ConfigItem.new(key: :output, env_name: "SIGH_OUTPUT_PATH", description: "Directory in which the profile should be stored", default_value: "notExistent", verify_block: proc do |value| UI.user_error!("Could not find output directory '#{value}'") end) expect do @config = FastlaneCore::Configuration.create([c], {}) end.to raise_error("Invalid default value for output, doesn't match verify_block") end it "calls verify_block for non nil values" do c = FastlaneCore::ConfigItem.new(key: :param, env_name: "PARAM", description: "Description", type: Object, verify_block: proc do |value| UI.user_error!("'#{value}' is not valid!") end) [true, false, '', 'a string', ['an array'], {}, :hash].each do |value| expect do c.valid?(value) end.to raise_error("'#{value}' is not valid!") end end it "passes for nil values" do c = FastlaneCore::ConfigItem.new(key: :param, env_name: "param", description: "Description", verify_block: proc do |value| UI.user_error!("'#{value}' is not valid!") end) expect(c.valid?(nil)).to eq(true) end it "verifies type" do c = FastlaneCore::ConfigItem.new(key: :param, env_name: "param", type: Float, description: "Description") expect do c.valid?('a string') end.to raise_error("'param' value must be a Float! Found String instead.") end it "skips type verification" do c = FastlaneCore::ConfigItem.new(key: :param, env_name: "param", type: Float, skip_type_validation: true, description: "Description") expect(c.valid?('a string')).to eq(true) end it "fails verification for a improper value set as an environment variable" do c = FastlaneCore::ConfigItem.new(key: :test_key, env_name: "TEST_KEY", description: "A test key", verify_block: proc do |value| UI.user_error!("Invalid value") unless value.start_with?('a') end) expect do @config = FastlaneCore::Configuration.create([c], {}) ENV["TEST_KEY"] = "does_not_start_with_a" @config[:test_key] end.to raise_error("Invalid value") end it "passes verification for a proper value set as an environment variable" do c = FastlaneCore::ConfigItem.new(key: :test_key, env_name: "TEST_KEY", description: "A test key", verify_block: proc do |value| UI.user_error!("Invalid value") unless value.start_with?('a') end) @config = FastlaneCore::Configuration.create([c], {}) ENV["TEST_KEY"] = "a_good_value" expect(@config[:test_key]).to eq('a_good_value') end end describe "deprecation", focus: true do it "deprecated message changes the description" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', deprecated: 'replaced by bar') expect(config_item.description).to eq("**DEPRECATED!** replaced by bar - foo") end it "deprecated boolean changes the description" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo. use bar instead', deprecated: true) expect(config_item.description).to eq("**DEPRECATED!** foo. use bar instead") end it "deprecated messages replaces empty description" do config_item = FastlaneCore::ConfigItem.new(key: :foo, deprecated: 'replaced by bar') expect(config_item.description).to eq("**DEPRECATED!** replaced by bar") end it "deprecated makes it optional" do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', deprecated: 'replaced by bar') expect(config_item.optional).to eq(true) end it "raises an exception if a deprecated option is not optional" do expect do config_item = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', optional: false, deprecated: 'replaced by bar') end.to raise_error(FastlaneCore::Interface::FastlaneCrash, 'Deprecated option must be optional') end it "doesn't display a deprecation message when loading a config if a deprecated option doesn't have a value" do c = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', deprecated: 'replaced by bar') values = { foo: "something" } expect(FastlaneCore::UI).to receive(:deprecated).with("Using deprecated option: '--foo' (replaced by bar)") config = FastlaneCore::Configuration.create([c], values) end it "displays a deprecation message when loading a config if a deprecated option has a value" do c = FastlaneCore::ConfigItem.new(key: :foo, description: 'foo', deprecated: 'replaced by bar') expect(FastlaneCore::UI).not_to(receive(:deprecated)) config = FastlaneCore::Configuration.create([c], {}) end end describe "misc features" do it "makes it non optional by default" do c = FastlaneCore::ConfigItem.new(key: :test, default_value: '123') expect(c.optional).to eq(false) end it "supports options without 'env_name'" do c = FastlaneCore::ConfigItem.new(key: :test, default_value: '123') config = FastlaneCore::Configuration.create([c], {}) expect(config.values[:test]).to eq('123') end it "takes the values from the environment if available" do c = FastlaneCore::ConfigItem.new(key: :test, env_name: "FL_TEST") config = FastlaneCore::Configuration.create([c], {}) ENV["FL_TEST"] = "123value" expect(config.values[:test]).to eq('123value') ENV.delete("FL_TEST") end it "supports modifying the value after taken from the environment" do c = FastlaneCore::ConfigItem.new(key: :test, env_name: "FL_TEST") config = FastlaneCore::Configuration.create([c], {}) ENV["FL_TEST"] = "123value" config.values[:test].gsub!("123", "456") expect(config.values[:test]).to eq('456value') ENV.delete("FL_TEST") end it "can push and pop configuration values" do name = FastlaneCore::ConfigItem.new(key: :name) platform = FastlaneCore::ConfigItem.new(key: :platform) other = FastlaneCore::ConfigItem.new(key: :other) config = FastlaneCore::Configuration.create([name, other, platform], {}) config.set(:name, "name1") config.set(:other, "other") config.push_values! expect(config._values).to be_empty config.set(:name, "name2") config.set(:platform, "platform") config.pop_values! expect(config.fetch(:name)).to eq("name2") expect(config.fetch(:other)).to eq("other") expect(config.fetch(:platform)).to eq("platform") end it "does nothing if you pop values with nothing pushed" do name = FastlaneCore::ConfigItem.new(key: :name) platform = FastlaneCore::ConfigItem.new(key: :platform) other = FastlaneCore::ConfigItem.new(key: :other) config = FastlaneCore::Configuration.create([name, other, platform], {}) config.set(:name, "name1") config.set(:other, "other") config.pop_values! expect(config.fetch(:name)).to eq("name1") expect(config.fetch(:other)).to eq("other") end end describe "Automatically removes the --verbose flag" do it "removes --verbose if not an available options (e.g. a tool)" do config = FastlaneCore::Configuration.create([], { verbose: true }) expect(config.values).to eq({}) end it "doesn't remove --verbose if it's a valid option" do options = [ FastlaneCore::ConfigItem.new(key: :verbose, is_string: false) ] config = FastlaneCore::Configuration.create(options, { verbose: true }) expect(config[:verbose]).to eq(true) end end describe "Use a valid Configuration Manager" do before do @options = [ FastlaneCore::ConfigItem.new(key: :cert_name, env_name: "SIGH_PROVISIONING_PROFILE_NAME", description: "Set the profile name", default_value: "production_default", verify_block: nil), FastlaneCore::ConfigItem.new(key: :output, env_name: "SIGH_OUTPUT_PATH", description: "Directory in which the profile should be stored", default_value: ".", verify_block: proc do |value| UI.user_error!("Could not find output directory '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :wait_processing_interval, short_option: "-k", env_name: "PILOT_WAIT_PROCESSING_INTERVAL", description: "Interval in seconds to wait for App Store Connect processing", default_value: 30, type: Integer, verify_block: proc do |value| UI.user_error!("Please enter a valid positive number of seconds") unless value.to_i > 0 end) ] @values = { cert_name: "asdf", output: "..", wait_processing_interval: 10 } @config = FastlaneCore::Configuration.create(@options, @values) end describe "#keys" do it "returns all available keys" do expect(@config.all_keys).to eq([:cert_name, :output, :wait_processing_interval]) end end describe "#values" do it "returns the user values" do values = @config.values expect(values[:output]).to eq('..') expect(values[:cert_name]).to eq('asdf') expect(values[:wait_processing_interval]).to eq(10) end it "returns the default values" do @config = FastlaneCore::Configuration.create(@options, {}) # no user inputs values = @config.values expect(values[:cert_name]).to eq('production_default') expect(values[:output]).to eq('.') expect(values[:wait_processing_interval]).to eq(30) end end describe "fetch" do it "raises an error if a non symbol was given" do expect do @config.fetch(123) end.to raise_error("Key '123' must be a symbol. Example :123") end it "raises an error if this option does not exist" do expect do @config[:asdfasdf] end.to raise_error("Could not find option 'asdfasdf' in the list of available options: cert_name, output, wait_processing_interval") end it "returns the value for the given key if given" do expect(@config.fetch(:cert_name)).to eq(@values[:cert_name]) end it "returns the value for the given key if given using []" do expect(@config[:cert_name]).to eq(@values[:cert_name]) end it "returns the default value if nothing else was given" do @config.set(:cert_name, nil) expect(@config[:cert_name]).to eq("production_default") end describe "auto converting the value after asking the user for one" do before(:each) do allow(FastlaneCore::Helper).to receive(:test?).and_return(false) allow(FastlaneCore::UI).to receive(:interactive?).and_return(true) allow(FastlaneCore::Helper).to receive(:ci?).and_return(false) end it "doesn't show an error and converts the value if the input matches the item type" do config_item = FastlaneCore::ConfigItem.new(key: :item, short_option: "-i", env_name: "ITEM_ENV_VAR", description: "a description", is_string: false, type: Integer, # false is the default, but let's be explicit skip_type_validation: false) config = FastlaneCore::Configuration.create([config_item], {}) config.set(:item, nil) expect(FastlaneCore::UI).to receive(:input).once.and_return("123") expect(FastlaneCore::UI).not_to(receive(:error)) expect(config[:item].class).to eq(Integer) expect(config[:item]).to eq(123) end it "shows an error after user inputs value that doesn't match type (the first time) and works the second time" do config_item = FastlaneCore::ConfigItem.new(key: :item, short_option: "-i", env_name: "ITEM_ENV_VAR", description: "a description", is_string: false, type: Integer, # false is the default, but let's be explicit skip_type_validation: false) config = FastlaneCore::Configuration.create([config_item], {}) config.set(:item, nil) expect(FastlaneCore::UI).to receive(:input).once.and_return("123abc") expect(FastlaneCore::UI).to receive(:input).once.and_return("123")
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
true
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/update_checker_spec.rb
fastlane_core/spec/update_checker_spec.rb
require 'fastlane_core/update_checker/update_checker' describe FastlaneCore do describe FastlaneCore::UpdateChecker do let(:name) { 'fastlane' } describe "#update_available?" do it "no update is available" do FastlaneCore::UpdateChecker.server_results[name] = '0.1' expect(FastlaneCore::UpdateChecker.update_available?(name, '0.9.11')).to eq(false) end it "new update is available" do FastlaneCore::UpdateChecker.server_results[name] = '999.0' expect(FastlaneCore::UpdateChecker.update_available?(name, '0.9.11')).to eq(true) end it "same version" do FastlaneCore::UpdateChecker.server_results[name] = Fastlane::VERSION expect(FastlaneCore::UpdateChecker.update_available?(name, Fastlane::VERSION)).to eq(false) end it "new pre-release" do FastlaneCore::UpdateChecker.server_results[name] = [Fastlane::VERSION, 'pre'].join(".") expect(FastlaneCore::UpdateChecker.update_available?(name, Fastlane::VERSION)).to eq(false) end it "current: Pre-Release - new official version" do FastlaneCore::UpdateChecker.server_results[name] = '0.9.1' expect(FastlaneCore::UpdateChecker.update_available?(name, '0.9.1.pre')).to eq(true) end it "a new pre-release when pre-release is installed" do FastlaneCore::UpdateChecker.server_results[name] = '0.9.1.pre2' expect(FastlaneCore::UpdateChecker.update_available?(name, '0.9.1.pre1')).to eq(true) end end describe "#update_command" do before do ENV.delete("BUNDLE_BIN_PATH") ENV.delete("BUNDLE_GEMFILE") end it "works a custom gem name" do expect(FastlaneCore::UpdateChecker.update_command(gem_name: "gym")).to eq("gem install gym") end it "works with system ruby" do expect(FastlaneCore::UpdateChecker.update_command).to eq("gem install fastlane") end it "works with bundler" do FastlaneSpec::Env.with_env_values('BUNDLE_BIN_PATH' => '/tmp') do expect(FastlaneCore::UpdateChecker.update_command).to eq("bundle update fastlane") end end it "works with bundled fastlane" do FastlaneSpec::Env.with_env_values('FASTLANE_SELF_CONTAINED' => 'true') do expect(FastlaneCore::UpdateChecker.update_command).to eq("fastlane update_fastlane") end end it "works with Fabric.app installed fastlane" do FastlaneSpec::Env.with_env_values('FASTLANE_SELF_CONTAINED' => 'false') do expect(FastlaneCore::UpdateChecker.update_command).to eq("the Fabric app. Launch the app and navigate to the fastlane tab to get the most recent version.") end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/clipboard_spec.rb
fastlane_core/spec/clipboard_spec.rb
describe FastlaneCore do describe FastlaneCore::Clipboard do describe '#copy and paste' do before(:each) do @test_message = "_fastlane_ is awesome" end it 'should work on supported environments', if: FastlaneCore::Clipboard.is_supported? do # Save clipboard clipboard = FastlaneCore::Clipboard.paste # Test copy and paste FastlaneCore::Clipboard.copy(content: @test_message) expect(FastlaneCore::Clipboard.paste).to eq(@test_message) # Restore clipboard FastlaneCore::Clipboard.copy(content: clipboard) expect(FastlaneCore::Clipboard.paste).to eq(clipboard) end it 'should throw on non-supported environment', if: !FastlaneCore::Clipboard.is_supported? do expect { FastlaneCore::Clipboard.copy(content: @test_message) }.to raise_error("'pbcopy' or 'pbpaste' command not found.") expect { FastlaneCore::Clipboard.paste }.to raise_error("'pbcopy' or 'pbpaste' command not found.") end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/env_spec.rb
fastlane_core/spec/env_spec.rb
describe FastlaneCore do describe FastlaneCore::Env do describe '#disabled/unset' do it "Reports false on disabled env" do FastlaneSpec::Env.with_env_values('FL_TEST_FALSE' => 'false', 'FL_TEST_ZERO' => '0', 'FL_TEST_OFF' => 'off', 'FL_TEST_NO' => 'no', 'FL_TEST_NIL' => nil) do expect(FastlaneCore::Env.truthy?('FL_TEST_FALSE')).to be_falsey expect(FastlaneCore::Env.truthy?('FL_TEST_ZERO')).to be_falsey expect(FastlaneCore::Env.truthy?('FL_TEST_OFF')).to be_falsey expect(FastlaneCore::Env.truthy?('FL_TEST_NO')).to be_falsey expect(FastlaneCore::Env.truthy?('FL_TEST_NOTSET')).to be_falsey expect(FastlaneCore::Env.truthy?('FL_TEST_NIL')).to be_falsey end end it "Reports true on enabled env" do FastlaneSpec::Env.with_env_values('FL_TEST_SET' => '1') do expect(FastlaneCore::Env.truthy?('FL_TEST_SET')).to be_truthy end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/ui_spec.rb
fastlane_core/spec/ui_spec.rb
require 'spec_helper' describe FastlaneCore::UI do it "uses a FastlaneCore::Shell by default" do expect(FastlaneCore::UI.ui_object).to be_kind_of(FastlaneCore::Shell) end it "redirects all method calls to the current UI object" do expect(FastlaneCore::UI.ui_object).to receive(:error).with("yolo") FastlaneCore::UI.error("yolo") end it "allows overwriting of the ui_object for fastlane.ci" do third_party_output = "third_party_output" FastlaneCore::UI.ui_object = third_party_output expect(third_party_output).to receive(:error).with("yolo") FastlaneCore::UI.error("yolo") FastlaneCore::UI.ui_object = nil end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/provisioning_profile_spec.rb
fastlane_core/spec/provisioning_profile_spec.rb
describe FastlaneCore do describe FastlaneCore::ProvisioningProfile do describe "#profiles_path" do ["16.0", "17"].each do |xcode_version| it "returns correct profiles path for Xcode #{xcode_version}" do allow(FastlaneCore::Helper).to receive(:xcode_version).and_return(xcode_version) expect(FastlaneCore::ProvisioningProfile.profiles_path).to eq(File.expand_path("~/Library/Developer/Xcode/UserData/Provisioning Profiles")) end end ["10", "15"].each do |xcode_version| it "returns correct profiles path for Xcode #{xcode_version}" do allow(FastlaneCore::Helper).to receive(:xcode_version).and_return(xcode_version) expect(FastlaneCore::ProvisioningProfile.profiles_path).to eq(File.expand_path("~/Library/MobileDevice/Provisioning Profiles")) end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/pkg_file_analyser_spec.rb
fastlane_core/spec/pkg_file_analyser_spec.rb
describe FastlaneCore do describe FastlaneCore::PkgFileAnalyser do let(:path) { File.expand_path("../fixtures/pkgs/#{pkg}.pkg", __FILE__) } context "with a normal path" do let(:pkg) { 'MacAppOnly' } describe '::fetch_app_identifier', requires_xar: true do subject { described_class.fetch_app_identifier(path) } it { is_expected.to eq('com.example.Sample') } end describe '::fetch_app_version', requires_xar: true do subject { described_class.fetch_app_version(path) } it { is_expected.to eq('1.0') } end end context "with a path containing spaces" do let(:pkg) { 'Spaces in Path' } describe '::fetch_app_identifier', requires_xar: true do subject { described_class.fetch_app_identifier(path) } it { is_expected.to eq('com.example.Sample') } end describe '::fetch_app_version', requires_xar: true do subject { described_class.fetch_app_version(path) } it { is_expected.to eq('1.0') } end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/fastlane_runner_spec.rb
fastlane_core/spec/fastlane_runner_spec.rb
describe Commander::Runner do describe 'tool collector interactions' do class CommandsGenerator include Commander::Methods def initialize(raise_error: nil) @raise_error = raise_error end def run program :name, 'tool_name' program :version, '1.9' program :description, 'Description' # This is required because we're running this real Commander instance inside of # the real rspec tests command. When we run rspec for all projects, these options # get set, and Commander is going to validate that they are something that our # fake program accepts. # # This is not ideal, but the downside is potential broken tests in the future, # which we can quickly adjust. global_option('--format', String) global_option('--out', String) command :run do |c| c.action do |args, options| raise @raise_error if @raise_error end end default_command(:run) run! end end end describe '#handle_unknown_error' do class CustomError < StandardError def preferred_error_info ['Title', 'Line 1', 'Line 2'] end end class NilReturningError < StandardError def preferred_error_info nil end end it 'should reraise errors that are not of special interest' do expect do Commander::Runner.new.handle_unknown_error!(StandardError.new('my message')) end.to raise_error(StandardError, '[!] my message'.red) end it 'should reraise errors that return nil from #preferred_error_info' do expect do Commander::Runner.new.handle_unknown_error!(NilReturningError.new('my message')) end.to raise_error(StandardError, '[!] my message'.red) end it 'should abort and show custom info for errors that have the Apple error info provider method with FastlaneCore::Globals.verbose?=false' do runner = Commander::Runner.new expect(runner).to receive(:abort).with("\n[!] Title\n\tLine 1\n\tLine 2".red) FastlaneSpec::Env.with_verbose(false) do runner.handle_unknown_error!(CustomError.new) end end it 'should reraise and show custom info for errors that have the Apple error info provider method with FastlaneCore::Globals.verbose?=true' do FastlaneSpec::Env.with_verbose(true) do expect do Commander::Runner.new.handle_unknown_error!(CustomError.new) end.to raise_error(CustomError, "[!] Title\n\tLine 1\n\tLine 2".red) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/simulator_spec.rb
fastlane_core/spec/simulator_spec.rb
require 'open3' describe FastlaneCore do describe FastlaneCore::Simulator do before do @valid_simulators = "== Devices == -- iOS 7.1 -- iPhone 4s (8E3D97C4-1143-4E84-8D57-F697140F2ED0) (Shutdown) (unavailable, failed to open liblaunch_sim.dylib) iPhone 5 (65D0F571-1260-4241-9583-611EAF4D56AE) (Shutdown) (unavailable, failed to open liblaunch_sim.dylib) -- iOS 8.1 -- iPhone 4s (DBABD2A2-0144-44B0-8F93-263EB656FC13) (Shutdown) iPhone 5 (0D80C781-8702-4156-855E-A9B737FF92D3) (Booted) -- iOS 9.1 -- iPhone 6s Plus (BB65C267-FAE9-4CB7-AE31-A5D9BA393AF0) (Shutdown) Resizable iPad (B323CCB4-840B-4B26-B57B-71681D6C30C2) (Shutdown) (unavailable, device type profile not found) iPad Air 2 (961A7DF9-F442-4CA5-B28E-D96288D39DCA) (Shutdown) -- tvOS 9.0 -- Apple TV 1080p (D239A51B-A61C-4B60-B4D6-B7EC16595128) (Shutdown) -- watchOS 2.0 -- Apple Watch - 38mm (FE0C82A5-CDD2-4062-A62C-21278EEE32BB) (Shutdown) Apple Watch - 38mm (66D1BF17-3003-465F-A165-E6E3A565E5EB) (Booted) " FastlaneCore::Simulator.clear_cache end it "can launch Simulator.app for a simulator device" do device = FastlaneCore::DeviceManager::Device.new(name: 'iPhone 5s', udid: '3E67398C-AF70-4D77-A22C-D43AA8623FE3', os_type: 'iOS', os_version: '10.0', state: 'Shutdown', is_simulator: true) simulator_path = File.join(FastlaneCore::Helper.xcode_path, 'Applications', 'Simulator.app') expected_command = "open -a #{simulator_path} --args -CurrentDeviceUDID #{device.udid}" expect(FastlaneCore::Helper).to receive(:backticks).with(expected_command, print: FastlaneCore::Globals.verbose?) FastlaneCore::Simulator.launch(device) end it "does not launch Simulator.app for a non-simulator device" do device = FastlaneCore::DeviceManager::Device.new(name: 'iPhone 5s', udid: '3E67398C-AF70-4D77-A22C-D43AA8623FE3', os_type: 'iOS', os_version: '10.0', state: 'Shutdown', is_simulator: false) expect(FastlaneCore::Helper).not_to(receive(:backticks)) FastlaneCore::Simulator.launch(device) end it "raises an error if xcrun CLI prints garbage" do response = "response" expect(response).to receive(:read).and_return("💩") expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) expect do devices = FastlaneCore::Simulator.all end.to raise_error("xcrun simctl not working.") end it "properly parses the simctl output and generates Device objects for iOS" do response = "response" expect(response).to receive(:read).and_return(@valid_simulators) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::Simulator.all expect(devices.count).to eq(4) expect(devices[0]).to have_attributes( name: "iPhone 4s", os_version: "8.1", udid: "DBABD2A2-0144-44B0-8F93-263EB656FC13", state: "Shutdown" ) expect(devices[1]).to have_attributes( name: "iPhone 5", os_version: "8.1", udid: "0D80C781-8702-4156-855E-A9B737FF92D3", state: "Booted" ) expect(devices[2]).to have_attributes( name: "iPhone 6s Plus", os_version: "9.1", udid: "BB65C267-FAE9-4CB7-AE31-A5D9BA393AF0", state: "Shutdown" ) expect(devices[3]).to have_attributes( name: "iPad Air 2", os_version: "9.1", udid: "961A7DF9-F442-4CA5-B28E-D96288D39DCA", state: "Shutdown" ) end it "properly parses the simctl output and generates Device objects for tvOS" do response = "response" expect(response).to receive(:read).and_return(@valid_simulators) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::SimulatorTV.all expect(devices.count).to eq(1) expect(devices[0]).to have_attributes( name: "Apple TV 1080p", os_version: "9.0", udid: "D239A51B-A61C-4B60-B4D6-B7EC16595128", state: "Shutdown" ) end it "properly parses the simctl output and generates Device objects for watchOS" do response = "response" expect(response).to receive(:read).and_return(@valid_simulators) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::SimulatorWatch.all expect(devices.count).to eq(2) expect(devices[0]).to have_attributes( name: "Apple Watch - 38mm", os_version: "2.0", udid: "FE0C82A5-CDD2-4062-A62C-21278EEE32BB", state: "Shutdown" ) expect(devices[1]).to have_attributes( name: "Apple Watch - 38mm", os_version: "2.0", udid: "66D1BF17-3003-465F-A165-E6E3A565E5EB", state: "Booted" ) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/queue_worker_spec.rb
fastlane_core/spec/queue_worker_spec.rb
describe FastlaneCore::QueueWorker do describe '#new' do it 'should initialize an instance' do expect(described_class.new { |_| }).to be_kind_of(described_class) expect(described_class.new(1) { |_| }).to be_kind_of(described_class) end end describe '#enqueue' do subject { described_class.new(1) { |_| } } it 'should accept any object' do expect { subject.enqueue(1) }.not_to(raise_error) expect { subject.enqueue('aaa') }.not_to(raise_error) expect { subject.enqueue([1, 2, 3]) }.not_to(raise_error) expect { subject.enqueue(Object.new) }.not_to(raise_error) end end describe '#batch_enqueue' do subject { described_class.new(1) { |_| } } it 'should take an array as multiple jobs' do expect { subject.batch_enqueue([1, 2, 3]) }.not_to(raise_error) expect { subject.batch_enqueue(1) }.to(raise_error(ArgumentError)) end end describe '#start' do it 'should dispatch enqueued items to given block in FIFO order' do dispatched_jobs = [] subject = described_class.new(1) do |job| dispatched_jobs << job end subject.enqueue(1) subject.enqueue('aaa') subject.start expect(dispatched_jobs).to eq([1, 'aaa']) end it 'should not be reused once it\'s started' do subject = described_class.new(1) { |_| } subject.enqueue(1) subject.start expect { subject.enqueue(2) }.to raise_error(ClosedQueueError) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/config_item_spec.rb
fastlane_core/spec/config_item_spec.rb
describe FastlaneCore do describe FastlaneCore::ConfigItem do describe "ConfigItem sensitivity testing" do it "is code_gen_sensitive if just sensitive" do item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", description: "tacos are the best, amirite?", default_value: "taco secret", sensitive: true) expect(item.code_gen_sensitive).to be(true) expect(item.code_gen_default_value).to be(nil) end it "is not code_gen_sensitive by default" do item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", default_value: "taco secret", description: "tacos are the best, amirite?") expect(item.code_gen_sensitive).to be(false) expect(item.code_gen_default_value).to eq("taco secret") end it "can be code_gen_sensitive even if not sensitive" do item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", default_value: "taco secret", description: "tacos are the best, amirite?", code_gen_sensitive: true) expect(item.code_gen_sensitive).to be(true) expect(item.code_gen_default_value).to be(nil) end it "must be code_gen_sensitive even if defined false, when sensitive is true" do item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", description: "tacos are the best, amirite?", sensitive: true, code_gen_sensitive: false) expect(item.code_gen_sensitive).to be(true) expect(item.sensitive).to be(true) end it "uses code_gen_default_value when default value exists" do item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", default_value: "taco secret", code_gen_default_value: "nothing", description: "tacos are the best, amirite?", code_gen_sensitive: true) expect(item.code_gen_sensitive).to be(true) expect(item.code_gen_default_value).to eq("nothing") item = FastlaneCore::ConfigItem.new(key: :tacos, short_option: "-t", default_value: "taco secret", code_gen_default_value: "nothing", description: "tacos are the best, amirite?") expect(item.code_gen_sensitive).to be(false) expect(item.code_gen_default_value).to eq("nothing") # Don't override default value expect(item.default_value).to eq("taco secret") end end describe "ConfigItem input validation" do it "doesn't raise an error if everything's valid" do result = FastlaneCore::ConfigItem.new(key: :foo, short_option: "-f", description: "foo") expect(result.key).to eq(:foo) expect(result.short_option).to eq("-f") expect(result.description).to eq("foo") end describe "raises an error if short option is invalid" do it "long string" do expect do FastlaneCore::ConfigItem.new(key: :foo, short_option: :f, description: "foo") end.to raise_error("short_option for key :foo must of type String") end it "long string" do expect do FastlaneCore::ConfigItem.new(key: :foo, short_option: "-abc", description: "foo") end.to raise_error("short_option for key :foo must be a string of length 1") end end describe "raises an error for invalid description" do it "raises an error if the description ends with a dot" do expect do FastlaneCore::ConfigItem.new(key: :foo, short_option: "-f", description: "foo.") end.to raise_error("Do not let descriptions end with a '.', since it's used for user inputs as well for key :foo") end end end describe "ConfigItem Boolean type auto_convert value" do it "auto convert to 'true' Boolean type if default value is 'yes' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "yes") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'true' Boolean type if default value is 'YES' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "YES") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'true' Boolean type if default value is 'true' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "true") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'true' Boolean type if default value is 'TRUE' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "TRUE") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'true' Boolean type if default value is 'on' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "on") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'true' Boolean type if default value is 'ON' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "ON") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(true) end it "auto convert to 'false' Boolean type if default value is 'no' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "no") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end it "auto convert to 'false' Boolean type if default value is 'NO' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "NO") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end it "auto convert to 'false' Boolean type if default value is 'false' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "false") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end it "auto convert to 'false' Boolean type if default value is 'FALSE' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "FALSE") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end it "auto convert to 'false' Boolean type if default value is 'off' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "off") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end it "auto convert to 'false' Boolean type if default value is 'OFF' string" do result = FastlaneCore::ConfigItem.new(key: :foo, type: FastlaneCore::Boolean, default_value: "OFF") auto_convert_value = result.auto_convert_value(result.default_value) expect(auto_convert_value).to be(false) end end describe "ConfigItem Array type input validation" do it "doesn't raise an error if value is Array type" do result = FastlaneCore::ConfigItem.new(key: :foo, default_value: ["foo1", "foo2"]) expect(UI).not_to receive(:user_error) result.ensure_array_type_passes_validation(result.default_value) end it "doesn't raise an error if value is String type" do result = FastlaneCore::ConfigItem.new(key: :foo, default_value: "foo1") expect(UI).not_to receive(:user_error) result.ensure_array_type_passes_validation(result.default_value) end it "doesn't raise an error if value is comma-separated String type" do result = FastlaneCore::ConfigItem.new(key: :foo, default_value: "foo1,foo2") expect(UI).not_to receive(:user_error) result.ensure_array_type_passes_validation(result.default_value) end it "does raise an error if value is Boolean type" do result = FastlaneCore::ConfigItem.new(key: :foo, default_value: true) expect do result.ensure_array_type_passes_validation(result.default_value) end.to raise_error("'foo' value must be either `Array` or `comma-separated String`! Found TrueClass instead.") end it "does raise an error if value is Hash type" do result = FastlaneCore::ConfigItem.new(key: :foo, default_value: {}) expect do result.ensure_array_type_passes_validation(result.default_value) end.to raise_error("'foo' value must be either `Array` or `comma-separated String`! Found Hash instead.") end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/ipa_file_analyser_spec.rb
fastlane_core/spec/ipa_file_analyser_spec.rb
describe FastlaneCore do describe FastlaneCore::IpaFileAnalyser do let(:ipa) { 'iOSAppOnly' } let(:path) { File.expand_path("../fixtures/ipas/#{ipa}.ipa", __FILE__) } context 'with fetch_info_plist_with_rubyzip' do before(:each) do expect(FastlaneCore::IpaFileAnalyser).to receive(:fetch_info_plist_with_rubyzip).and_call_original end describe '::fetch_app_identifier' do subject { described_class.fetch_app_identifier(path) } it { is_expected.to eq('com.example.Sample') } context 'when contains embedded app bundle' do let('ipa') { 'ContainsWatchApp' } it { is_expected.to eq('com.example.Sample') } end end describe '::fetch_app_build' do subject { described_class.fetch_app_build(path) } it { is_expected.to eq('1') } context 'when contains embedded app bundle' do let('ipa') { 'ContainsWatchApp' } it { is_expected.to eq('1') } end end end context 'with fetch_info_plist_with_unzip' do unless FastlaneCore::Helper.windows? before(:each) do expect(FastlaneCore::IpaFileAnalyser).to receive(:fetch_info_plist_with_rubyzip).and_return(nil) expect(FastlaneCore::IpaFileAnalyser).to receive(:fetch_info_plist_with_unzip).and_call_original end describe '::fetch_app_identifier' do subject { described_class.fetch_app_identifier(path) } it { is_expected.to eq('com.example.Sample') } context 'when contains embedded app bundle' do let('ipa') { 'ContainsWatchApp' } it { is_expected.to eq('com.example.Sample') } end end describe '::fetch_app_build' do subject { described_class.fetch_app_build(path) } it { is_expected.to eq('1') } context 'when contains embedded app bundle' do let('ipa') { 'ContainsWatchApp' } it { is_expected.to eq('1') } end end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/cert_checker_spec.rb
fastlane_core/spec/cert_checker_spec.rb
describe FastlaneCore do describe FastlaneCore::CertChecker do let(:success_status) { class ProcessStatusMock end allow_any_instance_of(ProcessStatusMock).to receive(:success?).and_return(true) ProcessStatusMock.new } describe '#installed_identities' do it 'should print an error when no local code signing identities are found' do allow(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return(['G2', 'G3', 'G4', 'G5', 'G6']) allow(FastlaneCore::CertChecker).to receive(:list_available_identities).and_return(" 0 valid identities found\n") expect(FastlaneCore::UI).to receive(:error).with(/There are no local code signing identities found/) FastlaneCore::CertChecker.installed_identities end it 'should not be fooled by 10 local code signing identities available' do allow(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return(['G2', 'G3', 'G4', 'G5', 'G6']) allow(FastlaneCore::CertChecker).to receive(:list_available_identities).and_return(" 10 valid identities found\n") expect(FastlaneCore::UI).not_to(receive(:error)) FastlaneCore::CertChecker.installed_identities end end describe '#installed_wwdr_certificates' do let(:cert) do cert = OpenSSL::X509::Certificate.new key = OpenSSL::PKey::RSA.new(2048) root_key = OpenSSL::PKey::RSA.new(2048) cert.public_key = key.public_key cert.sign(root_key, OpenSSL::Digest::SHA256.new) cert end it "should return installed certificate's alias" do expect(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::Helper).to receive(:backticks).with(/security find-certificate/, { print: false }).and_return("-----BEGIN CERTIFICATE-----\nG6\n-----END CERTIFICATE-----\n") allow(Digest::SHA256).to receive(:hexdigest).with(cert.to_der).and_return('bdd4ed6e74691f0c2bfd01be0296197af1379e0418e2d300efa9c3bef642ca30') allow(OpenSSL::X509::Certificate).to receive(:new).and_return(cert) expect(FastlaneCore::CertChecker.installed_wwdr_certificates).to eq(['G6']) end it "should return an empty array if unknown WWDR certificates are found" do expect(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::Helper).to receive(:backticks).with(/security find-certificate/, { print: false }).and_return("-----BEGIN CERTIFICATE-----\nG6\n-----END CERTIFICATE-----\n") allow(OpenSSL::X509::Certificate).to receive(:new).and_return(cert) expect(FastlaneCore::CertChecker.installed_wwdr_certificates).to eq([]) end end describe '#install_missing_wwdr_certificates' do it 'should install all official WWDR certificates' do allow(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return([]) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G2', { keychain: "login.keychain" }) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G3', { keychain: "login.keychain" }) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G4', { keychain: "login.keychain" }) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G5', { keychain: "login.keychain" }) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G6', { keychain: "login.keychain" }) FastlaneCore::CertChecker.install_missing_wwdr_certificates end it 'should install the missing official WWDR certificate' do allow(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return(['G2', 'G3', 'G4', 'G5']) expect(FastlaneCore::CertChecker).to receive(:install_wwdr_certificate).with('G6', { keychain: "login.keychain" }) FastlaneCore::CertChecker.install_missing_wwdr_certificates end it 'should download the WWDR certificate from correct URL' do allow(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return('login.keychain') expect(Open3).to receive(:capture3).with(include('https://www.apple.com/certificateauthority/AppleWWDRCAG2.cer')).and_return(["", "", success_status]) FastlaneCore::CertChecker.install_wwdr_certificate('G2') expect(Open3).to receive(:capture3).with(include('https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer')).and_return(["", "", success_status]) FastlaneCore::CertChecker.install_wwdr_certificate('G3') expect(Open3).to receive(:capture3).with(include('https://www.apple.com/certificateauthority/AppleWWDRCAG4.cer')).and_return(["", "", success_status]) FastlaneCore::CertChecker.install_wwdr_certificate('G4') expect(Open3).to receive(:capture3).with(include('https://www.apple.com/certificateauthority/AppleWWDRCAG5.cer')).and_return(["", "", success_status]) FastlaneCore::CertChecker.install_wwdr_certificate('G5') expect(Open3).to receive(:capture3).with(include('https://www.apple.com/certificateauthority/AppleWWDRCAG6.cer')).and_return(["", "", success_status]) FastlaneCore::CertChecker.install_wwdr_certificate('G6') end end describe 'shell escaping' do let(:keychain_name) { "keychain with spaces.keychain" } let(:shell_escaped_name) { keychain_name.shellescape } let(:name_regex) { Regexp.new(Regexp.escape(shell_escaped_name)) } it 'should shell escape keychain names when checking for installation' do expect(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return(keychain_name) expect(FastlaneCore::Helper).to receive(:backticks).with(name_regex, { print: false }).and_return("") FastlaneCore::CertChecker.installed_wwdr_certificates end describe 'uses the correct command to import it' do it 'with default' do # We have to execute *something* using ` since otherwise we set expectations to `nil`, which is not healthy `ls` keychain = "keychain with spaces.keychain" cmd = %r{curl -f -o (([A-Z]\:)?\/.+\.cer) https://www\.apple\.com/certificateauthority/AppleWWDRCAG6\.cer && security import \1 -k #{Regexp.escape(keychain.shellescape)}} require "open3" expect(Open3).to receive(:capture3).with(cmd).and_return(["", "", success_status]) expect(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return(keychain_name) allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return(['G2', 'G3', 'G4', 'G5']) expect(FastlaneCore::CertChecker.install_missing_wwdr_certificates).to be(1) end it 'with FASTLANE_WWDR_USE_HTTP1_AND_RETRIES feature' do # We have to execute *something* using ` since otherwise we set expectations to `nil`, which is not healthy `ls` stub_const('ENV', { "FASTLANE_WWDR_USE_HTTP1_AND_RETRIES" => "true" }) keychain = "keychain with spaces.keychain" cmd = %r{curl --http1.1 --retry 3 --retry-all-errors -f -o (([A-Z]\:)?\/.+\.cer) https://www\.apple\.com/certificateauthority/AppleWWDRCAG6\.cer && security import \1 -k #{Regexp.escape(keychain.shellescape)}} require "open3" expect(Open3).to receive(:capture3).with(cmd).and_return(["", "", success_status]) expect(FastlaneCore::CertChecker).to receive(:wwdr_keychain).and_return(keychain_name) allow(FastlaneCore::CertChecker).to receive(:installed_wwdr_certificates).and_return(['G2', 'G3', 'G4', 'G5']) expect(FastlaneCore::CertChecker.install_missing_wwdr_certificates).to be(1) end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/shell_spec.rb
fastlane_core/spec/shell_spec.rb
describe FastlaneCore do describe FastlaneCore::Shell do describe "command_output" do before(:all) do @shell = FastlaneCore::Shell.new end it 'command_output handles encodings incorrectly tagged as UTF-8' do expect do @shell.command_output("utf_16_string_tagged_as_utf_8\n".encode(Encoding::UTF_16).force_encoding(Encoding::UTF_8)) @shell.command_output("µm\n".encode(Encoding::UTF_16).force_encoding(Encoding::UTF_8)) end.not_to raise_error end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/app_identifier_guesser_spec.rb
fastlane_core/spec/app_identifier_guesser_spec.rb
require 'fastlane_core/analytics/app_identifier_guesser' describe FastlaneCore do describe FastlaneCore::AppIdentifierGuesser do def android_hash_of(value) hash_of("android_project_#{value}") end def hash_of(value) Digest::SHA256.hexdigest("p#{value}fastlan3_SAlt") end describe "#p_hash?" do let(:package_name) { 'com.test.app' } before do ENV.delete("FASTLANE_OPT_OUT_USAGE") end it "chooses the correct param for package name for supply" do args = ["--skip_upload_screenshots", "-a", "beta", "-p", package_name] guesser = FastlaneCore::AppIdentifierGuesser.new(args: args, gem_name: 'supply') expect(guesser.p_hash).to eq(android_hash_of(package_name)) end it "chooses the correct param for package name for screengrab" do args = ["--skip_open_summary", "-a", package_name, "-p", "com.test.app.test"] guesser = FastlaneCore::AppIdentifierGuesser.new(args: args, gem_name: 'screengrab') expect(guesser.p_hash).to eq(android_hash_of(package_name)) end it "chooses the correct param for package name for gym" do args = ["--clean", "-a", package_name, "-p", "test.xcodeproj"] guesser = FastlaneCore::AppIdentifierGuesser.new(args: args, gem_name: 'gym') expect(guesser.p_hash).to eq(hash_of(package_name)) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/ipa_upload_package_builder_spec.rb
fastlane_core/spec/ipa_upload_package_builder_spec.rb
describe FastlaneCore do describe FastlaneCore::IpaUploadPackageBuilder do let(:ipa) { 'iOSAppOnly' } let(:path) { File.expand_path("../fixtures/ipas/#{ipa}.ipa", __FILE__) } let(:uploader) { FastlaneCore::IpaUploadPackageBuilder.new } let(:unique_path) { uploader.unique_ipa_path(path) } let(:ipa_with_spaces) { 'iOS App With Spaces' } let(:path_with_spaces) { File.expand_path("../fixtures/ipas/#{ipa_with_spaces}.ipa", __FILE__) } let(:unique_path_with_spaces) { uploader.unique_ipa_path(path_with_spaces) } def special_chars?(string) string =~ /^[A-Za-z0-9_\.]+$/ ? false : true end context 'special_chars?' do it 'returns false for and zero special characters and emoji' do is_valid = special_chars?("something_IPA_1234567890.ipa") expect(is_valid).to be(false) end it 'returns true for all special characters' do special_chars = %w[! @ # $ % ^ & * ( ) + = [ ] " ' ; : < > ? / \\ | { } , ~ `] special_chars.each do |c| is_valid = special_chars?("something_#{c}.ipa") expect(is_valid).to be(true) end end it 'returns true for emoji' do is_valid = special_chars?("something_😝_🚀.ipa") expect(is_valid).to be(true) end end context 'unique IPA file name' do it 'does not contain any special characters' do is_valid = !special_chars?(unique_path) expect(is_valid).to be(true) end it 'does not start with allowed special characters' do okay_chars = %w[- . _] okay_chars.each do |okay_char| expect(unique_path).not_to(start_with(okay_char)) end end it 'does not contain any spaces' do expect(unique_path_with_spaces.include?(' ')).to eq(false) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/build_watcher_spec.rb
fastlane_core/spec/build_watcher_spec.rb
require 'spec_helper' describe FastlaneCore::BuildWatcher do context '.wait_for_build_processing_to_be_complete' do let(:processing_build) do double( app_version: "1.0", version: "1", processed?: false, platform: 'IOS', processing_state: 'PROCESSING' ) end let(:ready_build) do double( id: '123', app_version: "1.0", version: "1", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end let(:ready_build_dup) do double( id: '321', app_version: "1.0.0", version: "1", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end let(:mock_base_api_client) { "fake api base client" } let(:options_1_0) do { app_id: 'some-app-id', version: '1.0', build_number: '1', platform: 'IOS' } end let(:options_1_0_0) do { app_id: 'some-app-id', version: '1.0.0', build_number: '1', platform: 'IOS' } end before(:each) do allow(Spaceship::ConnectAPI::TestFlight::Client).to receive(:instance).and_return(mock_base_api_client) end it 'returns a ready to submit build' do expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([ready_build]) expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'returns a build that is still processing when return_when_build_appears is true' do expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([processing_build]) found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_when_build_appears: true, return_spaceship_testflight_build: false) expect(found_build).to eq(processing_build) end it 'returns a ready to submit build with train_version and build_version truncated' do expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).and_return([ready_build]) expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '01.00', build_version: '01', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end context 'waits when a build is still processing' do it 'when wait_for_build_beta_detail_processing is false' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'when wait_for_build_beta_detail_processing is true' do build_beta_detail_processing = double(processed?: false) build_beta_detail_processed = double(processed?: true) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(ready_build).to receive(:build_beta_detail).and_return(build_beta_detail_processing).twice expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(ready_build).to receive(:build_beta_detail).and_return(build_beta_detail_processed).twice expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{ready_build.platform}").twice expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false, wait_for_build_beta_detail_processing: true) expect(found_build).to eq(ready_build) end end it 'waits when the build disappears' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'watches the latest build when no builds are processing' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end describe 'multiple builds found' do describe 'select_latest is false' do it 'raises error select_latest is false' do builds = [ready_build, ready_build_dup] expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return(builds) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)") error_builds = builds.map { |b| "#{b.app_version}(#{b.version}) for #{b.platform} - #{b.processing_state}" }.join("\n") expect do FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false, select_latest: false) end.to raise_error(FastlaneCore::BuildWatcherError, "Found more than 1 matching build: \n#{error_builds}") end end describe 'select_latest is true' do let(:newest_ready_build) do double( id: "853", app_version: "1.0", version: "2", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end it 'returns latest build' do builds = [newest_ready_build, ready_build] expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return(builds) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false, select_latest: true) expect(found_build).to eq(newest_ready_build) end end end it 'sleeps 10 seconds by default' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep).with(10) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) allow(UI).to receive(:message) allow(UI).to receive(:success) found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) end it 'sleeps for the amount of time specified in poll_interval' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep).with(123) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) allow(UI).to receive(:message) allow(UI).to receive(:success) found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', poll_interval: 123, return_spaceship_testflight_build: false) end it 'notifies when a build is still processing with timeout duration' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with(/Will timeout watching build after [4-5]{1} seconds around (2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [+-][0-9]{2}[0-9]{2})\.\.\./) expect(UI).to receive(:verbose).with(/Will timeout watching build after pending [0-5]{1} seconds around (2[0-9]{3}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [+-][0-9]{2}[0-9]{2})\.\.\./) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false, timeout_duration: 5) expect(found_build).to eq(ready_build) end it 'raises error when a build is still processing and timeout duration exceeded' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect do FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false, timeout_duration: -1) end.to raise_error("FastlaneCore::BuildWatcher exceeded the '-1' seconds, Stopping now!") end describe 'alternate versions' do describe '1.0 with 1.0.0 alternate' do it 'specific version returns one with alternate returns none' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'specific version returns non but alternate returns one' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([ready_build]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end end describe '1.0.0 with 1.0 alternate' do let(:processing_build) do double( app_version: "1.0.0", version: "1", processed?: false, platform: 'IOS', processing_state: 'PROCESSING' ) end let(:ready_build) do double( app_version: "1.0.0", version: "1", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end it 'specific version returns one with alternate returns none' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([processing_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([ready_build]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'specific version returns non but alternate returns one' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_0).and_return([]) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0).and_return([ready_build]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0.0 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") expect(UI).to receive(:important).with("App version is 1.0.0 but build was found while querying 1.0") expect(UI).to receive(:important).with("This shouldn't be an issue as Apple sees 1.0.0 and 1.0 as equal") expect(UI).to receive(:important).with("See docs for more info - https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102364") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0.0', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end end describe '1.0.1 with no alternate versions' do let(:processing_build) do double( app_version: "1.0.1", version: "1", processed?: false, platform: 'IOS', processing_state: 'PROCESSING' ) end let(:ready_build) do double( app_version: "1.0.1", version: "1", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end let(:options_1_0_1) do { app_id: 'some-app-id', version: '1.0.1', build_number: '1', platform: 'IOS' } end it 'specific version returns one with alternate returns none' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_1).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_1).and_return([ready_build]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0.1 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0.1', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'specific version returns non but alternate returns one' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_1).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_1_0_1).and_return([ready_build]) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: #{ready_build.app_version}, build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0.1 - 1) for #{ready_build.platform}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, train_version: '1.0.1', build_version: '1', return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end end end describe 'no app version to watch' do describe 'with no build number' do let(:options_no_version) do { app_id: 'some-app-id', version: nil, build_number: nil, platform: 'IOS' } end it 'returns a ready to submit build when select_latest is true' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version).and_return([ready_build]) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: , platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, poll_interval: 0, select_latest: true, return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'waits when a build is still processing and returns a ready to submit build when select_latest is true' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version).and_return([ready_build]) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: , platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{processing_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, poll_interval: 0, select_latest: true, return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'raises error when select_latest is false' do expect(Spaceship::ConnectAPI::Build).to_not(receive(:all)) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: , platform: #{ready_build.platform}") expect(UI).to_not(receive(:message).with("Searching for the latest build")) expect do FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, poll_interval: 0, select_latest: false, return_spaceship_testflight_build: false) end.to raise_error(FastlaneCore::BuildWatcherError, "There is no app version to watch") end end describe 'with build number' do let(:options_no_version_but_with_build_number) do { app_id: 'some-app-id', version: nil, build_number: '1', platform: 'IOS' } end it 'returns a ready to submit build when select_latest is true' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version_but_with_build_number).and_return([ready_build]) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build with build number: #{ready_build.version}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, build_version: '1', poll_interval: 2, select_latest: true, return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'waits when a build is still processing and returns a ready to submit build when select_latest is true' do expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version_but_with_build_number).and_return([processing_build]) expect(FastlaneCore::BuildWatcher).to receive(:sleep) expect(Spaceship::ConnectAPI::Build).to receive(:all).with(options_no_version_but_with_build_number).and_return([ready_build]) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build with build number: #{ready_build.version}") expect(UI).to receive(:message).with("Waiting for App Store Connect to finish processing the new build (1.0 - 1) for #{processing_build.platform}") expect(UI).to receive(:message).with("Searching for the latest build with build number: #{ready_build.version}") expect(UI).to receive(:success).with("Successfully finished processing the build #{ready_build.app_version} - #{ready_build.version} for #{ready_build.platform}") found_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, build_version: '1', poll_interval: 2, select_latest: true, return_spaceship_testflight_build: false) expect(found_build).to eq(ready_build) end it 'raises error when select_latest is false' do expect(Spaceship::ConnectAPI::Build).to_not(receive(:all)) expect(FastlaneCore::BuildWatcher).to_not(receive(:sleep)) expect(UI).to receive(:message).with("Waiting for processing on... app_id: some-app-id, app_version: , build_version: #{ready_build.version}, platform: #{ready_build.platform}") expect(UI).to_not(receive(:message).with("Searching for the latest build with build number: #{ready_build.version}")) expect do FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(app_id: 'some-app-id', platform: :ios, build_version: '1', poll_interval: 2, select_latest: false, return_spaceship_testflight_build: false) end.to raise_error(FastlaneCore::BuildWatcherError, "There is no app version to watch") end end end describe 'app version to watch' do describe 'with no build number' do let(:options_1_0_nil) do { app_id: 'some-app-id', version: '1.0', build_number: nil, platform: 'IOS' } end let(:options_1_0_0_nil) do { app_id: 'some-app-id', version: '1.0.0', build_number: nil, platform: 'IOS' } end let(:newest_ready_build) do double( id: '482', app_version: "1.0", version: "2", processed?: true, platform: 'IOS', processing_state: 'VALID' ) end it 'returns a ready to submit build when select_latest is true' do
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
true
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/commander_generator_spec.rb
fastlane_core/spec/commander_generator_spec.rb
describe FastlaneCore do describe FastlaneCore::CommanderGenerator do describe 'while options parsing' do describe '' do it 'should not return `true` for String options with no short flag' do config_items = [ FastlaneCore::ConfigItem.new(key: :long_option_only_string, description: "desc", is_string: true, default_value: "blah", optional: true), FastlaneCore::ConfigItem.new(key: :bool, description: "desc", default_value: false, is_string: false) ] stub_commander_runner_args(['--long_option_only_string', 'value', '--bool', 'false']) program = TestCommanderProgram.run(config_items) expect(program.options[:long_option_only_string]).to eq('value') expect(program.options[:bool]).to eq('false') end end describe 'pass-through arguments' do it 'captures those that are not command names or flags' do # 'test' is the command name set up by TestCommanderProgram stub_commander_runner_args(['test', 'other', '-b']) program = TestCommanderProgram.run([ FastlaneCore::ConfigItem.new(key: :boolean_1, short_option: '-b', description: 'Boolean 1', is_string: false) ]) expect(program.args).to eq(['other']) end end describe 'String flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :string_1, short_option: '-s', description: 'String 1', is_string: true) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-s']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--string_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided value for short flags' do stub_commander_runner_args(['-s', 'value']) program = TestCommanderProgram.run(config_items) expect(program.options[:string_1]).to eq('value') end it 'captures the provided value for long flags' do stub_commander_runner_args(['--string_1', 'value']) program = TestCommanderProgram.run(config_items) expect(program.options[:string_1]).to eq('value') end end describe ':shell_string flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :shell_string_1, short_option: '-s', description: 'Shell String 1', type: :shell_string) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-s']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--shell_string_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided value for short flags' do stub_commander_runner_args(['-s', 'foo bar=baz qux']) program = TestCommanderProgram.run(config_items) expect(program.options[:shell_string_1]).to eq('foo bar=baz qux') end it 'captures the provided value for long flags' do stub_commander_runner_args(['--shell_string_1', 'foo bar=baz qux']) program = TestCommanderProgram.run(config_items) expect(program.options[:shell_string_1]).to eq('foo bar=baz qux') end end describe 'Integer flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :integer_1, short_option: '-i', description: 'Integer 1', is_string: false, type: Integer) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-i']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--integer_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided value for short flags' do stub_commander_runner_args(['-i', '123']) program = TestCommanderProgram.run(config_items) expect(program.options[:integer_1]).to eq(123) end it 'captures the provided value for long flags' do stub_commander_runner_args(['--integer_1', '123']) program = TestCommanderProgram.run(config_items) expect(program.options[:integer_1]).to eq(123) end end describe 'Float flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :float_1, short_option: '-f', description: 'Float 1', is_string: false, type: Float) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-f']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--float_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided value for short flags' do stub_commander_runner_args(['-f', '1.23']) program = TestCommanderProgram.run(config_items) expect(program.options[:float_1]).to eq(1.23) end it 'captures the provided value for long flags' do stub_commander_runner_args(['--float_1', '1.23']) program = TestCommanderProgram.run(config_items) expect(program.options[:float_1]).to eq(1.23) end end describe 'Boolean flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :boolean_1, short_option: '-a', description: 'Boolean 1', is_string: false) ] end it 'treats short flags with no data type as booleans with true values' do stub_commander_runner_args(['-a']) program = TestCommanderProgram.run(config_items) expect(program.options[:boolean_1]).to eq(true) end it 'treats long flags with no data type as booleans with true values' do stub_commander_runner_args(['--boolean_1']) program = TestCommanderProgram.run(config_items) expect(program.options[:boolean_1]).to eq(true) end it 'treats short flags with no data type as booleans and captures true values' do stub_commander_runner_args(['-a', 'true']) program = TestCommanderProgram.run(config_items) # At this point in the options lifecycle we're getting the value back as a String # this is OK because the Configuration will properly coerce the value when fetched expect(program.options[:boolean_1]).to eq('true') end it 'treats long flags with no data type as booleans and captures true values' do stub_commander_runner_args(['--boolean_1', 'true']) program = TestCommanderProgram.run(config_items) # At this point in the options lifecycle we're getting the value back as a String # this is OK because the Configuration will properly coerce the value when fetched expect(program.options[:boolean_1]).to eq('true') end it 'treats short flags with no data type as booleans and captures false values' do stub_commander_runner_args(['-a', 'false']) program = TestCommanderProgram.run(config_items) # At this point in the options lifecycle we're getting the value back as a String # this is OK because the Configuration will properly coerce the value when fetched expect(program.options[:boolean_1]).to eq('false') end it 'treats long flags with no data type as booleans and captures false values' do stub_commander_runner_args(['--boolean_1', 'false']) program = TestCommanderProgram.run(config_items) # At this point in the options lifecycle we're getting the value back as a String # this is OK because the Configuration will properly coerce the value when fetched expect(program.options[:boolean_1]).to eq('false') end end describe 'Array flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :array_1, short_option: '-a', description: 'Array 1', is_string: false, type: Array) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-a']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--array_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided value for short flags' do stub_commander_runner_args(['-a', 'a,b,c']) program = TestCommanderProgram.run(config_items) expect(program.options[:array_1]).to eq(%w(a b c)) end it 'captures the provided value for long flags' do stub_commander_runner_args(['--array_1', 'a,b,c']) program = TestCommanderProgram.run(config_items) expect(program.options[:array_1]).to eq(%w(a b c)) end end describe 'Multiple flags' do let(:config_items) do [ FastlaneCore::ConfigItem.new(key: :string_1, short_option: '-s', description: 'String 1', is_string: true), FastlaneCore::ConfigItem.new(key: :array_1, short_option: '-a', description: 'Array 1', is_string: false, type: Array), FastlaneCore::ConfigItem.new(key: :integer_1, short_option: '-i', description: 'Integer 1', is_string: false, type: Integer), FastlaneCore::ConfigItem.new(key: :float_1, short_option: '-f', description: 'Float 1', is_string: false, type: Float), FastlaneCore::ConfigItem.new(key: :boolean_1, short_option: '-b', description: 'Boolean 1', is_string: false) ] end it 'raises MissingArgument for short flags with missing values' do stub_commander_runner_args(['-b', '-s']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'raises MissingArgument for long flags with missing values' do stub_commander_runner_args(['--boolean_1', '--string_1']) expect { TestCommanderProgram.run(config_items) }.to raise_error(OptionParser::MissingArgument) end it 'captures the provided values for short flags' do stub_commander_runner_args(['-b', '-a', 'a,b,c', '-s', 'value']) program = TestCommanderProgram.run(config_items) expect(program.options[:boolean_1]).to be(true) expect(program.options[:string_1]).to eq('value') expect(program.options[:array_1]).to eq(%w(a b c)) end it 'captures the provided values for long flags' do stub_commander_runner_args(['--float_1', '1.23', '--boolean_1', 'false', '--integer_1', '123']) program = TestCommanderProgram.run(config_items) expect(program.options[:float_1]).to eq(1.23) # At this point in the options lifecycle we're getting the value back as a String # this is OK because the Configuration will properly coerce the value when fetched expect(program.options[:boolean_1]).to eq('false') expect(program.options[:integer_1]).to eq(123) end it 'captures the provided values for mixed flags' do stub_commander_runner_args(['-f', '1.23', '-b', '--integer_1', '123']) program = TestCommanderProgram.run(config_items) expect(program.options[:float_1]).to eq(1.23) expect(program.options[:boolean_1]).to eq(true) expect(program.options[:integer_1]).to eq(123) end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/device_manager_spec.rb
fastlane_core/spec/device_manager_spec.rb
require 'open3' describe FastlaneCore do describe FastlaneCore::DeviceManager do before(:all) do @simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode7') @system_profiler_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutput') @instruments_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerInstrumentsOutput') @system_profiler_output_items_without_items = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutputItemsWithoutItems') @system_profiler_output_usb_hub = File.read('./fastlane_core/spec/fixtures/DeviceManagerSystem_profilerOutputUsbHub') FastlaneCore::Simulator.clear_cache end it 'raises an error if broken xcrun simctl list devices' do response = double('xcrun simctl list devices', read: 'garbage') expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) expect do devices = FastlaneCore::Simulator.all end.to raise_error("xcrun simctl not working.") end it 'raises an error if broken xcrun simctl list runtimes' do status = double('status', "success?": true) expect(Open3).to receive(:capture2).with("xcrun simctl list -j runtimes").and_return(['garbage', status]) expect do FastlaneCore::DeviceManager.runtime_build_os_versions end.to raise_error(FastlaneCore::Interface::FastlaneError) end describe "properly parses the simctl output and generates Device objects for iOS simulator" do it "Xcode 7" do response = "response" expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::Simulator.all expect(devices.count).to eq(6) expect(devices[0]).to have_attributes( name: "iPhone 4s", os_type: "iOS", os_version: "8.1", udid: "DBABD2A2-0144-44B0-8F93-263EB656FC13", state: "Shutdown", is_simulator: true ) expect(devices[1]).to have_attributes( name: "iPhone 5", os_type: "iOS", os_version: "8.1", udid: "0D80C781-8702-4156-855E-A9B737FF92D3", state: "Booted", is_simulator: true ) expect(devices[2]).to have_attributes( name: "iPhone 6s Plus", os_type: "iOS", os_version: "9.1", udid: "BB65C267-FAE9-4CB7-AE31-A5D9BA393AF0", state: "Shutdown", is_simulator: true ) expect(devices[3]).to have_attributes( name: "iPad Air", os_type: "iOS", os_version: "9.1", udid: "B61CB41D-354B-4991-992A-80AFFF1062E6", state: "Shutdown", is_simulator: true ) expect(devices[4]).to have_attributes( name: "iPad Air 2", os_type: "iOS", os_version: "9.1", udid: "57836FE1-5443-4433-B164-A6C9EADAB3F9", state: "Shutdown", is_simulator: true ) expect(devices[5]).to have_attributes( name: "iPad Pro", os_type: "iOS", os_version: "9.1", udid: "B1DDED8D-E449-461A-94A5-4146A1F58B20", state: "Shutdown", is_simulator: true ) end it "Xcode 8" do response = "response" simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode8') expect(response).to receive(:read).and_return(simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::Simulator.all expect(devices.count).to eq(12) expect(devices[-3]).to have_attributes( name: "iPad Air 2", os_type: "iOS", os_version: "10.0", udid: "0FDEB396-0582-438A-B09E-8F8F889DB632", state: "Shutdown", is_simulator: true ) expect(devices[-2]).to have_attributes( name: "iPad Pro (9.7-inch)", os_type: "iOS", os_version: "10.0", udid: "C03658EC-1362-4D8D-A40A-45B1D7D5405E", state: "Shutdown", is_simulator: true ) expect(devices[-1]).to have_attributes( name: "iPad Pro (12.9-inch)", os_type: "iOS", os_version: "10.0", udid: "CEF11EB3-79DF-43CB-896A-0F33916C8BDE", state: "Shutdown", is_simulator: true ) end it 'Xcode 9' do response = "response" simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode9') expect(response).to receive(:read).and_return(simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::Simulator.all expect(devices.count).to eq(15) expect(devices[-3]).to have_attributes( name: "iPad Pro (12.9-inch)", os_type: "iOS", os_version: "11.0", udid: "C7C55339-DE8F-4DA3-B94A-09879CB1E5B5", state: "Shutdown", is_simulator: true ) expect(devices[-2]).to have_attributes( name: "iPad Pro (12.9-inch) (2nd generation)", os_type: "iOS", os_version: "11.0", udid: "D2408DE5-C74F-4AD1-93FA-CC083D438321", state: "Shutdown", is_simulator: true ) expect(devices[-1]).to have_attributes( name: "iPad Pro (10.5-inch)", os_type: "iOS", os_version: "11.0", udid: "ED8B6B96-11CC-4848-93B8-4D5D627ABF7E", state: "Shutdown", is_simulator: true ) end it 'Xcode 11' do response = "response" simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode11') expect(response).to receive(:read).and_return(simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::Simulator.all expect(devices.count).to eq(29) expect(devices[-3]).to have_attributes( name: "iPad Pro (12.9-inch) (4th generation)", os_type: "iOS", os_version: "13.4", udid: "D311F577-F7B7-4487-9322-BF9A418F4EF3", state: "Shutdown", is_simulator: true ) expect(devices[-2]).to have_attributes( name: "iPad Air (3rd generation)", os_type: "iOS", os_version: "13.4", udid: "B6EDB5A2-820D-4DBE-A4E2-06DFF06DCB20", state: "Shutdown", is_simulator: true ) expect(devices[-1]).to have_attributes( name: "iPad Air (3rd generation) Dark", os_type: "iOS", os_version: "13.4", udid: "2B0E9B5D-3680-42B1-BC44-26B380921500", state: "Shutdown", is_simulator: true ) end end it "properly parses the simctl output and generates Device objects for tvOS simulator" do response = "response" expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::SimulatorTV.all expect(devices.count).to eq(1) expect(devices[0]).to have_attributes( name: "Apple TV 1080p", os_type: "tvOS", os_version: "9.0", udid: "D239A51B-A61C-4B60-B4D6-B7EC16595128", state: "Shutdown", is_simulator: true ) end it "properly parses the simctl output and generates Device objects for watchOS simulator" do response = "response" expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::SimulatorWatch.all expect(devices.count).to eq(2) expect(devices[0]).to have_attributes( name: "Apple Watch - 38mm", os_type: "watchOS", os_version: "2.0", udid: "FE0C82A5-CDD2-4062-A62C-21278EEE32BB", state: "Shutdown", is_simulator: true ) expect(devices[1]).to have_attributes( name: "Apple Watch - 38mm", os_type: "watchOS", os_version: "2.0", udid: "66D1BF17-3003-465F-A165-E6E3A565E5EB", state: "Booted", is_simulator: true ) end it "properly parses the simctl output and generates Device objects for all simulators" do response = "response" expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.simulators expect(devices.count).to eq(9) expect(devices[0]).to have_attributes( name: "iPhone 4s", os_type: "iOS", os_version: "8.1", udid: "DBABD2A2-0144-44B0-8F93-263EB656FC13", state: "Shutdown", is_simulator: true ) expect(devices[1]).to have_attributes( name: "iPhone 5", os_type: "iOS", os_version: "8.1", udid: "0D80C781-8702-4156-855E-A9B737FF92D3", state: "Booted", is_simulator: true ) expect(devices[2]).to have_attributes( name: "iPhone 6s Plus", os_type: "iOS", os_version: "9.1", udid: "BB65C267-FAE9-4CB7-AE31-A5D9BA393AF0", state: "Shutdown", is_simulator: true ) expect(devices[3]).to have_attributes( name: "iPad Air", os_type: "iOS", os_version: "9.1", udid: "B61CB41D-354B-4991-992A-80AFFF1062E6", state: "Shutdown", is_simulator: true ) expect(devices[6]).to have_attributes( name: "Apple TV 1080p", os_type: "tvOS", os_version: "9.0", udid: "D239A51B-A61C-4B60-B4D6-B7EC16595128", state: "Shutdown", is_simulator: true ) expect(devices[7]).to have_attributes( name: "Apple Watch - 38mm", os_type: "watchOS", os_version: "2.0", udid: "FE0C82A5-CDD2-4062-A62C-21278EEE32BB", state: "Shutdown", is_simulator: true ) expect(devices[8]).to have_attributes( name: "Apple Watch - 38mm", os_type: "watchOS", os_version: "2.0", udid: "66D1BF17-3003-465F-A165-E6E3A565E5EB", state: "Booted", is_simulator: true ) end it "properly parses the simctl output with unavailable devices and generates Device objects for all simulators" do response = "response" simctl_output = File.read('./fastlane_core/spec/fixtures/DeviceManagerSimctlOutputXcode10BootedUnavailable') expect(response).to receive(:read).and_return(simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.simulators expect(devices.count).to eq(3) expect(devices[0]).to have_attributes( name: "iPhone 5s", os_type: "iOS", os_version: "12.0", udid: "238C6D64-8720-4BFF-9DE9-FFBB9A1375D4", state: "Shutdown", is_simulator: true ) expect(devices[1]).to have_attributes( name: "iPhone 6", os_type: "iOS", os_version: "12.0", udid: "C68031AE-E525-4065-9DB6-0D4450326BDA", state: "Shutdown", is_simulator: true ) expect(devices[2]).to have_attributes( name: "Apple Watch Series 2 - 38mm", os_type: "watchOS", os_version: "5.0", udid: "34144812-F701-4A49-9210-4A226FE5E0A9", state: "Shutdown", is_simulator: true ) end it "properly parses system_profiler and instruments output and generates Device objects for iOS" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@instruments_output) expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.connected_devices('iOS') expect(devices.count).to eq(2) expect(devices[0]).to have_attributes( name: "Matthew's iPhone", os_type: "iOS", os_version: "9.3", udid: "f0f9f44e7c2dafbae53d1a83fe27c37418ffffff", state: "Booted", is_simulator: false ) expect(devices[1]).to have_attributes( name: "iPhone XS Max", os_type: "iOS", os_version: "12.0", udid: "00008020-0006302A0CFFFFFF", state: "Booted", is_simulator: false ) end it "properly parses system_profiler output with entries that don't contain _items" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output_items_without_items) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.connected_devices('iOS') expect(devices).to be_empty end it "properly finds devices in system_profiler output when connected via USB hubs" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output_usb_hub) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@instruments_output) expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.connected_devices('iOS') expect(devices.count).to eq(1) expect(devices[0]).to have_attributes( name: "Matthew's iPhone", os_type: "iOS", os_version: "9.3", udid: "f0f9f44e7c2dafbae53d1a83fe27c37418ffffff", state: "Booted", is_simulator: false ) end it "properly parses system_profiler and instruments output and generates Device objects for tvOS" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@instruments_output) expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.connected_devices('tvOS') expect(devices.count).to eq(1) expect(devices[0]).to have_attributes( name: "Matthew's Apple TV", os_type: "tvOS", os_version: "9.1", udid: "82f1fb5c8362ee9eb89a9c2c6829fa0563ffffff", state: "Booted", is_simulator: false ) end it "properly parses output for all iOS devices" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@instruments_output) expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.all('iOS') expect(devices.count).to eq(8) expect(devices[0]).to have_attributes( name: "Matthew's iPhone", os_type: "iOS", os_version: "9.3", udid: "f0f9f44e7c2dafbae53d1a83fe27c37418ffffff", state: "Booted", is_simulator: false ) expect(devices[1]).to have_attributes( name: "iPhone XS Max", os_type: "iOS", os_version: "12.0", udid: "00008020-0006302A0CFFFFFF", state: "Booted", is_simulator: false ) expect(devices[2]).to have_attributes( name: "iPhone 4s", os_type: "iOS", os_version: "8.1", udid: "DBABD2A2-0144-44B0-8F93-263EB656FC13", state: "Shutdown", is_simulator: true ) expect(devices[3]).to have_attributes( name: "iPhone 5", os_type: "iOS", os_version: "8.1", udid: "0D80C781-8702-4156-855E-A9B737FF92D3", state: "Booted", is_simulator: true ) expect(devices[4]).to have_attributes( name: "iPhone 6s Plus", os_type: "iOS", os_version: "9.1", udid: "BB65C267-FAE9-4CB7-AE31-A5D9BA393AF0", state: "Shutdown", is_simulator: true ) expect(devices[5]).to have_attributes( name: "iPad Air", os_type: "iOS", os_version: "9.1", udid: "B61CB41D-354B-4991-992A-80AFFF1062E6", state: "Shutdown", is_simulator: true ) end it "properly parses output for all tvOS devices" do response = "response" expect(response).to receive(:read).and_return(@system_profiler_output) expect(Open3).to receive(:popen3).with("system_profiler SPUSBDataType -xml").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@instruments_output) expect(Open3).to receive(:popen3).with("instruments -s devices").and_yield(nil, response, nil, nil) expect(response).to receive(:read).and_return(@simctl_output) expect(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil) devices = FastlaneCore::DeviceManager.all('tvOS') expect(devices.count).to eq(2) expect(devices[0]).to have_attributes( name: "Matthew's Apple TV", os_type: "tvOS", os_version: "9.1", udid: "82f1fb5c8362ee9eb89a9c2c6829fa0563ffffff", state: "Booted", is_simulator: false ) expect(devices[1]).to have_attributes( name: "Apple TV 1080p", os_type: "tvOS", os_version: "9.0", udid: "D239A51B-A61C-4B60-B4D6-B7EC16595128", state: "Shutdown", is_simulator: true ) end it 'properly parses `xcrun simctl list runtimes` to associate runtime builds with their exact OS version' do status = double('status', "success?": true) runtime_output = File.read('./fastlane_core/spec/fixtures/XcrunSimctlListRuntimesOutput') expect(Open3).to receive(:capture2).with("xcrun simctl list -j runtimes").and_return([runtime_output, status]) expect(FastlaneCore::DeviceManager.runtime_build_os_versions['21A328']).to eq('17.0') expect(FastlaneCore::DeviceManager.runtime_build_os_versions['21A342']).to eq('17.0.1') expect(FastlaneCore::DeviceManager.runtime_build_os_versions['21R355']).to eq('10.0') end describe FastlaneCore::DeviceManager::Device do it "slide to type gets disabled if iOS 13.0 or greater" do device = FastlaneCore::DeviceManager::Device.new(os_type: "iOS", os_version: "13.0", is_simulator: true) expect(UI).to receive(:message).with("Disabling 'Slide to Type' #{device}") expect(FastlaneCore::Helper).to receive(:backticks).times.once device.disable_slide_to_type end it "bypass slide to type disabling if less than iOS 13.0" do device = FastlaneCore::DeviceManager::Device.new(os_type: "iOS", os_version: "12.4", is_simulator: true) expect(FastlaneCore::Helper).to_not(receive(:backticks)) device.disable_slide_to_type end it "bypass slide to type disabling if not a simulator" do device = FastlaneCore::DeviceManager::Device.new(os_type: "iOS", os_version: "13.0", is_simulator: false) expect(FastlaneCore::Helper).to_not(receive(:backticks)) device.disable_slide_to_type end it "bypass slide to type disabling if not iOS" do device = FastlaneCore::DeviceManager::Device.new(os_type: "somethingelse", os_version: "13.0", is_simulator: true) expect(FastlaneCore::Helper).to_not(receive(:backticks)) device.disable_slide_to_type end it "boots the simulator" do device = FastlaneCore::DeviceManager::Device.new(os_type: "iOS", os_version: "13.0", is_simulator: true, state: nil) device.boot expect(device.state).to eq('Booted') end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/fastlane_exception_spec.rb
fastlane_core/spec/fastlane_exception_spec.rb
describe FastlaneCore::Interface::FastlaneException do context 'raising fastlane exceptions' do it 'properly determines that it was called via `UI.user_error!`' do begin UI.user_error!('USER ERROR!!') rescue => e expect(e.caused_by_calling_ui_method?(method_name: 'user_error!')).to be(true) end end it 'properly determines that it was called via `UI.crash!`' do begin UI.crash!('CRASH!!') rescue => e expect(e.caused_by_calling_ui_method?(method_name: 'crash!')).to be(true) end end it 'properly determines that the exception was raised explicitly' do begin raise FastlaneCore::Interface::FastlaneError.new, 'EXPLICITLY RAISED ERROR' rescue => e expect(e.caused_by_calling_ui_method?(method_name: 'user_error!')). to be(false) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/android_package_name_guesser_spec.rb
fastlane_core/spec/android_package_name_guesser_spec.rb
require 'spec_helper' require 'fastlane_core/android_package_name_guesser' describe FastlaneCore::AndroidPackageNameGuesser do it 'returns nil if no clues' do # this might also fail if the environment or config files are not clean expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('fastlane', [])).to be_nil end describe 'guessing from command line args' do it 'returns Android package_name if specified with --package_name' do args = ["--package_name", "com.krausefx.app"] expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('fastlane', args)).to eq("com.krausefx.app") end it 'returns Android package_name if specified with --app_package_name' do args = ["--app_package_name", "com.krausefx.app"] expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('fastlane', args)).to eq("com.krausefx.app") end it 'returns Android package_name if specified for supply gem with -p' do args = ["-p", "com.krausefx.app"] expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('supply', args)).to eq("com.krausefx.app") end it 'returns Android package_name if specified for screengrab gem with -p' do args = ["-a", "com.krausefx.app"] expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('screengrab', args)).to eq("com.krausefx.app") end end describe 'guessing from environment' do it 'returns Android package_name present in environment' do ["SUPPLY", "SCREENGRAB_APP"].each do |current| env_var_name = "#{current}_PACKAGE_NAME" package_name = "#{current}.bundle.id" ENV[env_var_name] = package_name expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('fastlane', [])).to eq(package_name) ENV.delete(env_var_name) end end end describe 'guessing from configuration files' do def allow_non_target_configuration_file(file_name) allow_any_instance_of(FastlaneCore::Configuration).to receive(:load_configuration_file).with(file_name, any_args) do |configuration, config_file_name| nil end end def allow_target_configuration_file(file_name, package_name_key) allow_any_instance_of(FastlaneCore::Configuration).to receive(:load_configuration_file).with(file_name, any_args) do |configuration, config_file_name| configuration[package_name_key] = "#{config_file_name}.bundle.id" end end it 'returns iOS app_identifier found in Supplyfile' do allow_target_configuration_file("Supplyfile", :package_name) allow_non_target_configuration_file("Screengrabfile") expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('supply', [])).to eq("Supplyfile.bundle.id") end it 'returns iOS app_identifier found in Screengrabfile' do allow_target_configuration_file("Screengrabfile", :app_package_name) allow_non_target_configuration_file("Supplyfile") expect(FastlaneCore::AndroidPackageNameGuesser.guess_package_name('screengrab', [])).to eq("Screengrabfile.bundle.id") end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/feature_spec.rb
fastlane_core/spec/feature_spec.rb
class FeatureHelper def self.disabled_class_method end def self.enabled_class_method end def disabled_instance_method; end def enabled_instance_method; end def self.reset_test_method FeatureHelper.instance_eval { undef test_method } end def reset_test_method undef test_method end end describe FastlaneCore do describe FastlaneCore::Feature do describe "Register a Feature" do it "registers a feature successfully with environment variable and description" do expect do FastlaneCore::Feature.register(env_var: "TEST_ENV_VAR_VALID", description: "A valid test feature") end.not_to(raise_error) end it "raises an error if no environment variable specified" do expect do FastlaneCore::Feature.register(description: "An invalid test feature") end.to raise_error("Invalid Feature") end it "raises an error if no description specified" do expect do FastlaneCore::Feature.register(env_var: "TEST_ENV_VAR_INVALID_NO_DESCRIPTION") end.to raise_error("Invalid Feature") end end describe '#enabled?' do before(:all) do FastlaneCore::Feature.register(env_var: 'TEST_ENV_VAR_FOR_ENABLED_TESTS', description: 'Test feature for enabled? tests') end it "reports unregistered features as not enabled" do expect(FastlaneCore::Feature.enabled?('TEST_ENV_VAR_NOT_REGISTERED')).to be_falsey end it "reports undefined features as not enabled, even if the environment variable is set" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_NOT_REGISTERED' => '1') do expect(FastlaneCore::Feature.enabled?('TEST_ENV_VAR_NOT_REGISTERED')).to be_falsey end end it "reports features for missing environment variables as disabled" do expect(FastlaneCore::Feature.enabled?('TEST_ENV_VAR_FOR_ENABLED_TESTS')).to be_falsey end it "reports features for disabled environment variables as disabled" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_ENABLED_TESTS' => '0') do expect(FastlaneCore::Feature.enabled?('TEST_ENV_VAR_FOR_ENABLED_TESTS')).to be_falsey end end it "reports features for environment variables as enabled" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_ENABLED_TESTS' => '1') do expect(FastlaneCore::Feature.enabled?('TEST_ENV_VAR_FOR_ENABLED_TESTS')).to be_truthy end end end describe "Register feature methods" do before(:all) do FastlaneCore::Feature.register(env_var: 'TEST_ENV_VAR_FOR_METHOD_TESTS', description: 'Test feature for feature method registration tests') end it "Calls disabled class method with disabled environment variable" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_METHOD_TESTS' => '0') do FastlaneCore::Feature.register_class_method(klass: FeatureHelper, symbol: :test_method, disabled_symbol: :disabled_class_method, enabled_symbol: :enabled_class_method, env_var: 'TEST_ENV_VAR_FOR_METHOD_TESTS') expect(FeatureHelper).to receive(:disabled_class_method) FeatureHelper.test_method FeatureHelper.reset_test_method end end it "Calls enabled class method with enabled environment variable" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_METHOD_TESTS' => '1') do FastlaneCore::Feature.register_class_method(klass: FeatureHelper, symbol: :test_method, disabled_symbol: :disabled_class_method, enabled_symbol: :enabled_class_method, env_var: 'TEST_ENV_VAR_FOR_METHOD_TESTS') expect(FeatureHelper).to receive(:enabled_class_method) FeatureHelper.test_method FeatureHelper.reset_test_method end end it "Calls disabled instance method with disabled environment variable" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_METHOD_TESTS' => '0') do instance = FeatureHelper.new FastlaneCore::Feature.register_instance_method(klass: FeatureHelper, symbol: :test_method, disabled_symbol: :disabled_instance_method, enabled_symbol: :enabled_instance_method, env_var: 'TEST_ENV_VAR_FOR_METHOD_TESTS') expect(instance).to receive(:disabled_instance_method) instance.test_method instance.reset_test_method end end it "Calls enabled instance method with enabled environment variable" do FastlaneSpec::Env.with_env_values('TEST_ENV_VAR_FOR_METHOD_TESTS' => '1') do instance = FeatureHelper.new FastlaneCore::Feature.register_instance_method(klass: FeatureHelper, symbol: :test_method, disabled_symbol: :disabled_instance_method, enabled_symbol: :enabled_instance_method, env_var: 'TEST_ENV_VAR_FOR_METHOD_TESTS') expect(instance).to receive(:enabled_instance_method) instance.test_method instance.reset_test_method end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/configuration_file_spec.rb
fastlane_core/spec/configuration_file_spec.rb
describe FastlaneCore do describe FastlaneCore::ConfigurationFile do describe "Properly loads and handles various configuration files" do let(:options) do [ FastlaneCore::ConfigItem.new(key: :devices, description: "desc", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :a_boolean, description: "desc", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :another_boolean, description: "desc", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :ios_version, description: "desc", default_value: "123"), FastlaneCore::ConfigItem.new(key: :app_identifier, description: "Mac", verify_block: proc do |value| UI.user_error!("Invalid identifier '#{value}'") unless value.split('.').count == 3 end), FastlaneCore::ConfigItem.new(key: :apple_id, description: "yo", default_value: "123") ] end it "fills in the values from a valid config file" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileValid') expect(config[:app_identifier]).to eq("com.krausefx.app") expect(config[:apple_id]).to eq("from_le_block") end it "properly raises an exception if verify block doesn't match" do expect do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file("ConfigFileInvalidIdentifier") end.to raise_error("Invalid identifier 'such invalid'") end it "raises an exception if method is not available" do expect do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file("ConfigFileKeyNotHere") end.to raise_error(/Could not find option \'not_existent\' in the list of available options.*/) end it "overwrites existing values" do # not overwrite config = FastlaneCore::Configuration.create(options, { app_identifier: "detlef.app.super" }) config.load_configuration_file('ConfigFileEmpty') expect(config[:app_identifier]).to eq("detlef.app.super") end it "prints a warning if no value is provided" do important_message = "In the config file './fastlane_core/spec/fixtures/ConfigFileEmptyValue' you have the line apple_id, but didn't provide any value. Make sure to append a value right after the option name. Make sure to check the docs for more information" expect(FastlaneCore::UI).to receive(:important).with(important_message) expect(FastlaneCore::UI).to receive(:important).with("No values defined in './fastlane_core/spec/fixtures/ConfigFileEmptyValue'") config = FastlaneCore::Configuration.create(options, { app_identifier: "detlef.app.super" }) config.load_configuration_file('ConfigFileEmptyValue') expect(config[:app_identifier]).to eq("detlef.app.super") # original value end it "supports modifying of frozen strings too" do # Test that a value can be modified (this isn't the case by default if it's set via ENV) app_identifier = "com.krausefx.yolo" FastlaneSpec::Env.with_env_values('SOMETHING_RANDOM_APP_IDENTIFIER' => app_identifier) do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileEnv') expect(config[:app_identifier]).to eq(app_identifier) config[:app_identifier].gsub!("yolo", "yoLiveTwice") expect(config[:app_identifier]).to eq("com.krausefx.yoLiveTwice") end end it "supports modifying of frozen strings that are returned via blocks too" do # Test that a value can be modified (this isn't the case by default if it's set via ENV) ios_version = "9.1" FastlaneSpec::Env.with_env_values('SOMETHING_RANDOM_IOS_VERSION' => ios_version) do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileEnv') expect(config[:ios_version]).to eq(ios_version) config[:ios_version].gsub!(".1", ".2") expect(config[:ios_version]).to eq("9.2") end end it "properly loads boolean values" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileBooleanValues') expect(config[:a_boolean]).to be(false) expect(config[:another_boolean]).to be(true) end it "ignores the same item being set after the first time" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileRepeatedValueSet') expect(config[:app_identifier]).to eq('the.expected.value') end describe "Handling invalid broken configuration files" do it "automatically corrects invalid quotations" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('./fastlane_core/spec/fixtures/ConfigInvalidQuotation') # Not raising an error, even though we have invalid quotes expect(config[:app_identifier]).to eq("net.sunapps.1") end it "properly shows an error message when there is a syntax error in the Fastfile" do config = FastlaneCore::Configuration.create(options, {}) expect do config.load_configuration_file('./fastlane_core/spec/fixtures/ConfigSyntaxError') end.to raise_error(/Syntax error in your configuration file .* on line 15/) end end describe "Prints out a table of summary" do it "shows a warning when no values were found" do expect(FastlaneCore::UI).to receive(:important).with("No values defined in './fastlane_core/spec/fixtures/ConfigFileEmpty'") config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileEmpty') end it "prints out a table of all the set values" do expect(Terminal::Table).to receive(:new).with({ rows: [[:app_identifier, "com.krausefx.app"], [:apple_id, "from_le_block"]], title: "Detected Values from './fastlane_core/spec/fixtures/ConfigFileValid'" }) config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileValid') end end it "allows using a custom block to handle special callbacks" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileUnhandledBlock', proc do |method_sym, arguments, block| if method_sym == :some_custom_block if arguments == ["parameter"] expect do block.call(arguments.first, "custom") end.to raise_error("Yeah: parameter custom") else UI.user_error!("no") end else UI.user_error!("no") end end) end describe "for_lane and for_platform support" do it "reads global keys when not specifying lane or platform" do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileForLane') expect(config[:app_identifier]).to eq("com.global.id") end it "reads global keys when platform and lane don't match" do FastlaneSpec::Env.with_env_values('FASTLANE_PLATFORM_NAME' => 'osx', 'FASTLANE_LANE_NAME' => 'debug') do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileForLane') expect(config[:app_identifier]).to eq("com.global.id") end end it "reads lane setting when platform doesn't match or no for_platform" do FastlaneSpec::Env.with_env_values('FASTLANE_PLATFORM_NAME' => 'osx', 'FASTLANE_LANE_NAME' => 'enterprise') do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileForLane') expect(config[:app_identifier]).to eq("com.forlane.enterprise") end end it "reads platform setting when lane doesn't match or no for_lane" do FastlaneSpec::Env.with_env_values('FASTLANE_PLATFORM_NAME' => 'ios', 'FASTLANE_LANE_NAME' => 'debug') do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileForLane') expect(config[:app_identifier]).to eq("com.forplatform.ios") end end it "reads platform and lane setting" do FastlaneSpec::Env.with_env_values('FASTLANE_PLATFORM_NAME' => 'ios', 'FASTLANE_LANE_NAME' => 'release') do config = FastlaneCore::Configuration.create(options, {}) config.load_configuration_file('ConfigFileForLane') expect(config[:app_identifier]).to eq("com.forplatformios.forlanerelease") end end it "allows exceptions in blocks to escape but the configuration is still intact" do FastlaneSpec::Env.with_env_values('FASTLANE_PLATFORM_NAME' => 'ios', 'FASTLANE_LANE_NAME' => 'explode') do config = FastlaneCore::Configuration.create(options, {}) expect { config.load_configuration_file('ConfigFileForLane') }.to raise_error("oh noes!") expect(config[:app_identifier]).to eq("com.forplatformios.boom") end end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/spec_helper.rb
fastlane_core/spec/spec_helper.rb
require_relative 'test_commander_program' # Necessary, as we're now running this in a different context def stub_request(*args) WebMock::API.stub_request(*args) end def before_each_fastlane_core # iTunes Lookup API by Apple ID ["invalid", "", 0, '284882215', ['338986109', 'FR']].each do |current| if current.kind_of?(Array) id = current[0] country = current[1] url = "https://itunes.apple.com/lookup?id=#{id}&country=#{country}" body_file = "fastlane_core/spec/responses/itunesLookup-#{id}_#{country}.json" else id = current url = "https://itunes.apple.com/lookup?id=#{id}" body_file = "fastlane_core/spec/responses/itunesLookup-#{id}.json" end stub_request(:get, url). with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Ruby' }). to_return(status: 200, body: File.read(body_file), headers: {}) end # iTunes Lookup API by App Identifier stub_request(:get, "https://itunes.apple.com/lookup?bundleId=com.facebook.Facebook"). with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Ruby' }). to_return(status: 200, body: File.read("fastlane_core/spec/responses/itunesLookup-com.facebook.Facebook.json"), headers: {}) stub_request(:get, "https://itunes.apple.com/lookup?bundleId=net.sunapps.invalid"). with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent' => 'Ruby' }). to_return(status: 200, body: File.read("fastlane_core/spec/responses/itunesLookup-net.sunapps.invalid.json"), headers: {}) end def stub_commander_runner_args(args) runner = Commander::Runner.new(args) allow(Commander::Runner).to receive(:instance).and_return(runner) end def capture_stds require "stringio" orig_stdout = $stdout orig_stderr = $stderr $stdout = StringIO.new $stderr = StringIO.new yield if block_given? [$stdout.string, $stderr.string] ensure $stdout = orig_stdout $stderr = orig_stderr end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/itunes_transporter_spec.rb
fastlane_core/spec/itunes_transporter_spec.rb
require 'shellwords' require 'credentials_manager' describe FastlaneCore do let(:password) { "!> p@$s_-+=w'o%rd\"&#*<" } let(:email) { 'fabric.devtools@gmail.com' } let(:jwt) { '409jjl43j90ghjqoineio49024' } let(:api_key) { { key_id: "TESTAPIK2HW", issuer_id: "11223344-1122-aabb-aabb-uuvvwwxxyyzz" } } describe FastlaneCore::ItunesTransporter do let(:random_uuid) { '2a912f38-5dbc-4fc3-a5b3-1bf184b2b021' } before(:each) do allow(SecureRandom).to receive(:uuid).and_return(random_uuid) end def shell_upload_command(provider_short_name: nil, transporter: nil, jwt: nil, use_asset_path: false, username: email, input_pass: password, api_key: nil, is_mac: true, has_appstore_info: true) upload_part = if use_asset_path "-assetFile /tmp/#{random_uuid}.ipa" elsif !is_mac && has_appstore_info # On non-macOS platforms, use -assetFile with -assetDescription for .itmsp directories "-assetFile /tmp/my.app.id.itmsp/my.app.id.ipa -assetDescription /tmp/my.app.id.itmsp/AppStoreInfo.plist" else "-f /tmp/my.app.id.itmsp" end username = username if username != email escaped_password = input_pass unless escaped_password.nil? escaped_password = escaped_password.shellescape unless FastlaneCore::Helper.windows? escaped_password = escaped_password.gsub("\\'") do "'\"\\'\"'" end escaped_password = "'#{escaped_password}'" end end [ '"' + FastlaneCore::Helper.transporter_path + '"', "-m upload", (if jwt.nil? if api_key.nil? if username.nil? || escaped_password.nil? nil else "-u #{username.shellescape} -p #{escaped_password}" end else "-apiIssuer #{api_key[:issuer_id]} -apiKey #{api_key[:key_id]}" end else "-jwt #{jwt}" end), upload_part, (transporter.to_s if transporter), "-k 100000", ("-WONoPause true" if FastlaneCore::Helper.windows?), ("-itc_provider #{provider_short_name}" if provider_short_name) ].compact.join(' ') end def shell_verify_command(provider_short_name: nil, transporter: nil, jwt: nil) escaped_password = password.shellescape unless FastlaneCore::Helper.windows? escaped_password = escaped_password.gsub("\\'") do "'\"\\'\"'" end escaped_password = "'" + escaped_password + "'" end [ '"' + FastlaneCore::Helper.transporter_path + '"', "-m verify", ("-u #{email.shellescape}" if jwt.nil?), ("-p #{escaped_password}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), "-f /tmp/my.app.id.itmsp", (transporter.to_s if transporter), ("-WONoPause true" if FastlaneCore::Helper.windows?), ("-itc_provider #{provider_short_name}" if provider_short_name) ].compact.join(' ') end def shell_download_command(provider_short_name = nil, jwt: nil) escaped_password = password.shellescape unless FastlaneCore::Helper.windows? escaped_password = escaped_password.gsub("\\'") do "'\"\\'\"'" end escaped_password = "'" + escaped_password + "'" end [ '"' + FastlaneCore::Helper.transporter_path + '"', '-m lookupMetadata', ("-u #{email.shellescape}" if jwt.nil?), ("-p #{escaped_password}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), "-apple_id my.app.id", "-destination '/tmp'", ("-itc_provider #{provider_short_name}" if provider_short_name) ].compact.join(' ') end def shell_provider_id_command(jwt: nil) # Ruby doesn't escape "+" with Shellwords.escape from 2.7 https://bugs.ruby-lang.org/issues/14429 escaped_password = if RUBY_VERSION >= "2.7.0" "'\\!\\>\\ p@\\$s_-+\\=w'\"\\'\"'o\\%rd\\\"\\&\\#\\*\\<'" else "'\\!\\>\\ p@\\$s_-\\+\\=w'\"\\'\"'o\\%rd\\\"\\&\\#\\*\\<'" end [ '"' + FastlaneCore::Helper.transporter_path + '"', "-m provider", ('-u fabric.devtools@gmail.com' if jwt.nil?), ("-p #{escaped_password}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?) ].compact.join(' ') end def altool_upload_command(api_key: nil, platform: "macos", provider_short_name: "") use_api_key = !api_key.nil? upload_part = "-f /tmp/my.app.id.itmsp" escaped_password = password.shellescape [ "xcrun altool", "--upload-app", ("-u #{email.shellescape}" unless use_api_key), ("-p #{escaped_password}" unless use_api_key), ("--apiKey #{api_key[:key_id]}" if use_api_key), ("--apiIssuer #{api_key[:issuer_id]}" if use_api_key), ("--asc-provider #{provider_short_name}" unless use_api_key || provider_short_name.to_s.empty?), ("-t #{platform}"), upload_part, "-k 100000" ].compact.join(' ') end def altool_provider_id_command(api_key: nil) use_api_key = !api_key.nil? escaped_password = password.shellescape [ "xcrun altool", "--list-providers", ("-u #{email.shellescape}" unless use_api_key), ("-p #{escaped_password}" unless use_api_key), ("--apiKey #{api_key[:key_id]}" if use_api_key), ("--apiIssuer #{api_key[:issuer_id]}" if use_api_key), "--output-format json" ].compact.join(' ') end def java_upload_command(provider_short_name: nil, transporter: nil, jwt: nil, classpath: true, use_asset_path: false) upload_part = use_asset_path ? "-assetFile /tmp/#{random_uuid}.ipa" : "-f /tmp/my.app.id.itmsp" [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', ("-classpath #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" if classpath), ('com.apple.transporter.Application' if classpath), ("-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" unless classpath), "-m upload", ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), upload_part, (transporter.to_s if transporter), "-k 100000", ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def java_verify_command(provider_short_name: nil, transporter: nil, jwt: nil, classpath: true) [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', ("-classpath #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" if classpath), ('com.apple.transporter.Application' if classpath), ("-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" unless classpath), "-m verify", ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), "-f /tmp/my.app.id.itmsp", (transporter.to_s if transporter), ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def java_download_command(provider_short_name = nil, jwt: nil, classpath: true) [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', ("-classpath #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" if classpath), ('com.apple.transporter.Application' if classpath), ("-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}" unless classpath), '-m lookupMetadata', ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), '-apple_id my.app.id', '-destination /tmp', ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def java_provider_id_command(jwt: nil) [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', "-classpath #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}", 'com.apple.transporter.Application', '-m provider', ("-u fabric.devtools@gmail.com -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" if jwt), '2>&1' ].compact.join(' ') end def java_upload_command_9(provider_short_name: nil, transporter: nil, jwt: nil, use_asset_path: false) upload_part = use_asset_path ? "-assetFile /tmp/#{random_uuid}.ipa" : "-f /tmp/my.app.id.itmsp" [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', "-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}", "-m upload", ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), upload_part, (transporter.to_s if transporter), "-k 100000", ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def java_verify_command_9(provider_short_name: nil, transporter: nil, jwt: nil) [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', "-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}", "-m verify", ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), "-f /tmp/my.app.id.itmsp", (transporter.to_s if transporter), ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def java_download_command_9(provider_short_name = nil, jwt: nil) [ FastlaneCore::Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', "-jar #{FastlaneCore::Helper.transporter_java_jar_path.shellescape}", '-m lookupMetadata', ("-u #{email.shellescape} -p #{password.shellescape}" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), '-apple_id my.app.id', '-destination /tmp', ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def xcrun_upload_command(provider_short_name: nil, transporter: nil, jwt: nil, use_asset_path: false) upload_part = use_asset_path ? "-assetFile /tmp/#{random_uuid}.ipa" : "-f /tmp/my.app.id.itmsp" [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.nil?), "xcrun iTMSTransporter", "-m upload", ("-u #{email.shellescape}" if jwt.nil?), ("-p @env:ITMS_TRANSPORTER_PASSWORD" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), upload_part, (transporter.to_s if transporter), "-k 100000", ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end def xcrun_verify_command(transporter: nil, jwt: nil) [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.nil?), "xcrun iTMSTransporter", "-m verify", ("-u #{email.shellescape}" if jwt.nil?), ("-p @env:ITMS_TRANSPORTER_PASSWORD" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), "-f /tmp/my.app.id.itmsp", '2>&1' ].compact.join(' ') end def xcrun_download_command(provider_short_name = nil, jwt: nil) [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.nil?), "xcrun iTMSTransporter", '-m lookupMetadata', ("-u #{email.shellescape}" if jwt.nil?), ("-p @env:ITMS_TRANSPORTER_PASSWORD" if jwt.nil?), ("-jwt #{jwt}" unless jwt.nil?), '-apple_id my.app.id', '-destination /tmp', ("-itc_provider #{provider_short_name}" if provider_short_name), '2>&1' ].compact.join(' ') end describe "with Xcode 7.x installed" do before(:each) do allow(FastlaneCore::Helper).to receive(:xcode_version).and_return('7.3') allow(FastlaneCore::Helper).to receive(:mac?).and_return(true) allow(FastlaneCore::Helper).to receive(:windows?).and_return(false) allow(FastlaneCore::Helper).to receive(:itms_path).and_return('/tmp') end describe "by default" do describe "with username and password" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command) end end describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" } it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(transporter: "-t DAV,Signiant")) end after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") } end describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set to empty string" do before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = " " } it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command) end after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") } end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.verify('my.app.id', '/tmp')).to eq(java_verify_command) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.download('my.app.id', '/tmp')).to eq(java_download_command) end end describe "provider ID command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new('fabric.devtools@gmail.com', "!> p@$s_-+=w'o%rd\"&#*<") expect(transporter.provider_ids).to eq(java_provider_id_command) end end end describe "with JWt" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(jwt: jwt)) end end describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" } it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(transporter: "-t DAV,Signiant", jwt: jwt)) end after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") } end describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set to empty string" do before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = " " } it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(jwt: jwt)) end after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") } end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.verify('my.app.id', '/tmp')).to eq(java_verify_command(jwt: jwt)) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.download('my.app.id', '/tmp')).to eq(java_download_command(jwt: jwt)) end end describe "provider ID command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.provider_ids).to eq(java_provider_id_command(jwt: jwt)) end end describe "with package_path" do describe "upload command generation" do it 'generates a call to xcrun iTMSTransporter' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp')).to eq(java_upload_command(jwt: jwt)) end end describe "verify command generation" do it 'generates a call to xcrun iTMSTransporter' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.verify(package_path: '/tmp/my.app.id.itmsp')).to eq(java_verify_command(jwt: jwt)) end end end describe "with asset_path" do describe "upload command generation" do it 'generates a call to xcrun iTMSTransporter' do expect(Dir).to receive(:tmpdir).and_return("/tmp") expect(FileUtils).to receive(:cp) transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload(asset_path: '/tmp/my_app.ipa')).to eq(java_upload_command(jwt: jwt, use_asset_path: true)) end end end describe "with package_path and asset_path" do describe "upload command generation" do it 'generates a call to xcrun iTMSTransporter with -assetFile' do expect(Dir).to receive(:tmpdir).and_return("/tmp") expect(FileUtils).to receive(:cp) transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp', asset_path: '/tmp/my_app.ipa')).to eq(java_upload_command(jwt: jwt, use_asset_path: true)) end end describe "upload command generation with ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD=true" do it 'generates a call to xcrun iTMSTransporter with -assetFile' do stub_const('ENV', { 'ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD' => 'true' }) transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, jwt) expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp', asset_path: '/tmp/my_app.ipa')).to eq(java_upload_command(jwt: jwt, use_asset_path: false)) end end end end end describe "use_shell_script is false with a itc_provider short name set" do describe "with username and password" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false, 'abcd1234') expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(provider_short_name: 'abcd1234')) end end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false, 'abcd1234') expect(transporter.verify('my.app.id', '/tmp')).to eq(java_verify_command(provider_short_name: 'abcd1234')) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false, 'abcd1234') expect(transporter.download('my.app.id', '/tmp')).to eq(java_download_command('abcd1234')) end end describe "provider ID command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new('fabric.devtools@gmail.com', "!> p@$s_-+=w'o%rd\"&#*<") expect(transporter.provider_ids).to eq(java_provider_id_command) end end end describe "with JWT (ignores provider id)" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, 'abcd1234', jwt) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(jwt: jwt)) end end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, 'abcd1234', jwt) expect(transporter.verify('my.app.id', '/tmp')).to eq(java_verify_command(jwt: jwt)) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, false, 'abcd1234', jwt) expect(transporter.download('my.app.id', '/tmp')).to eq(java_download_command(jwt: jwt)) end end end end describe "use_shell_script is true with a itc_provider short name set" do describe "with username and password" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true, 'abcd1234') expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command(provider_short_name: 'abcd1234')) end end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true, 'abcd1234') expect(transporter.verify('my.app.id', '/tmp')).to eq(shell_verify_command(provider_short_name: 'abcd1234')) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true, 'abcd1234') expect(transporter.download('my.app.id', '/tmp')).to eq(shell_download_command('abcd1234')) end end describe "provider ID command generation" do it 'generates a call to the shell script' do transporter = FastlaneCore::ItunesTransporter.new('fabric.devtools@gmail.com', "!> p@$s_-+=w'o%rd\"&#*<", true, 'abcd1234') expect(transporter.provider_ids).to eq(shell_provider_id_command) end end end describe "with JWT (ignores provider id)" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command(jwt: jwt)) end end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.verify('my.app.id', '/tmp')).to eq(shell_verify_command(jwt: jwt)) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.download('my.app.id', '/tmp')).to eq(shell_download_command(jwt: jwt)) end end describe "with package_path" do describe "upload command generation" do it 'generates a call to xcrun iTMSTransporter' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.upload(package_path: '/tmp/my.app.id.itmsp')).to eq(shell_upload_command(jwt: jwt)) end end describe "verify command generation" do it 'generates a call to xcrun iTMSTransporter' do transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.verify(package_path: '/tmp/my.app.id.itmsp')).to eq(shell_verify_command(jwt: jwt)) end end end describe "with asset_path" do describe "upload command generation" do it 'generates a call to xcrun iTMSTransporter' do expect(Dir).to receive(:tmpdir).and_return("/tmp") expect(FileUtils).to receive(:cp) transporter = FastlaneCore::ItunesTransporter.new(nil, nil, true, 'abcd1234', jwt) expect(transporter.upload(asset_path: '/tmp/my_app.ipa')).to eq(shell_upload_command(jwt: jwt, use_asset_path: true)) end end end end end describe "when use shell script ENV var is set" do describe "upload command generation" do it 'generates a call to the shell script' do FastlaneSpec::Env.with_env_values('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT' => 'true') do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command) end end end describe "verify command generation" do it 'generates a call to the shell script' do FastlaneSpec::Env.with_env_values('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT' => 'true') do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.verify('my.app.id', '/tmp')).to eq(shell_verify_command) end end end describe "download command generation" do it 'generates a call to the shell script' do FastlaneSpec::Env.with_env_values('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT' => 'true') do transporter = FastlaneCore::ItunesTransporter.new(email, password) expect(transporter.download('my.app.id', '/tmp')).to eq(shell_download_command) end end end describe "provider ID command generation" do it 'generates a call to the shell script' do FastlaneSpec::Env.with_env_values('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT' => 'true') do transporter = FastlaneCore::ItunesTransporter.new('fabric.devtools@gmail.com', "!> p@$s_-+=w'o%rd\"&#*<") expect(transporter.provider_ids).to eq(shell_provider_id_command) end end end end describe "use_shell_script is true" do describe "upload command generation" do it 'generates a call to the shell script' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true) expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command) end end describe "verify command generation" do it 'generates a call to the shell script' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true) expect(transporter.verify('my.app.id', '/tmp')).to eq(shell_verify_command) end end describe "download command generation" do it 'generates a call to the shell script' do transporter = FastlaneCore::ItunesTransporter.new(email, password, true) expect(transporter.download('my.app.id', '/tmp')).to eq(shell_download_command) end end describe "provider ID command generation" do it 'generates a call to the shell script' do transporter = FastlaneCore::ItunesTransporter.new('fabric.devtools@gmail.com', "!> p@$s_-+=w'o%rd\"&#*<", true) expect(transporter.provider_ids).to eq(shell_provider_id_command) end end end describe "use_shell_script is false" do describe "upload command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false) expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command) end end describe "verify command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false) expect(transporter.verify('my.app.id', '/tmp')).to eq(java_verify_command) end end describe "download command generation" do it 'generates a call to java directly' do transporter = FastlaneCore::ItunesTransporter.new(email, password, false) expect(transporter.download('my.app.id', '/tmp')).to eq(java_download_command) end end describe "provider ID command generation" do it 'generates a call to java directly' do
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
true
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/globals_spec.rb
fastlane_core/spec/globals_spec.rb
require 'spec_helper' describe FastlaneCore do describe FastlaneCore::Globals do it "Toggle verbose mode" do FastlaneCore::Globals.verbose = true expect(FastlaneCore::Globals.verbose?).to eq(true) FastlaneCore::Globals.verbose = false expect(FastlaneCore::Globals.verbose?).to eq(nil) end it "Toggle capture_mode " do FastlaneCore::Globals.capture_output = true expect(FastlaneCore::Globals.capture_output?).to eq(true) FastlaneCore::Globals.capture_output = false expect(FastlaneCore::Globals.capture_output?).to eq(nil) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/core_ext/shellwords_ext_spec.rb
fastlane_core/spec/core_ext/shellwords_ext_spec.rb
# references # normal implementation: # https://ruby-doc.org/stdlib-2.3.0/libdoc/shellwords/rdoc/Shellwords.html # https://github.com/ruby/ruby/blob/trunk/lib/shellwords.rb # "tests": # https://github.com/ruby/ruby/blob/trunk/test/test_shellwords.rb # https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/shellwords/shellwords_spec.rb # other windows implementation: # https://github.com/larskanis/shellwords/tree/master/test # shellescape shellescape_testcases = [ # baseline { 'it' => '(#1) on simple string', 'it_result' => { 'windows' => "doesn't change it", 'other' => "doesn't change it" }, 'str' => 'normal_string_without_spaces', 'expect' => { 'windows' => 'normal_string_without_spaces', 'other' => 'normal_string_without_spaces' } }, { 'it' => '(#2) on empty string', 'it_result' => { 'windows' => "wraps it in double quotes", 'other' => 'wraps it in single quotes' }, 'str' => '', 'expect' => { 'windows' => '""', 'other' => '\'\'' } }, # spaces { 'it' => '(#3) on string with spaces', 'it_result' => { 'windows' => "wraps it in double quotes", 'other' => 'escapes spaces with <backslash>' }, 'str' => 'string with spaces', 'expect' => { 'windows' => '"string with spaces"', 'other' => 'string\ with\ spaces' } }, # double quotes { 'it' => '(#4) on simple string that is already wrapped in double quotes', 'it_result' => { 'windows' => "doesn't touch it", 'other' => 'escapes the double quotes with <backslash>' }, 'str' => '"normal_string_without_spaces"', 'expect' => { 'windows' => '"normal_string_without_spaces"', 'other' => '\"normal_string_without_spaces\"' } }, { 'it' => '(#5) on string with spaces that is already wrapped in double quotes', 'it_result' => { 'windows' => "wraps in double quotes and duplicates existing double quotes", 'other' => 'escapes the double quotes and spaces with <backslash>' }, 'str' => '"string with spaces already wrapped in double quotes"', 'expect' => { 'windows' => '"""string with spaces already wrapped in double quotes"""', 'other' => '\"string\ with\ spaces\ already\ wrapped\ in\ double\ quotes\"' } }, { 'it' => '(#6) on string with spaces and double quotes', 'it_result' => { 'windows' => "wraps in double quotes and duplicates existing double quotes", 'other' => 'escapes the double quotes and spaces with <backslash>' }, 'str' => 'string with spaces and "double" quotes', 'expect' => { 'windows' => '"string with spaces and ""double"" quotes"', 'other' => 'string\ with\ spaces\ and\ \"double\"\ quotes' } }, # https://github.com/ruby/ruby/blob/ac543abe91d7325ace7254f635f34e71e1faaf2e/test/test_shellwords.rb#L64-L65 { 'it' => '(#7) on simple int', 'it_result' => { 'windows' => "doesn't change it", 'other' => "doesn't change it" }, 'str' => 3, 'expect' => { 'windows' => '3', 'other' => '3' } }, # single quotes { 'it' => '(#8) on simple string that is already wrapped in single quotes', 'it_result' => { 'windows' => "doesn't touch it", 'other' => 'escapes the single quotes with <backslash>' }, 'str' => "'normal_string_without_spaces'", 'expect' => { 'windows' => "'normal_string_without_spaces'", 'other' => "\\'normal_string_without_spaces\\'" } }, { 'it' => '(#9) on string with spaces that is already wrapped in single quotes', 'it_result' => { 'windows' => "wraps in double quotes", 'other' => 'escapes the single quotes and spaces with <backslash>' }, 'str' => "'string with spaces already wrapped in single quotes'", 'expect' => { 'windows' => "\"'string with spaces already wrapped in single quotes'\"", 'other' => "\\'string\\ with\\ spaces\\ already\\ wrapped\\ in\\ single\\ quotes\\'" } }, { 'it' => '(#10) string with spaces and single quotes', 'it_result' => { 'windows' => "wraps in double quotes and leaves single quotes", 'other' => 'escapes the single quotes and spaces with <backslash>' }, 'str' => "string with spaces and 'single' quotes", 'expect' => { 'windows' => "\"string with spaces and 'single' quotes\"", 'other' => 'string\ with\ spaces\ and\ \\\'single\\\'\ quotes' } }, { 'it' => '(#11) string with spaces and <backslash>', 'it_result' => { 'windows' => "wraps in double quotes and escapes the backslash with backslash", 'other' => 'escapes the spaces and the backslash (which in results in quite a lot of them)' }, 'str' => "string with spaces and \\ in it", 'expect' => { 'windows' => "\"string with spaces and \\ in it\"", 'other' => "string\\ with\\ spaces\\ and\\ \\\\\\ in\\ it" } }, { 'it' => '(#12) string with spaces and <slash>', 'it_result' => { 'windows' => "wraps in double quotes", 'other' => 'escapes the spaces' }, 'str' => "string with spaces and / in it", 'expect' => { 'windows' => "\"string with spaces and / in it\"", 'other' => "string\\ with\\ spaces\\ and\\ /\\ in\\ it" } }, { 'it' => '(#13) string with spaces and parens', 'it_result' => { 'windows' => "wraps in double quotes", 'other' => 'escapes the spaces and parens' }, 'str' => "string with spaces and (parens) in it", 'expect' => { 'windows' => "\"string with spaces and (parens) in it\"", 'other' => "string\\ with\\ spaces\\ and\\ \\(parens\\)\\ in\\ it" } }, { 'it' => '(#14) string with spaces, single quotes and parens', 'it_result' => { 'windows' => "wraps in double quotes", 'other' => 'escapes the spaces, single quotes and parens' }, 'str' => "string with spaces and 'quotes' (and parens) in it", 'expect' => { 'windows' => "\"string with spaces and 'quotes' (and parens) in it\"", 'other' => "string\\ with\\ spaces\\ and\\ \\'quotes\\'\\ \\(and\\ parens\\)\\ in\\ it" } } ] # test shellescape Windows implementation directly describe "WindowsShellwords#shellescape" do os = 'windows' shellescape_testcases.each do |testcase| it testcase['it'] + ': ' + testcase['it_result'][os] do str = testcase['str'] escaped = WindowsShellwords.shellescape(str) expect(escaped).to eq(testcase['expect'][os]) confirm_shell_unescapes_string_correctly(str, escaped) end end end # confirms that the escaped string that is generated actually # gets turned back into the source string by the actual shell. # abuses a `grep` (or `find`) error message because that should be cross platform def confirm_shell_unescapes_string_correctly(string, escaped) compare_string = string.to_s.dup if FastlaneCore::CommandExecutor.which('grep') if FastlaneCore::Helper.windows? compare_string = simulate_windows_shell_unwrapping(compare_string) else compare_string = simulate_normal_shell_unwrapping(compare_string) end compare_command = "grep 'foo' #{escaped}" expected_compare_error = "grep: " + compare_string + ": No such file or directory" elsif FastlaneCore::CommandExecutor.which('find') compare_string = simulate_normal_shell_unwrapping(compare_string) compare_string = compare_string.upcase compare_command = "find \"foo\" #{escaped}" expected_compare_error = "File not found - " + compare_string end # https://stackoverflow.com/a/18623297/252627, last variant require 'open3' Open3.popen3(compare_command) do |stdin, stdout, stderr, thread| error = stderr.read.chomp # expect(error).to eq(expected_compare_error) expect(error).to eq(expected_compare_error) # match(/#{expected_compare_error}/) end end # remove (double and single) quote pairs # un-double-double quote resulting string def simulate_windows_shell_unwrapping(string) regex = /^("|')(([^"])(\S*)([^"]))("|')$/ unless string.to_s.match(regex).nil? string = string.to_s.match(regex)[2] # get only part in quotes string.to_s.gsub!('""', '"') # remove doubled double quotes end return string end # remove all double quotes completely def simulate_normal_shell_unwrapping(string) string.gsub!('"', '') regex = /^(')(\S*)(')$/ unless string.to_s.match(regex).nil? string = string.to_s.match(regex)[2] # get only part in quotes end return string end # test monkey patched method on both (simulated) OSes describe "monkey patch of String.shellescape (via CrossplatformShellwords)" do describe "on Windows" do before(:each) do allow(FastlaneCore::Helper).to receive(:windows?).and_return(true) end os = 'windows' shellescape_testcases.each do |testcase| it testcase['it'] + ': ' + testcase['it_result'][os] do str = testcase['str'].to_s expect_correct_implementation_to_be_called(str, :shellescape, os) escaped = str.shellescape expect(escaped).to eq(testcase['expect'][os]) end end end describe "on other OSs (macOS, Linux)" do before(:each) do allow(FastlaneCore::Helper).to receive(:windows?).and_return(false) end os = 'other' shellescape_testcases.each do |testcase| it testcase['it'] + ': ' + testcase['it_result'][os] do str = testcase['str'].to_s expect_correct_implementation_to_be_called(str, :shellescape, os) escaped = str.shellescape expect(escaped).to eq(testcase['expect'][os]) end end end end # shelljoin # based on (reversal of) https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/shellwords/shellwords_spec.rb shelljoin_testcases = [ { 'it' => '(#1) on array with entry with space', 'it_result' => { 'windows' => 'wraps this entry in double quotes', 'other' => 'escapes the space in this entry' }, 'input' => ['a', 'b c', 'd'], 'expect' => { 'windows' => 'a "b c" d', 'other' => 'a b\ c d' } }, { 'it' => '(#2) on array with entry with string wrapped in double quotes and space', 'it_result' => { 'windows' => 'wraps the entry with space in quote, and doubles the double quotes', 'other' => 'escapes the double quotes and escapes the space' }, 'input' => ['a', '"b" c', 'd'], 'expect' => { 'windows' => 'a """b"" c" d', 'other' => 'a \"b\"\ c d' } }, { 'it' => '(#3) on array with entry with string wrapped in single quotes and space', 'it_result' => { 'windows' => 'no changes', 'other' => 'escapes the single quotes and space' }, 'input' => ['a', "'b' c", 'd'], 'expect' => { 'windows' => "a \"'b' c\" d", 'other' => "a \\'b\\'\\ c d" } }, # https://github.com/ruby/ruby/blob/ac543abe91d7325ace7254f635f34e71e1faaf2e/test/test_shellwords.rb#L67-L68 { 'it' => '(#4) on array with entry that is `$$`', 'it_result' => { 'windows' => 'the result includes the process id', 'other' => 'the result includes the process id' }, 'input' => ['ps', '-p', $$], 'expect' => { 'windows' => "ps -p #{$$}", 'other' => "ps -p #{$$}" } } ] describe "monkey patch of Array.shelljoin (via CrossplatformShellwords)" do describe "on Windows" do before(:each) do allow(FastlaneCore::Helper).to receive(:windows?).and_return(true) end os = 'windows' shelljoin_testcases.each do |testcase| it testcase['it'] + ': ' + testcase['it_result'][os] do array = testcase['input'] expect_correct_implementation_to_be_called(array, :shelljoin, os) joined = array.shelljoin expect(joined).to eq(testcase['expect'][os]) end end end describe "on other OSs (macOS, Linux)" do before(:each) do allow(FastlaneCore::Helper).to receive(:windows?).and_return(false) end os = 'other' shelljoin_testcases.each do |testcase| it testcase['it'] + ': ' + testcase['it_result'][os] do array = testcase['input'] expect_correct_implementation_to_be_called(array, :shelljoin, os) joined = array.shelljoin expect(joined).to eq(testcase['expect'][os]) end end end end def expect_correct_implementation_to_be_called(obj, method, os) if method == :shellescape # String.shellescape => CrossplatformShellwords.shellescape => ... expect(obj).to receive(:shellescape).and_call_original expect(CrossplatformShellwords).to receive(:shellescape).with(obj).and_call_original if os == 'windows' # WindowsShellwords.shellescape expect(WindowsShellwords).to receive(:shellescape).with(obj).and_call_original expect(Shellwords).not_to(receive(:escape)) else # Shellwords.escape expect(Shellwords).to receive(:escape).with(obj).and_call_original expect(WindowsShellwords).not_to(receive(:shellescape)) end elsif method == :shelljoin # Array.shelljoin => CrossplatformShellwords.shelljoin => CrossplatformShellwords.shellescape ... expect(obj).to receive(:shelljoin).and_call_original expect(CrossplatformShellwords).to receive(:shelljoin).with(obj).and_call_original expect(CrossplatformShellwords).to receive(:shellescape).at_least(:once).and_call_original end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/spec/core_ext/cfpropertylist_ext_spec.rb
fastlane_core/spec/core_ext/cfpropertylist_ext_spec.rb
require "fastlane_core/core_ext/cfpropertylist" describe "Extension to CFPropertyList" do let(:array) { [1, 2, 3] } let(:hash) { ["key" => "value"] } it "adds a #to_binary_plist method to Array" do expect(array).to respond_to(:to_binary_plist) end it "adds a #to_binary_plist method to Hash" do expect(hash).to respond_to(:to_binary_plist) end it "produces an XML plist from an Array" do new_data = Plist.parse_xml(array.to_plist) expect(new_data).to eq(array) end it "produces an XML plist from a Hash" do new_data = Plist.parse_xml(hash.to_plist) expect(new_data).to eq(hash) end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core.rb
fastlane_core/lib/fastlane_core.rb
require_relative 'fastlane_core/globals' # Ruby monkey-patches - should be before almost all else require_relative 'fastlane_core/core_ext/string' require_relative 'fastlane_core/core_ext/shellwords' require_relative 'fastlane_core/analytics/action_completion_context' require_relative 'fastlane_core/analytics/action_launch_context' require_relative 'fastlane_core/analytics/analytics_event_builder' require_relative 'fastlane_core/analytics/analytics_ingester_client' require_relative 'fastlane_core/analytics/analytics_session' require_relative 'fastlane_core/build_watcher' require_relative 'fastlane_core/cert_checker' require_relative 'fastlane_core/clipboard' require_relative 'fastlane_core/command_executor' require_relative 'fastlane_core/configuration/configuration' require_relative 'fastlane_core/device_manager' require_relative 'fastlane_core/env' require_relative 'fastlane_core/fastlane_folder' require_relative 'fastlane_core/fastlane_pty' require_relative 'fastlane_core/feature/feature' require_relative 'fastlane_core/features' require_relative 'fastlane_core/helper' require_relative 'fastlane_core/ipa_file_analyser' require_relative 'fastlane_core/ipa_upload_package_builder' require_relative 'fastlane_core/itunes_transporter' require_relative 'fastlane_core/keychain_importer' require_relative 'fastlane_core/languages' require_relative 'fastlane_core/pkg_file_analyser' require_relative 'fastlane_core/pkg_upload_package_builder' require_relative 'fastlane_core/print_table' require_relative 'fastlane_core/project' require_relative 'fastlane_core/provisioning_profile' require_relative 'fastlane_core/queue_worker' require_relative 'fastlane_core/swag' require_relative 'fastlane_core/tag_version' require_relative 'fastlane_core/test_parser' require_relative 'fastlane_core/ui/errors' require_relative 'fastlane_core/ui/ui' require_relative 'fastlane_core/update_checker/update_checker' # Third Party code require 'colored' require 'commander' # after commander import require_relative 'fastlane_core/ui/fastlane_runner' # monkey patch require_relative 'fastlane_core/module'
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/fastlane_pty.rb
fastlane_core/lib/fastlane_core/fastlane_pty.rb
# Source: Mix of https://github.com/fastlane/fastlane/pull/7202/files, # https://github.com/fastlane/fastlane/pull/11384#issuecomment-356084518 and # https://github.com/DragonBox/u3d/blob/59e471ad78ac00cb629f479dbe386c5ad2dc5075/lib/u3d_core/command_runner.rb#L88-L96 class StandardError def exit_status return -1 end end module FastlaneCore class FastlanePtyError < StandardError attr_reader :exit_status, :process_status def initialize(e, exit_status, process_status) super(e) set_backtrace(e.backtrace) if e @exit_status = exit_status @process_status = process_status end end class FastlanePty def self.spawn(command, &block) spawn_with_pty(command, &block) rescue LoadError spawn_with_popen(command, &block) end def self.spawn_with_pty(original_command, &block) require 'pty' # this forces the PTY flush - fixes #21792 command = ENV['FASTLANE_EXEC_FLUSH_PTY_WORKAROUND'] ? "#{original_command};" : original_command PTY.spawn(command) do |command_stdout, command_stdin, pid| begin yield(command_stdout, command_stdin, pid) rescue Errno::EIO # Exception ignored intentionally. # https://stackoverflow.com/questions/10238298/ruby-on-linux-pty-goes-away-without-eof-raises-errnoeio # This is expected on some linux systems, that indicates that the subcommand finished # and we kept trying to read, ignore it ensure command_stdin.close command_stdout.close begin Process.wait(pid) rescue Errno::ECHILD, PTY::ChildExited # The process might have exited. end end end status = self.process_status raise StandardError, "Process crashed" if status.signaled? status.exitstatus rescue StandardError => e # Wrapping any error in FastlanePtyError to allow callers to see and use # $?.exitstatus that would usually get returned status = self.process_status raise FastlanePtyError.new(e, status.exitstatus || e.exit_status, status) end def self.spawn_with_popen(command, &block) status = nil require 'open3' Open3.popen2e(command) do |command_stdin, command_stdout, p| # note the inversion status = p.value yield(command_stdout, command_stdin, status.pid) command_stdin.close command_stdout.close raise StandardError, "Process crashed" if status.signaled? status.exitstatus end rescue StandardError => e # Wrapping any error in FastlanePtyError to allow callers to see and use # $?.exitstatus that would usually get returned raise FastlanePtyError.new(e, status.exitstatus || e.exit_status, status) end # to ease mocking def self.process_status $? end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
fastlane_core/lib/fastlane_core/ipa_file_analyser.rb
require 'open3' require 'stringio' require 'zip' require_relative 'core_ext/cfpropertylist' require_relative 'ui/ui' module FastlaneCore class IpaFileAnalyser # Fetches the app identifier (e.g. com.facebook.Facebook) from the given ipa file. def self.fetch_app_identifier(path) plist = self.fetch_info_plist_file(path) return plist['CFBundleIdentifier'] if plist return nil end # Fetches the app version from the given ipa file. def self.fetch_app_version(path) plist = self.fetch_info_plist_file(path) return plist['CFBundleShortVersionString'] if plist return nil end # Fetches the app build number from the given ipa file. def self.fetch_app_build(path) plist = self.fetch_info_plist_file(path) return plist['CFBundleVersion'] if plist return nil end # Fetches the app platform from the given ipa file. def self.fetch_app_platform(path) plist = self.fetch_info_plist_file(path) platform = "ios" platform = plist['DTPlatformName'] if plist platform = "ios" if platform == "iphoneos" # via https://github.com/fastlane/fastlane/issues/3484 return platform end def self.fetch_info_plist_file(path) UI.user_error!("Could not find file at path '#{path}'") unless File.exist?(path) plist_data = self.fetch_info_plist_with_rubyzip(path) if plist_data.nil? # Xcode produces invalid zip files for IPAs larger than 4GB. RubyZip # can't read them, but the unzip command is able to work around this. plist_data = self.fetch_info_plist_with_unzip(path) end return nil if plist_data.nil? result = CFPropertyList.native_types(CFPropertyList::List.new(data: plist_data).value) if result['CFBundleIdentifier'] || result['CFBundleVersion'] return result end return nil end def self.fetch_info_plist_with_rubyzip(path) Zip::File.open(path, "rb") do |zipfile| file = zipfile.glob('**/Payload/*.app/Info.plist').first return nil unless file zipfile.read(file) end end def self.fetch_info_plist_with_unzip(path) entry, error, = Open3.capture3("unzip", "-Z", "-1", path, "*Payload/*.app/Info.plist") # unzip can return multiple Info.plist files if is an embedded app bundle (a WatchKit app) # - ContainsWatchApp/Payload/Sample.app/Watch/Sample WatchKit App.app/Info.plist # - ContainsWatchApp/Payload/Sample.app/Info.plist # # we can determine the main Info.plist by the shortest path entry = entry.lines.map(&:chomp).min_by(&:size) UI.command_output(error) unless error.empty? return nil if entry.nil? || entry.empty? data, error, = Open3.capture3("unzip", "-p", path, entry) UI.command_output(error) unless error.empty? return nil if data.empty? data end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/fastlane_folder.rb
fastlane_core/lib/fastlane_core/fastlane_folder.rb
require_relative 'ui/ui' module FastlaneCore class FastlaneFolder FOLDER_NAME = 'fastlane' # Path to the fastlane folder containing the Fastfile and other configuration files def self.path value ||= "./#{FOLDER_NAME}/" if File.directory?("./#{FOLDER_NAME}/") value ||= "./.#{FOLDER_NAME}/" if File.directory?("./.#{FOLDER_NAME}/") # hidden folder value ||= "./" if File.basename(Dir.getwd) == FOLDER_NAME && File.exist?('Fastfile.swift') # inside the folder value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Fastfile.swift') # inside the folder and hidden value ||= "./" if File.basename(Dir.getwd) == FOLDER_NAME && File.exist?('Fastfile') # inside the folder value ||= "./" if File.basename(Dir.getwd) == ".#{FOLDER_NAME}" && File.exist?('Fastfile') # inside the folder and hidden return value end # path to the Swift runner executable if it has been built def self.swift_runner_path return File.join(self.path, 'FastlaneRunner') end def self.swift? return false unless self.fastfile_path return self.fastfile_path.downcase.end_with?(".swift") end def self.swift_folder_path return File.join(self.path, 'swift') end def self.swift_runner_project_path return File.join(self.swift_folder_path, 'FastlaneSwiftRunner', 'FastlaneSwiftRunner.xcodeproj') end def self.swift_runner_built? swift_runner_path = self.swift_runner_path if swift_runner_path.nil? return false end return File.exist?(swift_runner_path) end # Path to the Fastfile inside the fastlane folder. This is nil when none is available def self.fastfile_path return nil if self.path.nil? # Check for Swift first, because Swift is #1 path = File.join(self.path, 'Fastfile.swift') return path if File.exist?(path) path = File.join(self.path, 'Fastfile') return path if File.exist?(path) return nil end # Does a fastlane configuration already exist? def self.setup? return false unless self.fastfile_path File.exist?(self.fastfile_path) end def self.create_folder!(path = nil) path = File.join(path || '.', FOLDER_NAME) return if File.directory?(path) # directory is already there UI.user_error!("Found a file called 'fastlane' at path '#{path}', please delete it") if File.exist?(path) FileUtils.mkdir_p(path) UI.success("Created new folder '#{path}'.") end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/project.rb
fastlane_core/lib/fastlane_core/project.rb
require_relative 'helper' require 'xcodeproj' require_relative './configuration/configuration' require 'fastlane_core/command_executor' module FastlaneCore # Represents an Xcode project class Project # rubocop:disable Metrics/ClassLength class << self # Project discovery def detect_projects(config) if config[:workspace].to_s.length > 0 && config[:project].to_s.length > 0 UI.user_error!("You can only pass either a workspace or a project path, not both") end return if config[:project].to_s.length > 0 if config[:workspace].to_s.length == 0 workspace = Dir["./*.xcworkspace"] if workspace.count > 1 puts("Select Workspace: ") config[:workspace] = choose(*workspace) elsif !workspace.first.nil? config[:workspace] = workspace.first end end return if config[:workspace].to_s.length > 0 if config[:workspace].to_s.length == 0 && config[:project].to_s.length == 0 project = Dir["./*.xcodeproj"] if project.count > 1 puts("Select Project: ") config[:project] = choose(*project) elsif !project.first.nil? config[:project] = project.first end end if config[:workspace].nil? && config[:project].nil? select_project(config) end end def select_project(config) loop do path = UI.input("Couldn't automatically detect the project file, please provide a path: ") if File.directory?(path) if path.end_with?(".xcworkspace") config[:workspace] = path break elsif path.end_with?(".xcodeproj") config[:project] = path break else UI.error("Path must end with either .xcworkspace or .xcodeproj") end else UI.error("Couldn't find project at path '#{File.expand_path(path)}'") end end end end # Path to the project/workspace attr_accessor :path # Is this project a workspace? attr_accessor :is_workspace # @param options [FastlaneCore::Configuration|Hash] a set of configuration to run xcodebuild to work out build settings # @param xcodebuild_list_silent [Boolean] a flag to silent xcodebuild command's output # @param xcodebuild_suppress_stderr [Boolean] a flag to suppress output to stderr from xcodebuild def initialize(options) @options = options @path = File.expand_path(self.options[:workspace] || self.options[:project]) @is_workspace = (self.options[:workspace].to_s.length > 0) if !path || !File.directory?(path) UI.user_error!("Could not find project at path '#{path}'") end end # @return [Hash] a hash object containing project, workspace, scheme, any configuration related to xcodebuild, or etc... def options # To keep compatibility with actions using this class from outside of `fastlane` gem; i.e. `xcov`, # converts `options` to a plain Hash. Otherwise, it might crash when a new option's key is added # due to `FastlaneCore::Configuration` to validate valid keys defined. @options.kind_of?(FastlaneCore::Configuration) ? @options.values : @options end def options=(new_value) UI.deprecated('Update `options` is not worth doing since it can change behavior of this object entirely. Consider re-creating FastlaneCore::Project.') @options = new_value end def workspace? self.is_workspace end def project_name if is_workspace return File.basename(options[:workspace], ".xcworkspace") else return File.basename(options[:project], ".xcodeproj") end end # returns the Xcodeproj::Workspace or nil if it is a project def workspace return nil unless workspace? @workspace ||= Xcodeproj::Workspace.new_from_xcworkspace(path) @workspace end # returns the Xcodeproj::Project or nil if it is a workspace def project return nil if workspace? @project ||= Xcodeproj::Project.open(path) end # Get all available schemes in an array def schemes @schemes ||= if workspace? if FastlaneCore::Env.truthy?("FASTLANE_INCLUDE_PODS_PROJECT_SCHEMES") workspace.schemes.keys else workspace.schemes.reject do |k, v| v.include?("Pods/Pods.xcodeproj") end.keys end else Xcodeproj::Project.schemes(path) end end # Let the user select a scheme # Use a scheme containing the preferred_to_include string when multiple schemes were found def select_scheme(preferred_to_include: nil) if options[:scheme].to_s.length > 0 # Verify the scheme is available unless schemes.include?(options[:scheme].to_s) UI.error("Couldn't find specified scheme '#{options[:scheme]}'. Please make sure that the scheme is shared, see https://developer.apple.com/library/content/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/ConfigureBots.html#//apple_ref/doc/uid/TP40013292-CH9-SW3") options[:scheme] = nil end end return if options[:scheme].to_s.length > 0 if schemes.count == 1 options[:scheme] = schemes.last elsif schemes.count > 1 preferred = nil if preferred_to_include preferred = schemes.find_all { |a| a.downcase.include?(preferred_to_include.downcase) } end if preferred_to_include && preferred.count == 1 options[:scheme] = preferred.last elsif automated_scheme_selection? && schemes.include?(project_name) UI.important("Using scheme matching project name (#{project_name}).") options[:scheme] = project_name elsif Helper.ci? UI.error("Multiple schemes found but you haven't specified one.") UI.error("Since this is a CI, please pass one using the `scheme` option") show_scheme_shared_information UI.user_error!("Multiple schemes found") else puts("Select Scheme: ") options[:scheme] = choose(*schemes) end else show_scheme_shared_information UI.user_error!("No Schemes found") end end def show_scheme_shared_information UI.error("Couldn't find any schemes in this project, make sure that the scheme is shared if you are using a workspace") UI.error("Open Xcode, click on `Manage Schemes` and check the `Shared` box for the schemes you want to use") UI.error("Afterwards make sure to commit the changes into version control") end # Get all available configurations in an array def configurations @configurations ||= if workspace? workspace .file_references .map(&:path) .reject { |p| p.include?("Pods/Pods.xcodeproj") } .map do |p| # To maintain backwards compatibility, we # silently ignore nonexistent projects from # workspaces. begin Xcodeproj::Project.open(p).build_configurations rescue [] end end .flatten .compact .map(&:name) else project.build_configurations.map(&:name) end end # Returns bundle_id and sets the scheme for xcrun def default_app_identifier default_build_settings(key: "PRODUCT_BUNDLE_IDENTIFIER") end # Returns app name and sets the scheme for xcrun def default_app_name if is_workspace return default_build_settings(key: "PRODUCT_NAME") else return app_name end end def app_name # WRAPPER_NAME: Example.app # WRAPPER_SUFFIX: .app name = build_settings(key: "WRAPPER_NAME") return name.gsub(build_settings(key: "WRAPPER_SUFFIX"), "") if name return "App" # default value end def dynamic_library? (build_settings(key: "PRODUCT_TYPE") == "com.apple.product-type.library.dynamic") end def static_library? (build_settings(key: "PRODUCT_TYPE") == "com.apple.product-type.library.static") end def library? (static_library? || dynamic_library?) end def framework? (build_settings(key: "PRODUCT_TYPE") == "com.apple.product-type.framework") end def application? (build_settings(key: "PRODUCT_TYPE") == "com.apple.product-type.application") end def ios_library? ((static_library? or dynamic_library?) && build_settings(key: "PLATFORM_NAME") == "iphoneos") end def ios_tvos_app? (ios? || tvos?) end def ios_framework? (framework? && build_settings(key: "PLATFORM_NAME") == "iphoneos") end def ios_app? (application? && build_settings(key: "PLATFORM_NAME") == "iphoneos") end def produces_archive? !(framework? || static_library? || dynamic_library?) end def mac_app? (application? && build_settings(key: "PLATFORM_NAME") == "macosx") end def mac_library? ((dynamic_library? or static_library?) && build_settings(key: "PLATFORM_NAME") == "macosx") end def mac_framework? (framework? && build_settings(key: "PLATFORM_NAME") == "macosx") end def supports_mac_catalyst? build_settings(key: "SUPPORTS_MACCATALYST") == "YES" || build_settings(key: "SUPPORTS_UIKITFORMAC") == "YES" end def command_line_tool? (build_settings(key: "PRODUCT_TYPE") == "com.apple.product-type.tool") end def mac? supported_platforms.include?(:macOS) end def tvos? supported_platforms.include?(:tvOS) end def ios? supported_platforms.include?(:iOS) end def watchos? supported_platforms.include?(:watchOS) end def visionos? supported_platforms.include?(:visionOS) end def multiplatform? supported_platforms.count > 1 end def supported_platforms supported_platforms = build_settings(key: "SUPPORTED_PLATFORMS") if supported_platforms.nil? UI.important("Could not read the \"SUPPORTED_PLATFORMS\" build setting, assuming that the project supports iOS only.") return [:iOS] end supported_platforms.split.map do |platform| case platform when "macosx" then :macOS when "iphonesimulator", "iphoneos" then :iOS when "watchsimulator", "watchos" then :watchOS when "appletvsimulator", "appletvos" then :tvOS when "xros", "xrsimulator" then :visionOS end end.uniq.compact end def xcodebuild_parameters proj = [] proj << "-workspace #{options[:workspace].shellescape}" if options[:workspace] proj << "-scheme #{options[:scheme].shellescape}" if options[:scheme] proj << "-project #{options[:project].shellescape}" if options[:project] proj << "-configuration #{options[:configuration].shellescape}" if options[:configuration] proj << "-derivedDataPath #{options[:derived_data_path].shellescape}" if options[:derived_data_path] proj << "-xcconfig #{options[:xcconfig].shellescape}" if options[:xcconfig] proj << "-scmProvider system" if options[:use_system_scm] proj << "-packageAuthorizationProvider #{options[:package_authorization_provider].shellescape}" if options[:package_authorization_provider] xcode_at_least_11 = FastlaneCore::Helper.xcode_at_least?('11.0') if xcode_at_least_11 && options[:cloned_source_packages_path] proj << "-clonedSourcePackagesDirPath #{options[:cloned_source_packages_path].shellescape}" end if xcode_at_least_11 && options[:package_cache_path] proj << "-packageCachePath #{options[:package_cache_path].shellescape}" end if xcode_at_least_11 && options[:disable_package_automatic_updates] proj << "-disableAutomaticPackageResolution" end return proj end ##################################################### # @!group Raw Access ##################################################### def build_xcodebuild_showbuildsettings_command # We also need to pass the workspace and scheme to this command. # # The 'clean' portion of this command was a workaround for an xcodebuild bug with Core Data projects. # This xcodebuild bug is fixed in Xcode 8.3 so 'clean' it's not necessary anymore # See: https://github.com/fastlane/fastlane/pull/5626 if FastlaneCore::Helper.xcode_at_least?('8.3') command = "xcodebuild -showBuildSettings #{xcodebuild_parameters.join(' ')}#{xcodebuild_destination_parameter}" else command = "xcodebuild clean -showBuildSettings #{xcodebuild_parameters.join(' ')}" end command = "#{command} 2>&1" # xcodebuild produces errors on stderr #21672 command end def build_xcodebuild_resolvepackagedependencies_command return nil if options[:skip_package_dependencies_resolution] command = "xcodebuild -resolvePackageDependencies #{xcodebuild_parameters.join(' ')}#{xcodebuild_destination_parameter}" command end def xcodebuild_destination_parameter # Xcode13+ xcodebuild command 'without destination parameter' generates annoying warnings # See: https://github.com/fastlane/fastlane/issues/19579 destination_parameter = "" xcode_at_least_13 = FastlaneCore::Helper.xcode_at_least?("13") if xcode_at_least_13 && options[:destination] begin destination_parameter = " " + "-destination #{options[:destination].shellescape}" rescue => ex # xcodebuild command can continue without destination parameter, so # we really don't care about this exception if something goes wrong with shellescape UI.important("Failed to set destination parameter for xcodebuild command: #{ex}") end end destination_parameter end # Get the build settings for our project # e.g. to properly get the DerivedData folder # @param [String] The key of which we want the value for (e.g. "PRODUCT_NAME") def build_settings(key: nil, optional: true) unless @build_settings if is_workspace if schemes.count == 0 UI.user_error!("Could not find any schemes for Xcode workspace at path '#{self.path}'. Please make sure that the schemes you want to use are marked as `Shared` from Xcode.") end options[:scheme] ||= schemes.first end # SwiftPM support if FastlaneCore::Helper.xcode_at_least?('11.0') if (command = build_xcodebuild_resolvepackagedependencies_command) UI.important("Resolving Swift Package Manager dependencies...") FastlaneCore::CommandExecutor.execute( command: command, print_all: true, print_command: true ) else UI.important("Skipped Swift Package Manager dependencies resolution.") end end command = build_xcodebuild_showbuildsettings_command # Xcode might hang here and retrying fixes the problem, see fastlane#4059 begin timeout = FastlaneCore::Project.xcode_build_settings_timeout retries = FastlaneCore::Project.xcode_build_settings_retries @build_settings = FastlaneCore::Project.run_command(command, timeout: timeout, retries: retries, print: true) if @build_settings.empty? UI.error("Could not read build settings. Make sure that the scheme \"#{options[:scheme]}\" is configured for running by going to Product → Scheme → Edit Scheme…, selecting the \"Build\" section, checking the \"Run\" checkbox and closing the scheme window.") end rescue Timeout::Error raise FastlaneCore::Interface::FastlaneDependencyCausedException.new, "xcodebuild -showBuildSettings timed out after #{retries + 1} retries with a base timeout of #{timeout}." \ " You can override the base timeout value with the environment variable FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT," \ " and the number of retries with the environment variable FASTLANE_XCODEBUILD_SETTINGS_RETRIES ".red end end begin result = @build_settings.split("\n").find do |c| sp = c.split(" = ") next if sp.length == 0 sp.first.strip == key end return result.split(" = ").last rescue => ex return nil if optional # an optional value, we really don't care if something goes wrong UI.error(caller.join("\n\t")) UI.error("Could not fetch #{key} from project file: #{ex}") end nil end # Returns the build settings and sets the default scheme to the options hash def default_build_settings(key: nil, optional: true) options[:scheme] ||= schemes.first if is_workspace build_settings(key: key, optional: optional) end # @internal to module def self.xcode_build_settings_timeout (ENV['FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT'] || 3).to_i end # @internal to module def self.xcode_build_settings_retries (ENV['FASTLANE_XCODEBUILD_SETTINGS_RETRIES'] || 3).to_i end # @internal to module # runs the specified command with the specified number of retries, killing each run if it times out. # the first run times out after specified timeout elapses, and each successive run times out after # a doubling of the previous timeout has elapsed. # @raises Timeout::Error if all tries result in a timeout # @returns the output of the command # Note: - currently affected by https://github.com/fastlane/fastlane/issues/1504 # - retry feature added to solve https://github.com/fastlane/fastlane/issues/4059 def self.run_command(command, timeout: 0, retries: 0, print: true) require 'timeout' UI.command(command) if print result = '' total_tries = retries + 1 try = 1 try_timeout = timeout begin Timeout.timeout(try_timeout) do # Using Helper.backticks didn't work here. `Timeout` doesn't time out, and the command hangs forever result = `#{command}`.to_s end rescue Timeout::Error try_limit_reached = try >= total_tries # Try harder on each iteration next_timeout = try_timeout * 2 message = "Command timed out after #{try_timeout} seconds on try #{try} of #{total_tries}" message += ", trying again with a #{next_timeout} second timeout..." unless try_limit_reached UI.important(message) raise if try_limit_reached try += 1 try_timeout = next_timeout retry end return result end # Array of paths to all project files # (might be multiple, because of workspaces) def project_paths return @_project_paths if @_project_paths if self.workspace? # Find the xcodeproj file, as the information isn't included in the workspace file # We have a reference to the workspace, let's find the xcodeproj file # Use Xcodeproj gem here to # * parse the contents.xcworkspacedata XML file # * handle different types (group:, container: etc.) of file references and their paths # for details see https://github.com/CocoaPods/Xcodeproj/blob/e0287156d426ba588c9234bb2a4c824149889860/lib/xcodeproj/workspace/file_reference.rb``` workspace_dir_path = File.expand_path("..", self.path) file_references_paths = workspace.file_references.map { |fr| fr.absolute_path(workspace_dir_path) } @_project_paths = file_references_paths.select do |current_match| # Xcode workspaces can contain loose files now, so let's filter non-xcodeproj files. current_match.end_with?(".xcodeproj") end.reject do |current_match| # We're not interested in a `Pods` project, as it doesn't contain any relevant information about code signing current_match.end_with?("Pods/Pods.xcodeproj") end return @_project_paths else # Return the path as an array return @_project_paths = [path] end end private # If scheme not specified, do we want the scheme # matching project name? def automated_scheme_selection? FastlaneCore::Env.truthy?("AUTOMATED_SCHEME_SELECTION") end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/provisioning_profile.rb
fastlane_core/lib/fastlane_core/provisioning_profile.rb
require_relative 'ui/ui' module FastlaneCore class ProvisioningProfile class << self # @return (Hash) The hash with the data of the provisioning profile # @example # {"AppIDName"=>"My App Name", # "ApplicationIdentifierPrefix"=>["5A997XSAAA"], # "CreationDate"=>#<DateTime: 2015-05-24T20:38:03+00:00 ((2457167j,74283s,0n),+0s,2299161j)>, # "DeveloperCertificates"=>[#<StringIO:0x007f944b9666f8>], # "Entitlements"=> # {"keychain-access-groups"=>["5A997XSAAA.*"], # "get-task-allow"=>false, # "application-identifier"=>"5A997XAAA.net.sunapps.192", # "com.apple.developer.team-identifier"=>"5A997XAAAA", # "aps-environment"=>"production", # "beta-reports-active"=>true}, # "ExpirationDate"=>#<DateTime: 2015-11-25T22:45:50+00:00 ((2457352j,81950s,0n),+0s,2299161j)>, # "Name"=>"net.sunapps.192 AppStore", # "TeamIdentifier"=>["5A997XSAAA"], # "TeamName"=>"SunApps GmbH", # "TimeToLive"=>185, # "UUID"=>"1752e382-53bd-4910-a393-aaa7de0005ad", # "Version"=>1} def parse(path, keychain_path = nil) require 'plist' plist = Plist.parse_xml(decode(path, keychain_path)) if (plist || []).count > 5 plist else UI.crash!("Error parsing provisioning profile at path '#{path}'") end end # @return [String] The UUID of the given provisioning profile def uuid(path, keychain_path = nil) parse(path, keychain_path).fetch("UUID") end # @return [String] The Name of the given provisioning profile def name(path, keychain_path = nil) parse(path, keychain_path).fetch("Name") end def bundle_id(path, keychain_path = nil) profile = parse(path, keychain_path) app_id_prefix = profile["ApplicationIdentifierPrefix"].first entitlements = profile["Entitlements"] app_identifier = entitlements["application-identifier"] || entitlements["com.apple.application-identifier"] bundle_id = app_identifier.gsub("#{app_id_prefix}.", "") bundle_id rescue UI.error("Unable to extract the Bundle Id from the provided provisioning profile '#{path}'.") end def mac?(path, keychain_path = nil) parse(path, keychain_path).fetch("Platform", []).include?('OSX') end def profile_filename(path, keychain_path = nil) basename = uuid(path, keychain_path) basename + profile_extension(path, keychain_path) end def profile_extension(path, keychain_path = nil) if mac?(path, keychain_path) ".provisionprofile" else ".mobileprovision" end end def profiles_path path = File.expand_path("~") # Xcode 16 has a new location for provisioning profiles. if FastlaneCore::Helper.xcode_at_least?(16) path = File.join(path, "Library", "Developer", "Xcode", "UserData", "Provisioning Profiles") else path = File.join(path, "Library", "MobileDevice", "Provisioning Profiles") end # If the directory doesn't exist, create it first unless File.directory?(path) FileUtils.mkdir_p(path) end return path end # Installs a provisioning profile for Xcode to use def install(path, keychain_path = nil) UI.message("Installing provisioning profile...") destination = File.join(profiles_path, profile_filename(path, keychain_path)) if path != destination # copy to Xcode provisioning profile directory FileUtils.copy(path, destination) unless File.exist?(destination) UI.user_error!("Failed installation of provisioning profile at location: '#{destination}'") end end destination end private def decode(path, keychain_path = nil) require 'tmpdir' Dir.mktmpdir('fastlane') do |dir| err = "#{dir}/cms.err" # we want to prevent the error output to mix up with the standard output because of # /dev/null: https://github.com/fastlane/fastlane/issues/6387 if Helper.mac? if keychain_path.nil? decoded = `security cms -D -i "#{path}" 2> #{err}` else decoded = `security cms -D -i "#{path}" -k "#{keychain_path.shellescape}" 2> #{err}` end else # `security` only works on Mac, fallback to `openssl` # via https://stackoverflow.com/a/14379814/252627 decoded = `openssl smime -inform der -verify -noverify -in #{path.shellescape} 2> #{err}` end UI.error("Failure to decode #{path}. Exit: #{$?.exitstatus}: #{File.read(err)}") if $?.exitstatus != 0 decoded end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/globals.rb
fastlane_core/lib/fastlane_core/globals.rb
module FastlaneCore class Globals def self.captured_output @captured_output ||= "" end class << self attr_writer(:captured_output) attr_writer(:capture_output) attr_writer(:verbose) end def self.capture_output? return nil unless @capture_output return true end def self.captured_output? @capture_output && @captured_output.to_s.length > 0 end def self.verbose? return nil unless @verbose return true end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
fastlane_core/lib/fastlane_core/pkg_upload_package_builder.rb
require 'digest/md5' require 'securerandom' require_relative 'globals' require_relative 'ui/ui' require_relative 'module' 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}-#{SecureRandom.uuid}.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) # https://web.archive.org/web/20160430190141/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? return self.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
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/tag_version.rb
fastlane_core/lib/fastlane_core/tag_version.rb
require "rubygems/version" module FastlaneCore # Utility class to construct a Gem::Version from a tag. # Accepts vX.Y.Z and X.Y.Z. class TagVersion < Gem::Version class << self def correct?(tag) result = superclass.correct?(version_number_from_tag(tag)) # It seems like depending on the Ruby env, the result is # slightly different. We actually just want `true` and `false` # values here return false if result.nil? return true if result == 0 return result end # Gem::Version.new barfs on things like "v0.1.0", which is the style # generated by the rake release task. Just strip off any initial v # to generate a Gem::Version from a tag. def version_number_from_tag(tag) tag.sub(/^v/, "") end end def initialize(tag) super(self.class.version_number_from_tag(tag)) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/command_executor.rb
fastlane_core/lib/fastlane_core/command_executor.rb
require_relative 'ui/ui' require_relative 'globals' require_relative 'fastlane_pty' module FastlaneCore # Executes commands and takes care of error handling and more class CommandExecutor class << self # Cross-platform way of finding an executable in the $PATH. Respects the $PATHEXT, which lists # valid file extensions for executables on Windows. # # which('ruby') #=> /usr/bin/ruby # # Derived from https://stackoverflow.com/a/5471032/3005 def which(cmd) ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| cmd_path = File.join(path, cmd) executable_path = Helper.get_executable_path(cmd_path) return executable_path if Helper.executable?(executable_path) end return nil end # @param command [String] The command to be executed # @param print_all [Boolean] Do we want to print out the command output while running? # @param print_command [Boolean] Should we print the command that's being executed # @param error [Block] A block that's called if an error occurs # @param prefix [Array] An array containing a prefix + block which might get applied to the output # @param loading [String] A loading string that is shown before the first output # @param suppress_output [Boolean] Should we print the command's output? # @return [String] All the output as string def execute(command: nil, print_all: false, print_command: true, error: nil, prefix: nil, loading: nil, suppress_output: false) print_all = true if FastlaneCore::Globals.verbose? prefix ||= {} output = [] command = command.join(" ") if command.kind_of?(Array) UI.command(command) if print_command if print_all && loading # this is only used to show the "Loading text"... UI.command_output(loading) end begin status = FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid| command_stdout.each do |l| line = l.chomp line = line[1..-1] if line[0] == "\r" output << line next unless print_all # Prefix the current line with a string prefix.each do |element| line = element[:prefix] + line if element[:block] && element[:block].call(line) end UI.command_output(line) unless suppress_output end end rescue => ex # FastlanePty adds exit_status on to StandardError so every error will have a status code status = ex.exit_status # This could happen when the environment is wrong: # > invalid byte sequence in US-ASCII (ArgumentError) output << ex.to_s o = output.join("\n") puts(o) if error error.call(o, nil) else raise ex end end # Exit status for build command, should be 0 if build succeeded if status != 0 is_output_already_printed = print_all && !suppress_output o = output.join("\n") puts(o) unless is_output_already_printed UI.error("Exit status: #{status}") if error error.call(o, status) else UI.user_error!("Exit status: #{status}") end end return output.join("\n") end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/print_table.rb
fastlane_core/lib/fastlane_core/print_table.rb
require_relative 'configuration/configuration' require_relative 'helper' # Monkey patch Terminal::Table until this is merged # https://github.com/tj/terminal-table/pull/131 # solves https://github.com/fastlane/fastlane/issues/21852 # loads Terminal::Table first to be able to monkey patch it. require 'terminal-table' module Terminal class Table class Cell def lines # @value.to_s.split(/\n/) @value.to_s.encode("utf-8", invalid: :replace).split(/\n/) end end end end module FastlaneCore class PrintTable class << self # This method prints out all the user inputs in a nice table. Useful to summarize the run # You can pass an array to `hide_keys` if you don't want certain elements to show up (symbols or strings) # You can pass an array to `mask_keys` if you want to mask certain elements (symbols or strings) def print_values(config: nil, title: nil, hide_keys: [], mask_keys: [], transform: :newline) require 'terminal-table' options = {} unless config.nil? if config.kind_of?(FastlaneCore::Configuration) # find sensitive options and mask them by default config.available_options.each do |config_item| if config_item.sensitive mask_keys << config_item.key.to_s end end options = config.values(ask: false) else options = config end end rows = self.collect_rows(options: options, hide_keys: hide_keys.map(&:to_s), mask_keys: mask_keys.map(&:to_s), prefix: '') params = {} if transform params[:rows] = transform_output(rows, transform: transform) else params[:rows] = rows end params[:title] = title.green if title unless FastlaneCore::Env.truthy?("FASTLANE_SKIP_ALL_LANE_SUMMARIES") puts("") puts(Terminal::Table.new(params)) puts("") end return params end def colorize_array(array, colors) value = "" array.each do |l| colored_line = l colored_line = "#{colors.first}#{l}#{colors.last}" if colors.length > 0 value << colored_line value << "\n" end return value end def should_transform? if FastlaneCore::Helper.ci? || FastlaneCore::Helper.test? return false end return !FastlaneCore::Env.truthy?("FL_SKIP_TABLE_TRANSFORM") end def transform_row(column, transform, max_value_length) return column if column.nil? # we want to keep the nil and not convert it to a string return column if transform.nil? value = column.to_s.dup if transform == :truncate_middle return value.middle_truncate(max_value_length) elsif transform == :newline # remove all fixed newlines as it may mess up the output value.gsub!("\n", " ") if value.kind_of?(String) if value.length >= max_value_length colors = value.scan(/\e\[.*?m/) colors.each { |color| value.gsub!(color, '') } lines = value.wordwrap(max_value_length) return colorize_array(lines, colors) end elsif transform UI.user_error!("Unknown transform value '#{transform}'") end return value end def transform_output(rows, transform: :newline) return rows unless should_transform? require 'fastlane_core/string_filters' require 'tty-screen' number_of_cols = TTY::Screen.width col_count = rows.map(&:length).first || 1 # -4 per column - as tt adds "| " and " |" terminal_table_padding = 4 max_length = number_of_cols - (col_count * terminal_table_padding) max_value_length = (max_length / col_count) - 1 return_array = rows.map do |row| row.map do |column| transform_row(column, transform, max_value_length) end end return return_array end def collect_rows(options: nil, hide_keys: [], mask_keys: [], prefix: '', mask: '********') rows = [] options.each do |key, value| prefixed_key = "#{prefix}#{key}" next if value.nil? next if value.to_s == "" next if hide_keys.include?(prefixed_key) value = mask if mask_keys.include?(prefixed_key) if value.respond_to?(:key) rows.concat(self.collect_rows(options: value, hide_keys: hide_keys, mask_keys: mask_keys, prefix: "#{prefix}#{key}.", mask: mask)) else rows << [prefixed_key, value] end end rows end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/build_watcher.rb
fastlane_core/lib/fastlane_core/build_watcher.rb
require 'spaceship/connect_api' require_relative 'ui/ui' module FastlaneCore class BuildWatcherError < StandardError end class BuildWatcher VersionMatches = Struct.new(:version, :builds) class << self # @return The build we waited for. This method will always return a build def wait_for_build_processing_to_be_complete(app_id: nil, platform: nil, train_version: nil, app_version: nil, build_version: nil, poll_interval: 10, timeout_duration: nil, strict_build_watch: false, return_when_build_appears: false, return_spaceship_testflight_build: true, select_latest: false, wait_for_build_beta_detail_processing: false) # Warn about train_version being removed in the future if train_version UI.deprecated(":train_version is no longer a used argument on FastlaneCore::BuildWatcher. Please use :app_version instead.") app_version = train_version end # Warn about strict_build_watch being removed in the future if strict_build_watch UI.deprecated(":strict_build_watch is no longer a used argument on FastlaneCore::BuildWatcher.") end platform = Spaceship::ConnectAPI::Platform.map(platform) if platform UI.message("Waiting for processing on... app_id: #{app_id}, app_version: #{app_version}, build_version: #{build_version}, platform: #{platform}") build_watching_start_time = Time.new unless timeout_duration.nil? end_time = build_watching_start_time + timeout_duration UI.message("Will timeout watching build after #{timeout_duration} seconds around #{end_time}...") end showed_info = false loop do matched_build, app_version_queried = matching_build(watched_app_version: app_version, watched_build_version: build_version, app_id: app_id, platform: platform, select_latest: select_latest) if matched_build.nil? && !showed_info UI.important("Read more information on why this build isn't showing up yet - https://github.com/fastlane/fastlane/issues/14997") showed_info = true end report_status(build: matched_build, wait_for_build_beta_detail_processing: wait_for_build_beta_detail_processing) # Processing of builds by AppStoreConnect can be a very time consuming task and will # block the worker running this task until it is completed. In some cases, # having a build resource appear in AppStoreConnect (matched_build) may be enough (i.e. setting a changelog) # so here we may choose to skip the full processing of the build if return_when_build_appears is true if matched_build && (return_when_build_appears || processed?(build: matched_build, wait_for_build_beta_detail_processing: wait_for_build_beta_detail_processing)) if !app_version.nil? && app_version != app_version_queried UI.important("App version is #{app_version} but build was found while querying #{app_version_queried}") UI.important("This shouldn't be an issue as Apple sees #{app_version} and #{app_version_queried} as equal") UI.important("See docs for more info - https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102364") end if return_spaceship_testflight_build return matched_build.to_testflight_build else return matched_build end end # Before next poll, force stop build watching, if we exceeded the 'timeout_duration' waiting time force_stop_build_watching_if_required(start_time: build_watching_start_time, timeout_duration: timeout_duration) sleep(poll_interval) end end private # Remove leading zeros ( https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102364 ) def remove_version_leading_zeros(version: nil) return version.instance_of?(String) ? version.split('.').map { |s| s.to_i.to_s }.join('.') : version end def matching_build(watched_app_version: nil, watched_build_version: nil, app_id: nil, platform: nil, select_latest: false) # Get build deliveries (newly uploaded processing builds) watched_app_version = remove_version_leading_zeros(version: watched_app_version) watched_build_version = remove_version_leading_zeros(version: watched_build_version) # App Store Connect will allow users to upload X.Y is the same as X.Y.0 and treat them as the same version # However, only the first uploaded version format will be the one that is queryable # This could lead to BuildWatcher never finding X.Y.0 if X.Y was uploaded first as X.Y will only yield results # # This will add an additional request to search for both X.Y and X.Y.0 but # will give preference to the version format specified passed in watched_app_version_alternate = alternate_version(watched_app_version) versions = [watched_app_version, watched_app_version_alternate].compact if versions.empty? if select_latest message = watched_build_version.nil? ? "Searching for the latest build" : "Searching for the latest build with build number: #{watched_build_version}" UI.message(message) versions = [nil] else raise BuildWatcherError.new, "There is no app version to watch" end end version_matches = versions.map do |version| match = VersionMatches.new match.version = version match.builds = Spaceship::ConnectAPI::Build.all( app_id: app_id, version: version, build_number: watched_build_version, platform: platform ) match end.flatten # Raise error if more than 1 build is returned # This should never happen but need to inform the user if it does matched_builds = version_matches.map(&:builds).flatten # Need to filter out duplicate builds (which could be a result from the double X.Y.0 and X.Y queries) # See: https://github.com/fastlane/fastlane/issues/22248 matched_builds = matched_builds.uniq(&:id) if matched_builds.size > 1 && !select_latest error_builds = matched_builds.map do |build| "#{build.app_version}(#{build.version}) for #{build.platform} - #{build.processing_state}" end.join("\n") error_message = "Found more than 1 matching build: \n#{error_builds}" raise BuildWatcherError.new, error_message end version_match = version_matches.reject do |match| match.builds.empty? end.first matched_build = version_match&.builds&.first return matched_build, version_match&.version end def alternate_version(version) return nil if version.nil? version_info = Gem::Version.new(version) if version_info.segments.size == 3 && version_info.segments[2] == 0 return version_info.segments[0..1].join(".") elsif version_info.segments.size == 2 return "#{version}.0" end return nil end def processed?(build: nil, wait_for_build_beta_detail_processing: false) return false unless build is_processed = build.processed? # App Store Connect API has multiple build processing states # builds have one processing status # buildBetaDetails have two processing statues (internal and external testing) # # If set, this method will only return true if all three statuses are complete if wait_for_build_beta_detail_processing is_processed &&= (build.build_beta_detail&.processed? || false) end return is_processed end def report_status(build: nil, wait_for_build_beta_detail_processing: false) is_processed = processed?(build: build, wait_for_build_beta_detail_processing: wait_for_build_beta_detail_processing) if build && !is_processed UI.message("Waiting for App Store Connect to finish processing the new build (#{build.app_version} - #{build.version}) for #{build.platform}") elsif build && is_processed UI.success("Successfully finished processing the build #{build.app_version} - #{build.version} for #{build.platform}") else UI.message("Waiting for the build to show up in the build list - this may take a few minutes (check your email for processing issues if this continues)") end end def force_stop_build_watching_if_required(start_time: nil, timeout_duration: nil) return if start_time.nil? || timeout_duration.nil? # keep watching build for App Store Connect processing current_time = Time.new end_time = start_time + timeout_duration pending_duration = end_time - current_time if current_time > end_time UI.crash!("FastlaneCore::BuildWatcher exceeded the '#{timeout_duration.to_i}' seconds, Stopping now!") else UI.verbose("Will timeout watching build after pending #{pending_duration.to_i} seconds around #{end_time}...") end end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/keychain_importer.rb
fastlane_core/lib/fastlane_core/keychain_importer.rb
require_relative 'helper' require 'open3' require 'security' module FastlaneCore class KeychainImporter def self.import_file(path, keychain_path, keychain_password: nil, certificate_password: "", skip_set_partition_list: false, output: FastlaneCore::Globals.verbose?) UI.user_error!("Could not find file '#{path}'") unless File.exist?(path) password_part = " -P #{certificate_password.shellescape}" command = "security import #{path.shellescape} -k '#{keychain_path.shellescape}'" command << password_part command << " -T /usr/bin/codesign" # to not be asked for permission when running a tool like `gym` (before Sierra) command << " -T /usr/bin/security" command << " -T /usr/bin/productbuild" # to not be asked for permission when using an installer cert for macOS command << " -T /usr/bin/productsign" # to not be asked for permission when using an installer cert for macOS command << " 1> /dev/null" unless output sensitive_command = command.gsub(password_part, " -P ********") UI.command(sensitive_command) if output Open3.popen3(command) do |stdin, stdout, stderr, thrd| UI.command_output(stdout.read.to_s) if output # Set partition list only if success since it can be a time consuming process if a lot of keys are installed if thrd.value.success? && !skip_set_partition_list keychain_password ||= resolve_keychain_password(keychain_path) set_partition_list(path, keychain_path, keychain_password: keychain_password, output: output) else # Output verbose if file is already installed since not an error otherwise we will show the whole error err = stderr.read.to_s.strip if err.include?("SecKeychainItemImport") && err.include?("The specified item already exists in the keychain") UI.verbose("'#{File.basename(path)}' is already installed on this machine") else UI.error(err) end end end end def self.set_partition_list(path, keychain_path, keychain_password: nil, output: FastlaneCore::Globals.verbose?) # When security supports partition lists, also add the partition IDs # See https://openradar.appspot.com/28524119 if Helper.backticks('security -h | grep set-key-partition-list', print: false).length > 0 password_part = " -k #{keychain_password.to_s.shellescape}" command = "security set-key-partition-list" command << " -S apple-tool:,apple:,codesign:" command << " -s" # This is a needed in Catalina to prevent "security: SecKeychainItemCopyAccess: A missing value was detected." command << password_part command << " #{keychain_path.shellescape}" command << " 1> /dev/null" # always disable stdout. This can be very verbose, and leak potentially sensitive info # Showing loading indicator as this can take some time if a lot of keys installed Helper.show_loading_indicator("Setting key partition list... (this can take a minute if there are a lot of keys installed)") # Strip keychain password from command output sensitive_command = command.gsub(password_part, " -k ********") UI.command(sensitive_command) if output Open3.popen3(command) do |stdin, stdout, stderr, thrd| unless thrd.value.success? err = stderr.read.to_s.strip # Inform user when no/wrong password was used as its needed to prevent UI permission popup from Xcode when signing if err.include?("SecKeychainItemSetAccessWithPassword") keychain_name = File.basename(keychain_path, ".*") Security::InternetPassword.delete(server: server_name(keychain_name)) UI.important("") UI.important("Could not configure imported keychain item (certificate) to prevent UI permission popup when code signing\n" \ "Check if you supplied the correct `keychain_password` for keychain: `#{keychain_path}`\n" \ "#{err}") UI.important("") UI.important("Please look at the following docs to see how to set a keychain password:") UI.important(" - https://docs.fastlane.tools/actions/sync_code_signing") UI.important(" - https://docs.fastlane.tools/actions/get_certificates") else UI.error(err) end end end # Hiding after Open3 finishes Helper.hide_loading_indicator end end # https://github.com/fastlane/fastlane/issues/14196 # Keychain password is needed to set the partition list to # prevent Xcode from prompting dialog for keychain password when signing # 1. Uses keychain password from login keychain if found # 2. Prompts user for keychain password and stores it in login keychain for user later def self.resolve_keychain_password(keychain_path) keychain_name = File.basename(keychain_path, ".*") server = server_name(keychain_name) # Attempt to find password in keychain for keychain item = Security::InternetPassword.find(server: server) if item keychain_password = item.password UI.important("Using keychain password from keychain item #{server} in #{keychain_path}") end if keychain_password.nil? if UI.interactive? UI.important("Enter the password for #{keychain_path}") UI.important("This passphrase will be stored in your local keychain with the name #{server} and used in future runs") UI.important("This prompt can be avoided by specifying the 'keychain_password' option or 'MATCH_KEYCHAIN_PASSWORD' environment variable") keychain_password = FastlaneCore::Helper.ask_password(message: "Password for #{keychain_name} keychain: ", confirm: true, confirmation_message: "Type password for #{keychain_name} keychain again: ") Security::InternetPassword.add(server, "", keychain_password) else UI.important("Keychain password for #{keychain_path} was not specified and not found in your keychain. Specify the 'keychain_password' option to prevent the UI permission popup when code signing") keychain_password = "" end end return keychain_password end # server name used for accessing the macOS keychain def self.server_name(keychain_name) ["fastlane", "keychain", keychain_name].join("_") end private_class_method :server_name end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/env.rb
fastlane_core/lib/fastlane_core/env.rb
module FastlaneCore class Env def self.truthy?(env) return false unless ENV[env] return false if ["no", "false", "off", "0"].include?(ENV[env].to_s) return true end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
fastlane_core/lib/fastlane_core/ipa_upload_package_builder.rb
require "digest/md5" require 'securerandom' require_relative 'globals' require_relative 'ui/ui' require_relative 'module' module FastlaneCore # Builds a package for the binary ready to be uploaded with the iTunes Transporter class IpaUploadPackageBuilder METADATA_FILE_NAME = "metadata.xml" attr_accessor :package_path def generate(app_id: nil, ipa_path: nil, package_path: nil, platform: nil, app_identifier: nil, short_version: nil, bundle_version: nil) unless Helper.is_mac? # .itmsp packages are not supported for ipa uploads starting Transporter 4.1, for non-macOS self.package_path = package_path copy_ipa(ipa_path) # copy any AppStoreInfo.plist file that's next to the ipa file app_store_info_path = File.join(File.dirname(ipa_path), "AppStoreInfo.plist") if File.exist?(app_store_info_path) FileUtils.cp(app_store_info_path, File.join(self.package_path, "AppStoreInfo.plist")) end return self.package_path end self.package_path = File.join(package_path, "#{app_id}-#{SecureRandom.uuid}.itmsp") FileUtils.rm_rf(self.package_path) if File.directory?(self.package_path) FileUtils.mkdir_p(self.package_path) ipa_path = copy_ipa(ipa_path) @data = { apple_id: app_id, file_size: File.size(ipa_path), ipa_path: File.basename(ipa_path), # this is only the base name as the ipa is inside the package md5: Digest::MD5.file(ipa_path).hexdigest, archive_type: "bundle", platform: (platform || "ios"), # pass "appletvos" for Apple TV's IPA app_identifier: app_identifier, short_version: short_version, bundle_version: bundle_version } xml_path = File.join(FastlaneCore::ROOT, "lib/assets/XMLTemplate.xml.erb") xml = ERB.new(File.read(xml_path)).result(binding) # https://web.archive.org/web/20160430190141/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? return self.package_path end def unique_ipa_path(ipa_path) "#{Digest::SHA256.file(ipa_path).hexdigest}.ipa" end private def copy_ipa(ipa_path) ipa_file_name = unique_ipa_path(ipa_path) resulting_path = File.join(self.package_path, ipa_file_name) FileUtils.cp(ipa_path, resulting_path) return resulting_path end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/swag.rb
fastlane_core/lib/fastlane_core/swag.rb
require "stringio" require_relative 'helper' module FastlaneCore class Swag # rubocop:disable Layout/LineLength require 'zlib' FRAMES = ["x\x9C\xED[\xD9u\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3\xC1\xC3\n\xBD\xED\x84\x95\x99\xBF'b\xCC\xA76\xF9\x83\xA1\xA61P\x01\x93?z\f\xA53\xC5\xE6Q\x88\t\xA4\x8D\x7FG \x944\xEC\xF9\xE5}\x1A\x88?3\xF7\xFE \xB2\xD4\xAB<9\xB0/SQ{=\x95A4\xAE\xA0l\x01\xE5\x9E\x04\xEEE\xEE\x99\x1D\xEF\xB8\xBB+\x9D(\xEC\xE8\xF9\xF1\x01\xE1\x9ER\xCA\x009\xA9]E\x93\xE8\xEB\xBC9\xC9c\x15\"~\xB3\x83\xBD[]\xB2^\xB8;\x81\xB7xrk\x03\xF2C<\x89\x89v\xB8\xA7\xE4k\x87ZyW\xC3<E\xED4bZ\xC4_\xCB9\x949j\xF6\xAF\xA3\xBD4\x16m\x95\xE4\xEC\xAFG\x89\xA7\xE8gG\x1F\x05\x1A\xC9\xF4\xBC\xB82\xDE4:\xAAE\xD0m\xFFfA\xB2G\xDE\r2Dz>1-\xA9\xAE\x12\xE3\xFCU[?\xCE\xCB\xFD\xDD\xF6\xBD\xC4{\x89\x17X\xE2\x1FG\xA5\x05\xF7",
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
true
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/languages.rb
fastlane_core/lib/fastlane_core/languages.rb
module FastlaneCore module Languages # These are all the languages which are available to use to upload app metadata and screenshots # The old format which was used until August 2015 (good old times) ALL_LANGUAGES_LEGACY = %w[da-DK de-DE el-GR en-AU en-CA en-GB en-US es-ES es-MX fi-FI fr-CA fr-FR id-ID it-IT ja-JP ko-KR ms-MY nl-NL no-NO pt-BR pt-PT ru-RU sv-SE th-TH tr-TR vi-VI cmn-Hans cmn-Hant] # The new format used from September 2015 on # This was generated from `Spaceship::Tunes.client.available_languages.sort` # Updates should also be made to: # - produce/lib/produce/available_default_languages.rb # - spaceship/lib/assets/languageMapping.json # See pull request for example: https://github.com/fastlane/fastlane/pull/14110 ALL_LANGUAGES = %w[ar-SA ca cs da de-DE el en-AU en-CA en-GB en-US es-ES es-MX fi fr-CA fr-FR he hi hr hu id it ja ko ms nl-NL no pl pt-BR pt-PT ro ru sk sv th tr uk vi zh-Hans zh-Hant] end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/queue_worker.rb
fastlane_core/lib/fastlane_core/queue_worker.rb
require 'thread' module FastlaneCore # This dispatches jobs to worker threads and make it work in parallel. # It's suitable for I/O bounds works and not for CPU bounds works. # Use this when you have all the items that you'll process in advance. # Simply enqueue them to this and call `QueueWorker#start`. class QueueWorker NUMBER_OF_THREADS = FastlaneCore::Helper.test? ? 1 : [ENV["DELIVER_NUMBER_OF_THREADS"], ENV["FL_NUMBER_OF_THREADS"], 10].map(&:to_i).find(&:positive?).clamp(1, ENV.fetch("FL_MAX_NUMBER_OF_THREADS", 10).to_i) # @param concurrency (Numeric) - A number of threads to be created # @param block (Proc) - A task you want to execute with enqueued items def initialize(concurrency = NUMBER_OF_THREADS, &block) @concurrency = concurrency @block = block @queue = Queue.new end # @param job (Object) - An arbitrary object that keeps parameters def enqueue(job) @queue.push(job) end # @param jobs (Array<Object>) - An array of arbitrary object that keeps parameters def batch_enqueue(jobs) raise(ArgumentError, "Enqueue Array instead of #{jobs.class}") unless jobs.kind_of?(Array) jobs.each { |job| enqueue(job) } end # Call this after you enqueued all the jobs you want to process # This method blocks current thread until all the enqueued jobs are processed def start @queue.close threads = [] @concurrency.times do threads << Thread.new do job = @queue.pop while job @block.call(job) job = @queue.pop end end end threads.each(&:join) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/itunes_transporter.rb
fastlane_core/lib/fastlane_core/itunes_transporter.rb
require 'shellwords' require 'tmpdir' require 'fileutils' require 'credentials_manager/account_manager' require 'securerandom' require_relative 'features' require_relative 'helper' require_relative 'fastlane_pty' module FastlaneCore # The TransporterInputError occurs when you passed wrong inputs to the {Deliver::ItunesTransporter} class TransporterInputError < StandardError end # The TransporterTransferError occurs when some error happens # while uploading or downloading something from/to iTC class TransporterTransferError < StandardError end # Used internally class TransporterRequiresApplicationSpecificPasswordError < StandardError end # Base class for executing the iTMSTransporter class TransporterExecutor ERROR_REGEX = />\s*ERROR:\s+(.+)/ WARNING_REGEX = />\s*WARN:\s+(.+)/ OUTPUT_REGEX = />\s+(.+)/ RETURN_VALUE_REGEX = />\sDBG-X:\sReturning\s+(\d+)/ # Matches a line in the iTMSTransporter provider table: "12 Initech Systems Inc LG89CQY559" ITMS_PROVIDER_REGEX = /^\d+\s{2,}.+\s{2,}[^\s]+$/ SKIP_ERRORS = ["ERROR: An exception has occurred: Scheduling automatic restart in 1 minute"] private_constant :ERROR_REGEX, :WARNING_REGEX, :OUTPUT_REGEX, :RETURN_VALUE_REGEX, :SKIP_ERRORS def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) not_implemented(__method__) end def build_provider_ids_command(username, password, jwt = nil, api_key = nil) not_implemented(__method__) end def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) not_implemented(__method__) end def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs) not_implemented(__method__) end # Builds a string array of credentials parameters based on the provided authentication details. # # @param username [String, nil] The username for authentication (optional). # @param password [String, nil] The password for authentication (optional). # @param jwt [String, nil] A JSON Web Token for token-based authentication (optional). # @param api_key [Hash, nil] An API key for authentication (optional). # # @return [String] A string containing the appropriate credentials for authentication. def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) not_implemented(__method__) end # Runs preparations before executing any command from the executor. # # @param original_api_key [Hash] api key containing the issuer id and private key # @return [Hash] copy of `api_key` which includes an extra `key_dir` with the location of the .p8 file on disk def prepare(original_api_key:) return if original_api_key.nil? # Create .p8 file from api_key and provide api key info which contains .p8 file path api_key = original_api_key.dup if self.kind_of?(ShellScriptTransporterExecutor) # as of Transporter v3.3.0, the app is unable to detect the private keys under the 'private_keys' folder in current directory # so we must rely on the other search paths in the Home dir: # https://help.apple.com/itc/transporteruserguide/en.lproj/static.html#itc803b7be80 private_keys_dir = File.join(Dir.home, ".appstoreconnect/private_keys") unless Dir.exist?(private_keys_dir) FileUtils.mkdir_p(private_keys_dir) end api_key[:key_dir] = private_keys_dir else api_key[:key_dir] = Dir.mktmpdir("deliver-") end # Specified p8 needs to be generated to call altool or iTMSTransporter File.open(File.join(api_key[:key_dir], "AuthKey_#{api_key[:key_id]}.p8"), "wb") do |p8| p8.write(api_key[:key]) end api_key end def execute(command, hide_output) if Helper.test? yield(nil) if block_given? return command end @errors = [] @warnings = [] @all_lines = [] if hide_output # Show a one time message instead UI.success("Waiting for App Store Connect transporter to be finished.") UI.success("iTunes Transporter progress... this might take a few minutes...") end begin exit_status = FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid| begin command_stdout.each do |line| @all_lines << line parse_line(line, hide_output) # this is where the parsing happens end end end rescue => ex # FastlanePty adds exit_status on to StandardError so every error will have a status code exit_status = ex.exit_status @errors << ex.to_s end unless exit_status.zero? @errors << "The call to the iTMSTransporter completed with a non-zero exit status: #{exit_status}. This indicates a failure." end if @warnings.count > 0 UI.important(@warnings.join("\n")) end if @errors.join("").include?("app-specific") raise TransporterRequiresApplicationSpecificPasswordError end if @errors.count > 0 && @all_lines.count > 0 # Print out the last 15 lines, this is key for non-verbose mode @all_lines.last(15).each do |line| UI.important("[iTMSTransporter] #{line}") end UI.message("iTunes Transporter output above ^") UI.error(@errors.join("\n")) end # this is to handle GitHub issue #1896, which occurs when an # iTMSTransporter file transfer fails; iTMSTransporter will log an error # but will then retry; if that retry is successful, we will see the error # logged, but since the status code is zero, we want to return success if @errors.count > 0 && exit_status.zero? UI.important("Although errors occurred during execution of iTMSTransporter, it returned success status.") end yield(@all_lines) if block_given? return exit_status.zero? end def displayable_errors @errors.map { |error| "[Transporter Error Output]: #{error}" }.join("\n").gsub!(/"/, "") end def parse_provider_info(lines) lines.map { |line| itms_provider_pair(line) }.compact.to_h end private def itms_provider_pair(line) line = line.strip return nil unless line =~ ITMS_PROVIDER_REGEX line.split(/\s{2,}/).drop(1) end def parse_line(line, hide_output) # Taken from https://github.com/sshaw/itunes_store_transporter/blob/master/lib/itunes/store/transporter/output_parser.rb output_done = false re = Regexp.union(SKIP_ERRORS) if line.match(re) # Those lines will not be handled like errors or warnings elsif line =~ ERROR_REGEX @errors << $1 # Check if it's a login error if $1.include?("Your Apple ID or password was entered incorrectly") || $1.include?("This Apple ID has been locked for security reasons") unless Helper.test? CredentialsManager::AccountManager.new(user: @user).invalid_credentials UI.error("Please run this tool again to apply the new password") end end output_done = true elsif line =~ WARNING_REGEX @warnings << $1 UI.important("[Transporter Warning Output]: #{$1}") output_done = true end if line =~ RETURN_VALUE_REGEX if $1.to_i != 0 UI.error("Transporter transfer failed.") UI.important(@warnings.join("\n")) UI.error(@errors.join("\n")) UI.crash!("Return status of iTunes Transporter was #{$1}: #{@errors.join('\n')}") else UI.success("iTunes Transporter successfully finished its job") end end if !hide_output && line =~ OUTPUT_REGEX # General logging for debug purposes unless output_done UI.verbose("[Transporter]: #{$1}") end end end def file_upload_option(source) file_ext = File.extname(source).downcase is_asset_file_type = !File.directory?(source) && allowed_package_extensions.map { |ext| ".#{ext}" }.include?(file_ext) if is_asset_file_type return "-assetFile #{source.shellescape}" else return "-f #{source.shellescape}" end end def additional_upload_parameters # As Apple recommends in Transporter User Guide we shouldn't specify the -t transport parameter # and instead allow Transporter to use automatic transport discovery # to determine the best transport mode for packages. # It became crucial after WWDC 2020 as it leaded to "Broken pipe (Write failed)" exception # More information https://github.com/fastlane/fastlane/issues/16749 env_deliver_additional_params = ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] if env_deliver_additional_params.to_s.strip.empty? return nil end deliver_additional_params = env_deliver_additional_params.to_s.strip if deliver_additional_params.include?("-t ") UI.important("Apple recommends you don’t specify the -t transport and instead allow Transporter to use automatic transport discovery to determine the best transport mode for your packages. For more information, please read Apple's Transporter User Guide 2.1: https://help.apple.com/itc/transporteruserguide/#/apdATD1E1288-D1E1A1303-D1E1288A1126") end return deliver_additional_params end def allowed_package_extensions ["ipa", "pkg", "dmg", "zip"] end end # Generates commands and executes the altool. class AltoolTransporterExecutor < TransporterExecutor # Xcode 26 uses ERROR, while previous versions used *** Error ERROR_REGEX = /(?:\*\*\*\s*)?ERROR:\s+(.+)/i private_constant :ERROR_REGEX attr_reader :errors def execute(command, hide_output) if Helper.test? yield(nil) if block_given? return command end @errors = [] @all_lines = [] if hide_output # Show a one time message instead UI.success("Waiting for App Store Connect transporter to be finished.") UI.success("Application Loader progress... this might take a few minutes...") end begin exit_status = FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid| command_stdout.each do |line| @all_lines << line parse_line(line, hide_output) # this is where the parsing happens end end rescue => ex # FastlanePty adds exit_status on to StandardError so every error will have a status code exit_status = ex.exit_status @errors << ex.to_s end @errors << "The call to the altool completed with a non-zero exit status: #{exit_status}. This indicates a failure." unless exit_status.zero? @errors << "-1 indicates altool exited abnormally; try retrying (see https://github.com/fastlane/fastlane/issues/21535)" if exit_status == -1 unless @errors.empty? || @all_lines.empty? @all_lines.each do |line| UI.important("[altool] #{line}") end UI.message("Application Loader output above ^") @errors.each { |error| UI.error(error) } end yield(@all_lines) if block_given? @errors.empty? end def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) if !username.nil? && !password.nil? && api_key.nil? "-u #{username.shellescape} -p #{password.shellescape}" elsif !api_key.nil? "--apiKey #{api_key[:key_id]} --apiIssuer #{api_key[:issuer_id]}" end end def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--upload-app", build_credential_params(username, password, jwt, api_key), ("--asc-provider #{provider_short_name}" unless use_api_key || provider_short_name.to_s.empty?), platform_option(platform), file_upload_option(source), additional_upload_parameters, "-k 100000" ].compact.join(' ') end def build_provider_ids_command(username, password, jwt = nil, api_key = nil) use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--list-providers", build_credential_params(username, password, jwt, api_key), "--output-format json" ].compact.join(' ') end def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) raise "This feature has not been implemented yet with altool for Xcode 14" end def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs) api_key = kwargs[:api_key] platform = kwargs[:platform] use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--validate-app", build_credential_params(username, password, nil, api_key), ("--asc-provider #{provider_short_name}" unless use_api_key || provider_short_name.to_s.empty?), platform_option(platform), file_upload_option(source) ].compact.join(' ') end def additional_upload_parameters env_deliver_additional_params = ENV["DELIVER_ALTOOL_ADDITIONAL_UPLOAD_PARAMETERS"] return nil if env_deliver_additional_params.to_s.strip.empty? env_deliver_additional_params.to_s.strip end def handle_error(password) UI.error("Could not download/upload from App Store Connect!") end def displayable_errors @errors.map { |error| "[Application Loader Error Output]: #{error}" }.join("\n") end def parse_provider_info(lines) # This tries parsing the provider id from altool output to detect provider list provider_info = {} json_body = lines[-2] # altool outputs result in second line from last return provider_info if json_body.nil? providers = JSON.parse(json_body)["providers"] return provider_info if providers.nil? providers.each do |provider| provider_info[provider["ProviderName"]] = provider["ProviderShortname"] end provider_info end private def file_upload_option(source) "-f #{source.shellescape}" end def platform_option(platform) "-t #{platform == 'osx' ? 'macos' : platform}" end def parse_line(line, hide_output) output_done = false if line =~ ERROR_REGEX @errors << $1 output_done = true end unless hide_output # General logging for debug purposes unless output_done UI.verbose("[altool]: #{line}") end end end end # Generates commands and executes the iTMSTransporter through the shell script it provides by the same name class ShellScriptTransporterExecutor < TransporterExecutor def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) if !(username.nil? || password.nil?) && (jwt.nil? && api_key.nil?) "-u #{username.shellescape} -p #{shell_escaped_password(password)}" elsif !jwt.nil? && api_key.nil? "-jwt #{jwt}" elsif !api_key.nil? "-apiIssuer #{api_key[:issuer_id]} -apiKey #{api_key[:key_id]}" end end def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) [ '"' + Helper.transporter_path + '"', "-m upload", build_credential_params(username, password, jwt, api_key), file_upload_option(source), additional_upload_parameters, # that's here, because the user might overwrite the -t option "-k 100000", ("-WONoPause true" if Helper.windows?), # Windows only: process instantly returns instead of waiting for key press ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?) ].compact.join(' ') end def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) [ '"' + Helper.transporter_path + '"', "-m lookupMetadata", build_credential_params(username, password, jwt), "-apple_id #{apple_id}", "-destination '#{destination}'", ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?) ].compact.join(' ') end def build_provider_ids_command(username, password, jwt = nil, api_key = nil) [ '"' + Helper.transporter_path + '"', '-m provider', build_credential_params(username, password, jwt, api_key) ].compact.join(' ') end def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs) jwt = kwargs[:jwt] [ '"' + Helper.transporter_path + '"', '-m verify', build_credential_params(username, password, jwt), "-f #{source.shellescape}", ("-WONoPause true" if Helper.windows?), # Windows only: process instantly returns instead of waiting for key press ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?) ].compact.join(' ') end def handle_error(password) # rubocop:disable Style/CaseEquality # rubocop:disable Style/YodaCondition unless /^[0-9a-zA-Z\.\$\_\-]*$/ === password UI.error([ "Password contains special characters, which may not be handled properly by iTMSTransporter.", "If you experience problems uploading to App Store Connect, please consider changing your password to something with only alphanumeric characters." ].join(' ')) end # rubocop:enable Style/CaseEquality # rubocop:enable Style/YodaCondition UI.error("Could not download/upload from App Store Connect! It's probably related to your password or your internet connection.") end def file_upload_option(source) # uploading packages on non-macOS platforms requires AppStoreInfo.plist starting with Transporter >= 4.1 if !Helper.is_mac? && File.directory?(source) asset_file = Dir.glob(File.join(source, "*.{#{allowed_package_extensions.join(',')}}")).first unless asset_file UI.user_error!("No package file (#{allowed_package_extensions.join(',')}) found in #{source}") end appstore_info_path = File.join(source, "AppStoreInfo.plist") unless File.file?(appstore_info_path) UI.error("AppStoreInfo.plist is required for uploading #{File.extname(asset_file)} files on non-macOS platforms.") UI.error("Expected AppStoreInfo.plist in the same directory as the #{File.extname(asset_file)} file.") UI.error("Generate it by running either 'fastlane gym [...] --generate_appstore_info'") UI.error("Or add '<key>generateAppStoreInformation</key><true/>' in an options.plist then run 'fastlane gym [...] --export_options options.plist'.") UI.user_error!("Missing required AppStoreInfo.plist file for iTMSTransporter upload") end UI.verbose("Using AppStoreInfo.plist for iTMSTransporter upload: #{appstore_info_path}") return "-assetFile #{asset_file.shellescape} -assetDescription #{appstore_info_path.shellescape}" end # use standard behavior for other file types or macOS platform super(source) end private def shell_escaped_password(password) password = password.shellescape unless Helper.windows? # because the shell handles passwords with single-quotes incorrectly, use `gsub` to replace `shellescape`'d single-quotes of this form: # \' # with a sequence that wraps the escaped single-quote in double-quotes: # '"\'"' # this allows us to properly handle passwords with single-quotes in them # background: https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings/1250098#1250098 password = password.gsub("\\'") do # we use the 'do' version of gsub, because two-param version interprets the replace text as a pattern and does the wrong thing "'\"\\'\"'" end # wrap the fully-escaped password in single quotes, since the transporter expects a escaped password string (which must be single-quoted for the shell's benefit) password = "'" + password + "'" end return password end end # Generates commands and executes the iTMSTransporter by invoking its Java app directly, to avoid the crazy parameter # escaping problems in its accompanying shell script. class JavaTransporterExecutor < TransporterExecutor def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil, is_password_from_env = false) if !username.nil? && jwt.to_s.empty? if is_password_from_env "-u #{username.shellescape} -p @env:ITMS_TRANSPORTER_PASSWORD" elsif !password.nil? "-u #{username.shellescape} -p #{password.shellescape}" end elsif !jwt.to_s.empty? "-jwt #{jwt}" end end def build_upload_command(username, password, source = "/tmp", provider_short_name = "", jwt = nil, platform = nil, api_key = nil) credential_params = build_credential_params(username, password, jwt, api_key, is_default_itms_on_xcode_11?) if is_default_itms_on_xcode_11? [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?), 'xcrun iTMSTransporter', '-m upload', credential_params, file_upload_option(source), additional_upload_parameters, # that's here, because the user might overwrite the -t option '-k 100000', ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') # compact gets rid of the possibly nil ENV value else [ Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', java_code_option, '-m upload', credential_params, file_upload_option(source), additional_upload_parameters, # that's here, because the user might overwrite the -t option '-k 100000', ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') # compact gets rid of the possibly nil ENV value end end def build_verify_command(username, password, source = "/tmp", provider_short_name = "", **kwargs) jwt = kwargs[:jwt] credential_params = build_credential_params(username, password, jwt, nil, is_default_itms_on_xcode_11?) if is_default_itms_on_xcode_11? [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?), 'xcrun iTMSTransporter', '-m verify', credential_params, "-f #{source.shellescape}", ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') # compact gets rid of the possibly nil ENV value else [ Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', java_code_option, '-m verify', credential_params, "-f #{source.shellescape}", ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') # compact gets rid of the possibly nil ENV value end end def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) credential_params = build_credential_params(username, password, jwt, nil, is_default_itms_on_xcode_11?) if is_default_itms_on_xcode_11? [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?), 'xcrun iTMSTransporter', '-m lookupMetadata', credential_params, "-apple_id #{apple_id.shellescape}", "-destination #{destination.shellescape}", ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') else [ Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', java_code_option, '-m lookupMetadata', credential_params, "-apple_id #{apple_id.shellescape}", "-destination #{destination.shellescape}", ("-itc_provider #{provider_short_name}" if jwt.nil? && !provider_short_name.to_s.empty?), '2>&1' # cause stderr to be written to stdout ].compact.join(' ') end end def build_provider_ids_command(username, password, jwt = nil, api_key = nil) credential_params = build_credential_params(username, password, jwt, api_key, is_default_itms_on_xcode_11?) if is_default_itms_on_xcode_11? [ ("ITMS_TRANSPORTER_PASSWORD=#{password.shellescape}" if jwt.to_s.empty?), 'xcrun iTMSTransporter', '-m provider', credential_params, '2>&1' # cause stderr to be written to stdout ].compact.join(' ') else [ Helper.transporter_java_executable_path.shellescape, "-Djava.ext.dirs=#{Helper.transporter_java_ext_dir.shellescape}", '-XX:NewSize=2m', '-Xms32m', '-Xmx1024m', '-Xms1024m', '-Djava.awt.headless=true', '-Dsun.net.http.retryPost=false', java_code_option, '-m provider', credential_params, '2>&1' # cause stderr to be written to stdout ].compact.join(' ') end end def is_default_itms_on_xcode_11? !Helper.user_defined_itms_path? && Helper.mac? && Helper.xcode_at_least?(11) end def java_code_option if Helper.mac? && Helper.xcode_at_least?(9) return "-jar #{Helper.transporter_java_jar_path.shellescape}" else return "-classpath #{Helper.transporter_java_jar_path.shellescape} com.apple.transporter.Application" end end def handle_error(password) unless File.exist?(Helper.transporter_java_jar_path) UI.error("The iTMSTransporter Java app was not found at '#{Helper.transporter_java_jar_path}'.") UI.error("If you're using Xcode 6, please select the shell script executor by setting the environment variable "\ "FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT=1") end end def execute(command, hide_output) # The Java command needs to be run starting in a working directory in the iTMSTransporter # file area. The shell script takes care of changing directories over to there, but we'll # handle it manually here for this strategy. FileUtils.cd(Helper.itms_path) do return super(command, hide_output) end end end class ItunesTransporter TWO_STEP_HOST_PREFIX = "deliver.appspecific" # This will be called from the Deliverfile, and disables the logging of the transporter output def self.hide_transporter_output @hide_transporter_output = !FastlaneCore::Globals.verbose? end def self.hide_transporter_output? @hide_transporter_output end # Returns a new instance of the iTunesTransporter. # If no username or password given, it will be taken from # the #{CredentialsManager::AccountManager} # @param use_shell_script if true, forces use of the iTMSTransporter shell script. # if false, allows a direct call to the iTMSTransporter Java app (preferred). # see: https://github.com/fastlane/fastlane/pull/4003 # @param provider_short_name The provider short name to be given to the iTMSTransporter to identify the # correct team for this work. The provider short name is usually your Developer # Portal team ID, but in certain cases it is different! # see: https://github.com/fastlane/fastlane/issues/1524#issuecomment-196370628 # for more information about how to use the iTMSTransporter to list your provider # short names def initialize(user = nil, password = nil, use_shell_script = false, provider_short_name = nil, jwt = nil, altool_compatible_command: false, api_key: nil) # Xcode 6.x doesn't have the same iTMSTransporter Java setup as later Xcode versions, so # we can't default to using the newer direct Java invocation strategy for those versions. use_shell_script ||= Helper.is_mac? && Helper.xcode_version.start_with?('6.') use_shell_script ||= Helper.windows? use_shell_script ||= Feature.enabled?('FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT') if jwt.to_s.empty? && api_key.nil? @user = user @password = password || load_password_for_transporter end @jwt = jwt @api_key = api_key if should_use_altool?(altool_compatible_command, use_shell_script) UI.verbose("Using altool as transporter.") @transporter_executor = AltoolTransporterExecutor.new else UI.verbose("Using iTMSTransporter as transporter.") @transporter_executor = use_shell_script ? ShellScriptTransporterExecutor.new : JavaTransporterExecutor.new end @provider_short_name = provider_short_name end # Downloads the latest version of the app metadata package from iTC. # @param app_id [Integer] The unique App ID # @param dir [String] the path in which the package file should be stored # @return (Bool) True if everything worked fine # @raise [Deliver::TransporterTransferError] when something went wrong # when transferring def download(app_id, dir = nil) dir ||= "/tmp" password_placeholder = @jwt.nil? ? 'YourPassword' : nil jwt_placeholder = @jwt.nil? ? nil : 'YourJWT' UI.message("Going to download app metadata from App Store Connect") command = @transporter_executor.build_download_command(@user, @password, app_id, dir, @provider_short_name, @jwt) UI.verbose(@transporter_executor.build_download_command(@user, password_placeholder, app_id, dir, @provider_short_name, jwt_placeholder)) begin result = @transporter_executor.execute(command, ItunesTransporter.hide_transporter_output?) rescue TransporterRequiresApplicationSpecificPasswordError => ex handle_two_step_failure(ex) return download(app_id, dir) end return result if Helper.test? itmsp_path = File.join(dir, "#{app_id}.itmsp") successful = result && File.directory?(itmsp_path) if successful UI.success("✅ Successfully downloaded the latest package from App Store Connect to #{itmsp_path}") else handle_error(@password) end successful end # Uploads the modified package back to App Store Connect # @param app_id [Integer] The unique App ID # @param dir [String] the path in which the package file is located
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
true
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ios_app_identifier_guesser.rb
fastlane_core/lib/fastlane_core/ios_app_identifier_guesser.rb
require 'credentials_manager/appfile_config' require_relative 'env' require_relative 'configuration/configuration' module FastlaneCore class IOSAppIdentifierGuesser APP_ID_REGEX = /var\s*appIdentifier:\s*String\?{0,1}\s*\[?\]?\s*{\s*return\s*\[?\s*"(\s*[a-zA-Z.-]+\s*)"\s*\]?\s*}/ class << self def guess_app_identifier_from_args(args) # args example: ["-a", "com.krausefx.app", "--team_id", "5AA97AAHK2"] args.each_with_index do |current, index| next unless current == "-a" || current == "--app_identifier" # argument names are followed by argument values in the args array; # use [index + 1] to find the package name (range check the array # to avoid array bounds errors) return args[index + 1] if args.count > index end nil end def guess_app_identifier_from_environment ["FASTLANE", "DELIVER", "PILOT", "PRODUCE", "PEM", "SIGH", "SNAPSHOT", "MATCH"].each do |current| return ENV["#{current}_APP_IDENTIFIER"] if FastlaneCore::Env.truthy?("#{current}_APP_IDENTIFIER") end nil end def guess_app_identifier_from_appfile CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) end def fetch_app_identifier_from_ruby_file(file_name) # we only care about the app_identifier item in the configuration file, so # build an options array & Configuration with just that one key and it will # be fetched if it is present in the config file genericfile_options = [FastlaneCore::ConfigItem.new(key: :app_identifier)] options = FastlaneCore::Configuration.create(genericfile_options, {}) # pass the empty proc to disable options validation, otherwise this will fail # when the other (non-app_identifier) keys are encountered in the config file; # 3rd parameter "true" disables the printout of the contents of the # configuration file, which is noisy and confusing in this case options.load_configuration_file(file_name, proc {}, true) return options.fetch(:app_identifier, ask: false) rescue # any option/file error here should just be treated as identifier not found nil end def fetch_app_identifier_from_swift_file(file_name) swift_config_file_path = FastlaneCore::Configuration.find_configuration_file_path(config_file_name: file_name) return nil if swift_config_file_path.nil? # Deliverfile.swift, Snapfile.swift, Appfile.swift all look like: # var appIdentifier: String? { return nil } # var appIdentifier: String { return "" } # Matchfile.swift is the odd one out # var appIdentifier: [String] { return [] } # swift_config_file_path = File.expand_path(swift_config_file_path) swift_config_content = File.read(swift_config_file_path) swift_config_content.split("\n").reject(&:empty?).each do |line| application_id = match_swift_application_id(text_line: line) return application_id if application_id end return nil rescue # any option/file error here should just be treated as identifier not found return nil end def match_swift_application_id(text_line: nil) text_line.strip! application_id_match = APP_ID_REGEX.match(text_line) return application_id_match[1].strip if application_id_match return nil end def guess_app_identifier_from_config_files ["Deliverfile", "Gymfile", "Snapfile", "Matchfile"].each do |current| app_identifier = self.fetch_app_identifier_from_ruby_file(current) return app_identifier if app_identifier end # if we're swifty, let's look there # this isn't the same list as above ["Deliverfile.swift", "Snapfile.swift", "Appfile.swift", "Matchfile.swift"].each do |current| app_identifier = self.fetch_app_identifier_from_swift_file(current) return app_identifier if app_identifier end return nil end # make a best-guess for the app_identifier for this project, using most-reliable signals # first and then using less accurate ones afterwards; because this method only returns # a GUESS for the app_identifier, it is only useful for metrics or other places where # absolute accuracy is not required def guess_app_identifier(args) app_identifier = nil app_identifier ||= guess_app_identifier_from_args(args) app_identifier ||= guess_app_identifier_from_environment app_identifier ||= guess_app_identifier_from_appfile app_identifier ||= guess_app_identifier_from_config_files app_identifier end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/test_parser.rb
fastlane_core/lib/fastlane_core/test_parser.rb
require 'plist' require 'fastlane/junit_generator' require_relative 'ui/ui' require_relative 'print_table' module FastlaneCore class TestParser attr_accessor :data attr_accessor :file_content attr_accessor :raw_json def initialize(path) path = File.expand_path(path) UI.user_error!("File not found at path '#{path}'") unless File.exist?(path) self.file_content = File.read(path) self.raw_json = Plist.parse_xml(self.file_content) return if self.raw_json["FormatVersion"].to_s.length.zero? # maybe that's a useless plist file ensure_file_valid! parse_content end private def ensure_file_valid! format_version = self.raw_json["FormatVersion"] supported_versions = ["1.1", "1.2"] UI.user_error!("Format version '#{format_version}' is not supported, must be #{supported_versions.join(', ')}") unless supported_versions.include?(format_version) end # Converts the raw plist test structure into something that's easier to enumerate def unfold_tests(data) # `data` looks like this # => [{"Subtests"=> # [{"Subtests"=> # [{"Subtests"=> # [{"Duration"=>0.4, # "TestIdentifier"=>"Unit/testExample()", # "TestName"=>"testExample()", # "TestObjectClass"=>"IDESchemeActionTestSummary", # "TestStatus"=>"Success", # "TestSummaryGUID"=>"4A24BFED-03E6-4FBE-BC5E-2D80023C06B4"}, # {"FailureSummaries"=> # [{"FileName"=>"/Users/krausefx/Developer/themoji/Unit/Unit.swift", # "LineNumber"=>34, # "Message"=>"XCTAssertTrue failed - ", # "PerformanceFailure"=>false}], # "TestIdentifier"=>"Unit/testExample2()", tests = [] data.each do |current_hash| if current_hash["Subtests"] tests += unfold_tests(current_hash["Subtests"]) end if current_hash["TestStatus"] tests << current_hash end end return tests end # Convert the Hashes and Arrays in something more useful def parse_content self.data = self.raw_json["TestableSummaries"].collect do |testable_summary| summary_row = { project_path: testable_summary["ProjectPath"], target_name: testable_summary["TargetName"], test_name: testable_summary["TestName"], duration: testable_summary["Tests"].map { |current_test| current_test["Duration"] }.inject(:+), tests: unfold_tests(testable_summary["Tests"]).collect do |current_test| current_row = { identifier: current_test["TestIdentifier"], test_group: current_test["TestIdentifier"].split("/")[0..-2].join("."), name: current_test["TestName"], object_class: current_test["TestObjectClass"], status: current_test["TestStatus"], guid: current_test["TestSummaryGUID"], duration: current_test["Duration"] } if current_test["FailureSummaries"] current_row[:failures] = current_test["FailureSummaries"].collect do |current_failure| { file_name: current_failure['FileName'], line_number: current_failure['LineNumber'], message: current_failure['Message'], performance_failure: current_failure['PerformanceFailure'], failure_message: "#{current_failure['Message']} (#{current_failure['FileName']}:#{current_failure['LineNumber']})" } end end current_row end } summary_row[:number_of_tests] = summary_row[:tests].count summary_row[:number_of_failures] = summary_row[:tests].find_all { |a| (a[:failures] || []).count > 0 }.count summary_row end self.data.first[:run_destination_name] = self.raw_json["RunDestination"]["Name"] return self.data end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/cert_checker.rb
fastlane_core/lib/fastlane_core/cert_checker.rb
require 'tempfile' require 'openssl' require_relative 'features' require_relative 'helper' # WWDR Intermediate Certificates in https://www.apple.com/certificateauthority/ WWDRCA_CERTIFICATES = [ { alias: 'G2', sha256: '9ed4b3b88c6a339cf1387895bda9ca6ea31a6b5ce9edf7511845923b0c8ac94c', url: 'https://www.apple.com/certificateauthority/AppleWWDRCAG2.cer' }, { alias: 'G3', sha256: 'dcf21878c77f4198e4b4614f03d696d89c66c66008d4244e1b99161aac91601f', url: 'https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer' }, { alias: 'G4', sha256: 'ea4757885538dd8cb59ff4556f676087d83c85e70902c122e42c0808b5bce14c', url: 'https://www.apple.com/certificateauthority/AppleWWDRCAG4.cer' }, { alias: 'G5', sha256: '53fd008278e5a595fe1e908ae9c5e5675f26243264a5a6438c023e3ce2870760', url: 'https://www.apple.com/certificateauthority/AppleWWDRCAG5.cer' }, { alias: 'G6', sha256: 'bdd4ed6e74691f0c2bfd01be0296197af1379e0418e2d300efa9c3bef642ca30', url: 'https://www.apple.com/certificateauthority/AppleWWDRCAG6.cer' } ] module FastlaneCore # This class checks if a specific certificate is installed on the current mac class CertChecker def self.installed?(path, in_keychain: nil) UI.user_error!("Could not find file '#{path}'") unless File.exist?(path) in_keychain &&= FastlaneCore::Helper.keychain_path(in_keychain) ids = installed_identities(in_keychain: in_keychain) ids += installed_installers(in_keychain: in_keychain) finger_print = sha1_fingerprint(path) return ids.include?(finger_print) end # Legacy Method, use `installed?` instead def self.is_installed?(path) installed?(path) end def self.installed_identities(in_keychain: nil) install_missing_wwdr_certificates(in_keychain: in_keychain) available = list_available_identities(in_keychain: in_keychain) # Match for this text against word boundaries to avoid edge cases around multiples of 10 identities! if /\b0 valid identities found\b/ =~ available UI.error([ "There are no local code signing identities found.", "You can run" << " `security find-identity -v -p codesigning #{in_keychain}".rstrip << "` to get this output.", "This Stack Overflow thread has more information: https://stackoverflow.com/q/35390072/774.", "(Check in Keychain Access for an expired WWDR certificate: https://stackoverflow.com/a/35409835/774 has more info.)" ].join("\n")) end ids = [] available.split("\n").each do |current| next if current.include?("REVOKED") begin (ids << current.match(/.*\) ([[:xdigit:]]*) \".*/)[1]) rescue # the last line does not match end end return ids end def self.installed_installers(in_keychain: nil) available = self.list_available_third_party_mac_installer(in_keychain: in_keychain) available += self.list_available_developer_id_installer(in_keychain: in_keychain) return available.scan(/^SHA-1 hash: ([[:xdigit:]]+)$/).flatten end def self.list_available_identities(in_keychain: nil) # -v Show valid identities only (default is to show all identities) # -p Specify policy to evaluate commands = ['security find-identity -v -p codesigning'] commands << in_keychain if in_keychain `#{commands.join(' ')}` end def self.list_available_third_party_mac_installer(in_keychain: nil) # -Z Print SHA-256 (and SHA-1) hash of the certificate # -a Find all matching certificates, not just the first one # -c Match on "name" when searching (optional) commands = ['security find-certificate -Z -a -c "3rd Party Mac Developer Installer"'] commands << in_keychain if in_keychain `#{commands.join(' ')}` end def self.list_available_developer_id_installer(in_keychain: nil) # -Z Print SHA-256 (and SHA-1) hash of the certificate # -a Find all matching certificates, not just the first one # -c Match on "name" when searching (optional) commands = ['security find-certificate -Z -a -c "Developer ID Installer"'] commands << in_keychain if in_keychain `#{commands.join(' ')}` end def self.installed_wwdr_certificates(keychain: nil) certificate_name = "Apple Worldwide Developer Relations" keychain ||= wwdr_keychain # backwards compatibility # Find all installed WWDRCA certificates installed_certs = [] Helper.backticks("security find-certificate -a -c '#{certificate_name}' -p #{keychain.shellescape}", print: false) .lines .each do |line| if line.start_with?('-----BEGIN CERTIFICATE-----') installed_certs << line else installed_certs.last << line end end # Get the alias (see `WWDRCA_CERTIFICATES`) of the installed WWDRCA certificates installed_certs .map do |pem| sha256 = Digest::SHA256.hexdigest(OpenSSL::X509::Certificate.new(pem).to_der) WWDRCA_CERTIFICATES.find { |c| c[:sha256].casecmp?(sha256) }&.fetch(:alias) end .compact end def self.install_missing_wwdr_certificates(in_keychain: nil) # Install all Worldwide Developer Relations Intermediate Certificates listed here: https://www.apple.com/certificateauthority/ keychain = in_keychain || wwdr_keychain missing = WWDRCA_CERTIFICATES.map { |c| c[:alias] } - installed_wwdr_certificates(keychain: keychain) missing.each do |cert_alias| install_wwdr_certificate(cert_alias, keychain: keychain) end missing.count end def self.install_wwdr_certificate(cert_alias, keychain: nil) url = WWDRCA_CERTIFICATES.find { |c| c[:alias] == cert_alias }.fetch(:url) file = Tempfile.new([File.basename(url, ".cer"), ".cer"]) filename = file.path keychain ||= wwdr_keychain # backwards compatibility keychain = "-k #{keychain.shellescape}" unless keychain.empty? # Attempts to fix an issue installing WWDR cert tends to fail on CIs # https://github.com/fastlane/fastlane/issues/20960 curl_extras = "" if FastlaneCore::Feature.enabled?('FASTLANE_WWDR_USE_HTTP1_AND_RETRIES') curl_extras = "--http1.1 --retry 3 --retry-all-errors " end import_command = "curl #{curl_extras}-f -o #{filename} #{url} && security import #{filename} #{keychain}" UI.verbose("Installing WWDR Cert: #{import_command}") require 'open3' stdout, stderr, status = Open3.capture3(import_command) if FastlaneCore::Globals.verbose? UI.command_output(stdout) UI.command_output(stderr) end unless status.success? UI.verbose("Failed to install WWDR Certificate, checking output to see why") # Check the command output, WWDR might already exist unless /The specified item already exists in the keychain./ =~ stderr UI.user_error!("Could not install WWDR certificate") end UI.verbose("WWDR Certificate was already installed") end return true end def self.wwdr_keychain priority = [ "security default-keychain -d user", "security list-keychains -d user" ] priority.each do |command| keychains = Helper.backticks(command, print: FastlaneCore::Globals.verbose?).split("\n") unless keychains.empty? # Select first keychain name from returned keychains list return keychains[0].strip.tr('"', '') end end return "" end def self.sha1_fingerprint(path) file_data = File.read(path.to_s) cert = OpenSSL::X509::Certificate.new(file_data) return OpenSSL::Digest::SHA1.new(cert.to_der).to_s.upcase rescue => error UI.error(error) UI.user_error!("Error parsing certificate '#{path}'") end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/helper.rb
fastlane_core/lib/fastlane_core/helper.rb
require 'logger' require 'colored' require 'tty-spinner' require 'pathname' require_relative 'fastlane_folder' require_relative 'ui/ui' require_relative 'env' module FastlaneCore module Helper # fastlane # def self.fastlane_enabled? # This is called from the root context on the first start !FastlaneCore::FastlaneFolder.path.nil? end # Checks if fastlane is enabled for this project and returns the folder where the configuration lives def self.fastlane_enabled_folder_path fastlane_enabled? ? FastlaneCore::FastlaneFolder.path : '.' end # fastlane installation method # # @return [boolean] true if executing with bundler (like 'bundle exec fastlane [action]') def self.bundler? # Bundler environment variable ['BUNDLE_BIN_PATH', 'BUNDLE_GEMFILE'].each do |current| return true if ENV.key?(current) end return false end # Do we run from a bundled fastlane, which contains Ruby and OpenSSL? # Usually this means the fastlane directory is ~/.fastlane/bin/ # We set this value via the environment variable `FASTLANE_SELF_CONTAINED` def self.contained_fastlane? ENV["FASTLANE_SELF_CONTAINED"].to_s == "true" && !self.homebrew? end # returns true if fastlane was installed from the Fabric Mac app def self.mac_app? ENV["FASTLANE_SELF_CONTAINED"].to_s == "false" end # returns true if fastlane was installed via Homebrew def self.homebrew? ENV["FASTLANE_INSTALLED_VIA_HOMEBREW"].to_s == "true" end # returns true if fastlane was installed via RubyGems def self.rubygems? !self.bundler? && !self.contained_fastlane? && !self.homebrew? && !self.mac_app? end # environment # # @return true if the currently running program is a unit test def self.test? Object.const_defined?("SpecHelper") end # @return true if it is enabled to execute external commands def self.sh_enabled? !self.test? || ENV["FORCE_SH_DURING_TESTS"] end # @return [boolean] true if building in a known CI environment def self.ci? return true if self.is_circle_ci? # Check for Jenkins, Travis CI, ... environment variables ['JENKINS_HOME', 'JENKINS_URL', 'TRAVIS', 'CI', 'APPCENTER_BUILD_ID', 'TEAMCITY_VERSION', 'GO_PIPELINE_NAME', 'bamboo_buildKey', 'GITLAB_CI', 'XCS', 'TF_BUILD', 'GITHUB_ACTION', 'GITHUB_ACTIONS', 'BITRISE_IO', 'BUDDY', 'CODEBUILD_BUILD_ARN'].each do |current| return true if FastlaneCore::Env.truthy?(current) end return false end def self.is_circle_ci? return ENV.key?('CIRCLECI') end # @return [boolean] true if environment variable CODEBUILD_BUILD_ARN is set def self.is_codebuild? return ENV.key?('CODEBUILD_BUILD_ARN') end def self.operating_system return "macOS" if RUBY_PLATFORM.downcase.include?("darwin") return "Windows" if RUBY_PLATFORM.downcase.include?("mswin") return "Linux" if RUBY_PLATFORM.downcase.include?("linux") return "Unknown" end def self.windows? # taken from: https://stackoverflow.com/a/171011/1945875 (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end def self.linux? (/linux/ =~ RUBY_PLATFORM) != nil end # Is the currently running computer a Mac? def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end # Do we want to disable the colored output? def self.colors_disabled? FastlaneCore::Env.truthy?("FASTLANE_DISABLE_COLORS") || ENV.key?("NO_COLOR") end # Does the user use the Mac stock terminal def self.mac_stock_terminal? FastlaneCore::Env.truthy?("TERM_PROGRAM_VERSION") end # Logs base directory def self.buildlog_path return ENV["FL_BUILDLOG_PATH"] || "~/Library/Logs" end # Xcode # # @return the full path to the Xcode developer tools of the currently # running system def self.xcode_path return "" unless self.mac? if self.xcode_server? # Xcode server always creates a link here xcode_server_xcode_path = "/Library/Developer/XcodeServer/CurrentXcodeSymlink/Contents/Developer" UI.verbose("We're running as XcodeServer, setting path to #{xcode_server_xcode_path}") return xcode_server_xcode_path end return `xcode-select -p`.delete("\n") + "/" end def self.xcode_server? # XCS is set by Xcode Server return ENV["XCS"].to_i == 1 end # @return The version of the currently used Xcode installation (e.g. "7.0") def self.xcode_version return nil unless self.mac? return @xcode_version if @xcode_version && @developer_dir == ENV['DEVELOPER_DIR'] xcodebuild_path = "#{xcode_path}/usr/bin/xcodebuild" xcode_build_installed = File.exist?(xcodebuild_path) unless xcode_build_installed UI.verbose("Couldn't find xcodebuild at #{xcodebuild_path}, check that it exists") return nil end begin output = `DEVELOPER_DIR='' "#{xcodebuild_path}" -version` @xcode_version = output.split("\n").first.split(' ')[1] @developer_dir = ENV['DEVELOPER_DIR'] rescue => ex UI.error(ex) UI.user_error!("Error detecting currently used Xcode installation, please ensure that you have Xcode installed and set it using `sudo xcode-select -s [path]`") end @xcode_version end # @return true if installed Xcode version is 'greater than or equal to' the input parameter version def self.xcode_at_least?(version) installed_xcode_version = xcode_version UI.user_error!("Unable to locate Xcode. Please make sure to have Xcode installed on your machine") if installed_xcode_version.nil? Gem::Version.new(installed_xcode_version) >= Gem::Version.new(version) end # Swift # # @return Swift version def self.swift_version if system("which swift > /dev/null 2>&1") output = `swift --version 2> /dev/null` return output.split("\n").first.match(/version ([0-9.]+)/).captures.first end return nil end # iTMSTransporter # def self.transporter_java_executable_path return File.join(self.transporter_java_path, 'bin', 'java') end def self.transporter_java_ext_dir return File.join(self.transporter_java_path, 'lib', 'ext') end def self.transporter_java_jar_path return File.join(self.itms_path, 'lib', 'itmstransporter-launcher.jar') end def self.transporter_user_dir return File.join(self.itms_path, 'bin') end def self.transporter_java_path return File.join(self.itms_path, 'java') end # @return the full path to the iTMSTransporter executable def self.transporter_path return File.join(self.itms_path, 'bin', 'iTMSTransporter') unless Helper.windows? return File.join(self.itms_path, 'iTMSTransporter') end def self.user_defined_itms_path? return FastlaneCore::Env.truthy?("FASTLANE_ITUNES_TRANSPORTER_PATH") end def self.user_defined_itms_path return ENV["FASTLANE_ITUNES_TRANSPORTER_PATH"] if self.user_defined_itms_path? end # @return the full path to the iTMSTransporter executable def self.itms_path return self.user_defined_itms_path if FastlaneCore::Env.truthy?("FASTLANE_ITUNES_TRANSPORTER_PATH") if self.mac? # First check for manually install iTMSTransporter user_local_itms_path = "/usr/local/itms" return user_local_itms_path if File.exist?(user_local_itms_path) # Then check for iTMSTransporter in the Xcode path [ "../Applications/Application Loader.app/Contents/MacOS/itms", "../Applications/Application Loader.app/Contents/itms", "../SharedFrameworks/ContentDeliveryServices.framework/Versions/A/itms" # For Xcode 11 ].each do |path| result = File.expand_path(File.join(self.xcode_path, path)) return result if File.exist?(result) end UI.user_error!("Could not find transporter at #{self.xcode_path}. Please make sure you set the correct path to your Xcode installation.") elsif self.windows? [ "C:/Program Files (x86)/itms" ].each do |path| return path if File.exist?(path) end UI.user_error!("Could not find transporter at usual locations. Please use environment variable `FASTLANE_ITUNES_TRANSPORTER_PATH` to specify your installation path.") else # not Mac or Windows return '' end end # keychain # def self.keychain_path(keychain_name) # Existing code expects that a keychain name will be expanded into a default path to Library/Keychains # in the user's home directory. However, this will not allow the user to pass an absolute path # for the keychain value # # So, if the passed value can't be resolved as a file in Library/Keychains, just use it as-is # as the keychain path. # # We need to expand each path because File.exist? won't handle directories including ~ properly # # We also try to append `-db` at the end of the file path, as with Sierra the default Keychain name # has changed for some users: https://github.com/fastlane/fastlane/issues/5649 # Remove the ".keychain" at the end of the keychain name name = keychain_name.sub(/\.keychain$/, "") possible_locations = [ File.join(Dir.home, 'Library', 'Keychains', name), name ].map { |path| File.expand_path(path) } # Transforms ["thing"] to ["thing-db", "thing.keychain-db", "thing", "thing.keychain"] keychain_paths = [] possible_locations.each do |location| keychain_paths << "#{location}-db" keychain_paths << "#{location}.keychain-db" keychain_paths << location keychain_paths << "#{location}.keychain" end keychain_path = keychain_paths.find { |path| File.file?(path) } UI.user_error!("Could not locate the provided keychain. Tried:\n\t#{keychain_paths.join("\n\t")}") unless keychain_path keychain_path end # helper methods # # Runs a given command using backticks (`) # and prints them out using the UI.command method def self.backticks(command, print: true) UI.command(command) if print result = `#{command}` UI.command_output(result) if print return result end # removes ANSI colors from string def self.strip_ansi_colors(str) str.gsub(/\e\[([;\d]+)?m/, '') end # Zips directory def self.zip_directory(path, output_path, contents_only: false, overwrite: false, print: true) if overwrite overwrite_command = " && rm -f '#{output_path}'" else overwrite_command = "" end if contents_only command = "cd '#{path}'#{overwrite_command} && zip -r '#{output_path}' *" else containing_path = File.expand_path("..", path) contents_path = File.basename(path) command = "cd '#{containing_path}'#{overwrite_command} && zip -r '#{output_path}' '#{contents_path}'" end UI.command(command) unless print Helper.backticks(command, print: print) end # Executes the provided block after adjusting the ENV to have the # provided keys and values set as defined in hash. After the block # completes, restores the ENV to its previous state. def self.with_env_values(hash, &block) old_vals = ENV.select { |k, v| hash.include?(k) } hash.each do |k, v| ENV[k] = hash[k] end yield ensure hash.each do |k, v| ENV.delete(k) unless old_vals.include?(k) ENV[k] = old_vals[k] end end # loading indicator # def self.should_show_loading_indicator? return false if FastlaneCore::Env.truthy?("FASTLANE_DISABLE_ANIMATION") return false if Helper.ci? return true end # Show/Hide loading indicator def self.show_loading_indicator(text = nil) if self.should_show_loading_indicator? # we set the default here, instead of at the parameters # as we don't want to `UI.message` a rocket that's just there for the loading indicator text ||= "🚀" @require_fastlane_spinner = TTY::Spinner.new("[:spinner] #{text} ", format: :dots) @require_fastlane_spinner.auto_spin else UI.message(text) if text end end def self.hide_loading_indicator if self.should_show_loading_indicator? && @require_fastlane_spinner @require_fastlane_spinner.success end end # files # # checks if a given path is an executable file def self.executable?(cmd_path) if !cmd_path || File.directory?(cmd_path) return false end return File.exist?(get_executable_path(cmd_path)) end # returns the path of the executable with the correct extension on Windows def self.get_executable_path(cmd_path) cmd_path = localize_file_path(cmd_path) if self.windows? # PATHEXT contains the list of file extensions that Windows considers executable, semicolon separated. # e.g. ".COM;.EXE;.BAT;.CMD" exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [] # no executable files on Windows, so existing is enough there # also check if command + ext is present exts.each do |ext| executable_path = "#{cmd_path}#{ext.downcase}" return executable_path if File.exist?(executable_path) end end return cmd_path end # returns the path with the platform-specific path separator (`/` on UNIX, `\` on Windows) def self.localize_file_path(path) # change `/` to `\` on Windows return self.windows? ? path.gsub('/', '\\') : path end # checks if given file is a valid json file # base taken from: http://stackoverflow.com/a/26235831/1945875 def self.json_file?(filename) return false unless File.exist?(filename) begin JSON.parse(File.read(filename)) return true rescue JSON::ParserError return false end end # deprecated # # Use Helper.test?, Helper.ci?, Helper.mac? or Helper.windows? instead (legacy calls) def self.is_test? self.test? end def self.is_ci? ci? end def self.is_mac? self.mac? end def self.is_windows? self.windows? end # <b>DEPRECATED:</b> Use the `ROOT` constant from the appropriate tool module instead # e.g. File.join(Sigh::ROOT, 'lib', 'assets', 'resign.sh') # # Path to the installed gem to load resources (e.g. resign.sh) def self.gem_path(gem_name) UI.deprecated('`Helper.gem_path` is deprecated. Use the `ROOT` constant from the appropriate tool module instead.') if !Helper.test? && Gem::Specification.find_all_by_name(gem_name).any? return Gem::Specification.find_by_name(gem_name).gem_dir else return './' end end # This method is deprecated, use the `UI` class # https://docs.fastlane.tools/advanced/#user-input-and-output def self.log UI.deprecated("Helper.log is deprecated. Use `UI` class instead") UI.current.log end def self.ask_password(message: "Passphrase: ", confirm: nil, confirmation_message: "Type passphrase again: ") raise "This code should only run in interactive mode" unless UI.interactive? loop do password = UI.password(message) if confirm password2 = UI.password(confirmation_message) if password == password2 return password end else return password end UI.error("Your entries do not match. Please try again") end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/string_filters.rb
fastlane_core/lib/fastlane_core/string_filters.rb
class String # Truncates a given +text+ after a given <tt>length</tt> if +text+ is longer than <tt>length</tt>: # # 'Once upon a time, in a world far, far away'.truncate(28) # # => "Once upon a time, in a wo..." # # Pass a string or regexp <tt>:separator</tt> to truncate +text+ at a natural break: # # 'Once upon a time, in a world far, far away'.truncate(28, separator: ' ') # # => "Once upon a time, in a..." # # 'Once upon a time, in a world far, far away'.truncate(28, separator: /\s/) # # => "Once upon a time, in a..." # # The last characters will be replaced with the <tt>:omission</tt> string (defaults to "...") # for a total length not exceeding <tt>length</tt>: # # 'And they found that many people were sleeping better.'.truncate(25, omission: '... (continued)') # # => "And they f... (continued)" def truncate(truncate_at, options = {}) return dup unless length > truncate_at omission = options[:omission] || '...' length_with_room_for_omission = truncate_at - omission.length stop = \ if options[:separator] rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission else length_with_room_for_omission end "#{self[0, stop]}#{omission}" end # Base taken from: https://www.ruby-forum.com/topic/57805 def wordwrap(length = 80) return [] if length == 0 self.gsub!(/(\S{#{length}})(?=\S)/, '\1 ') self.scan(/.{1,#{length}}(?:\s+|$)/) end # Base taken from: http://stackoverflow.com/a/12202205/1945875 def middle_truncate(length = 20, options = {}) omission = options[:omission] || '...' return self if self.length <= length + omission.length return self[0..length] if length < omission.length len = (length - omission.length) / 2 s_len = len - length % 2 self[0..s_len] + omission + self[self.length - len..self.length] end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/module.rb
fastlane_core/lib/fastlane_core/module.rb
require 'fastlane/boolean' require_relative 'analytics/analytics_session' module FastlaneCore ROOT = Pathname.new(File.expand_path('../../..', __FILE__)) Boolean = Fastlane::Boolean # Session is used to report usage metrics. # If you opt out, we will not send anything. # You can confirm this by observing how we use the environment variable: FASTLANE_OPT_OUT_USAGE # Specifically, in AnalyticsSession.finalize_session # Learn more at https://docs.fastlane.tools/#metrics def self.session @session ||= AnalyticsSession.new end def self.reset_session @session = nil end # A directory that's being used to user-wide fastlane configs # This directory is also used for the bundled fastlane # Since we don't want to access FastlaneCore from spaceship # this method is duplicated in spaceship/client.rb def self.fastlane_user_dir path = File.expand_path(File.join(Dir.home, ".fastlane")) FileUtils.mkdir_p(path) unless File.directory?(path) return path end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/features.rb
fastlane_core/lib/fastlane_core/features.rb
require_relative 'feature/feature' FastlaneCore::Feature.register(env_var: 'FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT', description: 'Use iTunes Transporter shell script')
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/clipboard.rb
fastlane_core/lib/fastlane_core/clipboard.rb
require 'fastlane_core' require 'open3' module FastlaneCore class Clipboard def self.copy(content: nil) return UI.crash!("'pbcopy' or 'pbpaste' command not found.") unless is_supported? Open3.popen3('pbcopy') { |input, _, _| input << content } end def self.paste return UI.crash!("'pbcopy' or 'pbpaste' command not found.") unless is_supported? return `pbpaste` end def self.is_supported? return `which pbcopy`.length > 0 && `which pbpaste`.length > 0 end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
fastlane_core/lib/fastlane_core/pkg_file_analyser.rb
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 platform from the given pkg file. def self.fetch_app_platform(path) return "osx" 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 # Fetches the app version from the given pkg file. def self.fetch_app_build(path) xml = self.fetch_distribution_xml_file(path) return xml.elements['installer-gui-script/pkg-ref/bundle-version/bundle'].attributes['CFBundleVersion'] 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
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/device_manager.rb
fastlane_core/lib/fastlane_core/device_manager.rb
require 'open3' require 'plist' require_relative 'command_executor' require_relative 'helper' module FastlaneCore class DeviceManager class << self def all(requested_os_type = "") return connected_devices(requested_os_type) + simulators(requested_os_type) end def runtime_build_os_versions @runtime_build_os_versions ||= begin output, status = Open3.capture2('xcrun simctl list -j runtimes') raise status unless status.success? json = JSON.parse(output) json['runtimes'].map { |h| [h['buildversion'], h['version']] }.to_h rescue StandardError => e UI.error(e) UI.error('xcrun simctl CLI broken; cun `xcrun simctl list runtimes` and make sure it works') UI.user_error!('xcrun simctl not working') end end def simulators(requested_os_type = "") UI.verbose("Fetching available simulator devices") @devices = [] os_type = 'unknown' os_version = 'unknown' output = '' Open3.popen3('xcrun simctl list devices') do |stdin, stdout, stderr, wait_thr| output = stdout.read end unless output.include?("== Devices ==") UI.error("xcrun simctl CLI broken, run `xcrun simctl list devices` and make sure it works") UI.user_error!("xcrun simctl not working.") end output.split(/\n/).each do |line| next if line =~ /unavailable/ next if line =~ /^== / if line =~ /^-- / (os_type, os_version) = line.gsub(/-- (.*) --/, '\1').split else next if os_type =~ /^Unavailable/ # " iPad (5th generation) (852A5796-63C3-4641-9825-65EBDC5C4259) (Shutdown)" # This line will turn the above string into # ["iPad (5th generation)", "(852A5796-63C3-4641-9825-65EBDC5C4259)", "(Shutdown)"] matches = line.strip.scan(/^(.*?) (\([^)]*?\)) (\([^)]*?\))$/).flatten.reject(&:empty?) state = matches.pop.to_s.delete('(').delete(')') udid = matches.pop.to_s.delete('(').delete(')') name = matches.join(' ') if matches.count && (os_type == requested_os_type || requested_os_type == "") # This is disabled here because the Device is defined later in the file, and that's a problem for the cop @devices << Device.new(name: name, os_type: os_type, os_version: os_version, udid: udid, state: state, is_simulator: true) end end end return @devices end def connected_devices(requested_os_type) UI.verbose("Fetching available connected devices") device_types = if requested_os_type == "tvOS" ["AppleTV"] elsif requested_os_type == "iOS" ["iPhone", "iPad", "iPod"] else [] end devices = [] # Return early if no supported devices are being searched for if device_types.count == 0 return devices end usb_devices_output = '' Open3.popen3("system_profiler SPUSBDataType -xml") do |stdin, stdout, stderr, wait_thr| usb_devices_output = stdout.read end device_uuids = [] result = Plist.parse_xml(usb_devices_output) discover_devices(result[0], device_types, device_uuids) if result[0] if device_uuids.count > 0 # instruments takes a little while to return so skip it if we have no devices instruments_devices_output = '' Open3.popen3("instruments -s devices") do |stdin, stdout, stderr, wait_thr| instruments_devices_output = stdout.read end instruments_devices_output.split(/\n/).each do |instruments_device| device_uuids.each do |device_uuid| match = instruments_device.match(/(.+) \(([0-9.]+)\) \[(\h{40}|\h{8}-\h{16})\]?/) if match && match[3].delete("-") == device_uuid devices << Device.new(name: match[1], udid: match[3], os_type: requested_os_type, os_version: match[2], state: "Booted", is_simulator: false) UI.verbose("USB Device Found - \"" + match[1] + "\" (" + match[2] + ") UUID:" + match[3]) end end end end return devices end # Recursively handle all USB items, discovering devices that match the # desired types. def discover_devices(usb_item, device_types, discovered_device_udids) (usb_item['_items'] || []).each do |child_item| discover_devices(child_item, device_types, discovered_device_udids) end is_supported_device = device_types.any?(usb_item['_name']) serial_num = usb_item['serial_num'] || '' has_serial_number = serial_num.length == 40 || serial_num.length == 24 if is_supported_device && has_serial_number discovered_device_udids << serial_num end end def latest_simulator_version_for_device(device) simulators.select { |s| s.name == device } .sort_by { |s| Gem::Version.create(s.os_version) } .last .os_version end # The code below works from Xcode 7 on # def all # UI.verbose("Fetching available devices") # @devices = [] # output = '' # Open3.popen3('xcrun simctl list devices --json') do |stdin, stdout, stderr, wait_thr| # output = stdout.read # end # begin # data = JSON.parse(output) # rescue => ex # UI.error(ex) # UI.error("xcrun simctl CLI broken, run `xcrun simctl list devices` and make sure it works") # UI.user_error!("xcrun simctl not working.") # end # data["devices"].each do |os_version, l| # l.each do |device| # next if device['availability'].include?("unavailable") # next unless os_version.include?(requested_os_type) # os = os_version.gsub(requested_os_type + " ", "").strip # @devices << Device.new(name: device['name'], os_type: requested_os_type, os_version: os, udid: device['udid']) # end # end # return @devices # end end # Use the UDID for the given device when setting the destination # Why? Because we might get this error message # > The requested device could not be found because multiple devices matched the request. # # This happens when you have multiple simulators for a given device type / iOS combination # { platform:iOS Simulator, id:1685B071-AFB2-4DC1-BE29-8370BA4A6EBD, OS:9.0, name:iPhone 5 } # { platform:iOS Simulator, id:A141F23B-96B3-491A-8949-813B376C28A7, OS:9.0, name:iPhone 5 } # # We don't want to deal with that, so we just use the UDID class Device attr_accessor :name attr_accessor :udid attr_accessor :os_type attr_accessor :os_version attr_accessor :ios_version # Preserved for backwards compatibility attr_accessor :state attr_accessor :is_simulator def initialize(name: nil, udid: nil, os_type: nil, os_version: nil, state: nil, is_simulator: nil) self.name = name self.udid = udid self.os_type = os_type self.os_version = os_version self.ios_version = os_version self.state = state self.is_simulator = is_simulator end def to_s self.name end def boot return unless is_simulator return unless os_type == "iOS" return if self.state == 'Booted' # Boot the simulator and wait for it to finish booting UI.message("Booting #{self}") `xcrun simctl bootstatus #{self.udid} -b &> /dev/null` self.state = 'Booted' end def shutdown return unless is_simulator return unless os_type == "iOS" return if self.state != 'Booted' UI.message("Shutting down #{self.udid}") `xcrun simctl shutdown #{self.udid} 2>/dev/null` self.state = 'Shutdown' end def reset UI.message("Resetting #{self}") shutdown `xcrun simctl erase #{self.udid}` end def delete UI.message("Deleting #{self}") shutdown `xcrun simctl delete #{self.udid}` end def disable_slide_to_type return unless is_simulator return unless os_type == "iOS" return unless Gem::Version.new(os_version) >= Gem::Version.new('13.0') UI.message("Disabling 'Slide to Type' #{self}") plist_buddy = '/usr/libexec/PlistBuddy' plist_buddy_cmd = "-c \"Add :KeyboardContinuousPathEnabled bool false\"" plist_path = File.expand_path("~/Library/Developer/CoreSimulator/Devices/#{self.udid}/data/Library/Preferences/com.apple.keyboard.ContinuousPath.plist") Helper.backticks("#{plist_buddy} #{plist_buddy_cmd} #{plist_path} >/dev/null 2>&1") end end end class Simulator class << self def all return DeviceManager.simulators('iOS') end # Reset all simulators of this type def reset_all all.each(&:reset) end def reset_all_by_version(os_version: nil) return false unless os_version all.select { |device| device.os_version == os_version }.each(&:reset) end # Reset simulator by UDID or name and OS version # Latter is useful when combined with -destination option of xcodebuild def reset(udid: nil, name: nil, os_version: nil) match = all.detect { |device| device.udid == udid || device.name == name && device.os_version == os_version } match.reset if match end # Delete all simulators of this type def delete_all all.each(&:delete) end def delete_all_by_version(os_version: nil) return false unless os_version all.select { |device| device.os_version == os_version }.each(&:delete) end # Disable 'Slide to Type' by UDID or name and OS version # Latter is useful when combined with -destination option of xcodebuild def disable_slide_to_type(udid: nil, name: nil, os_version: nil) match = all.detect { |device| device.udid == udid || device.name == name && device.os_version == os_version } match.disable_slide_to_type if match end def clear_cache @devices = nil @runtime_build_os_versions = nil end def launch(device) return unless device.is_simulator simulator_path = File.join(Helper.xcode_path, 'Applications', 'Simulator.app') UI.verbose("Launching #{simulator_path} for device: #{device.name} (#{device.udid})") Helper.backticks("open -a #{simulator_path} --args -CurrentDeviceUDID #{device.udid}", print: FastlaneCore::Globals.verbose?) end def copy_logs(device, log_identity, logs_destination_dir, log_collection_start_time) logs_destination_dir = File.expand_path(logs_destination_dir) os_version = FastlaneCore::CommandExecutor.execute(command: 'sw_vers -productVersion', print_all: false, print_command: false) host_computer_supports_logarchives = Gem::Version.new(os_version) >= Gem::Version.new('10.12.0') device_supports_logarchives = Gem::Version.new(device.os_version) >= Gem::Version.new('10.0') are_logarchives_supported = device_supports_logarchives && host_computer_supports_logarchives if are_logarchives_supported copy_logarchive(device, log_identity, logs_destination_dir, log_collection_start_time) else copy_logfile(device, log_identity, logs_destination_dir) end end def uninstall_app(app_identifier, device_type, device_udid) UI.verbose("Uninstalling app '#{app_identifier}' from #{device_type}...") UI.message("Launch Simulator #{device_type}") if FastlaneCore::Helper.xcode_at_least?("13") Helper.backticks("open -a Simulator.app --args -CurrentDeviceUDID #{device_udid} &> /dev/null") else Helper.backticks("xcrun instruments -w #{device_udid} &> /dev/null") end UI.message("Uninstall application #{app_identifier}") Helper.backticks("xcrun simctl uninstall #{device_udid} #{app_identifier} &> /dev/null") end private def copy_logfile(device, log_identity, logs_destination_dir) logfile_src = File.expand_path("~/Library/Logs/CoreSimulator/#{device.udid}/system.log") return unless File.exist?(logfile_src) FileUtils.mkdir_p(logs_destination_dir) logfile_dst = File.join(logs_destination_dir, "system-#{log_identity}.log") FileUtils.rm_f(logfile_dst) FileUtils.cp(logfile_src, logfile_dst) UI.success("Copying file '#{logfile_src}' to '#{logfile_dst}'...") end def copy_logarchive(device, log_identity, logs_destination_dir, log_collection_start_time) require 'shellwords' logarchive_dst = File.join(logs_destination_dir, "system_logs-#{log_identity}.logarchive") FileUtils.rm_rf(logarchive_dst) FileUtils.mkdir_p(File.expand_path("..", logarchive_dst)) logs_collection_start = log_collection_start_time.strftime('%Y-%m-%d %H:%M:%S') command = "xcrun simctl spawn #{device.udid} log collect " command << "--start '#{logs_collection_start}' " command << "--output #{logarchive_dst.shellescape} 2>/dev/null" FastlaneCore::CommandExecutor.execute(command: command, print_all: false, print_command: true) end end end class SimulatorTV < Simulator class << self def all return DeviceManager.simulators('tvOS') end end end class SimulatorWatch < Simulator class << self def all return DeviceManager.simulators('watchOS') end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/android_package_name_guesser.rb
fastlane_core/lib/fastlane_core/android_package_name_guesser.rb
require 'credentials_manager/appfile_config' require_relative 'configuration/configuration' require_relative 'env' module FastlaneCore class AndroidPackageNameGuesser class << self def android_package_name_arg?(gem_name, arg) return arg == "--package_name" || arg == "--app_package_name" || (arg == '-p' && gem_name == 'supply') || (arg == '-a' && gem_name == 'screengrab') end def guess_package_name_from_args(gem_name, args) # args example: ["-a", "com.krausefx.app"] package_name = nil args.each_with_index do |current, index| next unless android_package_name_arg?(gem_name, current) # argument names are followed by argument values in the args array; # use [index + 1] to find the package name (range check the array # to avoid array bounds errors) package_name = args[index + 1] if args.count > index break end package_name end def guess_package_name_from_environment package_name = nil package_name ||= ENV["SUPPLY_PACKAGE_NAME"] if FastlaneCore::Env.truthy?("SUPPLY_PACKAGE_NAME") package_name ||= ENV["SCREENGRAB_APP_PACKAGE_NAME"] if FastlaneCore::Env.truthy?("SCREENGRAB_APP_PACKAGE_NAME") package_name end def guess_package_name_from_appfile CredentialsManager::AppfileConfig.try_fetch_value(:package_name) end def fetch_package_name_from_file(file_name, package_name_key) # we only care about the package name item in the configuration file, so # build an options array & Configuration with just that one key and it will # be fetched if it is present in the config file genericfile_options = [FastlaneCore::ConfigItem.new(key: package_name_key)] options = FastlaneCore::Configuration.create(genericfile_options, {}) # pass the empty proc to disable options validation, otherwise this will fail # when the other (non-package name) keys are encountered in the config file; # 3rd parameter "true" disables the printout of the contents of the # configuration file, which is noisy and confusing in this case options.load_configuration_file(file_name, proc {}, true) return options.fetch(package_name_key, ask: false) rescue # any option/file error here should just be treated as identifier not found nil end def guess_package_name_from_config_files package_name = nil package_name ||= fetch_package_name_from_file("Supplyfile", :package_name) package_name ||= fetch_package_name_from_file("Screengrabfile", :app_package_name) package_name end # make a best-guess for the package_name for this project, using most-reliable signals # first and then using less accurate ones afterwards; because this method only returns # a GUESS for the package_name, it is only useful for metrics or other places where # absolute accuracy is not required def guess_package_name(gem_name, args) package_name = nil package_name ||= guess_package_name_from_args(gem_name, args) package_name ||= guess_package_name_from_environment package_name ||= guess_package_name_from_appfile package_name ||= guess_package_name_from_config_files package_name end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/configuration/configuration_file.rb
fastlane_core/lib/fastlane_core/configuration/configuration_file.rb
require_relative '../print_table' require_relative '../ui/ui' module FastlaneCore # Responsible for loading configuration files class ConfigurationFile class ExceptionWhileParsingError < RuntimeError attr_reader :wrapped_exception attr_reader :recovered_options def initialize(wrapped_ex, options) @wrapped_exception = wrapped_ex @recovered_options = options end end # Available keys from the config file attr_accessor :available_keys # After loading, contains all the found options attr_accessor :options # Path to the config file represented by the current object attr_accessor :configfile_path # @param config [FastlaneCore::Configuration] is used to gather required information about the configuration # @param path [String] The path to the configuration file to use def initialize(config, path, block_for_missing, skip_printing_values = false) self.available_keys = config.all_keys self.configfile_path = path self.options = {} @block_for_missing = block_for_missing content = File.read(path, encoding: "utf-8") # From https://github.com/orta/danger/blob/master/lib/danger/Dangerfile.rb if content.tr!('“”‘’‛', %(""''')) UI.error("Your #{File.basename(path)} has had smart quotes sanitised. " \ 'To avoid issues in the future, you should not use ' \ 'TextEdit for editing it. If you are not using TextEdit, ' \ 'you should turn off smart quotes in your editor of choice.') end begin # rubocop:disable Security/Eval eval(content) # this is okay in this case # rubocop:enable Security/Eval print_resulting_config_values unless skip_printing_values # only on success rescue SyntaxError => ex line = ex.to_s.match(/\(eval.*\):(\d+)/)[1] UI.error("Error in your #{File.basename(path)} at line #{line}") UI.content_error(content, line) UI.user_error!("Syntax error in your configuration file '#{path}' on line #{line}: #{ex}") rescue => ex raise ExceptionWhileParsingError.new(ex, self.options), "Error while parsing config file at #{path}" end end def print_resulting_config_values require 'terminal-table' UI.success("Successfully loaded '#{File.expand_path(self.configfile_path)}' 📄") # Show message when self.modified_values is empty if self.modified_values.empty? UI.important("No values defined in '#{self.configfile_path}'") return end rows = self.modified_values.collect do |key, value| [key, value] if value.to_s.length > 0 end.compact puts("") puts(Terminal::Table.new(rows: FastlaneCore::PrintTable.transform_output(rows), title: "Detected Values from '#{self.configfile_path}'")) puts("") end # This is used to display only the values that have changed in the summary table def modified_values @modified_values ||= {} end def method_missing(method_sym, *arguments, &block) # First, check if the key is actually available return if self.options.key?(method_sym) if self.available_keys.include?(method_sym) value = arguments.first value = yield if value.nil? && block_given? if value.nil? unless block_given? # The config file has something like this: # # clean # # without specifying a value for the method call # or a block. This is most likely a user error # So we tell the user that they can provide a value warning = ["In the config file '#{self.configfile_path}'"] warning << "you have the line #{method_sym}, but didn't provide" warning << "any value. Make sure to append a value right after the" warning << "option name. Make sure to check the docs for more information" UI.important(warning.join(" ")) end return end self.modified_values[method_sym] = value # to support frozen strings (e.g. ENV variables) too # we have to dupe the value # in < Ruby 2.4.0 `.dup` is not support by boolean values # and there is no good way to check if a class actually # responds to `dup`, so we have to rescue the exception begin value = value.dup rescue TypeError # Nothing specific to do here, if we can't dupe, we just # deal with it (boolean values can't be from env variables anyway) end self.options[method_sym] = value else # We can't set this value, maybe the tool using this configuration system has its own # way of handling this block, as this might be a special block (e.g. ipa block) that's only # executed on demand if @block_for_missing @block_for_missing.call(method_sym, arguments, block) else self.options[method_sym] = '' # important, since this will raise a good exception for free end end end # Override configuration for a specific lane. If received lane name does not # match the lane name available as environment variable, no changes will # be applied. # # @param lane_name Symbol representing a lane name. # @yield Block to run for overriding configuration values. # def for_lane(lane_name) if ENV["FASTLANE_LANE_NAME"] == lane_name.to_s with_a_clean_config_merged_when_complete do yield end end end # Override configuration for a specific platform. If received platform name # does not match the platform name available as environment variable, no # changes will be applied. # # @param platform_name Symbol representing a platform name. # @yield Block to run for overriding configuration values. # def for_platform(platform_name) if ENV["FASTLANE_PLATFORM_NAME"] == platform_name.to_s with_a_clean_config_merged_when_complete do yield end end end # Allows a configuration block (for_lane, for_platform) to get a clean # configuration for applying values, so that values can be overridden # (once) again. Those values are then merged into the surrounding # configuration as the block completes def with_a_clean_config_merged_when_complete previous_config = self.options.dup self.options = {} begin yield ensure self.options = previous_config.merge(self.options) end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/configuration/configuration.rb
fastlane_core/lib/fastlane_core/configuration/configuration.rb
require_relative '../helper' require_relative '../globals' require_relative 'config_item' require_relative 'commander_generator' require_relative 'configuration_file' module FastlaneCore class Configuration attr_accessor :available_options attr_accessor :values # @return [Array] An array of symbols which are all available keys attr_reader :all_keys # @return [String] The name of the configuration file (not the path). Optional! attr_accessor :config_file_name # @return [Hash] Options that were set from a config file using load_configuration_file. Optional! attr_accessor :config_file_options def self.create(available_options, values) UI.user_error!("values parameter must be a hash") unless values.kind_of?(Hash) v = values.dup v.each do |key, val| v[key] = val.dup if val.kind_of?(String) # this is necessary when fetching a value from an environment variable end if v.kind_of?(Hash) && available_options.kind_of?(Array) # we only want to deal with the new configuration system # Now see if --verbose would be a valid input # If not, it might be because it's an action and not a tool unless available_options.find { |a| a.kind_of?(ConfigItem) && a.key == :verbose } v.delete(:verbose) # as this is being processed by commander end end Configuration.new(available_options, v) end ##################################################### # @!group Setting up the configuration ##################################################### # collect sensitive strings def self.sensitive_strings @sensitive_strings ||= [] end def initialize(available_options, values) self.available_options = available_options || [] self.values = values || {} self.config_file_options = {} # used for pushing and popping values to provide nesting configuration contexts @values_stack = [] # if we are in captured output mode - keep a array of sensitive option values # those will be later - replaced by #### if FastlaneCore::Globals.capture_output? available_options.each do |element| next unless element.sensitive self.class.sensitive_strings << values[element.key] end end verify_input_types verify_value_exists verify_no_duplicates verify_conflicts verify_default_value_matches_verify_block end def verify_input_types UI.user_error!("available_options parameter must be an array of ConfigItems but is #{@available_options.class}") unless @available_options.kind_of?(Array) @available_options.each do |item| UI.user_error!("available_options parameter must be an array of ConfigItems. Found #{item.class}.") unless item.kind_of?(ConfigItem) end UI.user_error!("values parameter must be a hash") unless @values.kind_of?(Hash) end def verify_value_exists # Make sure the given value keys exist @values.each do |key, value| next if key == :trace # special treatment option = self.verify_options_key!(key) @values[key] = option.auto_convert_value(value) UI.deprecated("Using deprecated option: '--#{key}' (#{option.deprecated})") if option.deprecated option.verify!(@values[key]) # Call the verify block for it too end end def verify_no_duplicates # Make sure a key was not used multiple times @available_options.each do |current| count = @available_options.count { |option| option.key == current.key } UI.user_error!("Multiple entries for configuration key '#{current.key}' found!") if count > 1 unless current.short_option.to_s.empty? count = @available_options.count { |option| option.short_option == current.short_option } UI.user_error!("Multiple entries for short_option '#{current.short_option}' found!") if count > 1 end end end def verify_conflicts option_keys = @values.keys option_keys.each do |current| index = @available_options.find_index { |item| item.key == current } current = @available_options[index] # ignore conflicts because option value is nil next if @values[current.key].nil? next if current.conflicting_options.nil? conflicts = current.conflicting_options & option_keys next if conflicts.nil? conflicts.each do |conflicting_option_key| index = @available_options.find_index { |item| item.key == conflicting_option_key } conflicting_option = @available_options[index] # ignore conflicts because value of conflict option is nil next if @values[conflicting_option.key].nil? if current.conflict_block begin current.conflict_block.call(conflicting_option) rescue => ex UI.error("Error resolving conflict between options: '#{current.key}' and '#{conflicting_option.key}'") raise ex end else UI.user_error!("Unresolved conflict between options: '#{current.key}' and '#{conflicting_option.key}'") end end end end # Verifies the default value is also valid def verify_default_value_matches_verify_block @available_options.each do |item| next unless item.verify_block && item.default_value begin unless @values[item.key] # this is important to not verify if there already is a value there item.verify_block.call(item.default_value) end rescue => ex UI.error(ex) UI.user_error!("Invalid default value for #{item.key}, doesn't match verify_block") end end end # This method takes care of parsing and using the configuration file as values # Call this once you know where the config file might be located # Take a look at how `gym` uses this method # # @param config_file_name [String] The name of the configuration file to use (optional) # @param block_for_missing [Block] A ruby block that is called when there is an unknown method # in the configuration file def load_configuration_file(config_file_name = nil, block_for_missing = nil, skip_printing_values = false) return unless config_file_name self.config_file_name = config_file_name path = FastlaneCore::Configuration.find_configuration_file_path(config_file_name: config_file_name) return if path.nil? begin configuration_file = ConfigurationFile.new(self, path, block_for_missing, skip_printing_values) options = configuration_file.options rescue FastlaneCore::ConfigurationFile::ExceptionWhileParsingError => e options = e.recovered_options wrapped_exception = e.wrapped_exception end # Make sure all the values set in the config file pass verification options.each do |key, val| option = self.verify_options_key!(key) option.verify!(val) end # Merge the new options into the old ones, keeping all previously set keys self.config_file_options = options.merge(self.config_file_options) verify_conflicts # important, since user can set conflicting options in configuration file # Now that everything is verified, re-raise an exception that was raised in the config file raise wrapped_exception unless wrapped_exception.nil? configuration_file end def self.find_configuration_file_path(config_file_name: nil) paths = [] paths += Dir["./fastlane/#{config_file_name}"] paths += Dir["./.fastlane/#{config_file_name}"] paths += Dir["./#{config_file_name}"] paths += Dir["./fastlane_core/spec/fixtures/#{config_file_name}"] if Helper.test? return nil if paths.count == 0 return paths.first end ##################################################### # @!group Actually using the class ##################################################### # Returns the value for a certain key. fastlane_core tries to fetch the value from different sources # if 'ask' is true and the value is not present, the user will be prompted to provide a value if optional # if 'force_ask' is true, the option is not required to be optional to ask # rubocop:disable Metrics/PerceivedComplexity def fetch(key, ask: true, force_ask: false) UI.crash!("Key '#{key}' must be a symbol. Example :#{key}") unless key.kind_of?(Symbol) option = verify_options_key!(key) # Same order as https://docs.fastlane.tools/advanced/#priorities-of-parameters-and-options value = if @values.key?(key) && !@values[key].nil? @values[key] elsif (env_value = option.fetch_env_value) env_value elsif self.config_file_options.key?(key) self.config_file_options[key] else option.default_value end value = option.auto_convert_value(value) value = nil if value.nil? && !option.string? # by default boolean flags are false return value unless value.nil? && (!option.optional || force_ask) && ask # fallback to asking if Helper.test? || !UI.interactive? # Since we don't want to be asked on tests, we'll just call the verify block with no value # to raise the exception that is shown when the user passes an invalid value set(key, '') # If this didn't raise an exception, just raise a default one UI.user_error!("No value found for '#{key}'") end while value.nil? UI.important("To not be asked about this value, you can specify it using '#{option.key}'") if ENV["FASTLANE_ONBOARDING_IN_PROCESS"].to_s.length == 0 value = option.sensitive ? UI.password("#{option.description}: ") : UI.input("#{option.description}: ") # ConfigItem allows to specify a type for the item but UI.password and # UI.input return String values. Try to convert the String input to # the option's type before passing it along. value = option.auto_convert_value(value) # Also store this value to use it from now on begin set(key, value) rescue => ex UI.error(ex) value = nil end end # It's very, very important to use the self[:my_key] notation # as this will make sure to use the `fetch` method # that is responsible for auto converting the values into the right # data type # Found out via https://github.com/fastlane/fastlane/issues/11243 return self[key] end # rubocop:enable Metrics/PerceivedComplexity # Overwrites or sets a new value for a given key # @param key [Symbol] Must be a symbol def set(key, value) UI.crash!("Key '#{key}' must be a symbol. Example :#{key}.") unless key.kind_of?(Symbol) option = option_for_key(key) unless option UI.user_error!("Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}") end option.verify!(value) @values[key] = value true end # see fetch def values(ask: true) # As the user accesses all values, we need to iterate through them to receive all the values @available_options.each do |option| @values[option.key] = fetch(option.key, ask: ask) unless @values[option.key] end @values end # Direct access to the values, without iterating through all items def _values @values end # Clears away any current configuration values by pushing them onto a stack. # Values set after calling push_values! will be merged with the previous # values after calling pop_values! # # see: pop_values! def push_values! @values_stack.push(@values) @values = {} end # Restores a previous set of configuration values by merging any current # values on top of them # # see: push_values! def pop_values! return if @values_stack.empty? @values = @values_stack.pop.merge(@values) end def all_keys @available_options.collect(&:key) end # Returns the config_item object for a given key def option_for_key(key) @available_options.find { |o| o.key == key } end # Aliases `[key]` to `fetch(key)` because Ruby can do it. alias [] fetch alias []= set def verify_options_key!(key) option = option_for_key(key) UI.user_error!("Could not find option '#{key}' in the list of available options: #{@available_options.collect(&:key).join(', ')}") unless option option end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/configuration/commander_generator.rb
fastlane_core/lib/fastlane_core/configuration/commander_generator.rb
require 'commander' require_relative '../module' require_relative '../ui/ui' module FastlaneCore class CommanderGenerator include Commander::Methods # Calls the appropriate methods for commander to show the available parameters def generate(options, command: nil) # First, enable `always_trace`, to show the stack trace always_trace! used_switches = [] options.each do |option| next if option.description.to_s.empty? # "private" options next unless option.display_in_shell short_switch = option.short_option key = option.key validate_short_switch(used_switches, short_switch, key) type = option.data_type # We added type: Hash to code generation, but Ruby's OptionParser doesn't like that # so we need to switch that to something that is supported, luckily, we have an `is_string` # property and if that is false, we'll default to nil if type == Hash type = option.is_string ? String : nil end # OptionParser doesn't like symbol but a symbol and string can be easily cast with `to_sym` and `to_s` if type == Symbol type = String end # Boolean is a fastlane thing, it's either TrueClass, or FalseClass, but we won't know # that until runtime, so nil is the best we get if type == Fastlane::Boolean type = nil end # This is an important bit of trickery to solve the boolean option situation. # # Typically, boolean command line flags do not accept trailing values. If the flag # is present, the value is true, if it is missing, the value is false. fastlane # supports this style of flag. For example, you can specify a flag like `--clean`, # and the :clean option will be true. # # However, fastlane also supports another boolean flag style that accepts trailing # values much like options for Strings and other value types. That looks like # `--include_bitcode false` The problem is that this does not work out of the box # for Commander and OptionsParser. So, we need to get tricky. # # The value_appendix below acts as a placeholder in the switch definition that # states that we expect to have a trailing value for our options. When an option # declares a data type, we use the name of that data type in all caps like: # "--devices ARRAY". When the data type is nil, this implies that we're going # to be doing some special handling on that value. One special thing we do # automatically in Configuration is to coerce special Strings into boolean values. # # If the data type is nil, the trick we do is to specify a value placeholder, but # we wrap it in [] brackets to mark it as optional. That means that the trailing # value may or may not be present for this flag. If the flag is present, but the # value is not, we get a value of `true`. Perfect for the boolean flag base-case! # If the value is there, we'll actually get it back as a String, which we can # later coerce into a boolean. # # In this way we support handling boolean flags with or without trailing values. value_appendix = (type || '[VALUE]').to_s.upcase long_switch = "--#{option.key} #{value_appendix}" description = option.description description += " (#{option.env_names.join(', ')})" unless option.env_names.empty? # We compact this array here to remove the short_switch variable if it is nil. # Passing a nil value to global_option has been shown to create problems with # option parsing! # # See: https://github.com/fastlane/fastlane_core/pull/89 # # If we don't have a data type for this option, we tell it to act like a String. # This allows us to get a reasonable value for boolean options that can be # automatically coerced or otherwise handled by the ConfigItem for others. args = [short_switch, long_switch, (type || String), description].compact if command command.option(*args) else # This is the call to Commander to set up the option we've been building. global_option(*args) end end end def validate_short_switch(used_switches, short_switch, key) return if short_switch.nil? UI.user_error!("Short option #{short_switch} already taken for key #{key}") if used_switches.include?(short_switch) UI.user_error!("-v is already used for the fastlane version (key #{key})") if short_switch == "-v" UI.user_error!("-h is already used for the fastlane help screen (key #{key})") if short_switch == "-h" UI.user_error!("-t is already used for the fastlane trace screen (key #{key})") if short_switch == "-t" used_switches << short_switch end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/configuration/config_item.rb
fastlane_core/lib/fastlane_core/configuration/config_item.rb
require_relative '../ui/ui' require_relative '../ui/errors/fastlane_error' require_relative '../helper' require_relative '../module' require 'json' module FastlaneCore class ConfigItem # [Symbol] the key which is used as command parameters or key in the fastlane tools attr_accessor :key # [String] the name of the environment variable, which is only used if no other values were found attr_accessor :env_name # [Array] the names of the environment variables, which is only used if no other values were found attr_accessor :env_names # [String] A description shown to the user attr_accessor :description # [String] A string of length 1 which is used for the command parameters (e.g. -f) attr_accessor :short_option # the value which is used if there was no given values and no environment values attr_accessor :default_value # [Boolean] Set if the default value is generated dynamically attr_accessor :default_value_dynamic # the value which is used during Swift code generation # if the default_value reads from ENV or a file, or from local credentials, we need # to provide a different default or it might be included in our autogenerated Swift # as a built-in default for the fastlane gem. This is because when we generate the # Swift API at deployment time, it fetches the default_value from the config_items attr_accessor :code_gen_default_value # An optional block which is called when a new value is set. # Check value is valid. This could be type checks or if a folder/file exists # You have to raise a specific exception if something goes wrong. Use `user_error!` for the message: UI.user_error!("your message") attr_accessor :verify_block # [Boolean] is false by default. If set to true, also string values will not be asked to the user attr_accessor :optional # [Boolean] is false by default. If set to true, type of the parameter will not be validated. attr_accessor :skip_type_validation # [Array] array of conflicting option keys(@param key). This allows to resolve conflicts intelligently attr_accessor :conflicting_options # An optional block which is called when options conflict happens attr_accessor :conflict_block # [String] Set if the option is deprecated. A deprecated option should be optional and is made optional if the parameter isn't set, and fails otherwise attr_accessor :deprecated # [Boolean] Set if the variable is sensitive, such as a password or API token, to prevent echoing when prompted for the parameter # If a default value exists, it won't be used during code generation as default values can read from environment variables. attr_accessor :sensitive # [Boolean] Set if the default value should never be used during code generation for Swift # We generate the Swift API at deployment time, and if there is a value that should never be # included in the Fastlane.swift or other autogenerated classes, we need to strip it out. # This includes things like API keys that could be read from ENV[] attr_accessor :code_gen_sensitive # [Boolean] Set if the variable is to be converted to a shell-escaped String when provided as a Hash or Array # Allows items expected to be strings used in shell arguments to be alternatively provided as a Hash or Array for better readability and auto-escaped for us. attr_accessor :allow_shell_conversion # [Boolean] Set if the variable can be used from shell attr_accessor :display_in_shell # Creates a new option # @param key (Symbol) the key which is used as command parameters or key in the fastlane tools # @param env_name (String) the name of the environment variable, which is only used if no other values were found # @param env_names (Array) the names of the environment variables, which is only used if no other values were found # @param description (String) A description shown to the user # @param short_option (String) A string of length 1 which is used for the command parameters (e.g. -f) # @param default_value the value which is used if there was no given values and no environment values # @param default_value_dynamic (Boolean) Set if the default value is generated dynamically # @param verify_block an optional block which is called when a new value is set. # Check value is valid. This could be type checks or if a folder/file exists # You have to raise a specific exception if something goes wrong. Append .red after the string # @param is_string *DEPRECATED: Use `type` instead* (Boolean) is that parameter a string? Defaults to true. If it's true, the type string will be verified. # @param type (Class) the data type of this config item. Takes precedence over `is_string`. Use `:shell_string` to allow types `String`, `Hash` and `Array` that will be converted to shell-escaped strings # @param skip_type_validation (Boolean) is false by default. If set to true, type of the parameter will not be validated. # @param optional (Boolean) is false by default. If set to true, also string values will not be asked to the user # @param conflicting_options ([]) array of conflicting option keys(@param key). This allows to resolve conflicts intelligently # @param conflict_block an optional block which is called when options conflict happens # @param deprecated (Boolean|String) Set if the option is deprecated. A deprecated option should be optional and is made optional if the parameter isn't set, and fails otherwise # @param sensitive (Boolean) Set if the variable is sensitive, such as a password or API token, to prevent echoing when prompted for the parameter # @param display_in_shell (Boolean) Set if the variable can be used from shell # rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/PerceivedComplexity def initialize(key: nil, env_name: nil, env_names: nil, description: nil, short_option: nil, default_value: nil, default_value_dynamic: false, verify_block: nil, is_string: true, type: nil, skip_type_validation: false, optional: nil, conflicting_options: nil, conflict_block: nil, deprecated: nil, sensitive: nil, code_gen_sensitive: false, code_gen_default_value: nil, display_in_shell: true) UI.user_error!("key must be a symbol") unless key.kind_of?(Symbol) UI.user_error!("env_name must be a String") unless (env_name || '').kind_of?(String) UI.user_error!("env_names must be an Array") unless (env_names || []).kind_of?(Array) (env_names || []).each do |name| UI.user_error!("env_names must only contain String") unless (name || '').kind_of?(String) end if short_option UI.user_error!("short_option for key :#{key} must of type String") unless short_option.kind_of?(String) UI.user_error!("short_option for key :#{key} must be a string of length 1") unless short_option.delete('-').length == 1 end if description UI.user_error!("Do not let descriptions end with a '.', since it's used for user inputs as well for key :#{key}") if description[-1] == '.' end if conflicting_options conflicting_options.each do |conflicting_option_key| UI.user_error!("Conflicting option key must be a symbol") unless conflicting_option_key.kind_of?(Symbol) end end if deprecated # deprecated options are automatically optional optional = true if optional.nil? UI.crash!("Deprecated option must be optional") unless optional # deprecated options are marked deprecated in their description description = deprecated_description(description, deprecated) end optional = false if optional.nil? sensitive = false if sensitive.nil? @key = key @env_name = env_name @env_names = [env_name].compact + (env_names || []) @description = description @short_option = short_option @default_value = default_value @default_value_dynamic = default_value_dynamic @verify_block = verify_block @is_string = is_string @data_type = type @data_type = String if type == :shell_string @optional = optional @conflicting_options = conflicting_options @conflict_block = conflict_block @deprecated = deprecated @sensitive = sensitive @code_gen_sensitive = code_gen_sensitive || sensitive @allow_shell_conversion = (type == :shell_string) @display_in_shell = display_in_shell @skip_type_validation = skip_type_validation # sometimes we allow multiple types which causes type validation failures, e.g.: export_options in gym @code_gen_default_value = code_gen_default_value update_code_gen_default_value_if_able! end # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/ParameterLists # if code_gen_default_value is nil, use the default value if it isn't a `code_gen_sensitive` value def update_code_gen_default_value_if_able! # we don't support default values for procs if @data_type == :string_callback @code_gen_default_value = nil return end if @code_gen_default_value.nil? unless @code_gen_sensitive @code_gen_default_value = @default_value end end end def verify!(value) valid?(value) end def ensure_generic_type_passes_validation(value) if @skip_type_validation return end if data_type != :string_callback && data_type && !value.kind_of?(data_type) UI.user_error!("'#{self.key}' value must be a #{data_type}! Found #{value.class} instead.") end end def ensure_boolean_type_passes_validation(value) if @skip_type_validation return end # We need to explicitly test against Fastlane::Boolean, TrueClass/FalseClass if value.class != FalseClass && value.class != TrueClass UI.user_error!("'#{self.key}' value must be either `true` or `false`! Found #{value.class} instead.") end end def ensure_array_type_passes_validation(value) if @skip_type_validation return end # Arrays can be an either be an array or string that gets split by comma in auto_convert_type if !value.kind_of?(Array) && !value.kind_of?(String) UI.user_error!("'#{self.key}' value must be either `Array` or `comma-separated String`! Found #{value.class} instead.") end end # Make sure, the value is valid (based on the verify block) # Raises an exception if the value is invalid def valid?(value) # we also allow nil values, which do not have to be verified. return true if value.nil? # Verify that value is the type that we're expecting, if we are expecting a type if data_type == Fastlane::Boolean ensure_boolean_type_passes_validation(value) elsif data_type == Array ensure_array_type_passes_validation(value) else ensure_generic_type_passes_validation(value) end if @verify_block begin @verify_block.call(value) rescue => ex UI.error("Error setting value '#{value}' for option '#{@key}'") raise Interface::FastlaneError.new, ex.to_s end end true end def fetch_env_value env_names.each do |name| next if ENV[name].nil? # verify! before using (see https://github.com/fastlane/fastlane/issues/14449) return ENV[name].dup if verify!(auto_convert_value(ENV[name])) end return nil end # rubocop:disable Metrics/PerceivedComplexity # Returns an updated value type (if necessary) def auto_convert_value(value) return nil if value.nil? if data_type == Array return value.split(',') if value.kind_of?(String) elsif data_type == Integer return value.to_i if value.to_i.to_s == value.to_s elsif data_type == Float return value.to_f if value.to_f.to_s == value.to_s elsif data_type == Symbol return value.to_sym if value.to_sym.to_s == value.to_s elsif allow_shell_conversion return value.shelljoin if value.kind_of?(Array) return value.map { |k, v| "#{k.to_s.shellescape}=#{v.shellescape}" }.join(' ') if value.kind_of?(Hash) elsif data_type == Hash && value.kind_of?(String) begin parsed = JSON.parse(value) return parsed if parsed.kind_of?(Hash) rescue JSON::ParserError end elsif data_type != String # Special treatment if the user specified true, false, on, off or YES, NO # There is no boolean type, so we just do it here if %w(yes YES true TRUE on ON).include?(value) return true elsif %w(no NO false FALSE off OFF).include?(value) return false end end # rubocop:enable Metrics/PerceivedComplexity return value # fallback to not doing anything end # Determines the defined data type of this ConfigItem def data_type if @data_type @data_type else (@is_string ? String : nil) end end # Replaces the attr_accessor, but maintains the same interface def string? data_type == String end # it's preferred to use self.string? In most cases, except in commander_generator.rb, cause... reasons def is_string return @is_string end def to_s [@key, @description].join(": ") end def deprecated_description(initial_description, deprecated) has_description = !initial_description.to_s.empty? description = "**DEPRECATED!**" if deprecated.kind_of?(String) description << " #{deprecated}" description << " -" if has_description end description << " #{initial_description}" if has_description description end def doc_default_value return "[*](#parameters-legend-dynamic)" if self.default_value_dynamic return "" if self.default_value.nil? return "`''`" if self.default_value.instance_of?(String) && self.default_value.empty? return "`:#{self.default_value}`" if self.default_value.instance_of?(Symbol) "`#{self.default_value}`" end def help_default_value return "#{self.default_value} *".strip if self.default_value_dynamic return "" if self.default_value.nil? return "''" if self.default_value.instance_of?(String) && self.default_value.empty? return ":#{self.default_value}" if self.default_value.instance_of?(Symbol) self.default_value end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/core_ext/cfpropertylist.rb
fastlane_core/lib/fastlane_core/core_ext/cfpropertylist.rb
# To be used instead of require "cfpropertylist". Restores extensions from # Plist overwritten by CFPropertyList. require "cfpropertylist" require "plist" # Brute-force solution to conflict between #to_plist introduced by # CFPropertyList and plist. Remove the method added by CFPropertyList # and restore the method from Plist::Emit. Each class gains a # #to_binary_plist method equivalent to #to_plist from CFPropertyList. # # CFPropertyList also adds Enumerator#to_plist, but there is no such # method from Plist, so leave it. [Array, Hash].each do |c| if c.method_defined?(:to_plist) begin c.send(:alias_method, :to_binary_plist, :to_plist) c.send(:remove_method, :to_plist) rescue NameError end end c.module_eval("include Plist::Emit") end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/core_ext/string.rb
fastlane_core/lib/fastlane_core/core_ext/string.rb
class String def fastlane_class split('_').collect!(&:capitalize).join end def fastlane_module self == "pem" ? 'PEM' : self.fastlane_class end def fastlane_underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/core_ext/shellwords.rb
fastlane_core/lib/fastlane_core/core_ext/shellwords.rb
require_relative '../helper' require 'shellwords' # Here be monkey patches class String # CrossplatformShellwords def shellescape CrossplatformShellwords.shellescape(self) end end class Array def shelljoin CrossplatformShellwords.shelljoin(self) end end # Here be helper module CrossplatformShellwords # handle switching between implementations of shellescape def shellescape(str) if FastlaneCore::Helper.windows? WindowsShellwords.shellescape(str) else # using `escape` instead of expected `shellescape` here # which corresponds to Shellword's `String.shellescape` implementation # https://github.com/ruby/ruby/blob/1cf2bb4b2085758112503e7da7414d1ef52d4f48/lib/shellwords.rb#L216 Shellwords.escape(str) end end module_function :shellescape # make sure local implementation is also used in shelljoin def shelljoin(array) array.map { |arg| shellescape(arg) }.join(' ') end module_function :shelljoin end # Windows implementation module WindowsShellwords def shellescape(str) str = str.to_s # An empty argument will be skipped, so return empty quotes. # https://github.com/ruby/ruby/blob/a6413848153e6c37f6b0fea64e3e871460732e34/lib/shellwords.rb#L142-L143 return '""'.dup if str.empty? str = str.dup # wrap in double quotes if contains space if str =~ /\s/ # double quotes have to be doubled if will be quoted str.gsub!('"', '""') return '"' + str + '"' else return str end end module_function :shellescape end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/feature/feature.rb
fastlane_core/lib/fastlane_core/feature/feature.rb
require_relative '../env' module FastlaneCore class Feature class << self attr_reader :features def register(env_var: nil, description: nil) feature = self.new(description: description, env_var: env_var) @features[feature.env_var] = feature end def enabled?(env_var) feature = @features[env_var] return false if feature.nil? return FastlaneCore::Env.truthy?(feature.env_var) end def register_class_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) return if klass.nil? || symbol.nil? || disabled_symbol.nil? || enabled_symbol.nil? || env_var.nil? klass.define_singleton_method(symbol) do |*args| if Feature.enabled?(env_var) klass.send(enabled_symbol, *args) else klass.send(disabled_symbol, *args) end end end def register_instance_method(klass: nil, symbol: nil, disabled_symbol: nil, enabled_symbol: nil, env_var: nil) return if klass.nil? || symbol.nil? || disabled_symbol.nil? || enabled_symbol.nil? || env_var.nil? klass.send(:define_method, symbol.to_s) do |*args| if Feature.enabled?(env_var) send(enabled_symbol, *args) else send(disabled_symbol, *args) end end end end @features = {} attr_reader :env_var, :description def initialize(env_var: nil, description: nil) raise "Invalid Feature" if env_var.nil? || description.nil? @env_var = env_var @description = description end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
fastlane_core/lib/fastlane_core/analytics/analytics_ingester_client.rb
require 'faraday' require 'openssl' require 'json' require_relative '../helper' module FastlaneCore class AnalyticsIngesterClient GA_URL = "https://www.google-analytics.com" private_constant :GA_URL def initialize(ga_tracking) @ga_tracking = ga_tracking end def post_event(event) # If our users want to opt out of usage metrics, don't post the events. # Learn more at https://docs.fastlane.tools/#metrics if Helper.test? || FastlaneCore::Env.truthy?("FASTLANE_OPT_OUT_USAGE") return nil end return Thread.new do send_request(event) end end def send_request(event, retries: 2) post_request(event) rescue retries -= 1 retry if retries >= 0 end def post_request(event) connection = Faraday.new(GA_URL) do |conn| conn.request(:url_encoded) conn.adapter(Faraday.default_adapter) end connection.headers[:user_agent] = 'fastlane/' + Fastlane::VERSION connection.post("/collect", { v: "1", # API Version tid: @ga_tracking, # Tracking ID / Property ID cid: event[:client_id], # Client ID t: "event", # Event hit type ec: event[:category], # Event category ea: event[:action], # Event action el: event[:label] || "na", # Event label ev: event[:value] || "0", # Event value aip: "1" # IP anonymization }) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/action_launch_context.rb
fastlane_core/lib/fastlane_core/analytics/action_launch_context.rb
require_relative '../helper' require_relative 'app_identifier_guesser' module FastlaneCore class ActionLaunchContext UNKNOWN_P_HASH = 'unknown' attr_accessor :action_name attr_accessor :p_hash attr_accessor :platform attr_accessor :fastlane_client_language # example: ruby fastfile, swift fastfile def initialize(action_name: nil, p_hash: UNKNOWN_P_HASH, platform: nil, fastlane_client_language: nil) @action_name = action_name @p_hash = p_hash @platform = platform @fastlane_client_language = fastlane_client_language end def self.context_for_action_name(action_name, fastlane_client_language: :ruby, args: nil) app_id_guesser = FastlaneCore::AppIdentifierGuesser.new(args: args) return self.new( action_name: action_name, p_hash: app_id_guesser.p_hash || UNKNOWN_P_HASH, platform: app_id_guesser.platform, fastlane_client_language: fastlane_client_language ) end def build_tool_version if platform == :android return 'android' else return "Xcode #{Helper.xcode_version}" end end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/app_identifier_guesser.rb
fastlane_core/lib/fastlane_core/analytics/app_identifier_guesser.rb
require_relative '../android_package_name_guesser' require_relative '../ios_app_identifier_guesser' require_relative '../env' module FastlaneCore class AppIdentifierGuesser attr_accessor :args attr_accessor :gem_name attr_accessor :platform attr_accessor :p_hash attr_accessor :app_id def initialize(args: nil, gem_name: 'fastlane') @args = args @gem_name = gem_name @app_id = android_app_identifier(args, gem_name) @platform = nil # since have a state in-between runs if @app_id @platform = :android else @app_id = ios_app_identifier(args) @platform = :ios if @app_id end @p_hash = generate_p_hash(@app_id) end # To not count the same projects multiple time for the number of launches # Learn more at https://docs.fastlane.tools/#metrics # Use the `FASTLANE_OPT_OUT_USAGE` variable to opt out # The resulting value is e.g. ce12f8371df11ef6097a83bdf2303e4357d6f5040acc4f76019489fa5deeae0d def generate_p_hash(app_id) if app_id.nil? return nil end return Digest::SHA256.hexdigest("p#{app_id}fastlan3_SAlt") # hashed + salted the bundle identifier rescue return nil # we don't want this method to cause a crash end # (optional) Returns the app identifier for the current tool def ios_app_identifier(args) return FastlaneCore::IOSAppIdentifierGuesser.guess_app_identifier(args) rescue nil # we don't want this method to cause a crash end # (optional) Returns the app identifier for the current tool # supply and screengrab use different param names and env variable patterns so we have to special case here # example: # fastlane supply --skip_upload_screenshots -a beta -p com.test.app should return com.test.app # screengrab -a com.test.app should return com.test.app def android_app_identifier(args, gem_name) app_identifier = FastlaneCore::AndroidPackageNameGuesser.guess_package_name(gem_name, args) # Add Android prefix to prevent collisions if there is an iOS app with the same identifier app_identifier ? "android_project_#{app_identifier}" : nil rescue nil # we don't want this method to cause a crash end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/analytics_session.rb
fastlane_core/lib/fastlane_core/analytics/analytics_session.rb
require_relative 'analytics_ingester_client' require_relative 'action_launch_context' require_relative 'analytics_event_builder' module FastlaneCore class AnalyticsSession GA_TRACKING = "UA-121171860-1" private_constant :GA_TRACKING attr_accessor :session_id attr_accessor :client def initialize(analytics_ingester_client: AnalyticsIngesterClient.new(GA_TRACKING)) require 'securerandom' @session_id = SecureRandom.uuid @client = analytics_ingester_client @threads = [] @launch_event_sent = false end def action_launched(launch_context: nil) if should_show_message? show_message end if @launch_event_sent || launch_context.p_hash.nil? return end @launch_event_sent = true builder = AnalyticsEventBuilder.new( p_hash: launch_context.p_hash, session_id: session_id, action_name: nil, fastlane_client_language: launch_context.fastlane_client_language ) launch_event = builder.new_event(:launch) post_thread = client.post_event(launch_event) unless post_thread.nil? @threads << post_thread end end def action_completed(completion_context: nil) end def show_message UI.message("Sending anonymous analytics information") UI.message("Learn more at https://docs.fastlane.tools/#metrics") UI.message("No personal or sensitive data is sent.") UI.message("You can disable this by adding `opt_out_usage` at the top of your Fastfile") end def should_show_message? return false if FastlaneCore::Env.truthy?("FASTLANE_OPT_OUT_USAGE") file_name = ".did_show_opt_info" new_path = File.join(FastlaneCore.fastlane_user_dir, file_name) return false if File.exist?(new_path) File.write(new_path, '1') true end def finalize_session @threads.map(&:join) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb
fastlane_core/lib/fastlane_core/analytics/analytics_event_builder.rb
module FastlaneCore class AnalyticsEventBuilder attr_accessor :action_name # fastlane_client_language valid options are :ruby or :swift def initialize(p_hash: nil, session_id: nil, action_name: nil, fastlane_client_language: :ruby) @p_hash = p_hash @session_id = session_id @action_name = action_name @fastlane_client_language = fastlane_client_language end def new_event(action_stage) { client_id: @p_hash, category: "fastlane Client Language - #{@fastlane_client_language}", action: action_stage, label: action_name, value: nil } end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/analytics/action_completion_context.rb
fastlane_core/lib/fastlane_core/analytics/action_completion_context.rb
require_relative 'app_identifier_guesser' module FastlaneCore class ActionCompletionStatus SUCCESS = 'success' FAILED = 'failed' # fastlane crashes unrelated to user_error! USER_ERROR = 'user_error' # Anytime a user_error! is triggered INTERRUPTED = 'interrupted' end class ActionCompletionContext attr_accessor :p_hash attr_accessor :action_name attr_accessor :status attr_accessor :fastlane_client_language def initialize(p_hash: nil, action_name: nil, status: nil, fastlane_client_language: nil) @p_hash = p_hash @action_name = action_name @status = status @fastlane_client_language = fastlane_client_language end def self.context_for_action_name(action_name, fastlane_client_language: :ruby, args: nil, status: nil) app_id_guesser = FastlaneCore::AppIdentifierGuesser.new(args: args) return self.new( action_name: action_name, p_hash: app_id_guesser.p_hash, status: status, fastlane_client_language: fastlane_client_language ) end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ui/help_formatter.rb
fastlane_core/lib/fastlane_core/ui/help_formatter.rb
require 'commander' module FastlaneCore class HelpFormatter < ::Commander::HelpFormatter::TerminalCompact def template(name) # fastlane only customizes the global command help return super unless name == :help ERB.new(File.read(File.join(File.dirname(__FILE__), "help.erb")), trim_mode: '-') end end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ui/disable_colors.rb
fastlane_core/lib/fastlane_core/ui/disable_colors.rb
# This code overwrites the methods from the colored gem # via https://github.com/defunkt/colored/blob/master/lib/colored.rb require 'colored' class String Colored::COLORS.keys.each do |color| define_method(color) do self # do nothing with the string, but return it end end Colored::EXTRAS.keys.each do |extra| next if extra == 'clear' define_method(extra) do self # do nothing with the string, but return it end end end # If a plugin uses the colorize gem, we also want to disable that begin require 'colorize' String.disable_colorization = true rescue LoadError # Colorize gem is not used by any plugin end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ui/ui.rb
fastlane_core/lib/fastlane_core/ui/ui.rb
module FastlaneCore class UI class << self attr_accessor(:ui_object) def ui_object require_relative 'implementations/shell' @ui_object ||= Shell.new end def method_missing(method_sym, *args, &_block) # not using `responds` because we don't care about methods like .to_s and so on require_relative 'interface' interface_methods = FastlaneCore::Interface.instance_methods - Object.instance_methods UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym) self.ui_object.send(method_sym, *args) end end end end # Import all available implementations Dir[File.dirname(__FILE__) + '/implementations/*.rb'].each do |file| require_relative file end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ui/errors.rb
fastlane_core/lib/fastlane_core/ui/errors.rb
Dir[File.dirname(__FILE__) + "/errors/*.rb"].each { |f| require_relative f }
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false
fastlane/fastlane
https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane_core/lib/fastlane_core/ui/interface.rb
fastlane_core/lib/fastlane_core/ui/interface.rb
require_relative 'errors' module FastlaneCore # Abstract super class class Interface ##################################################### # @!group Messaging: show text to the user ##################################################### # Level Error: Can be used to show additional error # information before actually raising an exception # or can be used to just show an error from which # fastlane can recover (much magic) # # By default those messages are shown in red def error(_message) not_implemented(__method__) end # Level Important: Can be used to show warnings to the user # not necessarily negative, but something the user should # be aware of. # # By default those messages are shown in yellow def important(_message) not_implemented(__method__) end # Level Success: Show that something was successful # # By default those messages are shown in green def success(_message) not_implemented(__method__) end # Level Message: Show a neutral message to the user # # By default those messages shown in white/black def message(_message) not_implemented(__method__) end # Level Deprecated: Show that a particular function is deprecated # # By default those messages shown in strong blue def deprecated(_message) not_implemented(__method__) end # Level Command: Print out a terminal command that is being # executed. # # By default those messages shown in cyan def command(_message) not_implemented(__method__) end # Level Command Output: Print the output of a command with # this method # # By default those messages shown in magenta def command_output(_message) not_implemented(__method__) end # Level Verbose: Print out additional information for the # users that are interested. Will only be printed when # FastlaneCore::Globals.verbose? = true # # By default those messages are shown in white def verbose(_message) not_implemented(__method__) end # Print a header = a text in a box # use this if this message is really important def header(_message) not_implemented(__method__) end # Print lines of content around specific line where # failed to parse. # # This message will be shown as error def content_error(content, error_line) not_implemented(__method__) end ##################################################### # @!group Errors: Inputs ##################################################### # Is is possible to ask the user questions? def interactive? not_implemented(__method__) end # get a standard text input (single line) def input(_message) not_implemented(__method__) end # A simple yes or no question def confirm(_message) not_implemented(__method__) end # Let the user select one out of x items # return value is the value of the option the user chose def select(_message, _options) not_implemented(__method__) end # Password input for the user, text field shouldn't show # plain text def password(_message) not_implemented(__method__) end ##################################################### # @!group Abort helper methods ##################################################### # Pass an exception to this method to exit the program # using the given exception # Use this method instead of user_error! if this error is # unexpected, e.g. an invalid server response that shouldn't happen def crash!(exception) raise FastlaneCrash.new, exception.to_s end # Use this method to exit the program because of an user error # e.g. app doesn't exist on the given Developer Account # or invalid user credentials # or scan tests fail # This will show the error message, but doesn't show the full # stack trace # Basically this should be used when you actively catch the error # and want to show a nice error message to the user def user_error!(error_message, options = {}) raise FastlaneError.new(show_github_issues: options[:show_github_issues], error_info: options[:error_info]), error_message.to_s end # Use this method to exit the program because of a shell command # failure -- the command returned a non-zero response. This does # not specify the nature of the error. The error might be from a # programming error, a user error, or an expected error because # the user of the Fastfile doesn't have their environment set up # properly. Because of this, when these errors occur, it means # that the caller of the shell command did not adequate error # handling and the caller error handling should be improved. def shell_error!(error_message, options = {}) raise FastlaneShellError.new(options), error_message.to_s end # Use this method to exit the program because of a build failure # that's caused by the source code of the user. Example for this # is that gym will fail when the code doesn't compile or because # settings for the project are incorrect. # By using this method we'll have more accurate results about # fastlane failures def build_failure!(error_message, options = {}) raise FastlaneBuildFailure.new(options), error_message.to_s end # Use this method to exit the program because of a test failure # that's caused by the source code of the user. Example for this # is that scan will fail when the tests fail. # By using this method we'll have more accurate results about # fastlane failures def test_failure!(error_message) raise FastlaneTestFailure.new, error_message end # Use this method to exit the program because of terminal state # that is neither the fault of fastlane, nor a problem with the # user's input. Using this method instead of user_error! will # avoid tracking this outcome as a fastlane failure. # # e.g. tests ran successfully, but no screenshots were found # # This will show the message, but hide the full stack trace. def abort_with_message!(message) raise FastlaneCommonException.new, message end ##################################################### # @!group Helpers ##################################################### def not_implemented(method_name) require_relative 'ui' UI.user_error!("Current UI '#{self}' doesn't support method '#{method_name}'") end def to_s self.class.name.split('::').last end end end class String def deprecated self.bold.blue end end
ruby
MIT
d1f6eb6228644936997aae1956d8036ea62cd5b4
2026-01-04T15:37:27.371479Z
false