Class: EyProCli
- Inherits:
-
Thor
- Object
- Thor
- EyProCli
- Defined in:
- lib/ey_pro_cli.rb
Class Attribute Summary collapse
-
.core_file ⇒ Object
Returns the value of attribute core_file.
Instance Method Summary collapse
Class Attribute Details
.core_file ⇒ Object
Returns the value of attribute core_file.
15 16 17 |
# File 'lib/ey_pro_cli.rb', line 15 def core_file @core_file end |
Instance Method Details
#deploy ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ey_pro_cli.rb', line 68 def deploy check_for_updates unless ["no-update-check"] environment = core_environment_for() app = core_application_for() = {} .merge!(ref: [:ref]) if [:ref] .merge!(migrate_command: [:migrate]) if [:migrate] .merge!(migrate_command: '') if ["no-migrate"] request = environment.deploy(app, ) puts "Deploy started to environment: #{environment.name} with application: #{app.name}" if [:stream] request.subscribe { |m| print m["message"] if m.is_a?(Hash) } puts "" # fix console output from stream else request.ready! end if request.successful puts "Deploy successful!" else abort "Deploy failed!" end end |
#login ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ey_pro_cli.rb', line 24 def login email = ENV["EMAIL"] || ask("Email:") password = ENV["PASSWORD"] || ask("Password:", echo: false) token = unauthenticated_core_client.get_api_token(email, password).body["api_token"] existing_token = core_yaml[core_url] write_token = if existing_token && existing_token != token puts "New token does not match existing token. Overwriting".yellow true elsif existing_token == token puts "Token already exists".green false else puts "Writing token".green true end write_core_yaml(token) if write_token rescue Ey::Core::Response:: abort "Invalid email or password".yellow end |
#logout ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/ey_pro_cli.rb', line 48 def logout if core_yaml[core_url] core_yaml.delete(core_url) write_core_yaml puts "Successfully removed API token from credentials file".green else puts "No API token found".yellow end end |