11# frozen_string_literal: true 
22
33require  "json" 
4+ require_relative  "utils" 
45require_relative  "system_checker" 
56
67begin 
@@ -120,6 +121,7 @@ def check_webpack
120121    def  check_development 
121122      check_javascript_bundles 
122123      check_procfile_dev 
124+       check_bin_dev_script 
123125      check_gitignore 
124126    end 
125127
@@ -138,21 +140,93 @@ def check_javascript_bundles
138140    end 
139141
140142    def  check_procfile_dev 
141-       procfile_dev  =  "Procfile.dev" 
142-       if  File . exist? ( procfile_dev ) 
143-         checker . add_success ( "✅ Procfile.dev exists for development" ) 
144-         check_procfile_content 
143+       check_procfiles 
144+     end 
145+ 
146+     def  check_procfiles 
147+       procfiles  =  { 
148+         "Procfile.dev"  =>  { 
149+           description : "HMR development with webpack-dev-server" , 
150+           required_for : "bin/dev (default/hmr mode)" , 
151+           should_contain : [ "shakapacker-dev-server" ,  "rails server" ] 
152+         } , 
153+         "Procfile.dev-static-assets"  =>  { 
154+           description : "Static development with webpack --watch" , 
155+           required_for : "bin/dev static" , 
156+           should_contain : [ "shakapacker" ,  "rails server" ] 
157+         } , 
158+         "Procfile.dev-prod-assets"  =>  { 
159+           description : "Production-optimized assets development" , 
160+           required_for : "bin/dev prod" , 
161+           should_contain : [ "rails server" ] 
162+         } 
163+       } 
164+ 
165+       procfiles . each  do  |filename ,  config |
166+         check_individual_procfile ( filename ,  config ) 
167+       end 
168+ 
169+       # Check if at least Procfile.dev exists 
170+       if  File . exist? ( "Procfile.dev" ) 
171+         checker . add_success ( "✅ Essential Procfiles available for bin/dev script" ) 
172+       else 
173+         checker . add_warning ( <<~MSG . strip ) 
174+           ⚠️  Procfile.dev missing - required for bin/dev development server 
175+           Run 'rails generate react_on_rails:install' to generate required Procfiles 
176+         MSG 
177+       end 
178+     end 
179+ 
180+     def  check_individual_procfile ( filename ,  config ) 
181+       if  File . exist? ( filename ) 
182+         checker . add_success ( "✅ #{ filename } #{ config [ :description ] }  ) 
183+ 
184+         content  =  File . read ( filename ) 
185+         config [ :should_contain ] . each  do  |expected_content |
186+           if  content . include? ( expected_content ) 
187+             checker . add_success ( "  ✓ Contains #{ expected_content }  ) 
188+           else 
189+             checker . add_info ( "  ℹ️  Could include #{ expected_content } #{ config [ :description ] }  ) 
190+           end 
191+         end 
192+       else 
193+         checker . add_info ( "ℹ️  #{ filename } #{ config [ :required_for ] }  ) 
194+       end 
195+     end 
196+ 
197+     def  check_bin_dev_script 
198+       bin_dev_path  =  "bin/dev" 
199+       if  File . exist? ( bin_dev_path ) 
200+         checker . add_success ( "✅ bin/dev script exists" ) 
201+         check_bin_dev_content ( bin_dev_path ) 
145202      else 
146-         checker . add_info ( "ℹ️  Procfile.dev not found (optional for development)" ) 
203+         checker . add_warning ( <<~MSG . strip ) 
204+           ⚠️  bin/dev script missing 
205+           This script provides an enhanced development workflow with HMR, static, and production modes. 
206+           Run 'rails generate react_on_rails:install' to generate the script. 
207+         MSG 
147208      end 
148209    end 
149210
150-     def  check_procfile_content 
151-       content  =  File . read ( "Procfile.dev" ) 
152-       if  content . include? ( "shakapacker-dev-server" ) 
153-         checker . add_success ( "✅ Procfile.dev includes webpack dev server" ) 
211+     def  check_bin_dev_content ( bin_dev_path ) 
212+       return  unless  File . exist? ( bin_dev_path ) 
213+ 
214+       content  =  File . read ( bin_dev_path ) 
215+ 
216+       # Check if it's using the new ReactOnRails::Dev::ServerManager 
217+       if  content . include? ( "ReactOnRails::Dev::ServerManager" ) 
218+         checker . add_success ( "  ✓ Uses enhanced ReactOnRails development server" ) 
219+       elsif  content . include? ( "foreman" )  || content . include? ( "overmind" ) 
220+         checker . add_info ( "  ℹ️  Using basic foreman/overmind - consider upgrading to ReactOnRails enhanced dev script" ) 
154221      else 
155-         checker . add_info ( "ℹ️  Consider adding shakapacker-dev-server to Procfile.dev" ) 
222+         checker . add_info ( "  ℹ️  Custom bin/dev script detected" ) 
223+       end 
224+ 
225+       # Check if it's executable 
226+       if  File . executable? ( bin_dev_path ) 
227+         checker . add_success ( "  ✓ Script is executable" ) 
228+       else 
229+         checker . add_warning ( "  ⚠️  Script is not executable - run 'chmod +x bin/dev'" ) 
156230      end 
157231    end 
158232
@@ -234,6 +308,22 @@ def print_recommendations
234308      if  checker . warnings? 
235309        puts  Rainbow ( "Suggested Improvements:" ) . yellow . bold 
236310        puts  "• Review warnings above for optimization opportunities" 
311+ 
312+         # Enhanced development workflow recommendations 
313+         unless  File . exist? ( "bin/dev" )  && File . read ( "bin/dev" ) . include? ( "ReactOnRails::Dev::ServerManager" ) 
314+           puts  "• #{ Rainbow ( 'Upgrade to enhanced bin/dev script' ) . yellow }  
315+           puts  "  - Run #{ Rainbow ( 'rails generate react_on_rails:install' ) . cyan }  
316+           puts  "  - Provides HMR, static, and production-like asset modes" 
317+           puts  "  - Better error handling and debugging capabilities" 
318+         end 
319+ 
320+         missing_procfiles  =  [ "Procfile.dev-static-assets" ,  "Procfile.dev-prod-assets" ] . reject  {  |f | File . exist? ( f )  } 
321+         unless  missing_procfiles . empty? 
322+           puts  "• #{ Rainbow ( 'Complete development workflow setup' ) . yellow }  
323+           puts  "  - Missing: #{ missing_procfiles . join ( ', ' ) }  
324+           puts  "  - Run #{ Rainbow ( 'rails generate react_on_rails:install' ) . cyan }  
325+         end 
326+ 
237327        puts  "• Consider updating packages to latest compatible versions" 
238328        puts  "• Check documentation for best practices" 
239329        puts 
@@ -260,9 +350,14 @@ def print_next_steps
260350        puts  "• Your setup is healthy! Consider these development workflow steps:" 
261351      end 
262352
263-       # Contextual suggestions based on what exists 
264-       if  File . exist? ( "Procfile.dev" ) 
265-         puts  "• Start development with: ./bin/dev" 
353+       # Enhanced contextual suggestions based on what exists 
354+       if  File . exist? ( "bin/dev" )  && File . exist? ( "Procfile.dev" ) 
355+         puts  "• Start development with HMR: #{ Rainbow ( './bin/dev' ) . cyan }  
356+         puts  "• Try static mode: #{ Rainbow ( './bin/dev static' ) . cyan }  
357+         puts  "• Test production assets: #{ Rainbow ( './bin/dev prod' ) . cyan }  
358+         puts  "• See all options: #{ Rainbow ( './bin/dev help' ) . cyan }  
359+       elsif  File . exist? ( "Procfile.dev" ) 
360+         puts  "• Start development with: #{ Rainbow ( './bin/dev' ) . cyan }  
266361      else 
267362        puts  "• Start Rails server: bin/rails server" 
268363        puts  "• Start webpack dev server: bin/shakapacker-dev-server (in separate terminal)" 
0 commit comments