From 46afb11171365cbe64da543e2eb4bd8b4a056e2b Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 23 Oct 2021 10:38:28 -0400 Subject: [PATCH] Update dependencies (2021-10) (#23) --- Rakefile | 16 ++--- lib/psenv/retriever.rb | 9 ++- psenv-rails.gemspec | 2 +- psenv.gemspec | 4 +- spec/rails/Gemfile | 2 +- spec/rails/bin/bundle | 10 ++- spec/rails/bin/rails | 5 -- spec/rails/bin/rake | 5 -- spec/rails/bin/setup | 4 +- spec/rails/bin/spring | 17 ----- spec/rails/config.ru | 1 + spec/rails/config/application.rb | 19 +++--- spec/rails/config/environments/development.rb | 24 +++++-- spec/rails/config/environments/production.rb | 20 ++++-- spec/rails/config/environments/test.rb | 21 ++++-- .../initializers/backtrace_silencers.rb | 7 +- .../initializers/filter_parameter_logging.rb | 4 +- .../new_framework_defaults_6_1.rb | 67 +++++++++++++++++++ spec/rails/config/puma.rb | 9 ++- spec/retriever_spec.rb | 14 ++-- 20 files changed, 171 insertions(+), 89 deletions(-) delete mode 100755 spec/rails/bin/spring create mode 100644 spec/rails/config/initializers/new_framework_defaults_6_1.rb diff --git a/Rakefile b/Rakefile index 7bb0b6b..59e3483 100644 --- a/Rakefile +++ b/Rakefile @@ -2,19 +2,19 @@ require "bundler/gem_helper" require "rspec/core/rake_task" require "rubocop/rake_task" +class ParameterStoreEnvRailsGemHelper < Bundler::GemHelper + def guard_already_tagged + end + + def tag_version + end +end + namespace "psenv" do Bundler::GemHelper.install_tasks name: "psenv" end namespace "psenv-rails" do - class ParameterStoreEnvRailsGemHelper < Bundler::GemHelper - def guard_already_tagged - end - - def tag_version - end - end - ParameterStoreEnvRailsGemHelper.install_tasks name: "psenv-rails" end diff --git a/lib/psenv/retriever.rb b/lib/psenv/retriever.rb index 8e77401..6717f3e 100644 --- a/lib/psenv/retriever.rb +++ b/lib/psenv/retriever.rb @@ -20,11 +20,10 @@ module Psenv end def call - Hash[ - parameters - .map { |parameter| Parameter.new(parameter) } - .map { |parameter| [parameter.name, parameter.value] } - ] + parameters + .map { |parameter| Parameter.new(parameter) } + .map { |parameter| [parameter.name, parameter.value] } + .to_h end def self.call(path) diff --git a/psenv-rails.gemspec b/psenv-rails.gemspec index be51e44..aded815 100644 --- a/psenv-rails.gemspec +++ b/psenv-rails.gemspec @@ -22,5 +22,5 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "psenv", Psenv::VERSION - spec.add_dependency "railties", ">= 3.2", "<= 6.1" + spec.add_dependency "railties", ">= 3.2", "< 6.2" end diff --git a/psenv.gemspec b/psenv.gemspec index d4ee13b..7d7b24f 100644 --- a/psenv.gemspec +++ b/psenv.gemspec @@ -21,8 +21,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency "pry" spec.add_development_dependency "rake", ">= 12.3.3" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "standard", "~> 0.1.9" + spec.add_development_dependency "rspec", "~> 3" + spec.add_development_dependency "standard" spec.add_development_dependency "webmock", "~> 3.3" spec.add_dependency "aws-sdk-ssm", "~> 1" diff --git a/spec/rails/Gemfile b/spec/rails/Gemfile index 553262a..727d07c 100644 --- a/spec/rails/Gemfile +++ b/spec/rails/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem "rails", "~> 6.0.0" +gem "rails", "6.1.4.1" # Use Puma as the app server gem "puma", ">= 4.3.8" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/spec/rails/bin/bundle b/spec/rails/bin/bundle index 1a4d56e..5ada67f 100755 --- a/spec/rails/bin/bundle +++ b/spec/rails/bin/bundle @@ -30,7 +30,7 @@ m = Module.new { if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN bundler_version = a end - next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o bundler_version = $1 || ">= 0.a" update_index = i end @@ -56,15 +56,13 @@ m = Module.new { def lockfile_version return unless File.file?(lockfile) lockfile_contents = File.read(lockfile) - return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o Regexp.last_match(1) end def bundler_version - @bundler_version ||= begin - env_var_version || cli_arg_version || - lockfile_version || "#{Gem::Requirement.default}.a" - end + @bundler_version ||= env_var_version || cli_arg_version || + lockfile_version || "#{Gem::Requirement.default}.a" end def load_bundler! diff --git a/spec/rails/bin/rails b/spec/rails/bin/rails index 40d2d5e..efc0377 100755 --- a/spec/rails/bin/rails +++ b/spec/rails/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError => e - raise unless e.message.include?("spring") -end APP_PATH = File.expand_path("../config/application", __dir__) require_relative "../config/boot" require "rails/commands" diff --git a/spec/rails/bin/rake b/spec/rails/bin/rake index 3df5805..4fbf10b 100755 --- a/spec/rails/bin/rake +++ b/spec/rails/bin/rake @@ -1,9 +1,4 @@ #!/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" Rake.application.run diff --git a/spec/rails/bin/setup b/spec/rails/bin/setup index 7e1934d..57b65c8 100755 --- a/spec/rails/bin/setup +++ b/spec/rails/bin/setup @@ -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 ==" diff --git a/spec/rails/bin/spring b/spec/rails/bin/spring deleted file mode 100755 index cbe59c6..0000000 --- a/spec/rails/bin/spring +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby - -# 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 - Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem "spring", spring.version - require "spring/binstub" - end -end diff --git a/spec/rails/config.ru b/spec/rails/config.ru index 441e6ff..4a3c09a 100644 --- a/spec/rails/config.ru +++ b/spec/rails/config.ru @@ -3,3 +3,4 @@ require_relative "config/environment" run Rails.application +Rails.application.load_server diff --git a/spec/rails/config/application.rb b/spec/rails/config/application.rb index 6c65484..1b00711 100644 --- a/spec/rails/config/application.rb +++ b/spec/rails/config/application.rb @@ -2,15 +2,15 @@ require_relative "boot" require "rails" # Pick the frameworks you want: -# require "active_model/railtie" -# require "active_job/railtie" +require "active_model/railtie" +require "active_job/railtie" # require "active_record/railtie" # require "active_storage/engine" -# require "action_controller/railtie" +require "action_controller/railtie" # require "action_mailer/railtie" # require "action_mailbox/engine" # require "action_text/engine" -# require "action_view/railtie" +require "action_view/railtie" # require "action_cable/engine" # require "sprockets/railtie" require "rails/test_unit/railtie" @@ -24,10 +24,13 @@ module PsenvTest # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.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. + # 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") # Only loads a smaller set of middleware suitable for API only apps. # Middleware like session, flash, cookies can be added back manually. diff --git a/spec/rails/config/environments/development.rb b/spec/rails/config/environments/development.rb index 9a4b1a4..2359977 100644 --- a/spec/rails/config/environments/development.rb +++ b/spec/rails/config/environments/development.rb @@ -1,8 +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. - # 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,10 +19,10 @@ Rails.application.configure do if Rails.root.join("tmp", "caching-dev.txt").exist? config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}", + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else - # config.action_controller.perform_caching = false + config.action_controller.perform_caching = false config.cache_store = :null_store end @@ -28,10 +30,22 @@ Rails.application.configure do # 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 = [] + # 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/spec/rails/config/environments/production.rb b/spec/rails/config/environments/production.rb index ff62d96..828fb6b 100644 --- a/spec/rails/config/environments/production.rb +++ b/spec/rails/config/environments/production.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -22,7 +24,7 @@ Rails.application.configure do config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # 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 @@ -31,9 +33,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] @@ -52,15 +54,21 @@ 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? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end diff --git a/spec/rails/config/environments/test.rb b/spec/rails/config/environments/test.rb index 50d6697..a21a28a 100644 --- a/spec/rails/config/environments/test.rb +++ b/spec/rails/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 @@ -6,7 +8,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - config.cache_classes = false + config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that @@ -16,23 +18,32 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}", + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. config.consider_all_requests_local = true - # config.action_controller.perform_caching = false + config.action_controller.perform_caching = false config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. - # config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # 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/spec/rails/config/initializers/backtrace_silencers.rb b/spec/rails/config/initializers/backtrace_silencers.rb index 59385cd..33699c3 100644 --- a/spec/rails/config/initializers/backtrace_silencers.rb +++ b/spec/rails/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/spec/rails/config/initializers/filter_parameter_logging.rb b/spec/rails/config/initializers/filter_parameter_logging.rb index 4a994e1..4b34a03 100644 --- a/spec/rails/config/initializers/filter_parameter_logging.rb +++ b/spec/rails/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/spec/rails/config/initializers/new_framework_defaults_6_1.rb b/spec/rails/config/initializers/new_framework_defaults_6_1.rb new file mode 100644 index 0000000..9526b83 --- /dev/null +++ b/spec/rails/config/initializers/new_framework_defaults_6_1.rb @@ -0,0 +1,67 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 6.1 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. + +# Support for inversing belongs_to -> has_many Active Record associations. +# Rails.application.config.active_record.has_many_inversing = true + +# Track Active Storage variants in the database. +# Rails.application.config.active_storage.track_variants = true + +# Apply random variation to the delay when retrying failed jobs. +# Rails.application.config.active_job.retry_jitter = 0.15 + +# Stop executing `after_enqueue`/`after_perform` callbacks if +# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. +# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true + +# Specify cookies SameSite protection level: either :none, :lax, or :strict. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax + +# Generate CSRF tokens that are encoded in URL-safe Base64. +# +# This change is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 6.1. +# Rails.application.config.action_controller.urlsafe_csrf_tokens = true + +# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an +# UTC offset or a UTC time. +# ActiveSupport.utc_to_local_returns_utc_offset_times = true + +# Change the default HTTP status code to `308` when redirecting non-GET/HEAD +# requests to HTTPS in `ActionDispatch::SSL` middleware. +# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 + +# Use new connection handling API. For most applications this won't have any +# effect. For applications using multiple databases, this new API provides +# support for granular connection swapping. +# Rails.application.config.active_record.legacy_connection_handling = false + +# Make `form_with` generate non-remote forms by default. +# Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Set the default queue name for the analysis job to the queue adapter default. +# Rails.application.config.active_storage.queues.analysis = nil + +# Set the default queue name for the purge job to the queue adapter default. +# Rails.application.config.active_storage.queues.purge = nil + +# Set the default queue name for the incineration job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.incineration = nil + +# Set the default queue name for the routing job to the queue adapter default. +# Rails.application.config.action_mailbox.queues.routing = nil + +# Set the default queue name for the mail deliver job to the queue adapter default. +# Rails.application.config.action_mailer.deliver_later_queue_name = nil + +# Generate a `Link` header that gives a hint to modern browsers about +# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. +# Rails.application.config.action_view.preload_links_header = true diff --git a/spec/rails/config/puma.rb b/spec/rails/config/puma.rb index 2d3d969..fa40ee6 100644 --- a/spec/rails/config/puma.rb +++ b/spec/rails/config/puma.rb @@ -4,13 +4,18 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT", 3000) # Specifies the `environment` that Puma will run in. # diff --git a/spec/retriever_spec.rb b/spec/retriever_spec.rb index 97090a9..663d214 100644 --- a/spec/retriever_spec.rb +++ b/spec/retriever_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Psenv::Parameter do name: "/psenv/test/VARIABLE", value: "value", type: "String", - version: 1, + version: 1 } end subject { Psenv::Parameter.new(parameter) } @@ -49,8 +49,8 @@ RSpec.describe Psenv::Retriever do name: "/psenv/test/API_KEY", value: "value", type: "String", - version: 1, - }], + version: 1 + }] ) } end @@ -68,7 +68,7 @@ RSpec.describe Psenv::Retriever do name: "/psenv/test/API_KEY", value: "value", type: "String", - version: 1, + version: 1 }], next_page?: true, next_page: OpenStruct.new( @@ -76,9 +76,9 @@ RSpec.describe Psenv::Retriever do name: "/psenv/test/CLIENT_KEY", value: "value", type: "String", - version: 1, - }], - ), + version: 1 + }] + ) ) } end