Sha256: 65382b49f72997f39f4133d3e7893099cef9b0e87e85de9824ca99dee86586b5

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'commander'
require_relative './fetch_emails.rb'

class CreateHerokuApp
  MASTER = 'master'.freeze
  DEVELOP = 'develop'.freeze
  TESTING = 'testing'.freeze
  ENVIRONMENTS = [MASTER, DEVELOP, TESTING].freeze
  ADMIN_EMAIL = 'admin@renuo.ch'.freeze

  def initialize; end

  def run(args)
    project_name = args[0]
    abort('>> No project name given.') unless project_name
    emails = FetchEmails.new.fetch_emails

    say "# Commands to setup your Heroku application\n".colorize :green
    ENVIRONMENTS.each do |env|
      print_environment_commands(emails, env, project_name)
    end
  end

  private

  def print_environment_commands(emails, env, project_name)
    heroku_name = "#{project_name}-#{env}"
    say "heroku apps:create --region eu #{heroku_name}"
    say "heroku domains:add #{heroku_name}.renuoapp.ch --app #{heroku_name}"
    say "heroku addons:create heroku-postgresql  --app #{heroku_name}"
    say "heroku addons:create papertrail --app #{heroku_name}"
    say "heroku pg:backups:schedule DATABASE_URL --at '02:00 Europe/Zurich' --app #{heroku_name}"
    print_ownership_commands(emails, heroku_name)
    print_pipelines_commands(heroku_name, project_name)
  end

  def print_pipelines_commands(heroku_name, project_name)
    say "heroku apps:transfer -a #{heroku_name} #{ADMIN_EMAIL}"
    say "heroku pipelines:create #{project_name} --app #{project_name}-#{MASTER} -s production"
    say "heroku pipelines:add #{project_name} --app #{project_name}-#{DEVELOP} -s staging"
    say "heroku pipelines:add #{project_name} --app #{project_name}-#{TESTING} -s staging"
    say "\n"
  end

  def print_ownership_commands(emails, heroku_name)
    say "\n"
    emails.each do |email|
      say "heroku access:add #{email} --app #{heroku_name}"
      say "heroku access:add #{ADMIN_EMAIL} --app #{heroku_name}"
    end
    say "\n"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renuo-cli-1.2.0 lib/renuo/cli/app/create_heroku_app.rb