lib/rails/generators/app_base.rb in railties-7.2.2 vs lib/rails/generators/app_base.rb in railties-8.0.0.beta1
- old
+ new
@@ -17,11 +17,10 @@
NODE_LTS_VERSION = "20.11.1"
BUN_VERSION = "1.0.1"
JAVASCRIPT_OPTIONS = %w( importmap bun webpack esbuild rollup )
CSS_OPTIONS = %w( tailwind bootstrap bulma postcss sass )
- ASSET_PIPELINE_OPTIONS = %w( none sprockets propshaft )
attr_accessor :rails_template
add_shebang_option!
argument :app_path, type: :string
@@ -72,14 +71,10 @@
class_option :skip_action_cable, type: :boolean, aliases: "-C", default: nil,
desc: "Skip Action Cable files"
class_option :skip_asset_pipeline, type: :boolean, aliases: "-A", default: nil
- class_option :asset_pipeline, type: :string, aliases: "-a", default: "sprockets",
- enum: ASSET_PIPELINE_OPTIONS,
- desc: "Choose your asset pipeline"
-
class_option :skip_javascript, type: :boolean, aliases: ["-J", "--skip-js"], default: (true if name == "plugin"),
desc: "Skip JavaScript files"
class_option :skip_hotwire, type: :boolean, default: nil,
desc: "Skip Hotwire integration"
@@ -97,23 +92,32 @@
desc: "Skip bootsnap gem"
class_option :skip_dev_gems, type: :boolean, default: nil,
desc: "Skip development gems (e.g., web-console)"
+ class_option :skip_thruster, type: :boolean, default: nil,
+ desc: "Skip Thruster setup"
+
class_option :skip_rubocop, type: :boolean, default: nil,
desc: "Skip RuboCop setup"
class_option :skip_brakeman, type: :boolean, default: nil,
desc: "Skip brakeman setup"
class_option :skip_ci, type: :boolean, default: nil,
desc: "Skip GitHub CI files"
+ class_option :skip_kamal, type: :boolean, default: nil,
+ desc: "Skip Kamal setup"
+
+ class_option :skip_solid, type: :boolean, default: nil,
+ desc: "Skip Solid Cache & Queue setup"
+
class_option :dev, type: :boolean, default: nil,
desc: "Set up the #{name} with Gemfile pointing to your Rails checkout"
- class_option :devcontainer, type: :boolean, default: false,
+ class_option :devcontainer, type: :boolean, default: nil,
desc: "Generate devcontainer files"
class_option :edge, type: :boolean, default: nil,
desc: "Set up the #{name} with a Gemfile pointing to the #{edge_branch} branch on the Rails repository"
@@ -195,11 +199,11 @@
end.to_h
end
OPTION_IMPLICATIONS = { # :nodoc:
skip_active_job: [:skip_action_mailer, :skip_active_storage],
- skip_active_record: [:skip_active_storage],
+ skip_active_record: [:skip_active_storage, :skip_solid],
skip_active_storage: [:skip_action_mailbox, :skip_action_text],
skip_javascript: [:skip_hotwire],
}
# ==== Options
@@ -285,16 +289,11 @@
def web_server_gemfile_entry # :doc:
GemfileEntry.new "puma", ">= 5.0", "Use the Puma web server [https://github.com/puma/puma]"
end
def asset_pipeline_gemfile_entry
- return if skip_asset_pipeline?
-
- if options[:asset_pipeline] == "sprockets"
- GemfileEntry.floats "sprockets-rails",
- "The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]"
- elsif options[:asset_pipeline] == "propshaft"
+ unless skip_asset_pipeline?
GemfileEntry.floats "propshaft", "The modern asset pipeline for Rails [https://github.com/rails/propshaft]"
end
end
def required_railties
@@ -384,18 +383,14 @@
def skip_asset_pipeline? # :doc:
options[:skip_asset_pipeline]
end
- def skip_sprockets?
- skip_asset_pipeline? || options[:asset_pipeline] != "sprockets"
+ def skip_thruster?
+ options[:skip_thruster]
end
- def skip_propshaft?
- skip_asset_pipeline? || options[:asset_pipeline] != "propshaft"
- end
-
def skip_rubocop?
options[:skip_rubocop]
end
def skip_brakeman?
@@ -412,10 +407,18 @@
def devcontainer?
options[:devcontainer]
end
+ def skip_kamal?
+ options[:skip_kamal]
+ end
+
+ def skip_solid?
+ options[:skip_solid]
+ end
+
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
def initialize(name, version, comment, options = {}, commented_out = false)
super
end
@@ -570,11 +573,11 @@
binfixups
end
def dockerfile_base_packages
- # Add curl to work with the default healthcheck strategy in Kamal
+ # Add curl to work with the default health check strategy in Kamal
packages = ["curl"]
# ActiveRecord databases
packages << database.base_package unless skip_active_record?
@@ -618,14 +621,14 @@
GemfileEntry.floats "cssbundling-rails", "Bundle and process CSS [https://github.com/rails/cssbundling-rails]"
end
end
def cable_gemfile_entry
- return if options[:skip_action_cable]
-
- comment = "Use Redis adapter to run Action Cable in production"
- GemfileEntry.new("redis", ">= 4.0.1", comment, {}, true)
+ if !options[:skip_action_cable] && options[:skip_solid]
+ comment = "Use Redis adapter to run Action Cable in production"
+ GemfileEntry.new("redis", ">= 4.0.1", comment, {}, true)
+ end
end
def bundle_command(command, env = {})
say_status :run, "bundle #{command}"
@@ -717,9 +720,28 @@
elsif !using_js_runtime? && options[:css] == "sass"
rails_command "dartsass:install"
else
rails_command "css:install:#{options[:css]}"
end
+ end
+
+ def run_kamal
+ return if options[:skip_kamal] || !bundle_install?
+
+ bundle_command "binstubs kamal"
+ bundle_command "exec kamal init"
+
+ template "kamal-secrets.tt", ".kamal/secrets", force: true
+ template "config/deploy.yml", force: true
+ end
+
+ def run_solid
+ return if skip_solid? || !bundle_install?
+
+ commands = "solid_cache:install solid_queue:install"
+ commands += " solid_cable:install" unless skip_action_cable?
+
+ rails_command commands
end
def add_bundler_platforms
if bundle_install?
# The vast majority of Rails apps will be deployed on `x86_64-linux`.