lib/suspenders/app_builder.rb in welaika-suspenders-2.33 vs lib/suspenders/app_builder.rb in welaika-suspenders-2.34
- old
+ new
@@ -98,11 +98,11 @@
copy_file "email.rb", "config/initializers/email.rb"
end
def enable_rack_canonical_host
config = <<-RUBY
- config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
+config.middleware.use Rack::CanonicalHost, ENV.fetch('APPLICATION_HOST')
RUBY
configure_environment "production", config
end
@@ -111,21 +111,21 @@
end
def setup_asset_host
replace_in_file 'config/environments/production.rb',
"# config.action_controller.asset_host = 'http://assets.example.com'",
- 'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
+ "config.action_controller.asset_host = ENV.fetch('ASSET_HOST', ENV.fetch('APPLICATION_HOST'))"
if File.exist?("config/initializers/assets.rb")
replace_in_file 'config/initializers/assets.rb',
"config.assets.version = '1.0'",
'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
end
config = <<-EOD
config.public_file_server.headers = {
- "Cache-Control" => "public, max-age=31557600",
+ 'Cache-Control' => 'public, max-age=31557600',
}
EOD
configure_environment("production", config)
end
@@ -173,11 +173,11 @@
def configure_locales_and_time_zone
remove_file "config/locales/en.yml"
template "config_locales_it.yml.erb", "config/locales/it.yml"
config = <<-RUBY
- config.i18n.available_locales = [:en, :it]
+ config.i18n.available_locales = %i[en it]
config.i18n.default_locale = :it
config.time_zone = 'Rome'
RUBY
inject_into_class 'config/application.rb', 'Application', config
@@ -186,23 +186,25 @@
def configure_action_mailer
action_mailer_host "development", %{"localhost:3000"}
action_mailer_asset_host "development", %{"http://localhost:3000"}
action_mailer_host "test", %{"www.example.com"}
action_mailer_asset_host "test", %{"http://www.example.com"}
- action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
+ action_mailer_host "production", %{ENV.fetch('APPLICATION_HOST')}
action_mailer_asset_host(
"production",
- %{ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))},
+ %{ENV.fetch('ASSET_HOST', ENV.fetch('APPLICATION_HOST'))},
)
end
def replace_default_puma_configuration
copy_file "puma.rb", "config/puma.rb", force: true
end
def set_up_forego
+ # NOTE: we want to use ruby foreman!
copy_file "Procfile", "Procfile"
+ Bundler.with_clean_env { run "gem install foreman" }
end
def setup_default_directories
[
'app/decorators',
@@ -234,12 +236,20 @@
def create_heroku_apps(flags)
create_staging_heroku_app(flags)
create_production_heroku_app(flags)
end
+ def configure_automatic_deployment
+ append_file "Procfile", "release: bin/auto_migrate"
+ end
+
+ def setup_bundler_audit
+ copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
+ append_file "Rakefile", %{\ntask default: "bundle:audit"\n}
+ end
+
def copy_miscellaneous_files
- copy_file "browserslist", "browserslist"
copy_file "errors.rb", "config/initializers/errors.rb"
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
end
def customize_error_pages
@@ -277,13 +287,11 @@
accepted_content.each { |line| file.puts line }
end
end
end
- def remove_routes_comment_lines
- replace_in_file 'config/routes.rb',
- /Rails\.application\.routes\.draw do.*end/m,
- "Rails.application.routes.draw do\nend"
+ def run_rubocop_autocorrect
+ Bundler.with_clean_env { run "bundle exec rubocop -a" }
end
def setup_rakefile
# NOTE: we named our file `rakefile_template` and not
# `Rakefile` because otherwise `copy_file` would copy the