railties 7.1.3.2 → 7.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +175 -734
- data/lib/minitest/rails_plugin.rb +5 -2
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +3 -2
- data/lib/rails/application/bootstrap.rb +5 -6
- data/lib/rails/application/configuration.rb +34 -39
- data/lib/rails/application/dummy_config.rb +2 -2
- data/lib/rails/application/finisher.rb +7 -0
- data/lib/rails/application.rb +7 -48
- data/lib/rails/backtrace_cleaner.rb +18 -3
- data/lib/rails/cli.rb +0 -1
- data/lib/rails/command.rb +1 -1
- data/lib/rails/commands/app/update_command.rb +86 -0
- data/lib/rails/commands/console/console_command.rb +2 -21
- data/lib/rails/commands/console/irb_console.rb +137 -0
- data/lib/rails/commands/credentials/credentials_command.rb +2 -2
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +21 -30
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +34 -0
- data/lib/rails/commands/rake/rake_command.rb +1 -1
- data/lib/rails/commands/runner/runner_command.rb +14 -3
- data/lib/rails/commands/server/server_command.rb +5 -3
- data/lib/rails/commands/test/test_command.rb +2 -0
- data/lib/rails/configuration.rb +10 -1
- data/lib/rails/console/app.rb +5 -32
- data/lib/rails/console/helpers.rb +5 -16
- data/lib/rails/console/methods.rb +23 -0
- data/lib/rails/engine.rb +5 -5
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/app_base.rb +70 -49
- data/lib/rails/generators/base.rb +5 -1
- data/lib/rails/generators/database.rb +227 -69
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +2 -0
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +2 -0
- data/lib/rails/generators/generated_attribute.rb +26 -1
- data/lib/rails/generators/migration.rb +3 -3
- data/lib/rails/generators/rails/app/app_generator.rb +52 -23
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +23 -14
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +16 -16
- data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/app/views/pwa/manifest.json.erb.tt +22 -0
- data/lib/rails/generators/rails/app/templates/app/views/pwa/service-worker.js +26 -0
- data/lib/rails/generators/rails/app/templates/bin/brakeman.tt +6 -0
- data/lib/rails/generators/rails/app/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +6 -2
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +7 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +8 -1
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +11 -6
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +70 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +42 -23
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +5 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +13 -0
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +138 -0
- data/lib/rails/generators/rails/app/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +3 -3
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +66 -0
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +3 -0
- data/lib/rails/generators/rails/app/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +131 -20
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +38 -7
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +5 -1
- data/lib/rails/generators/rails/plugin/templates/bin/rubocop.tt +7 -0
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +103 -0
- data/lib/rails/generators/rails/plugin/templates/github/dependabot.yml +12 -0
- data/lib/rails/generators/rails/plugin/templates/rubocop.yml.tt +8 -0
- data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +10 -0
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +2 -0
- data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb.tt +1 -1
- data/lib/rails/generators/testing/assertions.rb +20 -0
- data/lib/rails/generators/testing/behavior.rb +7 -6
- data/lib/rails/generators.rb +1 -1
- data/lib/rails/health_controller.rb +1 -1
- data/lib/rails/info.rb +2 -2
- data/lib/rails/mailers_controller.rb +14 -1
- data/lib/rails/paths.rb +2 -2
- data/lib/rails/pwa_controller.rb +15 -0
- data/lib/rails/rack/logger.rb +15 -7
- data/lib/rails/railtie/configurable.rb +2 -2
- data/lib/rails/railtie.rb +2 -3
- data/lib/rails/tasks/framework.rake +0 -26
- data/lib/rails/tasks/tmp.rake +1 -1
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +12 -8
- data/lib/rails/templates/rails/welcome/index.html.erb +3 -2
- data/lib/rails/test_help.rb +2 -4
- data/lib/rails/test_unit/reporter.rb +8 -2
- data/lib/rails/test_unit/runner.rb +21 -2
- data/lib/rails/test_unit/test_parser.rb +45 -0
- data/lib/rails.rb +7 -4
- metadata +38 -32
- data/lib/rails/app_updater.rb +0 -40
- data/lib/rails/commands/secrets/USAGE +0 -61
- data/lib/rails/commands/secrets/secrets_command.rb +0 -47
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +0 -68
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +0 -54
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +0 -70
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +0 -24
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +0 -62
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +0 -53
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +0 -284
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/rails/ruby_version_check.rb +0 -17
- data/lib/rails/secrets.rb +0 -110
@@ -94,7 +94,7 @@ module Minitest
|
|
94
94
|
if count.nil?
|
95
95
|
warn("Non integer specified as profile count, separate " \
|
96
96
|
"your path from options with -- e.g. " \
|
97
|
-
"
|
97
|
+
"`#{::Rails::TestUnitReporter.executable} --profile -- #{value}`")
|
98
98
|
count = default_count
|
99
99
|
end
|
100
100
|
end
|
@@ -109,7 +109,10 @@ module Minitest
|
|
109
109
|
# Owes great inspiration to test runner trailblazers like RSpec,
|
110
110
|
# minitest-reporters, maxitest, and others.
|
111
111
|
def self.plugin_rails_init(options)
|
112
|
-
unless
|
112
|
+
# Don't mess with Minitest unless RAILS_ENV is set
|
113
|
+
return unless ENV["RAILS_ENV"]
|
114
|
+
|
115
|
+
unless options[:full_backtrace]
|
113
116
|
# Plugin can run without Rails loaded, check before filtering.
|
114
117
|
if ::Rails.respond_to?(:backtrace_cleaner)
|
115
118
|
Minitest.backtrace_filter = BacktraceFilterWithFallback.new(::Rails.backtrace_cleaner, Minitest.backtrace_filter)
|
data/lib/rails/all.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Style/RedundantBegin
|
4
|
-
|
5
3
|
require "rails"
|
6
4
|
|
7
5
|
%w(
|
@@ -16,7 +14,7 @@ require "rails"
|
|
16
14
|
action_text/engine
|
17
15
|
rails/test_unit/railtie
|
18
16
|
).each do |railtie|
|
19
|
-
begin
|
17
|
+
begin # rubocop:disable Style/RedundantBegin
|
20
18
|
require railtie
|
21
19
|
rescue LoadError
|
22
20
|
end
|
data/lib/rails/api/task.rb
CHANGED
@@ -146,8 +146,6 @@ module Rails
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def configure_rdoc_files
|
149
|
-
rdoc_files.include(api_main)
|
150
|
-
|
151
149
|
RDOC_FILES.each do |component, cfg|
|
152
150
|
cdr = component_root_dir(component)
|
153
151
|
|
@@ -172,6 +170,9 @@ module Rails
|
|
172
170
|
# Nothing to do
|
173
171
|
exit(0) if rdoc_files.empty?
|
174
172
|
end
|
173
|
+
|
174
|
+
# This must come after the mtime comparison to ensure the main page is not excluded.
|
175
|
+
rdoc_files.include(api_main)
|
175
176
|
end
|
176
177
|
|
177
178
|
# These variables are used by the sdoc template
|
@@ -5,7 +5,6 @@ require "set"
|
|
5
5
|
require "active_support/notifications"
|
6
6
|
require "active_support/dependencies"
|
7
7
|
require "active_support/descendants_tracker"
|
8
|
-
require "rails/secrets"
|
9
8
|
|
10
9
|
module Rails
|
11
10
|
class Application
|
@@ -65,8 +64,12 @@ module Rails
|
|
65
64
|
broadcast_logger.formatter = Rails.logger.formatter
|
66
65
|
Rails.logger = broadcast_logger
|
67
66
|
end
|
67
|
+
end
|
68
68
|
|
69
|
-
|
69
|
+
initializer :initialize_error_reporter, group: :all do
|
70
|
+
if config.consider_all_requests_local
|
71
|
+
Rails.error.debug_mode = true
|
72
|
+
else
|
70
73
|
Rails.error.logger = Rails.logger
|
71
74
|
end
|
72
75
|
end
|
@@ -110,10 +113,6 @@ module Rails
|
|
110
113
|
initializer :bootstrap_hook, group: :all do |app|
|
111
114
|
ActiveSupport.run_load_hooks(:before_initialize, app)
|
112
115
|
end
|
113
|
-
|
114
|
-
initializer :set_secrets_root, group: :all do
|
115
|
-
Rails::Secrets.root = root
|
116
|
-
end
|
117
116
|
end
|
118
117
|
end
|
119
118
|
end
|
@@ -19,11 +19,11 @@ module Rails
|
|
19
19
|
:ssl_options, :public_file_server,
|
20
20
|
:session_options, :time_zone, :reload_classes_only_on_change,
|
21
21
|
:beginning_of_week, :filter_redirect, :x,
|
22
|
-
:
|
22
|
+
:content_security_policy_report_only,
|
23
23
|
:content_security_policy_nonce_generator, :content_security_policy_nonce_directives,
|
24
24
|
:require_master_key, :credentials, :disable_sandbox, :sandbox_by_default,
|
25
25
|
:add_autoload_paths_to_load_path, :rake_eager_load, :server_timing, :log_file_size,
|
26
|
-
:dom_testing_default_html_version
|
26
|
+
:dom_testing_default_html_version, :yjit
|
27
27
|
|
28
28
|
attr_reader :encoding, :api_only, :loaded_config_version, :log_level
|
29
29
|
|
@@ -67,8 +67,6 @@ module Rails
|
|
67
67
|
@api_only = false
|
68
68
|
@debug_exception_response_format = nil
|
69
69
|
@x = Custom.new
|
70
|
-
@enable_dependency_loading = false
|
71
|
-
@read_encrypted_secrets = false
|
72
70
|
@content_security_policy = nil
|
73
71
|
@content_security_policy_report_only = false
|
74
72
|
@content_security_policy_nonce_generator = nil
|
@@ -83,6 +81,7 @@ module Rails
|
|
83
81
|
@rake_eager_load = false
|
84
82
|
@server_timing = false
|
85
83
|
@dom_testing_default_html_version = :html4
|
84
|
+
@yjit = false
|
86
85
|
end
|
87
86
|
|
88
87
|
# Loads default configuration values for a target version. This includes
|
@@ -115,8 +114,6 @@ module Rails
|
|
115
114
|
action_controller.forgery_protection_origin_check = true
|
116
115
|
end
|
117
116
|
|
118
|
-
ActiveSupport.to_time_preserves_timezone = true
|
119
|
-
|
120
117
|
if respond_to?(:active_record)
|
121
118
|
active_record.belongs_to_required_by_default = true
|
122
119
|
end
|
@@ -279,8 +276,6 @@ module Rails
|
|
279
276
|
|
280
277
|
if respond_to?(:active_record)
|
281
278
|
active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false
|
282
|
-
active_record.commit_transaction_on_non_local_return = true
|
283
|
-
active_record.allow_deprecated_singular_associations_name = false
|
284
279
|
active_record.sqlite3_adapter_strict_strings_by_default = true
|
285
280
|
active_record.query_log_tags_format = :sqlcommenter
|
286
281
|
active_record.raise_on_assign_to_attr_readonly = true
|
@@ -305,10 +300,6 @@ module Rails
|
|
305
300
|
action_dispatch.debug_exception_log_level = :error
|
306
301
|
end
|
307
302
|
|
308
|
-
if respond_to?(:active_job)
|
309
|
-
active_job.use_big_decimal_serializer = true
|
310
|
-
end
|
311
|
-
|
312
303
|
if respond_to?(:active_support)
|
313
304
|
active_support.cache_format_version = 7.1
|
314
305
|
active_support.message_serializer = :json_allow_marshal
|
@@ -316,18 +307,31 @@ module Rails
|
|
316
307
|
active_support.raise_on_invalid_cache_expiration_time = true
|
317
308
|
end
|
318
309
|
|
319
|
-
if respond_to?(:
|
320
|
-
|
310
|
+
if respond_to?(:action_view)
|
311
|
+
require "rails-html-sanitizer"
|
312
|
+
action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
321
313
|
end
|
322
314
|
|
323
|
-
if
|
324
|
-
|
325
|
-
|
326
|
-
|
315
|
+
if respond_to?(:action_text)
|
316
|
+
require "rails-html-sanitizer"
|
317
|
+
action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor
|
318
|
+
end
|
319
|
+
when "7.2"
|
320
|
+
load_defaults "7.1"
|
327
321
|
|
328
|
-
|
329
|
-
|
330
|
-
|
322
|
+
self.yjit = true
|
323
|
+
|
324
|
+
if respond_to?(:active_job)
|
325
|
+
active_job.enqueue_after_transaction_commit = :default
|
326
|
+
end
|
327
|
+
|
328
|
+
if respond_to?(:active_storage)
|
329
|
+
active_storage.web_image_content_types = %w( image/png image/jpeg image/gif image/webp )
|
330
|
+
end
|
331
|
+
|
332
|
+
if respond_to?(:active_record)
|
333
|
+
active_record.postgresql_adapter_decode_dates = true
|
334
|
+
active_record.validate_migration_timestamps = true
|
331
335
|
end
|
332
336
|
else
|
333
337
|
raise "Unknown version #{target_version.to_s.inspect}"
|
@@ -348,20 +352,12 @@ module Rails
|
|
348
352
|
self.cache_classes = !value
|
349
353
|
end
|
350
354
|
|
351
|
-
|
352
|
-
|
353
|
-
To fix this deprecation, please just delete the reference.
|
354
|
-
MSG
|
355
|
-
private_constant :ENABLE_DEPENDENCY_LOADING_WARNING
|
356
|
-
|
357
|
-
def enable_dependency_loading
|
358
|
-
Rails.deprecator.warn(ENABLE_DEPENDENCY_LOADING_WARNING)
|
359
|
-
@enable_dependency_loading
|
355
|
+
def read_encrypted_secrets
|
356
|
+
Rails.deprecator.warn("'config.read_encrypted_secrets' is deprecated and will be removed in Rails 7.3.")
|
360
357
|
end
|
361
358
|
|
362
|
-
def
|
363
|
-
Rails.deprecator.warn(
|
364
|
-
@enable_dependency_loading = value
|
359
|
+
def read_encrypted_secrets=(value)
|
360
|
+
Rails.deprecator.warn("'config.read_encrypted_secrets=' is deprecated and will be removed in Rails 7.3.")
|
365
361
|
end
|
366
362
|
|
367
363
|
def encoding=(value)
|
@@ -384,9 +380,7 @@ module Rails
|
|
384
380
|
@broadcast_log_level = level
|
385
381
|
end
|
386
382
|
|
387
|
-
|
388
|
-
defined?(@broadcast_log_level) ? @broadcast_log_level : nil
|
389
|
-
end
|
383
|
+
attr_reader :broadcast_log_level # :nodoc:
|
390
384
|
|
391
385
|
def debug_exception_response_format
|
392
386
|
@debug_exception_response_format || :default
|
@@ -398,7 +392,6 @@ module Rails
|
|
398
392
|
@paths ||= begin
|
399
393
|
paths = super
|
400
394
|
paths.add "config/database", with: "config/database.yml"
|
401
|
-
paths.add "config/secrets", with: "config", glob: "secrets.yml{,.enc}"
|
402
395
|
paths.add "config/environment", with: "config/environment.rb"
|
403
396
|
paths.add "lib/templates"
|
404
397
|
paths.add "log", with: "log/#{Rails.env}.log"
|
@@ -584,14 +577,16 @@ module Rails
|
|
584
577
|
def method_missing(method, *args)
|
585
578
|
if method.end_with?("=")
|
586
579
|
@configurations[:"#{method[0..-2]}"] = args.first
|
587
|
-
|
580
|
+
elsif args.empty?
|
588
581
|
@configurations.fetch(method) {
|
589
582
|
@configurations[method] = ActiveSupport::OrderedOptions.new
|
590
583
|
}
|
584
|
+
else
|
585
|
+
raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 0) when reading configuration `#{method}`"
|
591
586
|
end
|
592
587
|
end
|
593
588
|
|
594
|
-
def respond_to_missing?(symbol,
|
589
|
+
def respond_to_missing?(symbol, _)
|
595
590
|
true
|
596
591
|
end
|
597
592
|
end
|
@@ -9,9 +9,9 @@ class DummyConfig # :nodoc:
|
|
9
9
|
"DummyConfig"
|
10
10
|
end
|
11
11
|
|
12
|
-
def method_missing(selector,
|
12
|
+
def method_missing(selector, ...)
|
13
13
|
if @config.respond_to?(selector)
|
14
|
-
@config.send(selector,
|
14
|
+
@config.send(selector, ...)
|
15
15
|
else
|
16
16
|
self
|
17
17
|
end
|
@@ -78,6 +78,7 @@ module Rails
|
|
78
78
|
if config.eager_load
|
79
79
|
ActiveSupport.run_load_hooks(:before_eager_load, self)
|
80
80
|
Zeitwerk::Loader.eager_load_all
|
81
|
+
Rails.eager_load!
|
81
82
|
config.eager_load_namespaces.each(&:eager_load!)
|
82
83
|
|
83
84
|
if config.reloading_enabled?
|
@@ -226,6 +227,12 @@ module Rails
|
|
226
227
|
ActiveSupport::DescendantsTracker.disable_clear!
|
227
228
|
end
|
228
229
|
end
|
230
|
+
|
231
|
+
initializer :enable_yjit do
|
232
|
+
if config.yjit && defined?(RubyVM::YJIT.enable)
|
233
|
+
RubyVM::YJIT.enable
|
234
|
+
end
|
235
|
+
end
|
229
236
|
end
|
230
237
|
end
|
231
238
|
end
|
data/lib/rails/application.rb
CHANGED
@@ -10,7 +10,6 @@ require "active_support/encrypted_configuration"
|
|
10
10
|
require "active_support/hash_with_indifferent_access"
|
11
11
|
require "active_support/configuration_file"
|
12
12
|
require "rails/engine"
|
13
|
-
require "rails/secrets"
|
14
13
|
require "rails/autoloaders"
|
15
14
|
|
16
15
|
module Rails
|
@@ -104,7 +103,7 @@ module Rails
|
|
104
103
|
delegate :default_url_options, :default_url_options=, to: :routes
|
105
104
|
|
106
105
|
INITIAL_VARIABLES = [:config, :railties, :routes_reloader, :reloaders,
|
107
|
-
:routes, :helpers, :app_env_config
|
106
|
+
:routes, :helpers, :app_env_config] # :nodoc:
|
108
107
|
|
109
108
|
def initialize(initial_variable_values = {}, &block)
|
110
109
|
super()
|
@@ -412,8 +411,8 @@ module Rails
|
|
412
411
|
def watchable_args # :nodoc:
|
413
412
|
files, dirs = config.watchable_files.dup, config.watchable_dirs.dup
|
414
413
|
|
415
|
-
|
416
|
-
|
414
|
+
Rails.autoloaders.main.dirs.each do |path|
|
415
|
+
dirs[path] = [:rb]
|
417
416
|
end
|
418
417
|
|
419
418
|
[files, dirs]
|
@@ -439,25 +438,7 @@ module Rails
|
|
439
438
|
end
|
440
439
|
|
441
440
|
attr_writer :config
|
442
|
-
|
443
|
-
def secrets
|
444
|
-
Rails.deprecator.warn(<<~MSG.squish)
|
445
|
-
`Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2.
|
446
|
-
MSG
|
447
|
-
@secrets ||= begin
|
448
|
-
secrets = ActiveSupport::OrderedOptions.new
|
449
|
-
files = config.paths["config/secrets"].existent
|
450
|
-
files = files.reject { |path| path.end_with?(".enc") } unless config.read_encrypted_secrets
|
451
|
-
secrets.merge! Rails::Secrets.parse(files, env: Rails.env)
|
452
|
-
|
453
|
-
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
454
|
-
secrets.secret_key_base ||= config.secret_key_base
|
455
|
-
|
456
|
-
secrets
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
attr_writer :secrets, :credentials
|
441
|
+
attr_writer :credentials
|
461
442
|
|
462
443
|
# The secret_key_base is used as the input secret to the application's key generator, which in turn
|
463
444
|
# is used to create all ActiveSupport::MessageVerifier and ActiveSupport::MessageEncryptor instances,
|
@@ -473,28 +454,14 @@ module Rails
|
|
473
454
|
# Dockerfile example: <tt>RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile</tt>.
|
474
455
|
#
|
475
456
|
# In all other environments, we look for it first in <tt>ENV["SECRET_KEY_BASE"]</tt>,
|
476
|
-
# then +credentials.secret_key_base
|
477
|
-
#
|
457
|
+
# then +credentials.secret_key_base+. For most applications, the correct place to store it is in the
|
458
|
+
# encrypted credentials file.
|
478
459
|
def secret_key_base
|
479
460
|
if Rails.env.local? || ENV["SECRET_KEY_BASE_DUMMY"]
|
480
461
|
config.secret_key_base ||= generate_local_secret
|
481
462
|
else
|
482
463
|
validate_secret_key_base(
|
483
|
-
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base
|
484
|
-
secret_skb = secrets_secret_key_base
|
485
|
-
|
486
|
-
if secret_skb.equal?(config.secret_key_base)
|
487
|
-
config.secret_key_base
|
488
|
-
else
|
489
|
-
Rails.deprecator.warn(<<~MSG.squish)
|
490
|
-
Your `secret_key_base` is configured in `Rails.application.secrets`,
|
491
|
-
which is deprecated in favor of `Rails.application.credentials` and
|
492
|
-
will be removed in Rails 7.2.
|
493
|
-
MSG
|
494
|
-
|
495
|
-
secret_skb
|
496
|
-
end
|
497
|
-
end
|
464
|
+
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base
|
498
465
|
)
|
499
466
|
end
|
500
467
|
end
|
@@ -671,8 +638,6 @@ module Rails
|
|
671
638
|
|
672
639
|
if File.exist?(key_file)
|
673
640
|
config.secret_key_base = File.binread(key_file)
|
674
|
-
elsif secrets_secret_key_base
|
675
|
-
config.secret_key_base = secrets_secret_key_base
|
676
641
|
else
|
677
642
|
random_key = SecureRandom.hex(64)
|
678
643
|
FileUtils.mkdir_p(key_file.dirname)
|
@@ -684,12 +649,6 @@ module Rails
|
|
684
649
|
config.secret_key_base
|
685
650
|
end
|
686
651
|
|
687
|
-
def secrets_secret_key_base
|
688
|
-
Rails.deprecator.silence do
|
689
|
-
secrets.secret_key_base
|
690
|
-
end
|
691
|
-
end
|
692
|
-
|
693
652
|
def build_request(env)
|
694
653
|
req = super
|
695
654
|
env["ORIGINAL_FULLPATH"] = req.fullpath
|
@@ -6,13 +6,15 @@ require "active_support/core_ext/string/access"
|
|
6
6
|
module Rails
|
7
7
|
class BacktraceCleaner < ActiveSupport::BacktraceCleaner # :nodoc:
|
8
8
|
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
|
9
|
-
RENDER_TEMPLATE_PATTERN = /:in
|
9
|
+
RENDER_TEMPLATE_PATTERN = /:in [`'].*_\w+_{2,3}\d+_\d+'/
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
super
|
13
|
-
@root = "#{Rails.root}/"
|
14
13
|
add_filter do |line|
|
15
|
-
|
14
|
+
# We may be called before Rails.root is assigned.
|
15
|
+
# When that happens we fallback to not truncating.
|
16
|
+
@root ||= Rails.root && "#{Rails.root}/"
|
17
|
+
@root && line.start_with?(@root) ? line.from(@root.size) : line
|
16
18
|
end
|
17
19
|
add_filter do |line|
|
18
20
|
if RENDER_TEMPLATE_PATTERN.match?(line)
|
@@ -23,5 +25,18 @@ module Rails
|
|
23
25
|
end
|
24
26
|
add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
|
25
27
|
end
|
28
|
+
|
29
|
+
def clean(backtrace, kind = :silent)
|
30
|
+
kind = nil if ENV["BACKTRACE"]
|
31
|
+
|
32
|
+
super(backtrace, kind)
|
33
|
+
end
|
34
|
+
alias_method :filter, :clean
|
35
|
+
|
36
|
+
def clean_frame(frame, kind = :silent)
|
37
|
+
kind = nil if ENV["BACKTRACE"]
|
38
|
+
|
39
|
+
super(frame, kind)
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
data/lib/rails/cli.rb
CHANGED
data/lib/rails/command.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "rails/generators/rails/app/app_generator"
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
module Command
|
8
|
+
module App
|
9
|
+
class UpdateCommand < Base # :nodoc:
|
10
|
+
include Thor::Actions
|
11
|
+
add_runtime_options!
|
12
|
+
|
13
|
+
desc "update", "Update configs and some other initially generated files (or use just update:configs or update:bin)"
|
14
|
+
def perform
|
15
|
+
configs
|
16
|
+
bin
|
17
|
+
active_storage
|
18
|
+
display_upgrade_guide_info
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "configs", "Update config files in the application config/ directory", hide: true
|
22
|
+
def configs
|
23
|
+
require_application!
|
24
|
+
app_generator.create_boot_file
|
25
|
+
app_generator.update_config_files
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "bin", "Add or update executables in the application bin/ directory", hide: true
|
29
|
+
def bin
|
30
|
+
require_application!
|
31
|
+
app_generator.update_bin_files
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "active_storage", "Run the active_storage:update command", hide: true
|
35
|
+
def active_storage
|
36
|
+
require_application!
|
37
|
+
app_generator.update_active_storage
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def display_upgrade_guide_info
|
42
|
+
say "\nAfter this, check Rails upgrade guide at https://guides.rubyonrails.org/upgrading_ruby_on_rails.html for more details about upgrading your app."
|
43
|
+
end
|
44
|
+
|
45
|
+
def app_generator
|
46
|
+
@app_generator ||= begin
|
47
|
+
gen = Rails::Generators::AppGenerator.new(["rails"], generator_options, destination_root: Rails.root)
|
48
|
+
gen.send(:valid_const?) unless File.exist?(Rails.root.join("config", "application.rb"))
|
49
|
+
gen
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def generator_options
|
54
|
+
{
|
55
|
+
api: !!Rails.application.config.api_only,
|
56
|
+
update: true,
|
57
|
+
name: Rails.application.class.name.chomp("::Application").underscore,
|
58
|
+
skip_active_job: !defined?(ActiveJob::Railtie),
|
59
|
+
skip_active_record: !defined?(ActiveRecord::Railtie),
|
60
|
+
skip_active_storage: !defined?(ActiveStorage::Engine),
|
61
|
+
skip_action_mailer: !defined?(ActionMailer::Railtie),
|
62
|
+
skip_action_mailbox: !defined?(ActionMailbox::Engine),
|
63
|
+
skip_action_text: !defined?(ActionText::Engine),
|
64
|
+
skip_action_cable: !defined?(ActionCable::Engine),
|
65
|
+
skip_test: !defined?(Rails::TestUnitRailtie),
|
66
|
+
skip_system_test: Rails.application.config.generators.system_tests.nil?,
|
67
|
+
asset_pipeline: asset_pipeline,
|
68
|
+
skip_asset_pipeline: asset_pipeline.nil?,
|
69
|
+
skip_bootsnap: !defined?(Bootsnap),
|
70
|
+
}.merge(options)
|
71
|
+
end
|
72
|
+
|
73
|
+
def asset_pipeline
|
74
|
+
case
|
75
|
+
when defined?(Sprockets::Railtie)
|
76
|
+
"sprockets"
|
77
|
+
when defined?(Propshaft::Railtie)
|
78
|
+
"propshaft"
|
79
|
+
else
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -4,14 +4,6 @@ require "rails/command/environment_argument"
|
|
4
4
|
|
5
5
|
module Rails
|
6
6
|
class Console
|
7
|
-
module BacktraceCleaner
|
8
|
-
def filter_backtrace(bt)
|
9
|
-
if result = super
|
10
|
-
Rails.backtrace_cleaner.filter([result]).first
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
7
|
def self.start(*args)
|
16
8
|
new(*args).start
|
17
9
|
end
|
@@ -32,16 +24,8 @@ module Rails
|
|
32
24
|
app.load_console
|
33
25
|
|
34
26
|
@console = app.config.console || begin
|
35
|
-
require "
|
36
|
-
|
37
|
-
|
38
|
-
IRB::WorkSpace.prepend(BacktraceCleaner)
|
39
|
-
|
40
|
-
if !Rails.env.local?
|
41
|
-
ENV["IRB_USE_AUTOCOMPLETE"] ||= "false"
|
42
|
-
end
|
43
|
-
|
44
|
-
IRB
|
27
|
+
require "rails/commands/console/irb_console"
|
28
|
+
IRBConsole.new(app)
|
45
29
|
end
|
46
30
|
end
|
47
31
|
|
@@ -72,9 +56,6 @@ module Rails
|
|
72
56
|
puts "Loading #{Rails.env} environment (Rails #{Rails.version})"
|
73
57
|
end
|
74
58
|
|
75
|
-
if defined?(console::ExtendCommandBundle)
|
76
|
-
console::ExtendCommandBundle.include(Rails::ConsoleMethods)
|
77
|
-
end
|
78
59
|
console.start
|
79
60
|
end
|
80
61
|
end
|