-
-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathweb.rb
54 lines (39 loc) · 1.06 KB
/
web.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def node_version
ENV["NODE_VERSION"] || `node --version`[/\d+\.\d+\.\d+/]
end
def node_not_installed?
!node_version.present?
end
def node_version_unsupported?
node_version < "20.0.0"
end
def apply_template!
if node_not_installed? || node_version_unsupported?
message = <<~ERROR
=== Node version unsupported ===
Suspenders requires Node >= 20.0.0
ERROR
fail Rails::Generators::Error, message
end
if options[:database] == "postgresql" && options[:skip_test]
after_bundle do
gem_group :development, :test do
gem "suspenders"
end
run "bundle install"
generate "suspenders:install:web"
rails_command "db:prepare"
say "\nCongratulations! You just pulled our suspenders."
end
else
message = <<~ERROR
=== Please use the correct options ===
rails new <app_name> \\
--skip-test \\
-d=postgresql \\
-m=https://raw.githubusercontent.com/thoughtbot/suspenders/main/lib/install/web.rb
ERROR
fail Rails::Generators::Error, message
end
end
apply_template!