From 7623fe2bd3b5bbb6cd76db7b7837c06af7514373 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sun, 7 Feb 2021 16:46:01 +0100 Subject: [PATCH] Upgrade Rails 7.0.0.alpha + webpacker --- .gitattributes | 10 + .gitignore | 1 - Gemfile | 17 +- Gemfile.lock | 172 ++++++------ app/javascript/channels/consumer.js | 2 +- .../controllers/hello_controller.js | 7 + app/javascript/controllers/index.js | 9 + app/javascript/packs/application.js | 19 +- app/packs/entrypoints/application.js | 22 -- app/packs/stylesheets/application.scss | 3 - app/views/layouts/application.html.erb | 10 +- bin/rails | 10 +- bin/rake | 10 +- bin/setup | 8 +- bin/spring | 21 +- bin/yarn | 12 +- config.ru | 3 +- config/application.rb | 20 +- config/boot.rb | 4 +- config/environment.rb | 2 +- config/environments/development.rb | 29 +- config/environments/production.rb | 23 +- config/environments/test.rb | 13 +- config/initializers/backtrace_silencers.rb | 7 +- .../initializers/filter_parameter_logging.rb | 4 +- .../new_framework_defaults_7_0.rb | 29 ++ config/initializers/permissions_policy.rb | 11 + config/puma.rb | 7 +- config/webpack/base.js | 3 - config/webpack/development.js | 4 +- config/webpack/production.js | 4 +- config/webpack/test.js | 4 +- config/webpacker.yml | 51 +++- package.json | 17 +- yarn.lock | 252 +----------------- 35 files changed, 335 insertions(+), 485 deletions(-) create mode 100644 .gitattributes create mode 100644 app/javascript/controllers/hello_controller.js create mode 100644 app/javascript/controllers/index.js delete mode 100644 app/packs/entrypoints/application.js delete mode 100644 app/packs/stylesheets/application.scss create mode 100644 config/initializers/new_framework_defaults_7_0.rb create mode 100644 config/initializers/permissions_policy.rb delete mode 100644 config/webpack/base.js diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5168571 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark the yarn lockfile as having been generated. +yarn.lock linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/.gitignore b/.gitignore index b7f3709..4176a33 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ # Ignore the default SQLite database. /db/*.sqlite3 -/db/*.sqlite3-journal /db/*.sqlite3-* # Ignore all logfiles and tempfiles. diff --git a/Gemfile b/Gemfile index 7df2eed..4759396 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '>= 2.7.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.1.0' +# gem 'rails', '~> 6.1.0' +gem 'rails', github: 'rails/rails', branch: 'main' # Use sqlite3 as the database for Active Record gem 'sqlite3', '~> 1.4' @@ -16,7 +17,7 @@ gem 'puma', '~> 5.1' gem 'sass-rails', '>= 6' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker -gem 'webpacker', git: 'https://github.com/rails/webpacker.git' +gem 'webpacker', '~> 5.0' # Use Hotwire for the frontend gem 'hotwire-rails' @@ -61,7 +62,7 @@ gem 'devise' gem "kaminari" # Reduces boot times through caching; required in config/boot.rb -gem 'bootsnap', '>= 1.4.2', require: false +gem 'bootsnap', '>= 1.4.4', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console @@ -71,16 +72,18 @@ end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. - gem 'web-console', '>= 3.3.0' - gem 'listen', '~> 3.2' + gem 'web-console', '>= 4.1.0' + # Display performance information such as SQL time and flame graphs for each request in your browser. + # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md + gem 'rack-mini-profiler', '~> 2.0' + gem 'listen', '~> 3.3' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15' + gem 'capybara', '>= 3.26' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' diff --git a/Gemfile.lock b/Gemfile.lock index 7eba423..16a51ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,75 +1,92 @@ GIT - remote: https://github.com/rails/webpacker.git - revision: d31f3d436aa7f140e6bb3e30726d3c7f9e81e60f + remote: https://github.com/rails/rails.git + revision: 39e49edaf9694c938c67ea997d3cfa8c935921b2 + branch: main specs: - webpacker (6.0.0.beta.5) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (6.1.0) - actionpack (= 6.1.0) - activesupport (= 6.1.0) + actioncable (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.0) - actionpack (= 6.1.0) - activejob (= 6.1.0) - activerecord (= 6.1.0) - activestorage (= 6.1.0) - activesupport (= 6.1.0) + actionmailbox (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + activejob (= 7.0.0.alpha) + activerecord (= 7.0.0.alpha) + activestorage (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) mail (>= 2.7.1) - actionmailer (6.1.0) - actionpack (= 6.1.0) - actionview (= 6.1.0) - activejob (= 6.1.0) - activesupport (= 6.1.0) + actionmailer (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + actionview (= 7.0.0.alpha) + activejob (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.0) - actionview (= 6.1.0) - activesupport (= 6.1.0) + actionpack (7.0.0.alpha) + actionview (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.0) - actionpack (= 6.1.0) - activerecord (= 6.1.0) - activestorage (= 6.1.0) - activesupport (= 6.1.0) + actiontext (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + activerecord (= 7.0.0.alpha) + activestorage (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) nokogiri (>= 1.8.5) - actionview (6.1.0) - activesupport (= 6.1.0) + actionview (7.0.0.alpha) + activesupport (= 7.0.0.alpha) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.0) - activesupport (= 6.1.0) + activejob (7.0.0.alpha) + activesupport (= 7.0.0.alpha) globalid (>= 0.3.6) - activemodel (6.1.0) - activesupport (= 6.1.0) - activerecord (6.1.0) - activemodel (= 6.1.0) - activesupport (= 6.1.0) - activestorage (6.1.0) - actionpack (= 6.1.0) - activejob (= 6.1.0) - activerecord (= 6.1.0) - activesupport (= 6.1.0) + activemodel (7.0.0.alpha) + activesupport (= 7.0.0.alpha) + activerecord (7.0.0.alpha) + activemodel (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) + activestorage (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + activejob (= 7.0.0.alpha) + activerecord (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) marcel (~> 0.3.1) mimemagic (~> 0.3.2) - activesupport (6.1.0) + activesupport (7.0.0.alpha) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + rails (7.0.0.alpha) + actioncable (= 7.0.0.alpha) + actionmailbox (= 7.0.0.alpha) + actionmailer (= 7.0.0.alpha) + actionpack (= 7.0.0.alpha) + actiontext (= 7.0.0.alpha) + actionview (= 7.0.0.alpha) + activejob (= 7.0.0.alpha) + activemodel (= 7.0.0.alpha) + activerecord (= 7.0.0.alpha) + activestorage (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) + bundler (>= 1.15.0) + railties (= 7.0.0.alpha) + sprockets-rails (>= 2.0.0) + railties (7.0.0.alpha) + actionpack (= 7.0.0.alpha) + activesupport (= 7.0.0.alpha) + method_source + rake (>= 0.8.7) + thor (~> 1.0) + +GEM + remote: https://rubygems.org/ + specs: addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) bcrypt (3.1.16) @@ -89,7 +106,7 @@ GEM childprocess (3.0.0) chronic (0.10.2) coderay (1.1.3) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.8) connection_pool (2.2.3) crass (1.0.6) devise (4.7.3) @@ -123,7 +140,7 @@ GEM rails (>= 6.0.0) stimulus-rails turbo-rails - i18n (1.8.5) + i18n (1.8.8) concurrent-ruby (~> 1.0) kaminari (1.2.1) activesupport (>= 4.1.0) @@ -140,7 +157,7 @@ GEM listen (3.3.3) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.8.0) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -151,7 +168,7 @@ GEM mimemagic (0.3.5) mini_mime (1.0.2) mini_portile2 (2.5.0) - minitest (5.14.2) + minitest (5.14.3) msgpack (1.3.3) multi_json (1.15.0) multipart-post (2.1.1) @@ -170,37 +187,18 @@ GEM nio4r (~> 2.0) racc (1.5.2) rack (2.2.3) + rack-mini-profiler (2.3.1) + rack (>= 1.2.0) rack-proxy (0.6.5) rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.0) - actioncable (= 6.1.0) - actionmailbox (= 6.1.0) - actionmailer (= 6.1.0) - actionpack (= 6.1.0) - actiontext (= 6.1.0) - actionview (= 6.1.0) - activejob (= 6.1.0) - activemodel (= 6.1.0) - activerecord (= 6.1.0) - activestorage (= 6.1.0) - activesupport (= 6.1.0) - bundler (>= 1.15.0) - railties (= 6.1.0) - sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (6.1.0) - actionpack (= 6.1.0) - activesupport (= 6.1.0) - method_source - rake (>= 0.8.7) - thor (~> 1.0) - rake (13.0.1) + rake (13.0.3) rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) @@ -231,9 +229,6 @@ GEM rack (~> 2.0) redis (>= 4.2.0) spring (2.1.1) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -246,11 +241,11 @@ GEM rails (>= 6.0.0) tailwindcss-rails (0.3.1) rails (>= 6.0.0) - thor (1.0.1) + thor (1.1.0) tilt (2.0.10) turbo-rails (0.5.9) rails (>= 6.0.0) - tzinfo (2.0.3) + tzinfo (2.0.4) concurrent-ruby (~> 1.0) warden (1.2.9) rack (>= 2.0.9) @@ -263,6 +258,11 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) + webpacker (5.2.1) + activesupport (>= 5.2) + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -275,35 +275,35 @@ PLATFORMS DEPENDENCIES bcrypt (~> 3.1.7) - bootsnap (>= 1.4.2) + bootsnap (>= 1.4.4) byebug - capybara (>= 2.15) + capybara (>= 3.26) chronic devise elasticsearch-model elasticsearch-rails hotwire-rails kaminari - listen (~> 3.2) + listen (~> 3.3) net-ldap nokogiri (= 1.11.0) open3 pry puma (~> 5.1) - rails (~> 6.1.0) + rack-mini-profiler (~> 2.0) + rails! redis (~> 4.0) rexml sass-rails (>= 6) selenium-webdriver sidekiq spring - spring-watcher-listen (~> 2.0.0) sqlite3 (~> 1.4) tailwindcss-rails tzinfo-data - web-console (>= 3.3.0) + web-console (>= 4.1.0) webdrivers - webpacker! + webpacker (~> 5.0) RUBY VERSION ruby 3.0.0p0 diff --git a/app/javascript/channels/consumer.js b/app/javascript/channels/consumer.js index 0eceb59..8ec3aad 100644 --- a/app/javascript/channels/consumer.js +++ b/app/javascript/channels/consumer.js @@ -1,5 +1,5 @@ // Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command. import { createConsumer } from "@rails/actioncable" diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js new file mode 100644 index 0000000..612a01f --- /dev/null +++ b/app/javascript/controllers/hello_controller.js @@ -0,0 +1,7 @@ +import { Controller } from "stimulus" + +export default class extends Controller { + connect() { + this.element.textContent = "Hello World!" + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000..6f53d84 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,9 @@ +// Load all the controllers within this directory and all subdirectories. +// Controller files must be named *_controller.js. + +import { Application } from "stimulus" +import { definitionsFromContext } from "stimulus/webpack-helpers" + +const application = Application.start() +const context = require.context("controllers", true, /_controller\.js$/) +application.load(definitionsFromContext(context)) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 9cd55d4..7b5fb97 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -3,15 +3,14 @@ // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled. -require("@rails/ujs").start() -require("turbolinks").start() -require("@rails/activestorage").start() -require("channels") +import Rails from "@rails/ujs" +import "@hotwired/turbo-rails" +import * as ActiveStorage from "@rails/activestorage" +import "channels" +Rails.start() +ActiveStorage.start() -// Uncomment to copy all static images under ../images to the output folder and reference -// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) -// or the `imagePath` JavaScript helper below. -// -// const images = require.context('../images', true) -// const imagePath = (name) => images(name, true) +import "controllers" + +import "stylesheets/application" diff --git a/app/packs/entrypoints/application.js b/app/packs/entrypoints/application.js deleted file mode 100644 index a894f7e..0000000 --- a/app/packs/entrypoints/application.js +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint no-console:0 */ -// This file is automatically compiled by Webpack, along with any other files -// present in this directory. You're encouraged to place your actual application logic in -// a relevant structure within app/packs and only use these pack files to reference -// that code so it'll be compiled. -// -// To reference this file, add <%= javascript_packs_with_chunks_tag 'application' %> to the appropriate -// layout file, like app/views/layouts/application.html.erb - -// Uncomment to copy all static images under ../images to the output folder and reference -// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) -// or the `imagePath` JavaScript helper below. -// -// const images = require.context('../images', true) -// const imagePath = (name) => images(name, true) - -import 'core-js/stable' -import 'regenerator-runtime/runtime' - -console.log('Hello World from Webpacker') - -require("stylesheets/application.scss") diff --git a/app/packs/stylesheets/application.scss b/app/packs/stylesheets/application.scss deleted file mode 100644 index 76fcadc..0000000 --- a/app/packs/stylesheets/application.scss +++ /dev/null @@ -1,3 +0,0 @@ -@import "tailwindcss/base"; -@import "tailwindcss/components"; -@import "tailwindcss/utilities"; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index bd68593..088188b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -6,13 +6,9 @@ <%= csrf_meta_tags %> <%= csp_meta_tag %> - <%= stylesheet_link_tag "inter-font" %> - <%= stylesheet_link_tag "tailwind" %> - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= yield :head %> - <%= turbo_include_tags %> - <%= stimulus_include_tags %> - <%= javascript_include_tag "turbo", type: "module-shim" %> + <%= stylesheet_link_tag "application", "data-turbolinks-track": "reload" %> + <%= javascript_pack_tag "application", "data-turbolinks-track": "reload" %> + <%= stylesheet_pack_tag "application", "data-turbo-track": "reload" %> diff --git a/bin/rails b/bin/rails index 5badb2f..21d3e02 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,5 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end +load File.expand_path("spring", __dir__) APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index d87d5f5..7327f47 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,5 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end -require_relative '../config/boot' -require 'rake' +load File.expand_path("spring", __dir__) +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/setup b/bin/setup index 5853b5e..90700ac 100755 --- a/bin/setup +++ b/bin/setup @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -require 'fileutils' +require "fileutils" # path to your application root. APP_ROOT = File.expand_path('..', __dir__) @@ -9,8 +9,8 @@ def system!(*args) end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. puts '== Installing dependencies ==' @@ -18,7 +18,7 @@ FileUtils.chdir APP_ROOT do system('bundle check') || system!('bundle install') # Install JavaScript dependencies - # system('bin/yarn') + system! 'bin/yarn' # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') diff --git a/bin/spring b/bin/spring index d89ee49..9675cce 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,14 @@ #!/usr/bin/env ruby +if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"]) + gem "bundler" + require "bundler" -# This file loads Spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require 'rubygems' - require 'bundler' - - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == 'spring' } - if spring + # Load Spring without loading other gems in the Gemfile, for speed. + Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring| Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem 'spring', spring.version - require 'spring/binstub' + gem "spring", spring.version + require "spring/binstub" + rescue Gem::LoadError + # Ignore when Spring is not installed. end end diff --git a/bin/yarn b/bin/yarn index 460dd56..9fab2c3 100755 --- a/bin/yarn +++ b/bin/yarn @@ -1,9 +1,15 @@ #!/usr/bin/env ruby APP_ROOT = File.expand_path('..', __dir__) Dir.chdir(APP_ROOT) do - begin - exec "yarnpkg", *ARGV - rescue Errno::ENOENT + yarn = ENV["PATH"].split(File::PATH_SEPARATOR). + select { |dir| File.expand_path(dir) != __dir__ }. + product(["yarn", "yarn.cmd", "yarn.ps1"]). + map { |dir, file| File.expand_path(file, dir) }. + find { |file| File.executable?(file) } + + if yarn + exec yarn, *ARGV + else $stderr.puts "Yarn executable was not detected in the system." $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" exit 1 diff --git a/config.ru b/config.ru index f7ba0b5..4a3c09a 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,6 @@ # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 62fea64..a4a8a2e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,7 @@ -require_relative 'boot' +require_relative "boot" -require 'rails/all' -require 'elasticsearch/rails/instrumentation' +require "rails/all" +require "elasticsearch/rails/instrumentation" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -12,12 +12,15 @@ module Evobal # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.1 - config.active_job.queue_adapter = :sidekiq + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") - # 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.active_job.queue_adapter = :sidekiq console do # this block is called only when running console, @@ -25,6 +28,5 @@ module Evobal require "pry" config.console = Pry end - end end diff --git a/config/boot.rb b/config/boot.rb index b9e460c..3cda23b 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -require 'bundler/setup' # Set up gems listed in the Gemfile. -require 'bootsnap/setup' # Speed up boot time by caching expensive operations. +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/environment.rb b/config/environment.rb index 426333b..cac5315 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 55dd523..f8f1bee 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,11 +1,10 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Prepare the ingress controller used to receive mail - config.action_mailbox.ingress = :relay - - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false @@ -17,7 +16,7 @@ Rails.application.configure do # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. - if Rails.root.join('tmp', 'caching-dev.txt').exist? + if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true @@ -39,11 +38,15 @@ Rails.application.configure do config.action_mailer.perform_caching = false - config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } - # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load @@ -53,15 +56,21 @@ Rails.application.configure do # 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 + config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = 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 + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index a8f2543..cacbb21 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,7 +1,6 @@ -Rails.application.configure do - # Prepare the ingress controller used to receive mail - config.action_mailbox.ingress = :relay +require "active_support/core_ext/integer/time" +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. @@ -26,13 +25,13 @@ Rails.application.configure do config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress CSS using a preprocessor. - config.assets.css_compressor = :purger + # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # config.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 @@ -49,9 +48,9 @@ Rails.application.configure do # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] @@ -76,11 +75,17 @@ Rails.application.configure do # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. - # require 'syslog/logger' + # require "syslog/logger" # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? diff --git a/config/environments/test.rb b/config/environments/test.rb index 0cb2424..93ed4f1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped @@ -44,6 +46,15 @@ Rails.application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cd..33699c3 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,8 @@ # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". +Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1..4b34a03 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 0000000..db2e4ce --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,29 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 7.0 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# `button_to` view helper will render `