railties 6.0.0 → 7.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +699 -245
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +7 -8
- data/lib/minitest/rails_plugin.rb +80 -2
- data/lib/rails/all.rb +0 -1
- data/lib/rails/api/task.rb +37 -5
- data/lib/rails/app_updater.rb +9 -6
- data/lib/rails/application/bootstrap.rb +52 -14
- data/lib/rails/application/configuration.rb +327 -86
- data/lib/rails/application/default_middleware_stack.rb +33 -7
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +94 -113
- data/lib/rails/application/routes_reloader.rb +17 -3
- data/lib/rails/application.rb +258 -201
- data/lib/rails/application_controller.rb +3 -4
- data/lib/rails/autoloaders/inflector.rb +21 -0
- data/lib/rails/autoloaders.rb +42 -42
- data/lib/rails/backtrace_cleaner.rb +13 -8
- data/lib/rails/cli.rb +5 -2
- data/lib/rails/code_statistics.rb +6 -4
- data/lib/rails/code_statistics_calculator.rb +16 -7
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +66 -46
- data/lib/rails/command/behavior.rb +3 -3
- data/lib/rails/command/environment_argument.rb +33 -17
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +90 -32
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +17 -13
- data/lib/rails/commands/credentials/USAGE +54 -39
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +53 -0
- data/lib/rails/commands/credentials/credentials_command.rb +83 -60
- data/lib/rails/commands/db/system/change/change_command.rb +8 -2
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +39 -124
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +3 -3
- data/lib/rails/commands/help/USAGE +15 -14
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +5 -14
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +27 -23
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +34 -21
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/secrets/USAGE +44 -43
- data/lib/rails/commands/secrets/secrets_command.rb +20 -38
- data/lib/rails/commands/server/server_command.rb +40 -64
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +58 -16
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +53 -23
- data/lib/rails/console/app.rb +1 -4
- data/lib/rails/console/helpers.rb +2 -2
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +54 -9
- data/lib/rails/engine/updater.rb +1 -1
- data/lib/rails/engine.rb +105 -81
- data/lib/rails/gem_version.rb +5 -5
- data/lib/rails/generators/actions/create_migration.rb +9 -5
- data/lib/rails/generators/actions.rb +275 -97
- data/lib/rails/generators/active_model.rb +28 -14
- data/lib/rails/generators/app_base.rb +487 -165
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +42 -31
- data/lib/rails/generators/database.rb +41 -4
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +0 -1
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +11 -11
- data/lib/rails/generators/erb/scaffold/templates/edit.html.erb.tt +8 -4
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +11 -28
- data/lib/rails/generators/erb/scaffold/templates/new.html.erb.tt +7 -3
- data/lib/rails/generators/erb/scaffold/templates/partial.html.erb.tt +17 -0
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +8 -17
- data/lib/rails/generators/erb.rb +1 -2
- data/lib/rails/generators/generated_attribute.rb +60 -19
- data/lib/rails/generators/migration.rb +4 -8
- data/lib/rails/generators/model_helpers.rb +29 -4
- data/lib/rails/generators/named_base.rb +15 -15
- data/lib/rails/generators/rails/app/USAGE +23 -6
- data/lib/rails/generators/rails/app/app_generator.rb +151 -80
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +103 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +44 -54
- data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/app/models/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -9
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +3 -3
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +19 -15
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +18 -23
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +5 -6
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +17 -16
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +12 -11
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +17 -18
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +14 -13
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
- data/lib/rails/generators/rails/app/templates/config/environment.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +32 -14
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +42 -55
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +27 -15
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +3 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +21 -28
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +6 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +284 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +13 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +13 -15
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +17 -20
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +8 -1
- data/lib/rails/generators/rails/app/templates/config/storage.yml.tt +5 -5
- data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +7 -5
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +9 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +12 -9
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +13 -11
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/USAGE +19 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +30 -0
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
- data/lib/rails/generators/rails/controller/USAGE +13 -5
- data/lib/rails/generators/rails/controller/controller_generator.rb +7 -42
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -5
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +30 -25
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +31 -1
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +6 -2
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/generator/USAGE +2 -2
- data/lib/rails/generators/rails/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +1 -1
- data/lib/rails/generators/rails/generator/templates/USAGE.tt +1 -1
- data/lib/rails/generators/rails/helper/USAGE +2 -3
- data/lib/rails/generators/rails/integration_test/USAGE +2 -2
- data/lib/rails/generators/rails/migration/USAGE +22 -12
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +86 -46
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +15 -20
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +10 -39
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/README.md.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -18
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +0 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +0 -3
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +7 -22
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +10 -14
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb.tt +1 -0
- data/lib/rails/generators/rails/plugin/templates/rails/boot.rb.tt +3 -3
- data/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb.tt +4 -4
- data/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +6 -14
- data/lib/rails/generators/rails/resource/USAGE +4 -4
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +2 -27
- data/lib/rails/generators/rails/scaffold/USAGE +5 -5
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -20
- data/lib/rails/generators/rails/scaffold_controller/USAGE +2 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +7 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -6
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +7 -11
- data/lib/rails/generators/rails/system_test/USAGE +2 -2
- data/lib/rails/generators/rails/task/USAGE +3 -3
- data/lib/rails/generators/resource_helpers.rb +2 -2
- data/lib/rails/generators/test_case.rb +3 -3
- data/lib/rails/generators/test_unit/controller/controller_generator.rb +2 -0
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb.tt +3 -3
- data/lib/rails/generators/test_unit/generator/generator_generator.rb +0 -1
- data/lib/rails/generators/test_unit/generator/templates/generator_test.rb.tt +3 -3
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +0 -1
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/job/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml.tt +3 -3
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +4 -5
- data/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb.tt +6 -6
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +8 -8
- data/lib/rails/generators/test_unit/scaffold/templates/system_test.rb.tt +9 -11
- data/lib/rails/generators/testing/assertions.rb +2 -2
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +8 -7
- data/lib/rails/generators.rb +43 -45
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +4 -4
- data/lib/rails/info_controller.rb +30 -13
- data/lib/rails/initializable.rb +1 -1
- data/lib/rails/mailers_controller.rb +18 -9
- data/lib/rails/paths.rb +28 -19
- data/lib/rails/rack/logger.rb +17 -17
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configurable.rb +0 -1
- data/lib/rails/railtie/configuration.rb +15 -3
- data/lib/rails/railtie.rb +80 -37
- data/lib/rails/ruby_version_check.rb +5 -3
- data/lib/rails/secrets.rb +14 -9
- data/lib/rails/source_annotation_extractor.rb +69 -34
- data/lib/rails/tasks/engine.rake +8 -11
- data/lib/rails/tasks/framework.rake +4 -6
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +4 -15
- data/lib/rails/tasks/statistics.rake +9 -6
- data/lib/rails/tasks/tmp.rake +13 -6
- data/lib/rails/tasks/yarn.rake +17 -6
- data/lib/rails/tasks/zeitwerk.rake +16 -41
- data/lib/rails/tasks.rb +0 -6
- data/lib/rails/templates/layouts/application.html.erb +15 -0
- data/lib/rails/templates/rails/mailers/email.html.erb +46 -11
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +65 -48
- data/lib/rails/test_help.rb +13 -14
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/railtie.rb +0 -4
- data/lib/rails/test_unit/reporter.rb +8 -3
- data/lib/rails/test_unit/runner.rb +61 -19
- data/lib/rails/test_unit/test_parser.rb +88 -0
- data/lib/rails/test_unit/testing.rake +17 -36
- data/lib/rails/testing/maintain_test_schema.rb +16 -0
- data/lib/rails/version.rb +1 -1
- data/lib/rails/welcome_controller.rb +1 -0
- data/lib/rails/zeitwerk_checker.rb +15 -0
- data/lib/rails.rb +31 -23
- metadata +89 -58
- data/RDOC_MAIN.rdoc +0 -98
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/command/spellchecker.rb +0 -58
- data/lib/rails/generators/css/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -18
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +0 -6
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +0 -5
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +0 -23
- data/lib/rails/generators/rails/app/templates/bin/yarn.tt +0 -10
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +0 -50
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +0 -86
- data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb.tt +0 -8
- data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +0 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb.tt +0 -5
- data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +0 -45
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +0 -6
- data/lib/rails/generators/rails/app/templates/package.json.tt +0 -11
- data/lib/rails/generators/rails/assets/USAGE +0 -17
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -26
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
- data/lib/rails/generators/rails/model/USAGE +0 -114
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -80
- data/lib/rails/tasks/annotations.rake +0 -22
- data/lib/rails/tasks/dev.rake +0 -11
- data/lib/rails/tasks/initializers.rake +0 -9
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
- data/lib/rails/tasks/routes.rake +0 -9
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support/deprecation"
|
4
3
|
require "active_support/core_ext/string/filters"
|
5
4
|
require "rails/command/environment_argument"
|
6
5
|
|
@@ -12,107 +11,52 @@ module Rails
|
|
12
11
|
|
13
12
|
def initialize(options = {})
|
14
13
|
@options = options
|
14
|
+
@options[:environment] ||= Rails::Command.environment
|
15
15
|
end
|
16
16
|
|
17
17
|
def start
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
args = {
|
23
|
-
"host" => "--host",
|
24
|
-
"port" => "--port",
|
25
|
-
"socket" => "--socket",
|
26
|
-
"username" => "--user",
|
27
|
-
"encoding" => "--default-character-set",
|
28
|
-
"sslca" => "--ssl-ca",
|
29
|
-
"sslcert" => "--ssl-cert",
|
30
|
-
"sslcapath" => "--ssl-capath",
|
31
|
-
"sslcipher" => "--ssl-cipher",
|
32
|
-
"sslkey" => "--ssl-key"
|
33
|
-
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
|
34
|
-
|
35
|
-
if config["password"] && @options["include_password"]
|
36
|
-
args << "--password=#{config['password']}"
|
37
|
-
elsif config["password"] && !config["password"].to_s.empty?
|
38
|
-
args << "-p"
|
39
|
-
end
|
40
|
-
|
41
|
-
args << config["database"]
|
42
|
-
|
43
|
-
find_cmd_and_exec(["mysql", "mysql5"], *args)
|
44
|
-
|
45
|
-
when /^postgres|^postgis/
|
46
|
-
ENV["PGUSER"] = config["username"] if config["username"]
|
47
|
-
ENV["PGHOST"] = config["host"] if config["host"]
|
48
|
-
ENV["PGPORT"] = config["port"].to_s if config["port"]
|
49
|
-
ENV["PGPASSWORD"] = config["password"].to_s if config["password"] && @options["include_password"]
|
50
|
-
find_cmd_and_exec("psql", config["database"])
|
51
|
-
|
52
|
-
when "sqlite3"
|
53
|
-
args = []
|
54
|
-
|
55
|
-
args << "-#{@options['mode']}" if @options["mode"]
|
56
|
-
args << "-header" if @options["header"]
|
57
|
-
args << File.expand_path(config["database"], Rails.respond_to?(:root) ? Rails.root : nil)
|
58
|
-
|
59
|
-
find_cmd_and_exec("sqlite3", *args)
|
60
|
-
|
61
|
-
when "oracle", "oracle_enhanced"
|
62
|
-
logon = ""
|
63
|
-
|
64
|
-
if config["username"]
|
65
|
-
logon = config["username"].dup
|
66
|
-
logon << "/#{config['password']}" if config["password"] && @options["include_password"]
|
67
|
-
logon << "@#{config['database']}" if config["database"]
|
68
|
-
end
|
69
|
-
|
70
|
-
find_cmd_and_exec("sqlplus", logon)
|
71
|
-
|
72
|
-
when "sqlserver"
|
73
|
-
args = []
|
74
|
-
|
75
|
-
args += ["-D", "#{config['database']}"] if config["database"]
|
76
|
-
args += ["-U", "#{config['username']}"] if config["username"]
|
77
|
-
args += ["-P", "#{config['password']}"] if config["password"]
|
78
|
-
|
79
|
-
if config["host"]
|
80
|
-
host_arg = +"#{config['host']}"
|
81
|
-
host_arg << ":#{config['port']}" if config["port"]
|
82
|
-
args += ["-S", host_arg]
|
83
|
-
end
|
18
|
+
adapter_class.dbconsole(db_config, @options)
|
19
|
+
rescue NotImplementedError
|
20
|
+
abort "Unknown command-line client for #{db_config.database}."
|
21
|
+
end
|
84
22
|
|
85
|
-
|
23
|
+
def db_config
|
24
|
+
return @db_config if defined?(@db_config)
|
86
25
|
|
26
|
+
# If the user provided a database, use that. Otherwise find
|
27
|
+
# the first config in the database.yml
|
28
|
+
if database
|
29
|
+
@db_config = configurations.configs_for(env_name: environment, name: database, include_hidden: true)
|
87
30
|
else
|
88
|
-
|
31
|
+
@db_config = configurations.find_db_config(environment)
|
89
32
|
end
|
90
|
-
end
|
91
33
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
# relying on 2-level database configuration.
|
97
|
-
if @options["database"] && configurations[database].blank?
|
98
|
-
raise ActiveRecord::AdapterNotSpecified, "'#{database}' database is not configured. Available configuration: #{configurations.inspect}"
|
99
|
-
elsif configurations[environment].blank? && configurations[database].blank?
|
100
|
-
raise ActiveRecord::AdapterNotSpecified, "'#{environment}' database is not configured. Available configuration: #{configurations.inspect}"
|
101
|
-
else
|
102
|
-
configurations[database] || configurations[environment].presence
|
103
|
-
end
|
34
|
+
unless @db_config
|
35
|
+
missing_db = database ? "'#{database}' database is not" : "No databases are"
|
36
|
+
raise ActiveRecord::AdapterNotSpecified,
|
37
|
+
"#{missing_db} configured for '#{environment}'. Available configuration: #{configurations.inspect}"
|
104
38
|
end
|
105
|
-
end
|
106
39
|
|
107
|
-
|
108
|
-
Rails.respond_to?(:env) ? Rails.env : Rails::Command.environment
|
40
|
+
@db_config
|
109
41
|
end
|
110
42
|
|
111
43
|
def database
|
112
|
-
@options
|
44
|
+
@options[:database]
|
45
|
+
end
|
46
|
+
|
47
|
+
def environment
|
48
|
+
@options[:environment]
|
113
49
|
end
|
114
50
|
|
115
51
|
private
|
52
|
+
def adapter_class
|
53
|
+
if ActiveRecord::Base.respond_to?(db_config.adapter_class_method)
|
54
|
+
ActiveRecord::Base.public_send(db_config.adapter_class_method)
|
55
|
+
else
|
56
|
+
ActiveRecord::ConnectionAdapters::AbstractAdapter
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
116
60
|
def configurations # :doc:
|
117
61
|
require APP_PATH
|
118
62
|
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
|
@@ -120,26 +64,11 @@ module Rails
|
|
120
64
|
end
|
121
65
|
|
122
66
|
def find_cmd_and_exec(commands, *args) # :doc:
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
full_path_command = nil
|
131
|
-
found = commands.detect do |cmd|
|
132
|
-
dirs_on_path.detect do |path|
|
133
|
-
full_path_command = File.join(path, cmd)
|
134
|
-
File.file?(full_path_command) && File.executable?(full_path_command)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
if found
|
139
|
-
exec full_path_command, *args
|
140
|
-
else
|
141
|
-
abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.")
|
142
|
-
end
|
67
|
+
Rails.deprecator.warn(<<~MSG.squish)
|
68
|
+
Rails::DBConsole#find_cmd_and_exec is deprecated and will be removed in Rails 7.2.
|
69
|
+
Please use find_cmd_and_exec on the connection adapter class instead.
|
70
|
+
MSG
|
71
|
+
ActiveRecord::Base.connection.find_cmd_and_exec(commands, *args)
|
143
72
|
end
|
144
73
|
end
|
145
74
|
|
@@ -151,30 +80,16 @@ module Rails
|
|
151
80
|
desc: "Automatically provide the password from database.yml"
|
152
81
|
|
153
82
|
class_option :mode, enum: %w( html list line column ), type: :string,
|
154
|
-
desc: "Automatically put the sqlite3 database in the specified mode
|
83
|
+
desc: "Automatically put the sqlite3 database in the specified mode"
|
155
84
|
|
156
85
|
class_option :header, type: :boolean
|
157
86
|
|
158
|
-
class_option :connection, aliases: "-c", type: :string,
|
159
|
-
desc: "Specifies the connection to use."
|
160
|
-
|
161
87
|
class_option :database, aliases: "--db", type: :string,
|
162
|
-
desc: "
|
88
|
+
desc: "Specify the database to use."
|
163
89
|
|
90
|
+
desc "dbconsole", "Start a console for the database specified in config/database.yml"
|
164
91
|
def perform
|
165
|
-
|
166
|
-
|
167
|
-
# RAILS_ENV needs to be set before config/application is required.
|
168
|
-
ENV["RAILS_ENV"] = options[:environment]
|
169
|
-
|
170
|
-
if options["connection"]
|
171
|
-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
172
|
-
`connection` option is deprecated and will be removed in Rails 6.1. Please use `database` option instead.
|
173
|
-
MSG
|
174
|
-
options["database"] = options["connection"]
|
175
|
-
end
|
176
|
-
|
177
|
-
require_application_and_environment!
|
92
|
+
boot_application!
|
178
93
|
Rails::DBConsole.start(options)
|
179
94
|
end
|
180
95
|
end
|
@@ -7,18 +7,19 @@ module Rails
|
|
7
7
|
class DestroyCommand < Base # :nodoc:
|
8
8
|
no_commands do
|
9
9
|
def help
|
10
|
-
|
10
|
+
boot_application!
|
11
11
|
load_generators
|
12
12
|
|
13
13
|
Rails::Generators.help self.class.command_name
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
desc "destroy GENERATOR", "Remove code generated by `bin/rails generate`"
|
17
18
|
def perform(*)
|
18
19
|
generator = args.shift
|
19
20
|
return help unless generator
|
20
21
|
|
21
|
-
|
22
|
+
boot_application!
|
22
23
|
load_generators
|
23
24
|
|
24
25
|
Rails::Generators.invoke generator, args, behavior: :revoke, destination_root: Rails::Command.root
|
@@ -5,12 +5,7 @@ require "rails/dev_caching"
|
|
5
5
|
module Rails
|
6
6
|
module Command
|
7
7
|
class DevCommand < Base # :nodoc:
|
8
|
-
|
9
|
-
def help
|
10
|
-
say "rails dev:cache # Toggle development mode caching on/off."
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
8
|
+
desc "cache", "Toggle development mode caching on/off"
|
14
9
|
def cache
|
15
10
|
Rails::DevCaching.enable_by_file
|
16
11
|
end
|
@@ -1,28 +1,23 @@
|
|
1
|
-
|
1
|
+
Description:
|
2
|
+
The Rails `encrypted` commands provide access to encrypted files or configurations.
|
3
|
+
See the `Rails.application.encrypted` documentation for using them in your app.
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
Encryption Keys:
|
6
|
+
By default, Rails looks for the encryption key in `ENV["RAILS_MASTER_KEY"]` or
|
7
|
+
`config/master.key`, but that lookup can be overridden with `--key`:
|
5
8
|
|
6
|
-
|
9
|
+
<%= executable(:edit) %> config/encrypted_file.yml.enc --key config/encrypted_file.key
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
Don't commit the key! Add it to your source control's ignore file. If you use
|
12
|
+
Git, Rails handles this for you.
|
10
13
|
|
11
|
-
|
14
|
+
Examples:
|
15
|
+
To edit or create an encrypted file use:
|
12
16
|
|
13
|
-
|
14
|
-
Git, Rails handles this for you.
|
17
|
+
<%= executable(:edit) %> config/encrypted_file.yml.enc
|
15
18
|
|
16
|
-
|
19
|
+
This opens a temporary file in `$VISUAL` or `$EDITOR` with the decrypted contents for editing.
|
17
20
|
|
18
|
-
To
|
21
|
+
To print the decrypted contents of an encrypted file use:
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
This opens a temporary file in `$EDITOR` with the decrypted contents for editing.
|
23
|
-
|
24
|
-
=== Viewing Files
|
25
|
-
|
26
|
-
To print the decrypted contents of an encrypted file use:
|
27
|
-
|
28
|
-
rails encrypted:show config/encrypted_file.yml.enc
|
23
|
+
<%= executable(:show) %> config/encrypted_file.yml.enc
|
@@ -12,54 +12,65 @@ module Rails
|
|
12
12
|
class_option :key, aliases: "-k", type: :string,
|
13
13
|
default: "config/master.key", desc: "The Rails.root relative path to the encryption key"
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
say ""
|
19
|
-
say self.class.desc
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def edit(file_path)
|
24
|
-
require_application_and_environment!
|
25
|
-
encrypted = Rails.application.encrypted(file_path, key_path: options[:key])
|
15
|
+
desc "edit", "Open the decrypted file in `$VISUAL` or `$EDITOR` for editing"
|
16
|
+
def edit(*)
|
17
|
+
load_environment_config!
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
ensure_encrypted_file_has_been_added(file_path, options[:key])
|
19
|
+
ensure_encryption_key_has_been_added
|
20
|
+
ensure_encrypted_configuration_has_been_added
|
30
21
|
|
31
|
-
|
32
|
-
change_encrypted_file_in_system_editor(file_path, options[:key])
|
33
|
-
end
|
34
|
-
|
35
|
-
say "File encrypted and saved."
|
36
|
-
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
37
|
-
say "Couldn't decrypt #{file_path}. Perhaps you passed the wrong key?"
|
22
|
+
change_encrypted_configuration_in_system_editor
|
38
23
|
end
|
39
24
|
|
40
|
-
|
41
|
-
|
42
|
-
|
25
|
+
desc "show", "Show the decrypted contents of the file"
|
26
|
+
def show(*)
|
27
|
+
load_environment_config!
|
43
28
|
|
44
|
-
say
|
29
|
+
say encrypted_configuration.read.presence || missing_encrypted_configuration_message
|
45
30
|
end
|
46
31
|
|
47
32
|
private
|
48
|
-
def
|
33
|
+
def content_path
|
34
|
+
@content_path ||= args[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
def key_path
|
38
|
+
options[:key]
|
39
|
+
end
|
40
|
+
|
41
|
+
def encrypted_configuration
|
42
|
+
@encrypted_configuration ||= Rails.application.encrypted(content_path, key_path: key_path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def ensure_encryption_key_has_been_added
|
46
|
+
return if encrypted_configuration.key?
|
49
47
|
encryption_key_file_generator.add_key_file(key_path)
|
50
48
|
encryption_key_file_generator.ignore_key_file(key_path)
|
51
49
|
end
|
52
50
|
|
53
|
-
def
|
54
|
-
encrypted_file_generator.add_encrypted_file_silently(
|
51
|
+
def ensure_encrypted_configuration_has_been_added
|
52
|
+
encrypted_file_generator.add_encrypted_file_silently(content_path, key_path)
|
55
53
|
end
|
56
54
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
55
|
+
def change_encrypted_configuration_in_system_editor
|
56
|
+
using_system_editor do
|
57
|
+
encrypted_configuration.change { |tmp_path| system_editor(tmp_path) }
|
58
|
+
say "File encrypted and saved."
|
59
|
+
warn_if_encrypted_configuration_is_invalid
|
60
60
|
end
|
61
|
+
rescue ActiveSupport::EncryptedFile::MissingKeyError => error
|
62
|
+
say error.message
|
63
|
+
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
64
|
+
say "Couldn't decrypt #{content_path}. Perhaps you passed the wrong key?"
|
61
65
|
end
|
62
66
|
|
67
|
+
def warn_if_encrypted_configuration_is_invalid
|
68
|
+
encrypted_configuration.validate!
|
69
|
+
rescue ActiveSupport::EncryptedConfiguration::InvalidContentError => error
|
70
|
+
say "WARNING: #{error.message}", :red
|
71
|
+
say ""
|
72
|
+
say "Your application will not be able to load '#{content_path}' until the error has been fixed.", :red
|
73
|
+
end
|
63
74
|
|
64
75
|
def encryption_key_file_generator
|
65
76
|
require "rails/generators"
|
@@ -75,11 +86,11 @@ module Rails
|
|
75
86
|
Rails::Generators::EncryptedFileGenerator.new
|
76
87
|
end
|
77
88
|
|
78
|
-
def
|
79
|
-
if key
|
80
|
-
"Missing '#{key_path}' to decrypt data. See
|
89
|
+
def missing_encrypted_configuration_message
|
90
|
+
if !encrypted_configuration.key?
|
91
|
+
"Missing '#{key_path}' to decrypt data. See `#{executable(:help)}`"
|
81
92
|
else
|
82
|
-
"File '#{
|
93
|
+
"File '#{content_path}' does not exist. Use `#{executable(:edit)} #{content_path}` to change that."
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Usage:
|
2
|
+
rails COMMAND [options]
|
3
|
+
|
4
|
+
You must specify a command:
|
5
|
+
|
6
|
+
new Create a new Rails application. "rails new my_app" creates a
|
7
|
+
new application called MyApp in "./my_app"
|
8
|
+
plugin new Create a new Rails railtie or engine
|
9
|
+
|
10
|
+
All commands can be run with -h (or --help) for more information.
|
11
|
+
|
12
|
+
Inside a Rails application directory, some common commands are:
|
13
|
+
|
14
|
+
console Start the Rails console
|
15
|
+
server Start the Rails server
|
16
|
+
test Run tests except system tests
|
@@ -7,7 +7,7 @@ module Rails
|
|
7
7
|
class GenerateCommand < Base # :nodoc:
|
8
8
|
no_commands do
|
9
9
|
def help
|
10
|
-
|
10
|
+
boot_application!
|
11
11
|
load_generators
|
12
12
|
|
13
13
|
Rails::Generators.help self.class.command_name
|
@@ -18,10 +18,10 @@ module Rails
|
|
18
18
|
generator = args.shift
|
19
19
|
return help unless generator
|
20
20
|
|
21
|
-
|
21
|
+
boot_application!
|
22
22
|
load_generators
|
23
23
|
|
24
|
-
ARGV.
|
24
|
+
ARGV.replace(args) # set up ARGV for third-party libraries
|
25
25
|
|
26
26
|
Rails::Generators.invoke generator, args, behavior: :invoke, destination_root: Rails::Command.root
|
27
27
|
end
|
@@ -1,16 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
console Start the Rails console (short-cut alias: "c")
|
4
|
-
server Start the Rails server (short-cut alias: "s")
|
5
|
-
test Run tests except system tests (short-cut alias: "t")
|
6
|
-
test:system Run system tests
|
7
|
-
dbconsole Start a console for the database specified in config/database.yml
|
8
|
-
(short-cut alias: "db")
|
9
|
-
<% unless engine? %>
|
10
|
-
new Create a new Rails application. "rails new my_app" creates a
|
11
|
-
new application called MyApp in "./my_app"
|
12
|
-
<% end %>
|
1
|
+
Usage:
|
2
|
+
bin/rails COMMAND [options]
|
13
3
|
|
14
|
-
|
15
|
-
|
4
|
+
You must specify a command. The most common commands are:
|
5
|
+
|
6
|
+
generate Generate new code (short-cut alias: "g")
|
7
|
+
console Start the Rails console (short-cut alias: "c")
|
8
|
+
server Start the Rails server (short-cut alias: "s")
|
9
|
+
test Run tests except system tests (short-cut alias: "t")
|
10
|
+
test:system Run system tests
|
11
|
+
dbconsole Start a console for the database specified in config/database.yml
|
12
|
+
(short-cut alias: "db")
|
13
|
+
<% unless engine? -%>
|
14
|
+
plugin new Create a new Rails railtie or engine
|
15
|
+
<% end -%>
|
16
16
|
|
17
|
+
All commands can be run with -h (or --help) for more information.
|
@@ -6,10 +6,29 @@ module Rails
|
|
6
6
|
hide_command!
|
7
7
|
|
8
8
|
def help(*)
|
9
|
-
say self.class.
|
9
|
+
say self.class.class_usage
|
10
|
+
end
|
11
|
+
|
12
|
+
def help_extended(*)
|
13
|
+
help
|
14
|
+
|
15
|
+
say ""
|
16
|
+
say "In addition to those commands, there are:"
|
17
|
+
say ""
|
10
18
|
|
11
|
-
|
19
|
+
extended_commands = printing_commands_not_in_usage.sort_by(&:first)
|
20
|
+
print_table(extended_commands, truncate: true)
|
12
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
COMMANDS_IN_USAGE = %w(generate console server test test:system dbconsole new)
|
25
|
+
private_constant :COMMANDS_IN_USAGE
|
26
|
+
|
27
|
+
def printing_commands_not_in_usage # :nodoc:
|
28
|
+
Rails::Command.printing_commands.reject do |command, _|
|
29
|
+
command.in?(COMMANDS_IN_USAGE)
|
30
|
+
end
|
31
|
+
end
|
13
32
|
end
|
14
33
|
end
|
15
34
|
end
|
@@ -9,10 +9,7 @@ module Rails
|
|
9
9
|
|
10
10
|
desc "initializers", "Print out all defined initializers in the order they are invoked by Rails."
|
11
11
|
def perform
|
12
|
-
|
13
|
-
ENV["RAILS_ENV"] = options[:environment]
|
14
|
-
|
15
|
-
require_application_and_environment!
|
12
|
+
boot_application!
|
16
13
|
|
17
14
|
Rails.application.initializers.tsort_each do |initializer|
|
18
15
|
say "#{initializer.context_class}.#{initializer.name}"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Command
|
5
|
+
class MiddlewareCommand < Base # :nodoc:
|
6
|
+
desc "middleware", "Print out your Rack middleware stack"
|
7
|
+
def perform
|
8
|
+
boot_application!
|
9
|
+
|
10
|
+
Rails.configuration.middleware.each do |middleware|
|
11
|
+
say "use #{middleware.inspect}"
|
12
|
+
end
|
13
|
+
say "run #{Rails.application.class.name}.routes"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -5,34 +5,25 @@ require "rails/source_annotation_extractor"
|
|
5
5
|
module Rails
|
6
6
|
module Command
|
7
7
|
class NotesCommand < Base # :nodoc:
|
8
|
-
class_option :annotations, aliases: "-a", desc: "Filter by specific annotations, e.g. Foobar TODO", type: :array
|
8
|
+
class_option :annotations, aliases: "-a", desc: "Filter by specific annotations, e.g. Foobar TODO", type: :array
|
9
9
|
|
10
|
+
desc "notes", "Show comments in your code annotated with FIXME, OPTIMIZE, and TODO"
|
10
11
|
def perform(*)
|
11
|
-
|
12
|
+
boot_application!
|
12
13
|
|
13
|
-
deprecation_warning
|
14
14
|
display_annotations
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
def display_annotations
|
19
|
-
annotations = options[:annotations]
|
19
|
+
annotations = options[:annotations] || Rails::SourceAnnotationExtractor::Annotation.tags
|
20
20
|
tag = (annotations.length > 1)
|
21
21
|
|
22
22
|
Rails::SourceAnnotationExtractor.enumerate annotations.join("|"), tag: tag, dirs: directories
|
23
23
|
end
|
24
24
|
|
25
25
|
def directories
|
26
|
-
Rails::SourceAnnotationExtractor::Annotation.directories
|
27
|
-
end
|
28
|
-
|
29
|
-
def deprecation_warning
|
30
|
-
return if source_annotation_directories.empty?
|
31
|
-
ActiveSupport::Deprecation.warn("`SOURCE_ANNOTATION_DIRECTORIES` is deprecated and will be removed in Rails 6.1. You can add default directories by using config.annotations.register_directories instead.")
|
32
|
-
end
|
33
|
-
|
34
|
-
def source_annotation_directories
|
35
|
-
ENV["SOURCE_ANNOTATION_DIRECTORIES"].to_s.split(",")
|
26
|
+
Rails::SourceAnnotationExtractor::Annotation.directories
|
36
27
|
end
|
37
28
|
end
|
38
29
|
end
|