lib/suspenders/app_builder.rb in welaika-suspenders-2.21.0 vs lib/suspenders/app_builder.rb in welaika-suspenders-2.22.0
- old
+ new
@@ -4,13 +4,19 @@
class AppBuilder < Rails::AppBuilder
include Suspenders::Actions
extend Forwardable
def_delegators :heroku_adapter,
+ :create_heroku_pipelines_config_file,
+ :create_heroku_pipeline,
+ :create_production_heroku_app,
+ :create_staging_heroku_app,
+ :provide_review_apps_setup_script,
+ :set_heroku_rails_secrets,
:set_heroku_remotes,
- :set_up_heroku_specific_gems,
- :set_heroku_rails_secrets
+ :set_heroku_serve_static_files,
+ :set_up_heroku_specific_gems
def readme
template 'README.md.erb', 'README.md'
end
@@ -67,11 +73,11 @@
inject_into_class "config/application.rb", "Application", config
end
def provide_setup_script
- template "bin_setup.erb", "bin/setup", force: true
+ template "bin_setup", "bin/setup", force: true
run "chmod a+x bin/setup"
end
def provide_dev_prime_task
copy_file 'dev.rake', 'lib/tasks/dev.rake'
@@ -125,18 +131,22 @@
end
def enable_rack_canonical_host
config = <<-RUBY
+ if ENV.fetch("HEROKU_APP_NAME", "").include?("staging-pr-")
+ ENV["APPLICATION_HOST"] = ENV["HEROKU_APP_NAME"] + ".herokuapp.com"
+ end
+
# Ensure requests are only served from one, canonical host name
config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
RUBY
inject_into_file(
"config/environments/production.rb",
config,
- after: serve_static_files_line
+ after: "Rails.application.configure do",
)
end
def enable_rack_deflater
config = <<-RUBY
@@ -262,15 +272,10 @@
def configure_i18n_for_missing_translations
raise_on_missing_translations_in("development")
raise_on_missing_translations_in("test")
end
- def configure_i18n_tasks
- run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
- copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml"
- end
-
def configure_background_jobs_for_rspec
run 'rails g delayed_job:active_record'
end
def configure_action_mailer_in_specs
@@ -389,35 +394,15 @@
def init_git
run 'git init'
end
- def create_staging_heroku_app(flags)
- rack_env = "RACK_ENV=staging RAILS_ENV=staging"
- app_name = heroku_app_name_for("staging")
-
- run_heroku "create #{app_name} #{flags}", "staging"
- run_heroku "config:add #{rack_env}", "staging"
- end
-
- def create_production_heroku_app(flags)
- app_name = heroku_app_name_for("production")
-
- run_heroku "create #{app_name} #{flags}", "production"
- end
-
def create_heroku_apps(flags)
create_staging_heroku_app(flags)
create_production_heroku_app(flags)
end
- def set_heroku_serve_static_files
- %w(staging production).each do |environment|
- run_heroku "config:add RAILS_SERVE_STATIC_FILES=true", environment
- end
- end
-
def provide_deploy_script
copy_file "bin_deploy", "bin/deploy"
instructions = <<-MARKDOWN
@@ -538,22 +523,14 @@
config = 'config.action_view.raise_on_missing_translations = true'
uncomment_lines("config/environments/#{environment}.rb", config)
end
- def run_heroku(command, environment)
- run "heroku #{command} --remote #{environment}"
- end
-
def heroku_adapter
@heroku_adapter ||= Adapters::Heroku.new(self)
end
def serve_static_files_line
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
- end
-
- def heroku_app_name_for(environment)
- "#{app_name.dasherize}-#{environment}"
end
end
end