railties 5.2.4.5 → 6.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of railties might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +185 -171
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +35 -28
- data/README.rdoc +1 -1
- data/lib/minitest/rails_plugin.rb +6 -10
- data/lib/rails/all.rb +4 -0
- data/lib/rails/api/generator.rb +2 -1
- data/lib/rails/api/task.rb +16 -0
- data/lib/rails/app_loader.rb +1 -1
- data/lib/rails/app_updater.rb +3 -1
- data/lib/rails/application.rb +21 -45
- data/lib/rails/application/configuration.rb +54 -12
- data/lib/rails/application/default_middleware_stack.rb +2 -0
- data/lib/rails/backtrace_cleaner.rb +5 -17
- data/lib/rails/code_statistics.rb +3 -3
- data/lib/rails/command.rb +11 -10
- data/lib/rails/command/actions.rb +0 -10
- data/lib/rails/command/base.rb +1 -5
- data/lib/rails/command/behavior.rb +4 -46
- data/lib/rails/command/environment_argument.rb +1 -11
- data/lib/rails/command/spellchecker.rb +58 -0
- data/lib/rails/commands/credentials/USAGE +19 -1
- data/lib/rails/commands/credentials/credentials_command.rb +42 -23
- data/lib/rails/commands/db/system/change/change_command.rb +20 -0
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +2 -2
- data/lib/rails/commands/dev/dev_command.rb +17 -0
- data/lib/rails/commands/encrypted/encrypted_command.rb +2 -3
- data/lib/rails/commands/help/help_command.rb +1 -1
- data/lib/rails/commands/initializers/initializers_command.rb +16 -0
- data/lib/rails/commands/new/new_command.rb +2 -2
- data/lib/rails/commands/notes/notes_command.rb +39 -0
- data/lib/rails/commands/plugin/plugin_command.rb +1 -1
- data/lib/rails/commands/routes/routes_command.rb +37 -0
- data/lib/rails/commands/runner/runner_command.rb +6 -6
- data/lib/rails/commands/secrets/USAGE +3 -3
- data/lib/rails/commands/secrets/secrets_command.rb +3 -3
- data/lib/rails/commands/server/server_command.rb +109 -48
- data/lib/rails/configuration.rb +1 -7
- data/lib/rails/engine.rb +3 -9
- data/lib/rails/engine/configuration.rb +3 -1
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators.rb +11 -12
- data/lib/rails/generators/actions.rb +48 -37
- data/lib/rails/generators/app_base.rb +49 -89
- data/lib/rails/generators/app_name.rb +50 -0
- data/lib/rails/generators/base.rb +0 -4
- data/lib/rails/generators/database.rb +57 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb.tt +1 -1
- data/lib/rails/generators/erb/scaffold/templates/show.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +17 -17
- data/lib/rails/generators/model_helpers.rb +8 -1
- data/lib/rails/generators/named_base.rb +1 -5
- data/lib/rails/generators/rails/app/app_generator.rb +37 -72
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +3 -6
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -3
- data/lib/rails/generators/rails/app/templates/app/{assets/javascripts/cable.js.tt → javascript/channels/consumer.js} +2 -9
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/index.js +5 -0
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +15 -0
- data/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb.tt +5 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +4 -5
- data/lib/rails/generators/rails/app/templates/bin/update.tt +6 -7
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/cable.yml.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +6 -6
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +3 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +5 -12
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt +33 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +3 -5
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/spring.rb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/gitignore.tt +2 -7
- data/lib/rails/generators/rails/app/templates/package.json.tt +7 -1
- data/lib/rails/generators/rails/app/templates/ruby-version.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +7 -0
- data/lib/rails/generators/rails/assets/USAGE +1 -4
- data/lib/rails/generators/rails/assets/assets_generator.rb +0 -8
- data/lib/rails/generators/rails/controller/controller_generator.rb +11 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +7 -8
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +55 -0
- data/lib/rails/generators/rails/encrypted_file/encrypted_file_generator.rb +4 -5
- data/lib/rails/generators/rails/helper/helper_generator.rb +5 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +9 -18
- data/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +1 -2
- data/lib/rails/generators/resource_helpers.rb +1 -6
- data/lib/rails/generators/test_unit/integration/integration_generator.rb +6 -0
- data/lib/rails/generators/test_unit/job/job_generator.rb +5 -0
- data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +1 -1
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +1 -1
- data/lib/rails/generators/test_unit/system/system_generator.rb +5 -0
- data/lib/rails/generators/testing/behaviour.rb +3 -0
- data/lib/rails/info.rb +2 -2
- data/lib/rails/info_controller.rb +1 -1
- data/lib/rails/mailers_controller.rb +1 -1
- data/lib/rails/paths.rb +19 -9
- data/lib/rails/railtie.rb +1 -1
- data/lib/rails/ruby_version_check.rb +3 -3
- data/lib/rails/secrets.rb +0 -1
- data/lib/rails/source_annotation_extractor.rb +125 -117
- data/lib/rails/tasks/annotations.rake +9 -9
- data/lib/rails/tasks/dev.rake +5 -4
- data/lib/rails/tasks/framework.rake +5 -1
- data/lib/rails/tasks/initializers.rake +5 -4
- data/lib/rails/tasks/log.rake +0 -1
- data/lib/rails/tasks/routes.rake +4 -26
- data/lib/rails/tasks/statistics.rake +1 -0
- data/lib/rails/tasks/yarn.rake +1 -1
- data/lib/rails/templates/rails/welcome/index.html.erb +2 -2
- data/lib/rails/test_help.rb +11 -9
- data/lib/rails/test_unit/reporter.rb +1 -1
- data/lib/rails/test_unit/runner.rb +5 -5
- data/lib/rails/test_unit/testing.rake +1 -1
- metadata +30 -24
- data/lib/rails/commands/encrypted/USAGE +0 -28
- data/lib/rails/generators/js/assets/assets_generator.rb +0 -15
- data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -22
- data/lib/rails/generators/rails/app/templates/bin/bundle.tt +0 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +0 -38
- data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
@@ -21,6 +21,7 @@ Rails.application.configure do
|
|
21
21
|
# Show full error reports and disable caching.
|
22
22
|
config.consider_all_requests_local = true
|
23
23
|
config.action_controller.perform_caching = false
|
24
|
+
config.cache_store = :null_store
|
24
25
|
|
25
26
|
# Raise exceptions instead of rendering exception templates.
|
26
27
|
config.action_dispatch.show_exceptions = false
|
@@ -29,7 +30,7 @@ Rails.application.configure do
|
|
29
30
|
config.action_controller.allow_forgery_protection = false
|
30
31
|
|
31
32
|
<%- unless skip_active_storage? -%>
|
32
|
-
# Store uploaded files on the local file system in a temporary directory
|
33
|
+
# Store uploaded files on the local file system in a temporary directory.
|
33
34
|
config.active_storage.service = :test
|
34
35
|
|
35
36
|
<%- end -%>
|
@@ -45,6 +46,9 @@ Rails.application.configure do
|
|
45
46
|
# Print deprecation notices to the stderr.
|
46
47
|
config.active_support.deprecation = :stderr
|
47
48
|
|
48
|
-
# Raises error for missing translations
|
49
|
+
# Raises error for missing translations.
|
49
50
|
# config.action_view.raise_on_missing_translations = true
|
51
|
+
|
52
|
+
# Prevent expensive template finalization at end of test suite runs.
|
53
|
+
config.action_view.finalize_compiled_template_methods = false
|
50
54
|
end
|
@@ -5,7 +5,7 @@ Rails.application.config.assets.version = '1.0'
|
|
5
5
|
|
6
6
|
# Add additional assets to the asset load path.
|
7
7
|
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
-
<%- unless options[:
|
8
|
+
<%- unless options[:skip_javascript] -%>
|
9
9
|
# Add Yarn node_modules folder to the asset load path.
|
10
10
|
Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
11
11
|
<%- end -%>
|
data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
# policy.object_src :none
|
12
12
|
# policy.script_src :self, :https
|
13
13
|
# policy.style_src :self, :https
|
14
|
+
<%- unless options[:skip_javascript] -%>
|
15
|
+
# # If you are using webpack-dev-server then specify webpack-dev-server host
|
16
|
+
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
|
17
|
+
<%- end -%>
|
14
18
|
|
15
19
|
# # Specify URI for violation reports
|
16
20
|
# # policy.report_uri "/csp-violation-report-endpoint"
|
data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_0.rb.tt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains migration options to ease your Rails 6.0 upgrade.
|
4
|
+
#
|
5
|
+
# Once upgraded flip defaults one by one to migrate to the new default.
|
6
|
+
#
|
7
|
+
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
8
|
+
|
9
|
+
# Don't force requests from old versions of IE to be UTF-8 encoded.
|
10
|
+
# Rails.application.config.action_view.default_enforce_utf8 = false
|
11
|
+
|
12
|
+
# Embed purpose and expiry metadata inside signed and encrypted
|
13
|
+
# cookies for increased security.
|
14
|
+
#
|
15
|
+
# This option is not backwards compatible with earlier Rails versions.
|
16
|
+
# It's best enabled when your entire app is migrated and stable on 6.0.
|
17
|
+
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
|
18
|
+
|
19
|
+
# Return false instead of self when enqueuing is aborted from a callback.
|
20
|
+
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
|
21
|
+
|
22
|
+
# Send Active Storage analysis and purge jobs to dedicated queues.
|
23
|
+
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
|
24
|
+
# Rails.application.config.active_storage.queues.purge = :active_storage_purge
|
25
|
+
|
26
|
+
# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
|
27
|
+
#
|
28
|
+
# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
|
29
|
+
# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
|
30
|
+
# If you send mail in the background, job workers need to have a copy of
|
31
|
+
# MailDeliveryJob to ensure all delivery jobs are processed properly.
|
32
|
+
# Make sure your entire app is migrated and stable on 6.0 before using this setting.
|
33
|
+
# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
|
@@ -4,8 +4,9 @@
|
|
4
4
|
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
5
|
# and maximum; this matches the default thread size of Active Record.
|
6
6
|
#
|
7
|
-
|
8
|
-
|
7
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
8
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
9
|
+
threads min_threads_count, max_threads_count
|
9
10
|
|
10
11
|
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
11
12
|
#
|
@@ -15,9 +16,6 @@ port ENV.fetch("PORT") { 3000 }
|
|
15
16
|
#
|
16
17
|
environment ENV.fetch("RAILS_ENV") { "development" }
|
17
18
|
|
18
|
-
# Specifies the `pidfile` that Puma will use.
|
19
|
-
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
20
|
-
|
21
19
|
# Specifies the number of `workers` to boot in clustered mode.
|
22
20
|
# Workers are forked webserver processes. If using threads and workers together
|
23
21
|
# the concurrency of the application would be max `threads` * `workers`.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
.ruby-version
|
3
|
-
.rbenv-vars
|
4
|
-
tmp/restart.txt
|
5
|
-
tmp/caching-dev.txt
|
6
|
-
|
1
|
+
Spring.watch(
|
2
|
+
".ruby-version",
|
3
|
+
".rbenv-vars",
|
4
|
+
"tmp/restart.txt",
|
5
|
+
"tmp/caching-dev.txt"
|
6
|
+
)
|
@@ -22,19 +22,14 @@
|
|
22
22
|
<% end -%>
|
23
23
|
|
24
24
|
<% unless skip_active_storage? -%>
|
25
|
-
# Ignore uploaded files in development
|
25
|
+
# Ignore uploaded files in development.
|
26
26
|
/storage/*
|
27
27
|
<% if keeps? -%>
|
28
28
|
!/storage/.keep
|
29
29
|
<% end -%>
|
30
|
-
<% end -%>
|
31
|
-
|
32
|
-
<% unless options.skip_yarn? -%>
|
33
|
-
/node_modules
|
34
|
-
/yarn-error.log
|
35
|
-
|
36
30
|
<% end -%>
|
37
31
|
<% unless options.api? -%>
|
32
|
+
|
38
33
|
/public/assets
|
39
34
|
<% end -%>
|
40
35
|
.byebug_history
|
@@ -1,5 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "<%= app_name %>",
|
3
3
|
"private": true,
|
4
|
-
"dependencies": {
|
4
|
+
"dependencies": {
|
5
|
+
"@rails/ujs": "^6.0.0-alpha"<% unless options[:skip_turbolinks] %>,
|
6
|
+
"turbolinks": "^5.2.0"<% end -%><% unless skip_active_storage? %>,
|
7
|
+
"@rails/activestorage": "^6.0.0-alpha"<% end -%><% unless options[:skip_action_cable] %>,
|
8
|
+
"@rails/actioncable": "^6.0.0-alpha"<% end %>
|
9
|
+
},
|
10
|
+
"version": "0.1.0"
|
5
11
|
}
|
@@ -1 +1 @@
|
|
1
|
-
<%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{
|
1
|
+
<%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>
|
@@ -3,6 +3,13 @@ require_relative '../config/environment'
|
|
3
3
|
require 'rails/test_help'
|
4
4
|
|
5
5
|
class ActiveSupport::TestCase
|
6
|
+
# Run tests in parallel with specified workers
|
7
|
+
<% if defined?(JRUBY_VERSION) || Gem.win_platform? -%>
|
8
|
+
parallelize(workers: :number_of_processors, with: :threads)
|
9
|
+
<%- else -%>
|
10
|
+
parallelize(workers: :number_of_processors)
|
11
|
+
<% end -%>
|
12
|
+
|
6
13
|
<% unless options[:skip_active_record] -%>
|
7
14
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
8
15
|
fixtures :all
|
@@ -5,16 +5,13 @@ Description:
|
|
5
5
|
To create an asset within a folder, specify the asset's name as a
|
6
6
|
path like 'parent/name'.
|
7
7
|
|
8
|
-
This generates a
|
9
|
-
stub in app/assets/stylesheets.
|
8
|
+
This generates a stylesheet stub in app/assets/stylesheets.
|
10
9
|
|
11
|
-
If CoffeeScript is available, JavaScripts will be generated with the .coffee extension.
|
12
10
|
If Sass 3 is available, stylesheets will be generated with the .scss extension.
|
13
11
|
|
14
12
|
Example:
|
15
13
|
`rails generate assets posts`
|
16
14
|
|
17
15
|
Posts assets.
|
18
|
-
JavaScript: app/assets/javascripts/posts.js
|
19
16
|
Stylesheet: app/assets/stylesheets/posts.css
|
20
17
|
|
@@ -3,22 +3,14 @@
|
|
3
3
|
module Rails
|
4
4
|
module Generators
|
5
5
|
class AssetsGenerator < NamedBase # :nodoc:
|
6
|
-
class_option :javascripts, type: :boolean, desc: "Generate JavaScripts"
|
7
6
|
class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
|
8
|
-
|
9
|
-
class_option :javascript_engine, desc: "Engine for JavaScripts"
|
10
7
|
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
|
11
8
|
|
12
9
|
private
|
13
|
-
|
14
10
|
def asset_name
|
15
11
|
file_name
|
16
12
|
end
|
17
13
|
|
18
|
-
hook_for :javascript_engine do |javascript_engine|
|
19
|
-
invoke javascript_engine, [name] if options[:javascripts]
|
20
|
-
end
|
21
|
-
|
22
14
|
hook_for :stylesheet_engine do |stylesheet_engine|
|
23
15
|
invoke stylesheet_engine, [name] if options[:stylesheets]
|
24
16
|
end
|
@@ -20,10 +20,20 @@ module Rails
|
|
20
20
|
route generate_routing_code
|
21
21
|
end
|
22
22
|
|
23
|
-
hook_for :template_engine, :test_framework, :helper, :assets
|
23
|
+
hook_for :template_engine, :test_framework, :helper, :assets do |generator|
|
24
|
+
invoke generator, [ remove_possible_suffix(name), actions ]
|
25
|
+
end
|
24
26
|
|
25
27
|
private
|
26
28
|
|
29
|
+
def file_name
|
30
|
+
@_file_name ||= remove_possible_suffix(super)
|
31
|
+
end
|
32
|
+
|
33
|
+
def remove_possible_suffix(name)
|
34
|
+
name.sub(/_?controller$/i, "")
|
35
|
+
end
|
36
|
+
|
27
37
|
# This method creates nested route entry for namespaced resources.
|
28
38
|
# For eg. rails g controller foo/bar/baz index show
|
29
39
|
# Will generate -
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require "rails/generators/base"
|
4
4
|
require "rails/generators/rails/master_key/master_key_generator"
|
5
|
-
require "active_support/core_ext/string/strip"
|
6
5
|
require "active_support/encrypted_configuration"
|
7
6
|
|
8
7
|
module Rails
|
@@ -21,7 +20,7 @@ module Rails
|
|
21
20
|
|
22
21
|
add_credentials_file_silently(template)
|
23
22
|
|
24
|
-
say "You can edit encrypted credentials with `
|
23
|
+
say "You can edit encrypted credentials with `rails credentials:edit`."
|
25
24
|
say ""
|
26
25
|
end
|
27
26
|
end
|
@@ -43,13 +42,13 @@ module Rails
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def credentials_template
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
<<~YAML
|
46
|
+
# aws:
|
47
|
+
# access_key_id: 123
|
48
|
+
# secret_access_key: 345
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
# Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
|
51
|
+
secret_key_base: #{SecureRandom.hex(64)}
|
53
52
|
YAML
|
54
53
|
end
|
55
54
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/base"
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Generators
|
7
|
+
module Db
|
8
|
+
module System
|
9
|
+
class ChangeGenerator < Base # :nodoc:
|
10
|
+
include Database
|
11
|
+
include AppName
|
12
|
+
|
13
|
+
class_option :to, required: true,
|
14
|
+
desc: "The database system to switch to."
|
15
|
+
|
16
|
+
def self.default_generator_root
|
17
|
+
path = File.expand_path(File.join(base_name, "app"), base_root)
|
18
|
+
path if File.exist?(path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(*)
|
22
|
+
super
|
23
|
+
|
24
|
+
unless DATABASES.include?(options[:to])
|
25
|
+
raise Error, "Invalid value for --to option. Supported preconfigurations are: #{DATABASES.join(", ")}."
|
26
|
+
end
|
27
|
+
|
28
|
+
opt = options.dup
|
29
|
+
opt[:database] ||= opt[:to]
|
30
|
+
self.options = opt.freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit_database_config
|
34
|
+
template("config/databases/#{options[:database]}.yml", "config/database.yml")
|
35
|
+
end
|
36
|
+
|
37
|
+
def edit_gemfile
|
38
|
+
database_gem_name, _ = gem_for_database
|
39
|
+
gsub_file("Gemfile", all_database_gems_regex, database_gem_name)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def all_database_gems
|
44
|
+
DATABASES.map { |database| gem_for_database(database) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def all_database_gems_regex
|
48
|
+
all_database_gem_names = all_database_gems.map(&:first)
|
49
|
+
/(\b#{all_database_gem_names.join('\b|\b')}\b)/
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails/generators/base"
|
4
|
-
require "active_support/core_ext/string/strip"
|
5
4
|
require "active_support/encrypted_file"
|
6
5
|
|
7
6
|
module Rails
|
@@ -16,10 +15,10 @@ module Rails
|
|
16
15
|
|
17
16
|
private
|
18
17
|
def encrypted_file_template
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
<<~YAML
|
19
|
+
# aws:
|
20
|
+
# access_key_id: 123
|
21
|
+
# secret_access_key: 345
|
23
22
|
|
24
23
|
YAML
|
25
24
|
end
|
@@ -88,7 +88,7 @@ task default: :test
|
|
88
88
|
|
89
89
|
PASSTHROUGH_OPTIONS = [
|
90
90
|
:skip_active_record, :skip_active_storage, :skip_action_mailer, :skip_javascript, :skip_action_cable, :skip_sprockets, :database,
|
91
|
-
:
|
91
|
+
:api, :quiet, :pretend, :skip
|
92
92
|
]
|
93
93
|
|
94
94
|
def generate_test_dummy(force = false)
|
@@ -98,6 +98,7 @@ task default: :test
|
|
98
98
|
opts[:skip_listen] = true
|
99
99
|
opts[:skip_git] = true
|
100
100
|
opts[:skip_turbolinks] = true
|
101
|
+
opts[:skip_webpack_install] = true
|
101
102
|
opts[:dummy_app] = true
|
102
103
|
|
103
104
|
invoke Rails::Generators::AppGenerator,
|
@@ -113,7 +114,7 @@ task default: :test
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def test_dummy_assets
|
116
|
-
template "rails/javascripts.js", "#{dummy_path}/app/
|
117
|
+
template "rails/javascripts.js", "#{dummy_path}/app/javascript/packs/application.js", force: true
|
117
118
|
template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
|
118
119
|
template "rails/dummy_manifest.js", "#{dummy_path}/app/assets/config/manifest.js", force: true
|
119
120
|
end
|
@@ -262,16 +263,6 @@ task default: :test
|
|
262
263
|
|
263
264
|
public_task :apply_rails_template
|
264
265
|
|
265
|
-
def run_after_bundle_callbacks
|
266
|
-
unless @after_bundle_callbacks.empty?
|
267
|
-
ActiveSupport::Deprecation.warn("`after_bundle` is deprecated and will be removed in the next version of Rails. ")
|
268
|
-
end
|
269
|
-
|
270
|
-
@after_bundle_callbacks.each do |callback|
|
271
|
-
callback.call
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
266
|
def name
|
276
267
|
@name ||= begin
|
277
268
|
# same as ActiveSupport::Inflector#underscore except not replacing '-'
|
@@ -348,9 +339,9 @@ task default: :test
|
|
348
339
|
def wrap_in_modules(unwrapped_code)
|
349
340
|
unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, "")
|
350
341
|
modules.reverse.inject(unwrapped_code) do |content, mod|
|
351
|
-
str = "module #{mod}\n"
|
352
|
-
str
|
353
|
-
str
|
342
|
+
str = +"module #{mod}\n"
|
343
|
+
str << content.lines.map { |line| " #{line}" }.join
|
344
|
+
str << (content.present? ? "\nend" : "end")
|
354
345
|
end
|
355
346
|
end
|
356
347
|
|
@@ -385,11 +376,11 @@ task default: :test
|
|
385
376
|
end
|
386
377
|
|
387
378
|
def valid_const?
|
388
|
-
if
|
379
|
+
if /-\d/.match?(original_name)
|
389
380
|
raise Error, "Invalid plugin name #{original_name}. Please give a name which does not contain a namespace starting with numeric characters."
|
390
|
-
elsif
|
381
|
+
elsif /[^\w-]+/.match?(original_name)
|
391
382
|
raise Error, "Invalid plugin name #{original_name}. Please give a name which uses only alphabetic, numeric, \"_\" or \"-\" characters."
|
392
|
-
elsif
|
383
|
+
elsif /^\d/.match?(camelized)
|
393
384
|
raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers."
|
394
385
|
elsif RESERVED_NAMES.include?(name)
|
395
386
|
raise Error, "Invalid plugin name #{original_name}. Please give a " \
|