Class: Suspenders::Adapters::Heroku
- Inherits:
-
Object
- Object
- Suspenders::Adapters::Heroku
- Defined in:
- lib/suspenders/adapters/heroku.rb
Instance Method Summary collapse
- #create_heroku_application_manifest_file ⇒ Object
- #create_heroku_pipeline ⇒ Object
- #create_production_heroku_app(flags) ⇒ Object
- #create_review_apps_setup_script ⇒ Object
- #create_staging_heroku_app(flags) ⇒ Object
-
#initialize(app_builder) ⇒ Heroku
constructor
A new instance of Heroku.
- #set_buildpacks ⇒ Object
- #set_heroku_application_host ⇒ Object
- #set_heroku_backup_schedule ⇒ Object
- #set_heroku_error_reporting_env ⇒ Object
- #set_heroku_metadata_for_sentry ⇒ Object
- #set_heroku_rails_secrets ⇒ Object
- #set_heroku_remotes ⇒ Object
Constructor Details
#initialize(app_builder) ⇒ Heroku
Returns a new instance of Heroku.
4 5 6 |
# File 'lib/suspenders/adapters/heroku.rb', line 4 def initialize(app_builder) @app_builder = app_builder end |
Instance Method Details
#create_heroku_application_manifest_file ⇒ Object
69 70 71 |
# File 'lib/suspenders/adapters/heroku.rb', line 69 def create_heroku_application_manifest_file app_builder.template "app.json.erb", "app.json" end |
#create_heroku_pipeline ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/suspenders/adapters/heroku.rb', line 73 def create_heroku_pipeline pipelines_plugin = `heroku help | grep pipelines` if pipelines_plugin.empty? puts "You need heroku pipelines plugin. Run: brew upgrade heroku-toolbelt" exit 1 end run_toolbelt_command( "pipelines:create #{heroku_app_name} \ -a #{heroku_app_name}-staging --stage staging", "staging", ) run_toolbelt_command( "pipelines:add #{heroku_app_name} \ -a #{heroku_app_name}-production --stage production", "production", ) end |
#create_production_heroku_app(flags) ⇒ Object
27 28 29 30 31 |
# File 'lib/suspenders/adapters/heroku.rb', line 27 def create_production_heroku_app(flags) app_name = heroku_app_name_for("production") run_toolbelt_command "create #{app_name} #{flags}", "production" end |
#create_review_apps_setup_script ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/suspenders/adapters/heroku.rb', line 60 def create_review_apps_setup_script app_builder.template( "bin_setup_review_app.erb", "bin/setup_review_app", force: true, ) app_builder.run "chmod a+x bin/setup_review_app" end |
#create_staging_heroku_app(flags) ⇒ Object
21 22 23 24 25 |
# File 'lib/suspenders/adapters/heroku.rb', line 21 def create_staging_heroku_app(flags) app_name = heroku_app_name_for("staging") run_toolbelt_command "create #{app_name} #{flags}", "staging" end |
#set_buildpacks ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/suspenders/adapters/heroku.rb', line 111 def set_buildpacks %w(staging production).each do |environment| run_toolbelt_command( "buildpacks:add --index 1 heroku/nodejs", environment ) run_toolbelt_command( "buildpacks:add --index 2 heroku/ruby", environment ) end end |
#set_heroku_application_host ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/suspenders/adapters/heroku.rb', line 93 def set_heroku_application_host %w(staging production).each do |environment| run_toolbelt_command( "config:add APPLICATION_HOST=#{heroku_app_name}-#{environment}.herokuapp.com", environment, ) end end |
#set_heroku_backup_schedule ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/suspenders/adapters/heroku.rb', line 51 def set_heroku_backup_schedule %w(staging production).each do |environment| run_toolbelt_command( "pg:backups:schedule DATABASE_URL --at '10:00 UTC'", environment, ) end end |
#set_heroku_error_reporting_env ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/suspenders/adapters/heroku.rb', line 42 def set_heroku_error_reporting_env %w(staging production).each do |environment| run_toolbelt_command( "config:add SENTRY_ENV=#{environment}", environment, ) end end |
#set_heroku_metadata_for_sentry ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/suspenders/adapters/heroku.rb', line 102 def %w(staging production).each do |environment| run_toolbelt_command( "labs:enable runtime-dyno-metadata", environment ) end end |
#set_heroku_rails_secrets ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/suspenders/adapters/heroku.rb', line 33 def set_heroku_rails_secrets %w(staging production).each do |environment| run_toolbelt_command( "config:add SECRET_KEY_BASE=#{generate_secret}", environment, ) end end |
#set_heroku_remotes ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/suspenders/adapters/heroku.rb', line 8 def set_heroku_remotes remotes = " echo \"\\n== Adding Heroku remotes ==\"\n \#{command_to_join_heroku_app('staging')}\n \#{command_to_join_heroku_app('production')}\n\n echo \"\\n== Setting default heroku remote to 'staging' ==\"\n git config heroku.remote staging\n SHELL\n\n app_builder.append_file \"bin/setup\", remotes\nend\n" |