Class: Spaceship::Playground

Inherits:
Object
  • Object
show all
Defined in:
spaceship/lib/spaceship/playground.rb

Instance Method Summary collapse

Constructor Details

#initialize(username: nil) ⇒ Playground

Returns a new instance of Playground.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'spaceship/lib/spaceship/playground.rb', line 9

def initialize(username: nil)
  # Make sure the user has pry installed
  begin
    Gem::Specification.find_by_name("pry")
  rescue Gem::LoadError
    puts("Could not find gem 'pry'".red)
    puts("")
    puts("If you installed spaceship using `sudo gem install spaceship` run")
    puts("  sudo gem install pry".yellow)
    puts("to install the missing gem")
    puts("")
    puts("If you use a Gemfile add this to your Gemfile:")
    puts("  gem 'pry'".yellow)
    puts("and run " + "`bundle install`".yellow)

    abort
  end

  require 'pry'

  @username = username
  @username ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
  @username ||= ask("Username: ")
end

Instance Method Details

#docsObject


69
70
71
72
73
# File 'spaceship/lib/spaceship/playground.rb', line 69

def docs
  url = 'https://github.com/fastlane/fastlane/tree/master/spaceship/docs'
  `open '#{url}'`
  url
end

#runObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'spaceship/lib/spaceship/playground.rb', line 34

def run
  begin
    puts("Logging into to App Store Connect (#{@username})...")
    Spaceship::Tunes.(@username)
    puts("Successfully logged in to App Store Connect".green)
    puts("")
  rescue
    puts("Could not login to App Store Connect...".red)
  end
  begin
    puts("Logging into the Developer Portal (#{@username})...")
    Spaceship::Portal.(@username)
    puts("Successfully logged in to the Developer Portal".green)
    puts("")
  rescue
    puts("Could not login to the Developer Portal...".red)
  end

  puts("---------------------------------------".green)
  puts("| Welcome to the spaceship playground |".green)
  puts("---------------------------------------".green)
  puts("")
  puts("Enter #{'docs'.yellow} to open up the documentation")
  puts("Enter #{'exit'.yellow} to exit the spaceship playground")
  puts("Enter #{'_'.yellow} to access the return value of the last executed command")
  puts("")
  puts("Just enter the commands and confirm with Enter".green)

  # rubocop:disable Lint/Debugger
  binding.pry(quiet: true)
  # rubocop:enable Lint/Debugger

  puts("") # Fixes https://github.com/fastlane/fastlane/issues/3493
end