Skip to content

Commit cc1135e

Browse files
justin808claude
andcommitted
Improve bin/dev generated script with hello_world default route
- Add DEFAULT_ROUTE variable in generated bin/dev template - Automatically append --route hello_world when no route specified - Remove confusing fallback code from generator template - Keep fallback in spec/dummy/bin/dev with clear comments for gem development - Improve developer experience: ./bin/dev now goes directly to generated component 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 622eecc commit cc1135e

File tree

1 file changed

+14
-9
lines changed
  • lib/generators/react_on_rails/templates/base/base/bin

1 file changed

+14
-9
lines changed

lib/generators/react_on_rails/templates/base/base/bin/dev

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@
1818
# 3. Extend ReactOnRails::Dev classes in your Rails app for advanced customization
1919
# 4. Use classes directly: ReactOnRails::Dev::ServerManager.start(:development, "Custom.procfile")
2020

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"
28-
end
21+
require "bundler/setup"
22+
require "react_on_rails/dev"
23+
24+
# Default route configuration
25+
# This is set by the ReactOnRails installer to point to your generated component.
26+
# Change this to your preferred default route, or pass --route=<route> to override.
27+
DEFAULT_ROUTE = "hello_world"
2928

3029
# Main execution
31-
ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV)
30+
# Add the default route to ARGV if no --route option is provided
31+
argv_with_defaults = ARGV.dup
32+
unless argv_with_defaults.any? { |arg| arg.start_with?("--route") }
33+
argv_with_defaults.push("--route", DEFAULT_ROUTE)
34+
end
35+
36+
ReactOnRails::Dev::ServerManager.run_from_command_line(argv_with_defaults)

0 commit comments

Comments
 (0)