Skip to content

Commit

Permalink
Run rake app:update task
Browse files Browse the repository at this point in the history
Individual changes reviewed to ensure that application behaviour
is maintained and any obsolete configuration options are removed.
  • Loading branch information
pixeltrix committed Aug 24, 2020
1 parent 20c65b4 commit 6316b86
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 117 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ group :development do
gem "better_errors"
gem "binding_of_caller"
gem "image_optim"
gem "listen"
end

group :development, :test do
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ GEM
kramdown (2.3.0)
rexml
link_header (0.0.8)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logstash-event (1.2.02)
logstasher (1.3.0)
activesupport (>= 4.0)
Expand Down Expand Up @@ -328,6 +331,7 @@ DEPENDENCIES
jasmine
jasmine-core
jasmine_selenium_runner
listen
minitest
minitest-capybara
mocha
Expand Down
2 changes: 1 addition & 1 deletion bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
load Gem.bin_path('bundler', 'bundle')
28 changes: 28 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
28 changes: 28 additions & 0 deletions bin/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
11 changes: 11 additions & 0 deletions bin/yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
39 changes: 8 additions & 31 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require_relative "boot"

require "rails"

require "action_controller/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"
Expand All @@ -10,38 +12,13 @@

module Static
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/lib)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Enable the asset pipeline
config.assets.enabled = true

config.assets.prefix = "/assets/static"

# Version of your assets, change this if you want to expire all your assets
config.assets.version = "1.0"
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.

config.paths["log"] = ENV["LOG_PATH"] if ENV["LOG_PATH"]

Expand Down
47 changes: 30 additions & 17 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,45 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
# config.action_mailer.raise_delivery_errors = false
# Do not eager load code on boot.
config.eager_load = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Show full error reports.
config.consider_all_requests_local = true

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true

# Do not compress assets
config.assets.compress = false
config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

# rev filenames for assets
config.assets.digest = false
config.cache_store = :null_store
end

config.asset_host = ENV["ASSET_HOST"] || ENV["GOVUK_ASSET_ROOT"] || Plek.current.find("static")
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Expands the lines which load the assets
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# Suppress logger output for asset requests.
config.assets.quiet = true

config.eager_load = false
# Allow overriding the asset host with an environment variable.
config.asset_host = ENV["ASSET_HOST"] || ENV["GOVUK_ASSET_ROOT"] || Plek.current.find("static")

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
95 changes: 57 additions & 38 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,73 +1,92 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Set GOVUK_ASSET_ROOT & PLEK_SERVICE_STATIC_URI for heroku - for review
# apps we have the hostname set at the time of the app being built so can't
# be set up in the app.json
if ENV["HEROKU_APP_NAME"]
ENV["ASSET_HOST"] = "#{ENV['HEROKU_APP_NAME']}.herokuapp.com" unless ENV.include?("ASSET_HOST")
ENV["PLEK_SERVICE_STATIC_URI"] = "#{ENV['HEROKU_APP_NAME']}.herokuapp.com" unless ENV.include?("PLEK_SERVICE_STATIC_URI")
end

# Code is not reloaded between requests
# Code is not reloaded between requests.
config.cache_classes = true

# Full error reports are disabled and caching is turned on
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?

# Compress JavaScripts and CSS
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Don't fallback to assets pipeline if a precompiled asset is missed
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# Generate digests for assets URLs
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

# Defaults to Rails.root.join("public/assets")
# config.assets.manifest = YOUR_PATH
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'

# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# See everything in the log
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :info

# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Prepend all log lines with the following tags.
# config.log_tags = [ :request_id ]

# Use a different cache store in production
# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( ie.js libs/jquery/jquery-1.12.4.min.js high-contrast.css dyslexic.css admin.css libs/jquery/jquery-ui-1.8.16.custom.min.js libs/jquery/plugins/jquery.mustache.js )

# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# config.action_mailer.delivery_method = :ses

# Enable threaded mode
# config.threadsafe!
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "static_#{Rails.env}"

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

config.action_controller.asset_host = ENV["ASSET_HOST"] || ENV["GOVUK_ASSET_ROOT"]
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

config.eager_load = true
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end

# Allow overriding the asset host with an environment variable.
config.action_controller.asset_host = ENV["ASSET_HOST"] || ENV["GOVUK_ASSET_ROOT"]

# Google Analytics ID
config.ga_universal_id = ENV.fetch("GA_UNIVERSAL_ID", "UA-26179049-1")
config.ga_secondary_id = ENV.fetch("GA_SECONDARY_ID", "UA-145652997-1")

# Set GOVUK_ASSET_ROOT & PLEK_SERVICE_STATIC_URI for heroku - for review
# apps we have the hostname set at the time of the app being built so can't
# be set up in the app.json
if ENV["HEROKU_APP_NAME"]
ENV["ASSET_HOST"] = "#{ENV['HEROKU_APP_NAME']}.herokuapp.com" unless ENV.include?("ASSET_HOST")
ENV["PLEK_SERVICE_STATIC_URI"] = "#{ENV['HEROKU_APP_NAME']}.herokuapp.com" unless ENV.include?("PLEK_SERVICE_STATIC_URI")
end
end
Loading

0 comments on commit 6316b86

Please sign in to comment.