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 Apr 22, 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("Could not authenticate with Heroku") 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('Heroku app could not be created') unless status.success?
  @ctx.puts(output)

  new_remote = output.split("\n").last.split("|").last.strip
  result = @ctx.system('git', 'remote', 'add', 'heroku', new_remote)

  msg = "Heroku app created, but couldn’t be set as a git remote"
  @ctx.abort(msg) unless result.success?
end
---

deploy

deploy(branch_to_deploy)

see source

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

download

download()

see source

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

  result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli::ROOT)
  @ctx.abort("Heroku CLI could not be downloaded") unless result.success?
  @ctx.abort("Heroku CLI could not be downloaded") unless File.exist?(download_path)
end
---

install

install()

see source

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

  result = @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli::ROOT)
  @ctx.abort("Could not install Heroku CLI") 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 59
def select_existing_app(app_name)
  result = @ctx.system(heroku_command, 'git:remote', '-a', app_name)

  msg = "Heroku app `#{app_name}` could not be selected"
  @ctx.abort(msg) unless result.success?
end
---

whoami

whoami()

see source

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