Class: ShopifyCLI::Services::App::Deploy::Heroku::RailsService
- Inherits:
-
BaseService
- Object
- BaseService
- ShopifyCLI::Services::App::Deploy::Heroku::RailsService
- Defined in:
- lib/shopify_cli/services/app/deploy/heroku/rails_service.rb
Constant Summary collapse
- DB_CHECK_CMD =
'bundle exec rails runner "puts ActiveRecord::Base.connection.adapter_name.downcase"'
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(context:) ⇒ RailsService
constructor
A new instance of RailsService.
Methods inherited from BaseService
Constructor Details
#initialize(context:) ⇒ RailsService
Returns a new instance of RailsService.
11 12 13 14 |
# File 'lib/shopify_cli/services/app/deploy/heroku/rails_service.rb', line 11 def initialize(context:) @context = context super() end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
9 10 11 |
# File 'lib/shopify_cli/services/app/deploy/heroku/rails_service.rb', line 9 def context @context end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 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 93 94 95 96 97 98 99 100 101 |
# File 'lib/shopify_cli/services/app/deploy/heroku/rails_service.rb', line 16 def call CLI::UI::Frame.open(context.("core.app.deploy.heroku.rails.db_check.validating")) do CLI::UI::Spinner.spin(context.("core.app.deploy.heroku.rails.db_check.checking")) do |spinner| db_type, err = check_db(context) context.abort(context.(err)) unless err.nil? spinner.update_title(context.("core.app.deploy.heroku.rails.db_check.validated", db_type)) end true end spin_group = CLI::UI::SpinGroup.new heroku_service = ShopifyCLI::Heroku.new(context) spin_group.add(context.("core.app.deploy.heroku.downloading")) do |spinner| heroku_service.download spinner.update_title(context.("core.app.deploy.heroku.downloaded")) end spin_group.wait spin_group.add(context.("core.app.deploy.heroku.installing")) do |spinner| heroku_service.install spinner.update_title(context.("core.app.deploy.heroku.installed")) end spin_group.add(context.("core.app.deploy.heroku.git.checking")) do |spinner| ShopifyCLI::Git.init(context) spinner.update_title(context.("core.app.deploy.heroku.git.initialized")) end spin_group.wait if (account = heroku_service.whoami) context.puts(context.("core.app.deploy.heroku.authenticated_with_account", account)) else CLI::UI::Frame.open( context.("core.app.deploy.heroku.authenticating"), success_text: context.("core.app.deploy.heroku.authenticated") ) do heroku_service.authenticate end end if (app_name = heroku_service.app) context.puts(context.("core.app.deploy.heroku.app.selected", app_name)) else app_type = CLI::UI::Prompt.ask(context.("core.app.deploy.heroku.app.no_apps_found")) do |handler| handler.option(context.("core.app.deploy.heroku.app.create")) { :new } handler.option(context.("core.app.deploy.heroku.app.select")) { :existing } end if app_type == :existing app_name = CLI::UI::Prompt.ask(context.("core.app.deploy.heroku.app.name")) CLI::UI::Frame.open( context.("core.app.deploy.heroku.app.selecting", app_name), success_text: context.("core.app.deploy.heroku.app.selected", app_name) ) do heroku_service.select_existing_app(app_name) end elsif app_type == :new CLI::UI::Frame.open( context.("core.app.deploy.heroku.app.creating"), success_text: context.("core.app.deploy.heroku.app.created") ) do heroku_service.create_new_app end end end branches = ShopifyCLI::Git.branches(context) if branches.length == 1 branch_to_deploy = branches[0] context.puts(context.("core.app.deploy.heroku.git.branch_selected", branch_to_deploy)) else prompt_question = context.("core.app.deploy.heroku.git.what_branch") branch_to_deploy = CLI::UI::Prompt.ask(prompt_question) do |handler| branches.each do |branch| handler.option(branch) { branch } end end end CLI::UI::Frame.open( context.("core.app.deploy.heroku.deploying"), success_text: context.("core.app.deploy.heroku.deployed") ) do heroku_service.deploy(branch_to_deploy) end end |