@@ -103,37 +103,6 @@ def add_js_dependencies
103103 install_js_dependencies
104104 end
105105
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-
137106 def update_gitignore_for_auto_registration
138107 gitignore_path = File . join ( destination_root , ".gitignore" )
139108 return unless File . exist? ( gitignore_path )
@@ -160,6 +129,8 @@ def append_to_spec_rails_helper
160129 end
161130 end
162131
132+ private
133+
163134 def add_react_on_rails_package
164135 major_minor_patch_only = /\A \d +\. \d +\. \d +\z /
165136
@@ -222,6 +193,35 @@ def add_dev_dependencies
222193 handle_npm_failure ( "development dependencies" , dev_deps , dev : true ) unless success
223194 end
224195
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+
225225 CONFIGURE_RSPEC_TO_COMPILE_ASSETS = <<-STR . strip_heredoc
226226 RSpec.configure do |config|
227227 # Ensure that if we are running js tests, we are using latest webpack assets
@@ -230,8 +230,6 @@ def add_dev_dependencies
230230 end
231231 STR
232232
233- private
234-
235233 def handle_npm_failure ( dependency_type , packages , dev : false )
236234 install_command = dev ? "npm install --save-dev" : "npm install"
237235 GeneratorMessages . add_warning ( <<~MSG . strip )
0 commit comments