Skip to content

Commit

Permalink
Require Rails 7.2 in web template
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-antonopoulos committed Nov 1, 2024
1 parent 947dccf commit eef59b4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/install/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ def node_version_unsupported?
node_version < "20.0.0"
end

def rails_version
version = `rails --version`[/\d+\.\d+\.\d+/]

return if version.blank?

Gem::Version.new(version)
end

def rails_version_unsupported?
minimum_rails_version = Gem::Version.new("7.2.0")

rails_version < minimum_rails_version
end

def apply_template!
if node_not_installed? || node_version_unsupported?
message = <<~ERROR
Expand All @@ -22,6 +36,22 @@ def apply_template!

fail Rails::Generators::Error, message
end

if rails_version_unsupported?
message = <<~ERROR
=== Rails version unsupported for creating new apps ===
Suspenders requires Rails >= 7.2.0 when creating a **new** app.
Suspenders can be added to an **existing** app meeting "~> 7.0.0".
ERROR

fail Rails::Generators::Error, message
end

if options[:database] == "postgresql" && options[:skip_test] && options[:skip_rubocop]
after_bundle do
gem_group :development, :test do
Expand Down

0 comments on commit eef59b4

Please sign in to comment.