Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

class ShopifyCli::Heroku

Tim Anema edited this page Jul 21, 2020 · 7 revisions

Constants

  • DOWNLOAD_URLS

Class Methods

new

new(ctx)

see source

# File lib/shopify-cli/heroku.rb, line 9
def initialize(ctx)
  @ctx = ctx
end

Instance Methods

app

app()

see source

# File lib/shopify-cli/heroku.rb, line 13
def app
  return nil unless (app = git_remote)
  app = app.split('/').last
  app = app.split('.').first
  app
end

authenticate

authenticate()

see source

# File lib/shopify-cli/heroku.rb, line 20
def authenticate
  result = @ctx.system(heroku_command, 'login')
  @ctx.abort(@ctx.message('core.heroku.error.authentication')) unless result.success?
end

create_new_app

create_new_app()

see source

# File lib/shopify-cli/heroku.rb, line 25
def create_new_app
  output, status = @ctx.capture2e(heroku_command, 'create')
  @ctx.abort(@ctx.message('core.heroku.error.creation')) unless status.success?
  @ctx.puts(output)
end

deploy

deploy(branch_to_deploy)

see source

# File lib/shopify-cli/heroku.rb, line 31
def deploy(branch_to_deploy)
  result = @ctx.system('git', 'push', '-u', 'heroku', "#{branch_to_deploy}:master")
  @ctx.abort(@ctx.message('core.heroku.error.deploy')) unless result.success?
end

download

download()

see source

# File lib/shopify-cli/heroku.rb, line 36
def download
  return if installed?

  result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli::CACHE_DIR)
  @ctx.abort(@ctx.message('core.heroku.error.download')) unless result.success?
  @ctx.abort(@ctx.message('core.heroku.error.download')) unless File.exist?(download_path)
end

install

install()

see source

# File lib/shopify-cli/heroku.rb, line 44
def install
  return if installed?

  result = @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli::CACHE_DIR)
  @ctx.abort(@ctx.message('core.heroku.error.install')) unless result.success?

  @ctx.rm(download_path)
end

select_existing_app

select_existing_app(app_name)

see source

# File lib/shopify-cli/heroku.rb, line 53
def select_existing_app(app_name)
  result = @ctx.system(heroku_command, 'git:remote', '-a', app_name)

  msg = @ctx.message('core.heroku.error.could_not_select_app', app_name)
  @ctx.abort(msg) unless result.success?
end

whoami

whoami()

see source

# File lib/shopify-cli/heroku.rb, line 60
def whoami
  output, status = @ctx.capture2e(heroku_command, 'whoami')
  return output.strip if status.success?
  nil
end

Clone this wiki locally