railties 7.2.1.1 → 8.0.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 +122 -278
- data/lib/minitest/rails_plugin.rb +1 -1
- data/lib/rails/application/bootstrap.rb +0 -1
- data/lib/rails/application/configuration.rb +15 -14
- data/lib/rails/application/default_middleware_stack.rb +4 -0
- data/lib/rails/application/finisher.rb +2 -3
- data/lib/rails/application/routes_reloader.rb +11 -1
- data/lib/rails/application.rb +5 -0
- data/lib/rails/code_statistics.rb +128 -86
- data/lib/rails/code_statistics_calculator.rb +78 -76
- data/lib/rails/command/helpers/editor.rb +1 -1
- data/lib/rails/command.rb +0 -6
- data/lib/rails/commands/app/update_command.rb +1 -9
- data/lib/rails/commands/console/irb_console.rb +11 -8
- data/lib/rails/commands/credentials/USAGE +4 -4
- data/lib/rails/commands/credentials/credentials_command.rb +5 -1
- data/lib/rails/commands/dev/dev_command.rb +1 -1
- data/lib/rails/commands/devcontainer/devcontainer_command.rb +2 -1
- data/lib/rails/commands/stats/stats_command.rb +19 -0
- data/lib/rails/console/methods.rb +5 -21
- data/lib/rails/dev_caching.rb +2 -2
- data/lib/rails/engine/configuration.rb +3 -1
- data/lib/rails/engine/lazy_route_set.rb +114 -0
- data/lib/rails/engine.rb +12 -8
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/app_base.rb +46 -28
- data/lib/rails/generators/base.rb +0 -4
- data/lib/rails/generators/database.rb +101 -67
- data/lib/rails/generators/erb/authentication/authentication_generator.rb +15 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/passwords/edit.html.erb +9 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/passwords/new.html.erb +8 -0
- data/lib/rails/generators/erb/authentication/templates/app/views/sessions/new.html.erb +11 -0
- data/lib/rails/generators/generated_attribute.rb +16 -11
- data/lib/rails/generators/rails/app/app_generator.rb +20 -32
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +13 -4
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +25 -10
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css.tt +6 -11
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +10 -3
- data/lib/rails/generators/rails/app/templates/bin/dev.tt +1 -0
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +5 -8
- data/lib/rails/generators/rails/app/templates/bin/thrust.tt +4 -0
- data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml.tt +23 -0
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +23 -0
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +40 -0
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +23 -0
- data/lib/rails/generators/rails/app/templates/config/deploy.yml.tt +128 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +12 -23
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +34 -51
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -19
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +0 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_8_0.rb.tt +25 -0
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +11 -2
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +3 -3
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +4 -3
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +1 -2
- data/lib/rails/generators/rails/app/templates/github/ci.yml.tt +5 -1
- data/lib/rails/generators/rails/app/templates/gitignore.tt +1 -2
- data/lib/rails/generators/rails/app/templates/kamal-secrets.tt +17 -0
- data/lib/rails/generators/rails/app/templates/public/400.html +114 -0
- data/lib/rails/generators/rails/app/templates/public/404.html +113 -66
- data/lib/rails/generators/rails/app/templates/public/406-unsupported-browser.html +113 -65
- data/lib/rails/generators/rails/app/templates/public/422.html +113 -66
- data/lib/rails/generators/rails/app/templates/public/500.html +113 -65
- data/lib/rails/generators/rails/app/templates/public/icon.png +0 -0
- data/lib/rails/generators/rails/app/templates/public/icon.svg +2 -2
- data/lib/rails/generators/rails/authentication/USAGE +6 -0
- data/lib/rails/generators/rails/authentication/authentication_generator.rb +56 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt +55 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +33 -0
- data/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +21 -0
- data/lib/rails/generators/rails/authentication/templates/app/mailers/passwords_mailer.rb.tt +6 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/current.rb.tt +4 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/session.rb.tt +3 -0
- data/lib/rails/generators/rails/authentication/templates/app/models/user.rb.tt +6 -0
- data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.html.erb.tt +4 -0
- data/lib/rails/generators/rails/authentication/templates/app/views/passwords_mailer/reset.text.erb.tt +2 -0
- data/lib/rails/generators/rails/authentication/templates/test/mailers/previews/passwords_mailer_preview.rb.tt +7 -0
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +4 -0
- data/lib/rails/generators/rails/db/system/change/change_generator.rb +1 -1
- data/lib/rails/generators/rails/devcontainer/devcontainer_generator.rb +10 -3
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/Dockerfile.tt +1 -1
- data/lib/rails/generators/rails/devcontainer/templates/devcontainer/devcontainer.json.tt +1 -1
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +11 -11
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb.tt +2 -2
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb.tt +3 -3
- data/lib/rails/generators/rails/script/USAGE +18 -0
- data/lib/rails/generators/rails/script/script_generator.rb +18 -0
- data/lib/rails/generators/rails/script/templates/script.rb.tt +3 -0
- data/lib/rails/generators/test_unit/authentication/authentication_generator.rb +14 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/fixtures/users.yml.tt +9 -0
- data/lib/rails/generators/test_unit/authentication/templates/test/models/user_test.rb.tt +7 -0
- data/lib/rails/generators.rb +7 -2
- data/lib/rails/info_controller.rb +10 -2
- data/lib/rails/rack/silence_request.rb +33 -0
- data/lib/rails/rack.rb +1 -0
- data/lib/rails/railtie.rb +13 -13
- data/lib/rails/source_annotation_extractor.rb +31 -14
- data/lib/rails/tasks/statistics.rake +13 -28
- data/lib/rails/templates/rails/info/notes.html.erb +65 -0
- data/lib/rails/test_unit/runner.rb +1 -0
- metadata +44 -23
- data/lib/rails/console/app.rb +0 -8
- data/lib/rails/console/helpers.rb +0 -8
- data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb.tt +0 -4
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_2.rb.tt +0 -70
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +0 -13
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +0 -13
- data/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js.tt +0 -10
- data/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js.tt +0 -6
- data/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt +0 -17
@@ -1,23 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.method_added(_method_name)
|
11
|
-
raise_deprecation_warning
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.raise_deprecation_warning
|
16
|
-
Rails.deprecator.warn(<<~MSG, caller_locations(2..2))
|
17
|
-
Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 8.0.
|
18
|
-
Please directly use IRB's extension API to add new commands or helpers to the console.
|
19
|
-
For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
|
20
|
-
MSG
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
3
|
+
Rails.deprecator.warn(<<~MSG, caller_locations(0..1))
|
4
|
+
`rails/console/methods` has been deprecated and will be removed in Rails 8.1.
|
5
|
+
Please directly use IRB's extension API to add new commands or helpers to the console.
|
6
|
+
For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md
|
7
|
+
MSG
|
data/lib/rails/dev_caching.rb
CHANGED
@@ -12,10 +12,10 @@ module Rails
|
|
12
12
|
|
13
13
|
if File.exist?(FILE)
|
14
14
|
delete_cache_file
|
15
|
-
puts "
|
15
|
+
puts "Action Controller caching disabled for development mode."
|
16
16
|
else
|
17
17
|
create_cache_file
|
18
|
-
puts "
|
18
|
+
puts "Action Controller caching enabled for development mode."
|
19
19
|
end
|
20
20
|
|
21
21
|
FileUtils.touch "tmp/restart.txt"
|
@@ -6,7 +6,7 @@ module Rails
|
|
6
6
|
class Engine
|
7
7
|
class Configuration < ::Rails::Railtie::Configuration
|
8
8
|
attr_reader :root
|
9
|
-
attr_accessor :middleware, :javascript_path
|
9
|
+
attr_accessor :middleware, :javascript_path, :route_set_class, :default_scope
|
10
10
|
attr_writer :eager_load_paths, :autoload_once_paths, :autoload_paths
|
11
11
|
|
12
12
|
# An array of custom autoload paths to be added to the ones defined
|
@@ -44,6 +44,8 @@ module Rails
|
|
44
44
|
@generators = app_generators.dup
|
45
45
|
@middleware = Rails::Configuration::MiddlewareStackProxy.new
|
46
46
|
@javascript_path = "javascript"
|
47
|
+
@route_set_class = ActionDispatch::Routing::RouteSet
|
48
|
+
@default_scope = nil
|
47
49
|
|
48
50
|
@autoload_paths = []
|
49
51
|
@autoload_once_paths = []
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :markup: markdown
|
4
|
+
|
5
|
+
require "action_dispatch/routing/route_set"
|
6
|
+
|
7
|
+
module Rails
|
8
|
+
class Engine
|
9
|
+
class LazyRouteSet < ActionDispatch::Routing::RouteSet # :nodoc:
|
10
|
+
class NamedRouteCollection < ActionDispatch::Routing::RouteSet::NamedRouteCollection
|
11
|
+
def route_defined?(name)
|
12
|
+
Rails.application&.reload_routes_unless_loaded
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ProxyUrlHelpers
|
18
|
+
def url_for(options)
|
19
|
+
Rails.application&.reload_routes_unless_loaded
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def full_url_for(options)
|
24
|
+
Rails.application&.reload_routes_unless_loaded
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def route_for(name, *args)
|
29
|
+
Rails.application&.reload_routes_unless_loaded
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def optimize_routes_generation?
|
34
|
+
Rails.application&.reload_routes_unless_loaded
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def polymorphic_url(record_or_hash_or_array, options = {})
|
39
|
+
Rails.application&.reload_routes_unless_loaded
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def polymorphic_path(record_or_hash_or_array, options = {})
|
44
|
+
Rails.application&.reload_routes_unless_loaded
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(config = DEFAULT_CONFIG)
|
50
|
+
super
|
51
|
+
self.named_routes = NamedRouteCollection.new
|
52
|
+
named_routes.url_helpers_module.prepend(method_missing_module)
|
53
|
+
named_routes.path_helpers_module.prepend(method_missing_module)
|
54
|
+
end
|
55
|
+
|
56
|
+
def generate_extras(options, recall = {})
|
57
|
+
Rails.application&.reload_routes_unless_loaded
|
58
|
+
|
59
|
+
super(options, recall)
|
60
|
+
end
|
61
|
+
|
62
|
+
def generate_url_helpers(supports_path)
|
63
|
+
super.tap { |mod| mod.singleton_class.prepend(ProxyUrlHelpers) }
|
64
|
+
end
|
65
|
+
|
66
|
+
def call(req)
|
67
|
+
Rails.application&.reload_routes_unless_loaded
|
68
|
+
super
|
69
|
+
end
|
70
|
+
|
71
|
+
def draw(&block)
|
72
|
+
Rails.application&.reload_routes_unless_loaded
|
73
|
+
super
|
74
|
+
end
|
75
|
+
|
76
|
+
def recognize_path(path, environment = {})
|
77
|
+
Rails.application&.reload_routes_unless_loaded
|
78
|
+
super
|
79
|
+
end
|
80
|
+
|
81
|
+
def recognize_path_with_request(...)
|
82
|
+
Rails.application&.reload_routes_unless_loaded
|
83
|
+
super
|
84
|
+
end
|
85
|
+
|
86
|
+
def routes
|
87
|
+
Rails.application&.reload_routes_unless_loaded
|
88
|
+
super
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
def method_missing_module
|
93
|
+
@method_missing_module ||= Module.new do
|
94
|
+
private
|
95
|
+
def method_missing(...)
|
96
|
+
if Rails.application&.reload_routes_unless_loaded
|
97
|
+
public_send(...)
|
98
|
+
else
|
99
|
+
super
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def respond_to_missing?(...)
|
104
|
+
if Rails.application&.reload_routes_unless_loaded
|
105
|
+
respond_to?(...)
|
106
|
+
else
|
107
|
+
super
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/lib/rails/engine.rb
CHANGED
@@ -6,7 +6,6 @@ require "active_support/callbacks"
|
|
6
6
|
require "active_support/core_ext/module/delegation"
|
7
7
|
require "active_support/core_ext/object/try"
|
8
8
|
require "pathname"
|
9
|
-
require "thread"
|
10
9
|
|
11
10
|
module Rails
|
12
11
|
# +Rails::Engine+ allows you to wrap a specific \Rails application or subset of
|
@@ -246,7 +245,7 @@ module Rails
|
|
246
245
|
# polymorphic_url(MyEngine::Article.new)
|
247
246
|
# # => "articles_path" # not "my_engine_articles_path"
|
248
247
|
#
|
249
|
-
#
|
248
|
+
# form_with(model: MyEngine::Article.new) do
|
250
249
|
# text_field :title # => <input type="text" name="article[title]" id="article_title" />
|
251
250
|
# end
|
252
251
|
#
|
@@ -295,7 +294,7 @@ module Rails
|
|
295
294
|
# All you need to do is pass the helper as the first element in array with
|
296
295
|
# attributes for URL:
|
297
296
|
#
|
298
|
-
#
|
297
|
+
# form_with(model: [my_engine, @user])
|
299
298
|
#
|
300
299
|
# This code will use <tt>my_engine.user_path(@user)</tt> to generate the proper route.
|
301
300
|
#
|
@@ -349,6 +348,7 @@ module Rails
|
|
349
348
|
# config.railties_order = [Blog::Engine, :main_app, :all]
|
350
349
|
class Engine < Railtie
|
351
350
|
autoload :Configuration, "rails/engine/configuration"
|
351
|
+
autoload :LazyRouteSet, "rails/engine/lazy_route_set"
|
352
352
|
|
353
353
|
class << self
|
354
354
|
attr_accessor :called_from, :isolated
|
@@ -385,7 +385,8 @@ module Rails
|
|
385
385
|
def isolate_namespace(mod)
|
386
386
|
engine_name(generate_railtie_name(mod.name))
|
387
387
|
|
388
|
-
|
388
|
+
config.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
|
389
|
+
|
389
390
|
self.isolated = true
|
390
391
|
|
391
392
|
unless mod.respond_to?(:railtie_namespace)
|
@@ -451,7 +452,6 @@ module Rails
|
|
451
452
|
# Load console and invoke the registered hooks.
|
452
453
|
# Check Rails::Railtie.console for more info.
|
453
454
|
def load_console(app = self)
|
454
|
-
require "rails/console/methods"
|
455
455
|
run_console_blocks(app)
|
456
456
|
self
|
457
457
|
end
|
@@ -543,7 +543,7 @@ module Rails
|
|
543
543
|
# Defines the routes for this engine. If a block is given to
|
544
544
|
# routes, it is appended to the engine.
|
545
545
|
def routes(&block)
|
546
|
-
@routes ||=
|
546
|
+
@routes ||= config.route_set_class.new_with_config(config)
|
547
547
|
@routes.append(&block) if block_given?
|
548
548
|
@routes
|
549
549
|
end
|
@@ -588,6 +588,10 @@ module Rails
|
|
588
588
|
config.eager_load_paths.freeze
|
589
589
|
end
|
590
590
|
|
591
|
+
initializer :make_routes_lazy, before: :bootstrap_hook do |app|
|
592
|
+
config.route_set_class = LazyRouteSet if Rails.env.local?
|
593
|
+
end
|
594
|
+
|
591
595
|
initializer :add_routing_paths do |app|
|
592
596
|
routing_paths = paths["config/routes.rb"].existent
|
593
597
|
external_paths = self.paths["config/routes"].paths
|
@@ -643,9 +647,9 @@ module Rails
|
|
643
647
|
end
|
644
648
|
end
|
645
649
|
|
646
|
-
initializer :
|
650
|
+
initializer :wrap_reloader_around_load_seed do |app|
|
647
651
|
self.class.set_callback(:load_seed, :around) do |engine, seeds_block|
|
648
|
-
app.
|
652
|
+
app.reloader.wrap(&seeds_block)
|
649
653
|
end
|
650
654
|
end
|
651
655
|
|
data/lib/rails/gem_version.rb
CHANGED
@@ -19,7 +19,6 @@ module Rails
|
|
19
19
|
|
20
20
|
JAVASCRIPT_OPTIONS = %w( importmap bun webpack esbuild rollup )
|
21
21
|
CSS_OPTIONS = %w( tailwind bootstrap bulma postcss sass )
|
22
|
-
ASSET_PIPELINE_OPTIONS = %w( none sprockets propshaft )
|
23
22
|
|
24
23
|
attr_accessor :rails_template
|
25
24
|
add_shebang_option!
|
@@ -74,10 +73,6 @@ module Rails
|
|
74
73
|
|
75
74
|
class_option :skip_asset_pipeline, type: :boolean, aliases: "-A", default: nil
|
76
75
|
|
77
|
-
class_option :asset_pipeline, type: :string, aliases: "-a", default: "sprockets",
|
78
|
-
enum: ASSET_PIPELINE_OPTIONS,
|
79
|
-
desc: "Choose your asset pipeline"
|
80
|
-
|
81
76
|
class_option :skip_javascript, type: :boolean, aliases: ["-J", "--skip-js"], default: (true if name == "plugin"),
|
82
77
|
desc: "Skip JavaScript files"
|
83
78
|
|
@@ -99,6 +94,9 @@ module Rails
|
|
99
94
|
class_option :skip_dev_gems, type: :boolean, default: nil,
|
100
95
|
desc: "Skip development gems (e.g., web-console)"
|
101
96
|
|
97
|
+
class_option :skip_thruster, type: :boolean, default: nil,
|
98
|
+
desc: "Skip Thruster setup"
|
99
|
+
|
102
100
|
class_option :skip_rubocop, type: :boolean, default: nil,
|
103
101
|
desc: "Skip RuboCop setup"
|
104
102
|
|
@@ -108,10 +106,16 @@ module Rails
|
|
108
106
|
class_option :skip_ci, type: :boolean, default: nil,
|
109
107
|
desc: "Skip GitHub CI files"
|
110
108
|
|
109
|
+
class_option :skip_kamal, type: :boolean, default: nil,
|
110
|
+
desc: "Skip Kamal setup"
|
111
|
+
|
112
|
+
class_option :skip_solid, type: :boolean, default: nil,
|
113
|
+
desc: "Skip Solid Cache & Queue setup"
|
114
|
+
|
111
115
|
class_option :dev, type: :boolean, default: nil,
|
112
116
|
desc: "Set up the #{name} with Gemfile pointing to your Rails checkout"
|
113
117
|
|
114
|
-
class_option :devcontainer, type: :boolean, default:
|
118
|
+
class_option :devcontainer, type: :boolean, default: nil,
|
115
119
|
desc: "Generate devcontainer files"
|
116
120
|
|
117
121
|
class_option :edge, type: :boolean, default: nil,
|
@@ -197,7 +201,7 @@ module Rails
|
|
197
201
|
|
198
202
|
OPTION_IMPLICATIONS = { # :nodoc:
|
199
203
|
skip_active_job: [:skip_action_mailer, :skip_active_storage],
|
200
|
-
skip_active_record: [:skip_active_storage],
|
204
|
+
skip_active_record: [:skip_active_storage, :skip_solid],
|
201
205
|
skip_active_storage: [:skip_action_mailbox, :skip_action_text],
|
202
206
|
skip_javascript: [:skip_hotwire],
|
203
207
|
}
|
@@ -287,12 +291,7 @@ module Rails
|
|
287
291
|
end
|
288
292
|
|
289
293
|
def asset_pipeline_gemfile_entry
|
290
|
-
|
291
|
-
|
292
|
-
if options[:asset_pipeline] == "sprockets"
|
293
|
-
GemfileEntry.floats "sprockets-rails",
|
294
|
-
"The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]"
|
295
|
-
elsif options[:asset_pipeline] == "propshaft"
|
294
|
+
unless skip_asset_pipeline?
|
296
295
|
GemfileEntry.floats "propshaft", "The modern asset pipeline for Rails [https://github.com/rails/propshaft]"
|
297
296
|
end
|
298
297
|
end
|
@@ -386,12 +385,8 @@ module Rails
|
|
386
385
|
options[:skip_asset_pipeline]
|
387
386
|
end
|
388
387
|
|
389
|
-
def
|
390
|
-
|
391
|
-
end
|
392
|
-
|
393
|
-
def skip_propshaft?
|
394
|
-
skip_asset_pipeline? || options[:asset_pipeline] != "propshaft"
|
388
|
+
def skip_thruster?
|
389
|
+
options[:skip_thruster]
|
395
390
|
end
|
396
391
|
|
397
392
|
def skip_rubocop?
|
@@ -414,6 +409,14 @@ module Rails
|
|
414
409
|
options[:devcontainer]
|
415
410
|
end
|
416
411
|
|
412
|
+
def skip_kamal?
|
413
|
+
options[:skip_kamal]
|
414
|
+
end
|
415
|
+
|
416
|
+
def skip_solid?
|
417
|
+
options[:skip_solid]
|
418
|
+
end
|
419
|
+
|
417
420
|
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
|
418
421
|
def initialize(name, version, comment, options = {}, commented_out = false)
|
419
422
|
super
|
@@ -572,7 +575,7 @@ module Rails
|
|
572
575
|
end
|
573
576
|
|
574
577
|
def dockerfile_base_packages
|
575
|
-
# Add curl to work with the default
|
578
|
+
# Add curl to work with the default health check strategy in Kamal
|
576
579
|
packages = ["curl"]
|
577
580
|
|
578
581
|
# ActiveRecord databases
|
@@ -620,10 +623,10 @@ module Rails
|
|
620
623
|
end
|
621
624
|
|
622
625
|
def cable_gemfile_entry
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
626
|
+
if !options[:skip_action_cable] && options[:skip_solid]
|
627
|
+
comment = "Use Redis adapter to run Action Cable in production"
|
628
|
+
GemfileEntry.new("redis", ">= 4.0.1", comment, {}, true)
|
629
|
+
end
|
627
630
|
end
|
628
631
|
|
629
632
|
def bundle_command(command, env = {})
|
@@ -656,10 +659,6 @@ module Rails
|
|
656
659
|
!(options[:skip_bundle] || options[:pretend])
|
657
660
|
end
|
658
661
|
|
659
|
-
def bundler_windows_platforms
|
660
|
-
Gem.rubygems_version >= Gem::Version.new("3.3.22") ? "windows" : "mswin mswin64 mingw x64_mingw"
|
661
|
-
end
|
662
|
-
|
663
662
|
def depends_on_system_test?
|
664
663
|
!(options[:skip_system_test] || options[:skip_test] || options[:api])
|
665
664
|
end
|
@@ -721,6 +720,25 @@ module Rails
|
|
721
720
|
end
|
722
721
|
end
|
723
722
|
|
723
|
+
def run_kamal
|
724
|
+
return if options[:skip_kamal] || !bundle_install?
|
725
|
+
|
726
|
+
bundle_command "binstubs kamal"
|
727
|
+
bundle_command "exec kamal init"
|
728
|
+
|
729
|
+
template "kamal-secrets.tt", ".kamal/secrets", force: true
|
730
|
+
template "config/deploy.yml", force: true
|
731
|
+
end
|
732
|
+
|
733
|
+
def run_solid
|
734
|
+
return if skip_solid? || !bundle_install?
|
735
|
+
|
736
|
+
commands = "solid_cache:install solid_queue:install"
|
737
|
+
commands += " solid_cable:install" unless skip_action_cable?
|
738
|
+
|
739
|
+
rails_command commands
|
740
|
+
end
|
741
|
+
|
724
742
|
def add_bundler_platforms
|
725
743
|
if bundle_install?
|
726
744
|
# The vast majority of Rails apps will be deployed on `x86_64-linux`.
|
@@ -423,10 +423,6 @@ module Rails
|
|
423
423
|
path = File.expand_path(File.join(base_name, generator_name), base_root)
|
424
424
|
path if File.exist?(path)
|
425
425
|
end
|
426
|
-
|
427
|
-
def gem_ruby_version
|
428
|
-
Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION
|
429
|
-
end
|
430
426
|
end
|
431
427
|
end
|
432
428
|
end
|
@@ -3,25 +3,91 @@
|
|
3
3
|
module Rails
|
4
4
|
module Generators
|
5
5
|
class Database
|
6
|
-
DATABASES = %w( mysql trilogy postgresql sqlite3 )
|
6
|
+
DATABASES = %w( mysql trilogy postgresql sqlite3 mariadb-mysql mariadb-trilogy )
|
7
|
+
|
8
|
+
module MySQL
|
9
|
+
def name
|
10
|
+
"mysql"
|
11
|
+
end
|
12
|
+
|
13
|
+
def port
|
14
|
+
3306
|
15
|
+
end
|
16
|
+
|
17
|
+
def service
|
18
|
+
{
|
19
|
+
"image" => "mysql/mysql-server:8.0",
|
20
|
+
"restart" => "unless-stopped",
|
21
|
+
"environment" => {
|
22
|
+
"MYSQL_ALLOW_EMPTY_PASSWORD" => "true",
|
23
|
+
"MYSQL_ROOT_HOST" => "%"
|
24
|
+
},
|
25
|
+
"volumes" => ["mysql-data:/var/lib/mysql"],
|
26
|
+
"networks" => ["default"],
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def socket
|
31
|
+
@socket ||= [
|
32
|
+
"/tmp/mysql.sock", # default
|
33
|
+
"/var/run/mysqld/mysqld.sock", # debian/gentoo
|
34
|
+
"/var/tmp/mysql.sock", # freebsd
|
35
|
+
"/var/lib/mysql/mysql.sock", # fedora
|
36
|
+
"/opt/local/lib/mysql/mysql.sock", # fedora
|
37
|
+
"/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
|
38
|
+
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
39
|
+
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
|
40
|
+
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
|
41
|
+
].find { |f| File.exist?(f) } unless Gem.win_platform?
|
42
|
+
end
|
43
|
+
|
44
|
+
def host
|
45
|
+
"127.0.0.1"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module MariaDB
|
50
|
+
def name
|
51
|
+
"mariadb"
|
52
|
+
end
|
53
|
+
|
54
|
+
def port
|
55
|
+
3306
|
56
|
+
end
|
57
|
+
|
58
|
+
def service
|
59
|
+
{
|
60
|
+
"image" => "mariadb:10.5",
|
61
|
+
"restart" => "unless-stopped",
|
62
|
+
"networks" => ["default"],
|
63
|
+
"volumes" => ["mariadb-data:/var/lib/mysql"],
|
64
|
+
"environment" => {
|
65
|
+
"MARIADB_ALLOW_EMPTY_ROOT_PASSWORD" => "true",
|
66
|
+
},
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
7
70
|
|
8
71
|
class << self
|
9
72
|
def build(database_name)
|
10
73
|
case database_name
|
11
|
-
when "mysql" then
|
74
|
+
when "mysql" then MySQL2.new
|
12
75
|
when "postgresql" then PostgreSQL.new
|
13
|
-
when "trilogy" then
|
76
|
+
when "trilogy" then Trilogy.new
|
14
77
|
when "sqlite3" then SQLite3.new
|
78
|
+
when "mariadb-mysql" then MariaDBMySQL2.new
|
79
|
+
when "mariadb-trilogy" then MariaDBTrilogy.new
|
15
80
|
else Null.new
|
16
81
|
end
|
17
82
|
end
|
18
83
|
|
19
84
|
def all
|
20
85
|
@all ||= [
|
21
|
-
|
86
|
+
MySQL2.new,
|
22
87
|
PostgreSQL.new,
|
23
|
-
MariaDB.new,
|
24
88
|
SQLite3.new,
|
89
|
+
MariaDBMySQL2.new,
|
90
|
+
MariaDBTrilogy.new
|
25
91
|
]
|
26
92
|
end
|
27
93
|
end
|
@@ -30,6 +96,10 @@ module Rails
|
|
30
96
|
raise NotImplementedError
|
31
97
|
end
|
32
98
|
|
99
|
+
def template
|
100
|
+
raise NotImplementedError
|
101
|
+
end
|
102
|
+
|
33
103
|
def service
|
34
104
|
raise NotImplementedError
|
35
105
|
end
|
@@ -69,48 +139,11 @@ module Rails
|
|
69
139
|
"#{name}-data"
|
70
140
|
end
|
71
141
|
|
72
|
-
|
73
|
-
|
74
|
-
@socket ||= [
|
75
|
-
"/tmp/mysql.sock", # default
|
76
|
-
"/var/run/mysqld/mysqld.sock", # debian/gentoo
|
77
|
-
"/var/tmp/mysql.sock", # freebsd
|
78
|
-
"/var/lib/mysql/mysql.sock", # fedora
|
79
|
-
"/opt/local/lib/mysql/mysql.sock", # fedora
|
80
|
-
"/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
|
81
|
-
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
82
|
-
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
|
83
|
-
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
|
84
|
-
].find { |f| File.exist?(f) } unless Gem.win_platform?
|
85
|
-
end
|
86
|
-
|
87
|
-
def host
|
88
|
-
"localhost"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class MySQL < Database
|
93
|
-
include MySqlSocket
|
142
|
+
class MySQL2 < Database
|
143
|
+
include MySQL
|
94
144
|
|
95
|
-
def
|
96
|
-
"mysql"
|
97
|
-
end
|
98
|
-
|
99
|
-
def service
|
100
|
-
{
|
101
|
-
"image" => "mysql/mysql-server:8.0",
|
102
|
-
"restart" => "unless-stopped",
|
103
|
-
"environment" => {
|
104
|
-
"MYSQL_ALLOW_EMPTY_PASSWORD" => "true",
|
105
|
-
"MYSQL_ROOT_HOST" => "%"
|
106
|
-
},
|
107
|
-
"volumes" => ["mysql-data:/var/lib/mysql"],
|
108
|
-
"networks" => ["default"],
|
109
|
-
}
|
110
|
-
end
|
111
|
-
|
112
|
-
def port
|
113
|
-
3306
|
145
|
+
def template
|
146
|
+
"config/databases/mysql.yml"
|
114
147
|
end
|
115
148
|
|
116
149
|
def gem
|
@@ -135,6 +168,10 @@ module Rails
|
|
135
168
|
"postgres"
|
136
169
|
end
|
137
170
|
|
171
|
+
def template
|
172
|
+
"config/databases/postgresql.yml"
|
173
|
+
end
|
174
|
+
|
138
175
|
def service
|
139
176
|
{
|
140
177
|
"image" => "postgres:16.1",
|
@@ -169,27 +206,11 @@ module Rails
|
|
169
206
|
end
|
170
207
|
end
|
171
208
|
|
172
|
-
class
|
173
|
-
include
|
209
|
+
class Trilogy < Database
|
210
|
+
include MySQL
|
174
211
|
|
175
|
-
def
|
176
|
-
"
|
177
|
-
end
|
178
|
-
|
179
|
-
def service
|
180
|
-
{
|
181
|
-
"image" => "mariadb:10.5",
|
182
|
-
"restart" => "unless-stopped",
|
183
|
-
"networks" => ["default"],
|
184
|
-
"volumes" => ["mariadb-data:/var/lib/mysql"],
|
185
|
-
"environment" => {
|
186
|
-
"MARIADB_ALLOW_EMPTY_ROOT_PASSWORD" => "true",
|
187
|
-
},
|
188
|
-
}
|
189
|
-
end
|
190
|
-
|
191
|
-
def port
|
192
|
-
3306
|
212
|
+
def template
|
213
|
+
"config/databases/trilogy.yml"
|
193
214
|
end
|
194
215
|
|
195
216
|
def gem
|
@@ -214,6 +235,10 @@ module Rails
|
|
214
235
|
"sqlite3"
|
215
236
|
end
|
216
237
|
|
238
|
+
def template
|
239
|
+
"config/databases/sqlite3.yml"
|
240
|
+
end
|
241
|
+
|
217
242
|
def service
|
218
243
|
nil
|
219
244
|
end
|
@@ -223,7 +248,7 @@ module Rails
|
|
223
248
|
end
|
224
249
|
|
225
250
|
def gem
|
226
|
-
["sqlite3", [">= 1
|
251
|
+
["sqlite3", [">= 2.1"]]
|
227
252
|
end
|
228
253
|
|
229
254
|
def base_package
|
@@ -239,8 +264,17 @@ module Rails
|
|
239
264
|
end
|
240
265
|
end
|
241
266
|
|
267
|
+
class MariaDBMySQL2 < MySQL2
|
268
|
+
include MariaDB
|
269
|
+
end
|
270
|
+
|
271
|
+
class MariaDBTrilogy < Trilogy
|
272
|
+
include MariaDB
|
273
|
+
end
|
274
|
+
|
242
275
|
class Null < Database
|
243
276
|
def name; end
|
277
|
+
def template; end
|
244
278
|
def service; end
|
245
279
|
def port; end
|
246
280
|
def volume; end
|