Class: Pilot::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/pilot/manager.rb

Instance Method Summary collapse

Instance Method Details

#appObject

The app object we’re currently using



23
24
25
26
27
28
29
30
# File 'lib/pilot/manager.rb', line 23

def app
  @apple_id ||= fetch_app_id

  unless (@app ||= Spaceship::Application.find(@apple_id))
    raise "Could not find app with #{(config[:apple_id] || config[:app_identifier])}"
  end
  return @app
end

#configObject

Access the current configuration



33
34
35
# File 'lib/pilot/manager.rb', line 33

def config
  @config
end

#fetch_app_idObject

Config Related



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pilot/manager.rb', line 40

def fetch_app_id
  return @apple_id if @apple_id
  config[:app_identifier] = fetch_app_identifier

  if config[:app_identifier]
    @app ||= Spaceship::Application.find(config[:app_identifier])
    app_id ||= @app.apple_id
  end

  app_id ||= ask("Could not automatically find the app ID, please enter it here (e.g. 956814360): ")

  return app_id
end

#fetch_app_identifierObject



54
55
56
57
58
59
# File 'lib/pilot/manager.rb', line 54

def fetch_app_identifier
  result = config[:app_identifier]
  result ||= FastlaneCore::IpaFileAnalyser.fetch_app_identifier(config[:ipa])
  result ||= ask("Please enter the app's bundle identifier: ")
  return result
end

#loginObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/pilot/manager.rb', line 11

def 
  user = config[:username]
  user ||= ENV["DELIVER_USERNAME"]
  user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
  CredentialsManager::PasswordManager.shared_manager(user) if user

  Helper.log.info "Login to iTunes Connect"
  Spaceship::Tunes.(user, CredentialsManager::PasswordManager.shared_manager(user).password)
  Helper.log.info "Login successful"
end

#start(options) ⇒ Object



5
6
7
8
9
# File 'lib/pilot/manager.rb', line 5

def start(options)
  return if @config # to not login multiple times
  @config = options
  
end