railties 6.0.3.4 → 6.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +228 -382
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.rdoc +1 -1
- data/lib/minitest/rails_plugin.rb +16 -1
- data/lib/rails.rb +5 -8
- data/lib/rails/application.rb +49 -83
- data/lib/rails/application/bootstrap.rb +5 -5
- data/lib/rails/application/configuration.rb +52 -21
- data/lib/rails/application/default_middleware_stack.rb +5 -3
- data/lib/rails/application/finisher.rb +15 -2
- data/lib/rails/application/routes_reloader.rb +9 -2
- data/lib/rails/backtrace_cleaner.rb +12 -7
- data/lib/rails/code_statistics.rb +3 -3
- data/lib/rails/code_statistics_calculator.rb +6 -6
- data/lib/rails/command.rb +7 -1
- data/lib/rails/command/base.rb +1 -1
- data/lib/rails/command/behavior.rb +1 -1
- data/lib/rails/command/environment_argument.rb +1 -1
- data/lib/rails/commands/credentials/USAGE +17 -2
- data/lib/rails/commands/credentials/credentials_command.rb +28 -4
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +41 -0
- data/lib/rails/commands/db/system/change/change_command.rb +6 -1
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +59 -57
- data/lib/rails/commands/encrypted/encrypted_command.rb +4 -4
- data/lib/rails/commands/generate/generate_command.rb +1 -1
- data/lib/rails/commands/notes/notes_command.rb +1 -11
- data/lib/rails/commands/rake/rake_command.rb +9 -8
- data/lib/rails/commands/secrets/USAGE +9 -3
- data/lib/rails/commands/server/server_command.rb +14 -41
- data/lib/rails/commands/test/test_command.rb +2 -2
- data/lib/rails/configuration.rb +40 -10
- data/lib/rails/engine.rb +26 -15
- data/lib/rails/engine/configuration.rb +1 -0
- data/lib/rails/engine/updater.rb +1 -1
- data/lib/rails/gem_version.rb +3 -3
- data/lib/rails/generators.rb +29 -15
- data/lib/rails/generators/actions.rb +48 -27
- data/lib/rails/generators/actions/create_migration.rb +5 -0
- data/lib/rails/generators/app_base.rb +31 -16
- data/lib/rails/generators/base.rb +14 -11
- data/lib/rails/generators/database.rb +3 -4
- data/lib/rails/generators/erb/scaffold/templates/_form.html.erb.tt +2 -2
- data/lib/rails/generators/generated_attribute.rb +3 -9
- data/lib/rails/generators/migration.rb +2 -1
- data/lib/rails/generators/model_helpers.rb +26 -2
- data/lib/rails/generators/named_base.rb +1 -1
- data/lib/rails/generators/rails/app/USAGE +2 -1
- data/lib/rails/generators/rails/app/app_generator.rb +89 -15
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +10 -10
- data/lib/rails/generators/rails/app/templates/Rakefile.tt +1 -1
- data/lib/rails/generators/rails/app/templates/app/javascript/channels/consumer.js +1 -1
- data/lib/rails/generators/rails/app/templates/app/javascript/packs/application.js.tt +11 -4
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +2 -1
- data/lib/rails/generators/rails/app/templates/bin/rails.tt +2 -2
- data/lib/rails/generators/rails/app/templates/bin/rake.tt +2 -2
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +4 -4
- data/lib/rails/generators/rails/app/templates/bin/spring.tt +7 -0
- data/lib/rails/generators/rails/app/templates/bin/yarn.tt +5 -7
- data/lib/rails/generators/rails/app/templates/config.ru.tt +2 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +7 -3
- data/lib/rails/generators/rails/app/templates/config/boot.rb.tt +8 -2
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml.tt +3 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml.tt +10 -9
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml.tt +11 -10
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +10 -9
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt +11 -10
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +11 -10
- data/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml.tt +10 -9
- 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 +17 -3
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -4
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +12 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.tt +4 -3
- data/lib/rails/generators/rails/app/templates/config/initializers/feature_policy.rb.tt +11 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +3 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_6_1.rb.tt +45 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/gitattributes.tt +14 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +0 -1
- data/lib/rails/generators/rails/app/templates/package.json.tt +1 -1
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +5 -5
- data/lib/rails/generators/rails/assets/USAGE +2 -3
- data/lib/rails/generators/rails/benchmark/USAGE +19 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +29 -0
- data/lib/rails/generators/rails/benchmark/templates/benchmark.rb.tt +15 -0
- data/lib/rails/generators/rails/controller/USAGE +2 -2
- data/lib/rails/generators/rails/controller/controller_generator.rb +2 -40
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +1 -1
- data/lib/rails/generators/rails/generator/USAGE +2 -2
- 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 +4 -4
- data/lib/rails/generators/rails/model/USAGE +15 -16
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +24 -23
- data/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt +10 -19
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +3 -10
- 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/bin/rails.tt +3 -3
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +13 -11
- 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 +1 -1
- 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 +0 -3
- data/lib/rails/generators/rails/resource/USAGE +4 -4
- 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_controller/USAGE +2 -2
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +6 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +1 -1
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/rails/system_test/USAGE +2 -2
- data/lib/rails/generators/rails/task/USAGE +3 -3
- data/lib/rails/generators/test_case.rb +1 -1
- 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/templates/generator_test.rb.tt +2 -2
- 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 +1 -1
- 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/templates/api_functional_test.rb.tt +1 -1
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb.tt +1 -1
- data/lib/rails/generators/testing/assertions.rb +2 -2
- data/lib/rails/generators/testing/behaviour.rb +1 -1
- data/lib/rails/info.rb +1 -1
- data/lib/rails/info_controller.rb +1 -1
- data/lib/rails/mailers_controller.rb +1 -0
- data/lib/rails/paths.rb +14 -6
- data/lib/rails/rack/logger.rb +1 -1
- data/lib/rails/railtie.rb +29 -3
- data/lib/rails/railtie/configuration.rb +3 -2
- data/lib/rails/source_annotation_extractor.rb +1 -15
- data/lib/rails/tasks.rb +0 -4
- data/lib/rails/tasks/engine.rake +1 -4
- data/lib/rails/tasks/framework.rake +7 -1
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/statistics.rake +1 -1
- data/lib/rails/templates/rails/mailers/email.html.erb +1 -0
- data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
- data/lib/rails/test_unit/reporter.rb +2 -1
- data/lib/rails/test_unit/runner.rb +20 -3
- data/lib/rails/test_unit/testing.rake +6 -0
- metadata +28 -34
- 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/new_framework_defaults_6_0.rb.tt +0 -45
- data/lib/rails/generators/rails/plugin/templates/rails/application.rb.tt +0 -23
- 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/routes.rake +0 -9
@@ -4,7 +4,7 @@ module Rails
|
|
4
4
|
module Generators
|
5
5
|
module Database # :nodoc:
|
6
6
|
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
|
7
|
-
DATABASES = %w( mysql postgresql sqlite3 oracle
|
7
|
+
DATABASES = %w( mysql postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES
|
8
8
|
|
9
9
|
def initialize(*)
|
10
10
|
super
|
@@ -13,11 +13,10 @@ module Rails
|
|
13
13
|
|
14
14
|
def gem_for_database(database = options[:database])
|
15
15
|
case database
|
16
|
-
when "mysql" then ["mysql2", ["
|
17
|
-
when "postgresql" then ["pg", ["
|
16
|
+
when "mysql" then ["mysql2", ["~> 0.5"]]
|
17
|
+
when "postgresql" then ["pg", ["~> 1.1"]]
|
18
18
|
when "sqlite3" then ["sqlite3", ["~> 1.4"]]
|
19
19
|
when "oracle" then ["activerecord-oracle_enhanced-adapter", nil]
|
20
|
-
when "frontbase" then ["ruby-frontbase", nil]
|
21
20
|
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
|
22
21
|
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
|
23
22
|
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
|
@@ -4,8 +4,8 @@
|
|
4
4
|
<h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
5
|
|
6
6
|
<ul>
|
7
|
-
<%% <%= singular_table_name %>.errors.
|
8
|
-
<li><%%=
|
7
|
+
<%% <%= singular_table_name %>.errors.each do |error| %>
|
8
|
+
<li><%%= error.full_message %></li>
|
9
9
|
<%% end %>
|
10
10
|
</ul>
|
11
11
|
</div>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/time"
|
4
|
-
require "active_support/deprecation"
|
5
4
|
|
6
5
|
module Rails
|
7
6
|
module Generators
|
@@ -52,11 +51,6 @@ module Rails
|
|
52
51
|
provided_options = $2.split(/[,.-]/)
|
53
52
|
options = Hash[provided_options.map { |opt| [opt.to_sym, true] }]
|
54
53
|
|
55
|
-
if options[:required]
|
56
|
-
ActiveSupport::Deprecation.warn("Passing {required} option has no effect on the model generator. It will be removed in Rails 6.1.\n")
|
57
|
-
options.delete(:required)
|
58
|
-
end
|
59
|
-
|
60
54
|
return type, options
|
61
55
|
else
|
62
56
|
return type, {}
|
@@ -107,11 +101,11 @@ module Rails
|
|
107
101
|
end
|
108
102
|
|
109
103
|
def plural_name
|
110
|
-
name.
|
104
|
+
name.delete_suffix("_id").pluralize
|
111
105
|
end
|
112
106
|
|
113
107
|
def singular_name
|
114
|
-
name.
|
108
|
+
name.delete_suffix("_id").singularize
|
115
109
|
end
|
116
110
|
|
117
111
|
def human_name
|
@@ -131,7 +125,7 @@ module Rails
|
|
131
125
|
end
|
132
126
|
|
133
127
|
def foreign_key?
|
134
|
-
|
128
|
+
name.end_with?("_id")
|
135
129
|
end
|
136
130
|
|
137
131
|
def reference?
|
@@ -62,13 +62,14 @@ module Rails
|
|
62
62
|
dir, base = File.split(destination)
|
63
63
|
numbered_destination = File.join(dir, ["%migration_number%", base].join("_"))
|
64
64
|
|
65
|
-
create_migration numbered_destination, nil, config do
|
65
|
+
file = create_migration numbered_destination, nil, config do
|
66
66
|
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
67
67
|
ERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer").result(context)
|
68
68
|
else
|
69
69
|
ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context)
|
70
70
|
end
|
71
71
|
end
|
72
|
+
Rails::Generators.add_generated_file(file)
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
@@ -11,6 +11,11 @@ module Rails
|
|
11
11
|
[WARNING] Rails cannot recover singular form from its plural form '%s'.
|
12
12
|
Please setup custom inflection rules for this noun before running the generator in config/initializers/inflections.rb.
|
13
13
|
WARNING
|
14
|
+
INFLECTION_IMPOSSIBLE_ERROR_MESSAGE = <<~ERROR
|
15
|
+
Rails cannot recover the underscored form from its camelcase form '%s'.
|
16
|
+
Please use an underscored name instead, either '%s' or '%s'.
|
17
|
+
Or setup custom inflection rules for this noun before running the generator in config/initializers/inflections.rb.
|
18
|
+
ERROR
|
14
19
|
mattr_accessor :skip_warn
|
15
20
|
|
16
21
|
def self.included(base) #:nodoc:
|
@@ -19,7 +24,7 @@ module Rails
|
|
19
24
|
|
20
25
|
def initialize(args, *_options)
|
21
26
|
super
|
22
|
-
if name
|
27
|
+
if plural_model_name?(name) && !options[:force_plural]
|
23
28
|
singular = name.singularize
|
24
29
|
unless ModelHelpers.skip_warn
|
25
30
|
say PLURAL_MODEL_NAME_WARN_MESSAGE % [name, singular]
|
@@ -27,11 +32,30 @@ module Rails
|
|
27
32
|
name.replace singular
|
28
33
|
assign_names!(name)
|
29
34
|
end
|
30
|
-
if name
|
35
|
+
if inflection_impossible?(name)
|
36
|
+
option1 = name.singularize.underscore
|
37
|
+
option2 = name.pluralize.underscore.singularize
|
38
|
+
raise Error, INFLECTION_IMPOSSIBLE_ERROR_MESSAGE % [name, option1, option2]
|
39
|
+
end
|
40
|
+
if irregular_model_name?(name) && ! ModelHelpers.skip_warn
|
31
41
|
say IRREGULAR_MODEL_NAME_WARN_MESSAGE % [name.pluralize]
|
32
42
|
end
|
33
43
|
ModelHelpers.skip_warn = true
|
34
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def plural_model_name?(name)
|
48
|
+
name == name.pluralize && name.singularize != name.pluralize
|
49
|
+
end
|
50
|
+
|
51
|
+
def irregular_model_name?(name)
|
52
|
+
name.singularize != name.pluralize.singularize
|
53
|
+
end
|
54
|
+
|
55
|
+
def inflection_impossible?(name)
|
56
|
+
name != name.underscore &&
|
57
|
+
name.singularize.underscore != name.pluralize.underscore.singularize
|
58
|
+
end
|
35
59
|
end
|
36
60
|
end
|
37
61
|
end
|
@@ -3,7 +3,8 @@ Description:
|
|
3
3
|
directory structure and configuration at the path you specify.
|
4
4
|
|
5
5
|
You can specify extra command-line arguments to be used every time
|
6
|
-
'rails new' runs in the .railsrc configuration file in your home directory
|
6
|
+
'rails new' runs in the .railsrc configuration file in your home directory,
|
7
|
+
or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set.
|
7
8
|
|
8
9
|
Note that the arguments specified in the .railsrc file don't affect the
|
9
10
|
defaults values shown above in this help message.
|
@@ -66,6 +66,10 @@ module Rails
|
|
66
66
|
template "gitignore", ".gitignore"
|
67
67
|
end
|
68
68
|
|
69
|
+
def gitattributes
|
70
|
+
template "gitattributes", ".gitattributes"
|
71
|
+
end
|
72
|
+
|
69
73
|
def version_control
|
70
74
|
if !options[:skip_git] && !options[:pretend]
|
71
75
|
run "git init", capture: options[:quiet], abort_on_failure: false
|
@@ -90,14 +94,23 @@ module Rails
|
|
90
94
|
"#{shebang}\n" + content
|
91
95
|
end
|
92
96
|
chmod "bin", 0755 & ~File.umask, verbose: false
|
97
|
+
|
98
|
+
remove_file "bin/spring" unless spring_install?
|
99
|
+
remove_file "bin/yarn" if options[:skip_javascript]
|
93
100
|
end
|
94
101
|
|
95
102
|
def bin_when_updating
|
96
103
|
bin
|
104
|
+
end
|
97
105
|
|
98
|
-
|
99
|
-
|
106
|
+
def yarn_when_updating
|
107
|
+
return if File.exist?("bin/yarn")
|
108
|
+
|
109
|
+
template "bin/yarn" do |content|
|
110
|
+
"#{shebang}\n" + content
|
100
111
|
end
|
112
|
+
|
113
|
+
chmod "bin", 0755 & ~File.umask, verbose: false
|
101
114
|
end
|
102
115
|
|
103
116
|
def config
|
@@ -125,10 +138,12 @@ module Rails
|
|
125
138
|
rack_cors_config_exist = File.exist?("config/initializers/cors.rb")
|
126
139
|
assets_config_exist = File.exist?("config/initializers/assets.rb")
|
127
140
|
csp_config_exist = File.exist?("config/initializers/content_security_policy.rb")
|
141
|
+
feature_policy_config_exist = File.exist?("config/initializers/feature_policy.rb")
|
128
142
|
|
129
143
|
@config_target_version = Rails.application.config.loaded_config_version || "5.0"
|
130
144
|
|
131
145
|
config
|
146
|
+
configru
|
132
147
|
|
133
148
|
unless cookie_serializer_config_exist
|
134
149
|
gsub_file "config/initializers/cookies_serializer.rb", /json(?!,)/, "marshal"
|
@@ -158,6 +173,10 @@ module Rails
|
|
158
173
|
unless csp_config_exist
|
159
174
|
remove_file "config/initializers/content_security_policy.rb"
|
160
175
|
end
|
176
|
+
|
177
|
+
unless feature_policy_config_exist
|
178
|
+
remove_file "config/initializers/feature_policy.rb"
|
179
|
+
end
|
161
180
|
end
|
162
181
|
end
|
163
182
|
|
@@ -205,7 +224,6 @@ module Rails
|
|
205
224
|
end
|
206
225
|
|
207
226
|
def test
|
208
|
-
empty_directory_with_keep_file "test/fixtures"
|
209
227
|
empty_directory_with_keep_file "test/fixtures/files"
|
210
228
|
empty_directory_with_keep_file "test/controllers"
|
211
229
|
empty_directory_with_keep_file "test/mailers"
|
@@ -244,7 +262,9 @@ module Rails
|
|
244
262
|
# can change in Ruby 1.8.7 when we FileUtils.cd.
|
245
263
|
RAILS_DEV_PATH = File.expand_path("../../../../../..", __dir__)
|
246
264
|
|
247
|
-
class AppGenerator < AppBase
|
265
|
+
class AppGenerator < AppBase
|
266
|
+
# :stopdoc:
|
267
|
+
|
248
268
|
WEBPACKS = %w( react vue angular elm stimulus )
|
249
269
|
|
250
270
|
add_shared_options_for "application"
|
@@ -256,6 +276,9 @@ module Rails
|
|
256
276
|
class_option :api, type: :boolean,
|
257
277
|
desc: "Preconfigure smaller stack for API only apps"
|
258
278
|
|
279
|
+
class_option :minimal, type: :boolean,
|
280
|
+
desc: "Preconfigure a minimal rails app"
|
281
|
+
|
259
282
|
class_option :skip_bundle, type: :boolean, aliases: "-B", default: false,
|
260
283
|
desc: "Don't run bundle install"
|
261
284
|
|
@@ -278,6 +301,29 @@ module Rails
|
|
278
301
|
self.options = options.merge(skip_sprockets: true, skip_javascript: true).freeze
|
279
302
|
end
|
280
303
|
|
304
|
+
if options[:minimal]
|
305
|
+
self.options = options.merge(
|
306
|
+
skip_action_cable: true,
|
307
|
+
skip_action_mailer: true,
|
308
|
+
skip_action_mailbox: true,
|
309
|
+
skip_action_text: true,
|
310
|
+
skip_active_job: true,
|
311
|
+
skip_active_storage: true,
|
312
|
+
skip_bootsnap: true,
|
313
|
+
skip_dev_gems: true,
|
314
|
+
skip_javascript: true,
|
315
|
+
skip_jbuilder: true,
|
316
|
+
skip_spring: true,
|
317
|
+
skip_system_test: true,
|
318
|
+
skip_webpack_install: true,
|
319
|
+
skip_turbolinks: true).tap do |option|
|
320
|
+
if option[:webpack]
|
321
|
+
option[:skip_webpack_install] = false
|
322
|
+
option[:skip_javascript] = false
|
323
|
+
end
|
324
|
+
end.freeze
|
325
|
+
end
|
326
|
+
|
281
327
|
@after_bundle_callbacks = []
|
282
328
|
end
|
283
329
|
|
@@ -289,8 +335,13 @@ module Rails
|
|
289
335
|
build(:rakefile)
|
290
336
|
build(:ruby_version)
|
291
337
|
build(:configru)
|
292
|
-
|
293
|
-
|
338
|
+
|
339
|
+
unless options[:skip_git]
|
340
|
+
build(:gitignore)
|
341
|
+
build(:gitattributes)
|
342
|
+
end
|
343
|
+
|
344
|
+
build(:gemfile) unless options[:skip_gemfile]
|
294
345
|
build(:version_control)
|
295
346
|
build(:package_json) unless options[:skip_javascript]
|
296
347
|
end
|
@@ -308,9 +359,14 @@ module Rails
|
|
308
359
|
end
|
309
360
|
remove_task :update_bin_files
|
310
361
|
|
362
|
+
def update_bin_yarn
|
363
|
+
build(:yarn_when_updating)
|
364
|
+
end
|
365
|
+
remove_task :update_bin_yarn
|
366
|
+
|
311
367
|
def update_active_storage
|
312
368
|
unless skip_active_storage?
|
313
|
-
rails_command "active_storage:update"
|
369
|
+
rails_command "active_storage:update", inline: true
|
314
370
|
end
|
315
371
|
end
|
316
372
|
remove_task :update_active_storage
|
@@ -420,11 +476,18 @@ module Rails
|
|
420
476
|
end
|
421
477
|
|
422
478
|
def delete_js_folder_skipping_javascript
|
423
|
-
if options[:skip_javascript]
|
479
|
+
if options[:skip_javascript] && !options[:minimal]
|
424
480
|
remove_dir "app/javascript"
|
425
481
|
end
|
426
482
|
end
|
427
483
|
|
484
|
+
def delete_js_packs_when_minimal_skipping_webpack
|
485
|
+
if options[:minimal] && options[:skip_webpack_install]
|
486
|
+
remove_dir "app/javascript/packs"
|
487
|
+
keep_file "app/javascript"
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
428
491
|
def delete_assets_initializer_skipping_sprockets
|
429
492
|
if options[:skip_sprockets]
|
430
493
|
remove_file "config/initializers/assets.rb"
|
@@ -437,6 +500,12 @@ module Rails
|
|
437
500
|
end
|
438
501
|
end
|
439
502
|
|
503
|
+
def delete_active_job_folder_if_skipping_active_job
|
504
|
+
if options[:skip_active_job]
|
505
|
+
remove_dir "app/jobs"
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
440
509
|
def delete_action_mailer_files_skipping_action_mailer
|
441
510
|
if options[:skip_action_mailer]
|
442
511
|
remove_file "app/views/layouts/mailer.html.erb"
|
@@ -458,6 +527,7 @@ module Rails
|
|
458
527
|
if options[:api]
|
459
528
|
remove_file "config/initializers/cookies_serializer.rb"
|
460
529
|
remove_file "config/initializers/content_security_policy.rb"
|
530
|
+
remove_file "config/initializers/feature_policy.rb"
|
461
531
|
end
|
462
532
|
end
|
463
533
|
|
@@ -469,20 +539,16 @@ module Rails
|
|
469
539
|
|
470
540
|
def delete_new_framework_defaults
|
471
541
|
unless options[:update]
|
472
|
-
remove_file "config/initializers/
|
542
|
+
remove_file "config/initializers/new_framework_defaults_6_1.rb"
|
473
543
|
end
|
474
544
|
end
|
475
545
|
|
476
|
-
def delete_bin_yarn
|
477
|
-
remove_file "bin/yarn" if options[:skip_javascript]
|
478
|
-
end
|
479
|
-
|
480
546
|
def finish_template
|
481
547
|
build(:leftovers)
|
482
548
|
end
|
483
549
|
|
484
550
|
public_task :apply_rails_template, :run_bundle
|
485
|
-
public_task :generate_bundler_binstub
|
551
|
+
public_task :generate_bundler_binstub
|
486
552
|
public_task :run_webpack
|
487
553
|
|
488
554
|
def run_after_bundle_callbacks
|
@@ -493,6 +559,8 @@ module Rails
|
|
493
559
|
"rails new #{arguments.map(&:usage).join(' ')} [options]"
|
494
560
|
end
|
495
561
|
|
562
|
+
# :startdoc:
|
563
|
+
|
496
564
|
private
|
497
565
|
# Define file as an alias to create_file for backwards compatibility.
|
498
566
|
def file(*args, &block)
|
@@ -534,7 +602,13 @@ module Rails
|
|
534
602
|
end
|
535
603
|
|
536
604
|
def self.default_rc_file
|
537
|
-
|
605
|
+
xdg_config_home = ENV["XDG_CONFIG_HOME"].presence || "~/.config"
|
606
|
+
xdg_railsrc = File.expand_path("rails/railsrc", xdg_config_home)
|
607
|
+
if File.exist?(xdg_railsrc)
|
608
|
+
xdg_railsrc
|
609
|
+
else
|
610
|
+
File.expand_path("~/.railsrc")
|
611
|
+
end
|
538
612
|
end
|
539
613
|
|
540
614
|
private
|
@@ -3,7 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
3
|
|
4
4
|
ruby <%= "'#{RUBY_VERSION}'" -%>
|
5
5
|
|
6
|
-
<% unless gemfile_entries.first
|
6
|
+
<% unless gemfile_entries.first&.comment -%>
|
7
7
|
|
8
8
|
<% end -%>
|
9
9
|
<% gemfile_entries.each do |gem| -%>
|
@@ -14,7 +14,7 @@ ruby <%= "'#{RUBY_VERSION}'" -%>
|
|
14
14
|
<%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<%= %(, '#{gem.version}') if gem.version -%>
|
15
15
|
<% if gem.options.any? -%>
|
16
16
|
, <%= gem.options.map { |k,v|
|
17
|
-
"#{k}: #{v.inspect}" }.join(', ') %>
|
17
|
+
"#{k}: #{v.inspect.gsub('"', '\'')}" }.join(', ') %>
|
18
18
|
<% end -%>
|
19
19
|
<% end -%>
|
20
20
|
|
@@ -28,7 +28,7 @@ ruby <%= "'#{RUBY_VERSION}'" -%>
|
|
28
28
|
|
29
29
|
<% if depend_on_bootsnap? -%>
|
30
30
|
# Reduces boot times through caching; required in config/boot.rb
|
31
|
-
gem 'bootsnap', '>= 1.4.
|
31
|
+
gem 'bootsnap', '>= 1.4.4', require: false
|
32
32
|
|
33
33
|
<%- end -%>
|
34
34
|
<%- if options.api? -%>
|
@@ -44,13 +44,16 @@ end
|
|
44
44
|
|
45
45
|
<% end -%>
|
46
46
|
group :development do
|
47
|
-
<%- unless options.api? -%>
|
47
|
+
<%- unless options.api? || options.skip_dev_gems? -%>
|
48
48
|
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
49
|
-
<%- if options.dev? || options.edge? -%>
|
49
|
+
<%- if options.dev? || options.edge? || options.master? -%>
|
50
50
|
gem 'web-console', github: 'rails/web-console'
|
51
51
|
<%- else -%>
|
52
|
-
gem 'web-console', '>=
|
52
|
+
gem 'web-console', '>= 4.0.3'
|
53
53
|
<%- end -%>
|
54
|
+
# Display performance information such as SQL time and flame graphs for each request in your browser.
|
55
|
+
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
|
56
|
+
gem 'rack-mini-profiler', '~> 2.0'
|
54
57
|
<%- end -%>
|
55
58
|
<% if depend_on_listen? -%>
|
56
59
|
gem 'listen', '~> 3.2'
|
@@ -58,16 +61,13 @@ group :development do
|
|
58
61
|
<% if spring_install? -%>
|
59
62
|
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
60
63
|
gem 'spring'
|
61
|
-
<% if depend_on_listen? -%>
|
62
|
-
gem 'spring-watcher-listen', '~> 2.0.0'
|
63
|
-
<% end -%>
|
64
64
|
<% end -%>
|
65
65
|
end
|
66
66
|
|
67
67
|
<%- if depends_on_system_test? -%>
|
68
68
|
group :test do
|
69
69
|
# Adds support for Capybara system testing and selenium driver
|
70
|
-
gem 'capybara', '>=
|
70
|
+
gem 'capybara', '>= 3.26'
|
71
71
|
gem 'selenium-webdriver'
|
72
72
|
# Easy installation and use of web drivers to run system tests with browsers
|
73
73
|
gem 'webdrivers'
|