railties 7.1.0 → 7.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +203 -650
- data/lib/minitest/rails_plugin.rb +5 -2
- data/lib/rails/all.rb +1 -3
- data/lib/rails/api/task.rb +6 -4
- data/lib/rails/application/bootstrap.rb +11 -8
- data/lib/rails/application/configuration.rb +80 -36
- data/lib/rails/application/dummy_config.rb +2 -2
- data/lib/rails/application/finisher.rb +10 -0
- data/lib/rails/application.rb +29 -76
- 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 +102 -0
- data/lib/rails/commands/boot/boot_command.rb +14 -0
- data/lib/rails/commands/console/console_command.rb +2 -21
- data/lib/rails/commands/console/irb_console.rb +146 -0
- data/lib/rails/commands/credentials/USAGE +1 -1
- 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 +39 -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/configuration.rb +45 -6
- data/lib/rails/engine.rb +24 -17
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators/active_model.rb +26 -12
- data/lib/rails/generators/app_base.rb +80 -61
- data/lib/rails/generators/base.rb +9 -5
- 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 +57 -32
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +23 -16
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +17 -17
- 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 +11 -4
- 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 +14 -7
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -6
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +10 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -3
- 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 +25 -26
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +6 -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 +134 -20
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +166 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +3 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/compose.yaml.tt +47 -0
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +37 -0
- data/lib/rails/generators/rails/migration/migration_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +40 -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/app/views/layouts/%namespaced_name%/application.html.erb.tt +2 -0
- 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/rails/plugin/templates/test/test_helper.rb.tt +2 -2
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +6 -4
- data/lib/rails/generators/test_unit/mailer/templates/preview.rb.tt +3 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +15 -1
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +2 -2
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +2 -2
- 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 +7 -3
- data/lib/rails/health_controller.rb +2 -2
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +4 -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 +15 -16
- data/lib/rails/tasks/framework.rake +0 -26
- data/lib/rails/tasks/tmp.rake +1 -1
- data/lib/rails/tasks/zeitwerk.rake +14 -34
- data/lib/rails/templates/layouts/application.html.erb +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +20 -9
- data/lib/rails/templates/rails/welcome/index.html.erb +4 -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 +26 -2
- data/lib/rails/test_unit/test_parser.rb +45 -0
- data/lib/rails/testing/maintain_test_schema.rb +1 -1
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +7 -4
- metadata +46 -35
- 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 -46
- 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 -223
- 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
data/lib/rails/secrets.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
require "tempfile"
|
5
|
-
require "active_support/message_encryptor"
|
6
|
-
|
7
|
-
module Rails
|
8
|
-
# Greatly inspired by Ara T. Howard's magnificent sekrets gem. 😘
|
9
|
-
class Secrets # :nodoc:
|
10
|
-
class MissingKeyError < RuntimeError
|
11
|
-
def initialize
|
12
|
-
super(<<-end_of_message.squish)
|
13
|
-
Missing encryption key to decrypt secrets with.
|
14
|
-
Ask your team for your master key and put it in ENV["RAILS_MASTER_KEY"]
|
15
|
-
end_of_message
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
@cipher = "aes-128-gcm"
|
20
|
-
@root = File # Wonky, but ensures `join` uses the current directory.
|
21
|
-
|
22
|
-
class << self
|
23
|
-
attr_writer :root
|
24
|
-
|
25
|
-
def parse(paths, env:)
|
26
|
-
paths.each_with_object(Hash.new) do |path, all_secrets|
|
27
|
-
require "erb"
|
28
|
-
|
29
|
-
source = ERB.new(preprocess(path)).result
|
30
|
-
secrets = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(source) : YAML.load(source)
|
31
|
-
secrets ||= {}
|
32
|
-
|
33
|
-
all_secrets.merge!(secrets["shared"].deep_symbolize_keys) if secrets["shared"]
|
34
|
-
all_secrets.merge!(secrets[env].deep_symbolize_keys) if secrets[env]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def key
|
39
|
-
ENV["RAILS_MASTER_KEY"] || read_key_file || handle_missing_key
|
40
|
-
end
|
41
|
-
|
42
|
-
def encrypt(data)
|
43
|
-
encryptor.encrypt_and_sign(data)
|
44
|
-
end
|
45
|
-
|
46
|
-
def decrypt(data)
|
47
|
-
encryptor.decrypt_and_verify(data)
|
48
|
-
end
|
49
|
-
|
50
|
-
def read
|
51
|
-
decrypt(IO.binread(path))
|
52
|
-
end
|
53
|
-
|
54
|
-
def write(contents)
|
55
|
-
IO.binwrite("#{path}.tmp", encrypt(contents))
|
56
|
-
FileUtils.mv("#{path}.tmp", path)
|
57
|
-
end
|
58
|
-
|
59
|
-
def read_for_editing(&block)
|
60
|
-
writing(read, &block)
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
def handle_missing_key
|
65
|
-
raise MissingKeyError
|
66
|
-
end
|
67
|
-
|
68
|
-
def read_key_file
|
69
|
-
if File.exist?(key_path)
|
70
|
-
IO.binread(key_path).strip
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def key_path
|
75
|
-
@root.join("config", "secrets.yml.key")
|
76
|
-
end
|
77
|
-
|
78
|
-
def path
|
79
|
-
@root.join("config", "secrets.yml.enc").to_s
|
80
|
-
end
|
81
|
-
|
82
|
-
def preprocess(path)
|
83
|
-
if path.end_with?(".enc")
|
84
|
-
decrypt(IO.binread(path))
|
85
|
-
else
|
86
|
-
IO.read(path)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def writing(contents)
|
91
|
-
file_name = "#{File.basename(path)}.#{Process.pid}"
|
92
|
-
|
93
|
-
Tempfile.create(["", "-" + file_name]) do |tmp_file|
|
94
|
-
tmp_path = Pathname.new(tmp_file)
|
95
|
-
tmp_path.binwrite contents
|
96
|
-
|
97
|
-
yield tmp_path
|
98
|
-
|
99
|
-
updated_contents = tmp_path.binread
|
100
|
-
|
101
|
-
write(updated_contents) if updated_contents != contents
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def encryptor
|
106
|
-
@encryptor ||= ActiveSupport::MessageEncryptor.new([ key ].pack("H*"), cipher: @cipher)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|