pilot/lib/pilot/manager.rb in fastlane_hotfix-2.165.1 vs pilot/lib/pilot/manager.rb in fastlane_hotfix-2.187.0
- old
+ new
@@ -11,29 +11,32 @@
module Pilot
class Manager
def start(options, should_login: true)
return if @config # to not login multiple times
@config = options
- login if should_login
+
+ # we will always start with App Store Connect API login 'if possible'
+ # else fallback to 'should_login' param for 'apple_id' login
+ login if options[:api_key_path] || options[:api_key] || should_login
end
def login
- if api_token
+ if (api_token = Spaceship::ConnectAPI::Token.from(hash: config[:api_key], filepath: config[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
+ elsif !Spaceship::ConnectAPI.token.nil?
+ UI.message("Using existing authorization token for App Store Connect API")
else
config[:username] ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
+ # Username is now optional since addition of App Store Connect API Key
+ # Force asking for username to prompt user if not already set
+ config.fetch(:username, force_ask: true)
+
UI.message("Login to App Store Connect (#{config[:username]})")
Spaceship::ConnectAPI.login(config[:username], use_portal: false, use_tunes: true, tunes_team_id: config[:team_id], team_name: config[:team_name])
UI.message("Login successful")
end
- end
-
- def api_token
- @api_token ||= Spaceship::ConnectAPI::Token.create(config[:api_key]) if config[:api_key]
- @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(config[:api_key_path]) if config[:api_key_path]
- return @api_token
end
# The app object we're currently using
def app
@app_id ||= fetch_app_id