-
Notifications
You must be signed in to change notification settings - Fork 380
Upgrade React on Rails to 16.0.1.rc.4 with enhanced dev tools #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
55c2194
d088c2e
ea788b7
c3bbc27
8427012
d56639e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# You can run these commands in separate shells | ||
web: bin/rails s -p 3001 | ||
redis: redis-server | ||
|
||
# Next line runs a watch process with webpack to compile the changed files. | ||
# When making frequent changes to client side assets, you will prefer building webpack assets | ||
# upon saving rather than when you refresh your browser page. | ||
# Note, if using React on Rails localization you will need to run | ||
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker | ||
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w' | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# You can run these commands in separate shells | ||
web: bin/rails s -p 3000 | ||
redis: redis-server | ||
|
||
# Next line runs a watch process with webpack to compile the changed files. | ||
# When making frequent changes to client side assets, you will prefer building webpack assets | ||
# upon saving rather than when you refresh your browser page. | ||
# Note, if using React on Rails localization you will need to run | ||
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker | ||
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
def installed?(process) | ||
IO.popen "#{process} -v" | ||
rescue Errno::ENOENT | ||
false | ||
end | ||
# ReactOnRails Development Server | ||
# | ||
# This script provides a simple interface to the ReactOnRails development | ||
# server management. The core logic is implemented in ReactOnRails::Dev | ||
# classes for better maintainability and testing. | ||
# | ||
# Each command uses a specific Procfile for process management: | ||
# - bin/dev (default/hmr): Uses Procfile.dev | ||
# - bin/dev static: Uses Procfile.dev-static-assets-assets | ||
# - bin/dev prod: Uses Procfile.dev-prod-assets | ||
# | ||
# To customize development environment: | ||
# 1. Edit the appropriate Procfile to modify which processes run | ||
# 2. Modify this script for project-specific command-line behavior | ||
# 3. Extend ReactOnRails::Dev classes in your Rails app for advanced customization | ||
# 4. Use classes directly: ReactOnRails::Dev::ServerManager.start(:development, "Custom.procfile") | ||
|
||
def run(process) | ||
system "#{process} start -f Procfile.dev" | ||
rescue Errno::ENOENT | ||
warn <<~MSG | ||
ERROR: | ||
Please ensure `Procfile.dev` exists in your project! | ||
MSG | ||
exit! | ||
begin | ||
require "bundler/setup" | ||
require "react_on_rails/dev" | ||
rescue LoadError | ||
# Fallback for when gem is not yet installed | ||
puts "Loading ReactOnRails development tools..." | ||
require_relative "../../lib/react_on_rails/dev" | ||
end | ||
Comment on lines
+21
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect require_relative path; fallback wonβt find local dev code. From bin/dev, "../../lib/β¦" is one directory too high. Also prefer stderr for the notice and a single rescue covering only the gem require. Apply: -begin
- require "bundler/setup"
- require "react_on_rails/dev"
-rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
-end
+begin
+ require "bundler/setup"
+ require "react_on_rails/dev"
+rescue LoadError
+ # Fallback when gem not installed
+ warn "Loading ReactOnRails development tools from local lib..."
+ require_relative File.expand_path("../lib/react_on_rails/dev", __dir__)
+end
π€ Prompt for AI Agents
|
||
|
||
if installed? "overmind" | ||
run "overmind" | ||
elsif installed? "foreman" | ||
run "foreman" | ||
else | ||
warn <<~MSG | ||
NOTICE: | ||
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them. | ||
MSG | ||
exit! | ||
end | ||
# Main execution | ||
ReactOnRails::Dev::ServerManager.run_from_command_line(ARGV) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,30 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#!/usr/bin/env ruby | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# frozen_string_literal: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def installed?(process) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IO.popen "#{process} -v" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rescue Errno::ENOENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# ReactOnRails Development Server - Static Assets Mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# This runs development with static assets instead of HMR. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Useful when you want faster startup or HMR is causing issues. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def run(process) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
system "#{process} start -f Procfile.dev-static" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rescue Errno::ENOENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
warn <<~MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ERROR: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Please ensure `Procfile.dev-static` exists in your project! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exit! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
require "bundler/setup" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
require "react_on_rails/dev" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rescue LoadError | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Fallback for when gem is not yet installed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
puts "Loading ReactOnRails development tools..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
require_relative "../../lib/react_on_rails/dev" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if installed? "overmind" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run "overmind" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elsif installed? "foreman" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run "foreman" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
warn <<~MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
NOTICE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MSG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exit! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Force static mode by passing 'static' argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ReactOnRails::Dev::ServerManager.run_from_command_line(["static"]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+9
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainFallback require path is wrong; breaks when gem isnβt installed. bin/dev-static lives in project/bin, so require_relative should go up one, not two. -rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
+rescue LoadError
+ # Fallback for when gem is not yet installed
+ puts "Loading ReactOnRails development tools..."
+ require_relative "../lib/react_on_rails/dev" Also ensure this file has +x perms and is referenced in docs. π Script executed: #!/bin/bash
set -euo pipefail
test -x bin/dev-static && echo "bin/dev-static is executable" || { echo "chmod +x bin/dev-static"; exit 1; } Length of output: 28 π Script executed: #!/bin/bash
set -euo pipefail
echo "PWD: $(pwd -P)"
echo
echo "Root listing:"
ls -la | sed -n '1,200p' || true
echo
echo "---- bin/dev-static (first 200 lines) ----"
if [ -f bin/dev-static ]; then
sed -n '1,200p' bin/dev-static
else
echo "bin/dev-static not found"
exit 0
fi
echo
echo "---- require_relative lines in repo ----"
if command -v rg >/dev/null 2>&1; then
rg -n "require_relative" --hidden --no-ignore || true
else
grep -RIn --exclude-dir=.git "require_relative" . || true
fi
echo
echo "---- File existence checks ----"
if [ -f lib/react_on_rails/dev.rb ]; then
echo "FOUND: lib/react_on_rails/dev.rb"
else
echo "MISSING: lib/react_on_rails/dev.rb"
fi
if [ -f bin/../lib/react_on_rails/dev.rb ]; then
echo "FOUND: bin/../lib/react_on_rails/dev.rb"
else
echo "MISSING: bin/../lib/react_on_rails/dev.rb"
fi
if [ -f bin/../../lib/react_on_rails/dev.rb ]; then
echo "FOUND: bin/../../lib/react_on_rails/dev.rb"
else
echo "MISSING: bin/../../lib/react_on_rails/dev.rb"
fi
echo
echo "---- Search repo for references to 'dev-static' ----"
if command -v rg >/dev/null 2>&1; then
rg -n --hidden --no-ignore 'dev-static' || true
else
grep -RIn --exclude-dir=.git 'dev-static' . || true
fi Length of output: 4710 Fix fallback require_relative path and restore missing fallback file
-rescue LoadError
- # Fallback for when gem is not yet installed
- puts "Loading ReactOnRails development tools..."
- require_relative "../../lib/react_on_rails/dev"
+rescue LoadError
+ # Fallback for when gem is not yet installed
+ puts "Loading ReactOnRails development tools..."
+ require_relative "../lib/react_on_rails/dev"
π Committable suggestion
Suggested change
π€ Prompt for AI Agents
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Prod assets" file currently builds dev watch; align with production mode.
This Procfile claims production assets but uses a watch and no production env. Switch to a one-time production build and run Rails with production env (and static files).
Optionally export SECRET_KEY_BASE/RAILS_MASTER_KEY via your process manager if required.
π Committable suggestion
π€ Prompt for AI Agents