@@ -103,37 +103,6 @@ def add_js_dependencies
103
103
install_js_dependencies
104
104
end
105
105
106
- private
107
-
108
- def install_js_dependencies
109
- # Detect which package manager to use
110
- success = if File . exist? ( File . join ( destination_root , "yarn.lock" ) )
111
- run "yarn install"
112
- elsif File . exist? ( File . join ( destination_root , "pnpm-lock.yaml" ) )
113
- run "pnpm install"
114
- elsif File . exist? ( File . join ( destination_root , "package-lock.json" ) ) ||
115
- File . exist? ( File . join ( destination_root , "package.json" ) )
116
- # Use npm for package-lock.json or as default fallback
117
- run "npm install"
118
- else
119
- true # No package manager detected, skip
120
- end
121
-
122
- unless success
123
- GeneratorMessages . add_warning ( <<~MSG . strip )
124
- ⚠️ JavaScript dependencies installation failed.
125
-
126
- This could be due to network issues or missing package manager.
127
- You can install dependencies manually later by running:
128
- • npm install (if using npm)
129
- • yarn install (if using yarn)
130
- • pnpm install (if using pnpm)
131
- MSG
132
- end
133
-
134
- success
135
- end
136
-
137
106
def update_gitignore_for_auto_registration
138
107
gitignore_path = File . join ( destination_root , ".gitignore" )
139
108
return unless File . exist? ( gitignore_path )
@@ -160,6 +129,8 @@ def append_to_spec_rails_helper
160
129
end
161
130
end
162
131
132
+ private
133
+
163
134
def add_react_on_rails_package
164
135
major_minor_patch_only = /\A \d +\. \d +\. \d +\z /
165
136
@@ -222,6 +193,35 @@ def add_dev_dependencies
222
193
handle_npm_failure ( "development dependencies" , dev_deps , dev : true ) unless success
223
194
end
224
195
196
+ def install_js_dependencies
197
+ # Detect which package manager to use
198
+ success = if File . exist? ( File . join ( destination_root , "yarn.lock" ) )
199
+ run "yarn install"
200
+ elsif File . exist? ( File . join ( destination_root , "pnpm-lock.yaml" ) )
201
+ run "pnpm install"
202
+ elsif File . exist? ( File . join ( destination_root , "package-lock.json" ) ) ||
203
+ File . exist? ( File . join ( destination_root , "package.json" ) )
204
+ # Use npm for package-lock.json or as default fallback
205
+ run "npm install"
206
+ else
207
+ true # No package manager detected, skip
208
+ end
209
+
210
+ unless success
211
+ GeneratorMessages . add_warning ( <<~MSG . strip )
212
+ ⚠️ JavaScript dependencies installation failed.
213
+
214
+ This could be due to network issues or missing package manager.
215
+ You can install dependencies manually later by running:
216
+ • npm install (if using npm)
217
+ • yarn install (if using yarn)
218
+ • pnpm install (if using pnpm)
219
+ MSG
220
+ end
221
+
222
+ success
223
+ end
224
+
225
225
CONFIGURE_RSPEC_TO_COMPILE_ASSETS = <<-STR . strip_heredoc
226
226
RSpec.configure do |config|
227
227
# Ensure that if we are running js tests, we are using latest webpack assets
@@ -230,8 +230,6 @@ def add_dev_dependencies
230
230
end
231
231
STR
232
232
233
- private
234
-
235
233
def handle_npm_failure ( dependency_type , packages , dev : false )
236
234
install_command = dev ? "npm install --save-dev" : "npm install"
237
235
GeneratorMessages . add_warning ( <<~MSG . strip )
0 commit comments