| 
1 | 1 | #!/usr/bin/env ruby  | 
2 | 2 | # frozen_string_literal: true  | 
3 | 3 | 
 
  | 
4 |  | -def installed?(process)  | 
5 |  | -  IO.popen "#{process} -v"  | 
6 |  | -rescue Errno::ENOENT  | 
7 |  | -  false  | 
8 |  | -end  | 
 | 4 | +# ReactOnRails Development Server  | 
 | 5 | +#  | 
 | 6 | +# This script provides a simple interface to the ReactOnRails development  | 
 | 7 | +# server management. The core logic is implemented in ReactOnRails::Dev  | 
 | 8 | +# classes for better maintainability and testing.  | 
 | 9 | +#  | 
 | 10 | +# Each command uses a specific Procfile for process management:  | 
 | 11 | +# - bin/dev (default/hmr): Uses Procfile.dev  | 
 | 12 | +# - bin/dev static: Uses Procfile.dev-static-assets-assets  | 
 | 13 | +# - bin/dev prod: Uses Procfile.dev-prod-assets  | 
 | 14 | +#  | 
 | 15 | +# To customize development environment:  | 
 | 16 | +# 1. Edit the appropriate Procfile to modify which processes run  | 
 | 17 | +# 2. Modify this script for project-specific command-line behavior  | 
 | 18 | +# 3. Extend ReactOnRails::Dev classes in your Rails app for advanced customization  | 
 | 19 | +# 4. Use classes directly: ReactOnRails::Dev::ServerManager.start(:development, "Custom.procfile")  | 
9 | 20 | 
 
  | 
10 |  | -def run(process)  | 
11 |  | -  system "#{process} start -f Procfile.dev"  | 
12 |  | -rescue Errno::ENOENT  | 
13 |  | -  warn <<~MSG  | 
14 |  | -    ERROR:  | 
15 |  | -    Please ensure `Procfile.dev` exists in your project!  | 
16 |  | -  MSG  | 
17 |  | -  exit!  | 
 | 21 | +begin  | 
 | 22 | +  require "bundler/setup"  | 
 | 23 | +  require "react_on_rails/dev"  | 
 | 24 | +rescue LoadError  | 
 | 25 | +  # Fallback for when gem is not yet installed  | 
 | 26 | +  puts "Loading ReactOnRails development tools..."  | 
 | 27 | +  require_relative "../../lib/react_on_rails/dev"  | 
18 | 28 | end  | 
19 | 29 | 
 
  | 
20 |  | -if installed? "overmind"  | 
21 |  | -  run "overmind"  | 
22 |  | -elsif installed? "foreman"  | 
23 |  | -  run "foreman"  | 
24 |  | -else  | 
25 |  | -  warn <<~MSG  | 
26 |  | -    NOTICE:  | 
27 |  | -    For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them.  | 
28 |  | -  MSG  | 
29 |  | -  exit!  | 
30 |  | -end  | 
 | 30 | +# Main execution  | 
 | 31 | +ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV)  | 
0 commit comments