Skip to content

Commit da7f61b

Browse files
committed
wip
1 parent 4be1e1b commit da7f61b

File tree

10 files changed

+84
-85
lines changed

10 files changed

+84
-85
lines changed

Gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
ruby "3.3.4"
77

8-
gem "react_on_rails", "14.1.0.rc.0"
8+
# gem "react_on_rails", "14.1.0.rc.0"
9+
gem 'react_on_rails', path: '../../../shakacode/react-on-rails/react_on_rails_2'
10+
11+
12+
913
gem "shakapacker", "8.0.0"
1014

1115
# Bundle edge Rails instead: gem "rails", github: "rails/rails"

Gemfile.lock

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ GIT
44
specs:
55
net-pop (0.1.2)
66

7+
PATH
8+
remote: ../react_on_rails_2
9+
specs:
10+
react_on_rails (16.0.0)
11+
addressable
12+
connection_pool
13+
execjs (~> 2.5)
14+
rails (>= 5.2)
15+
rainbow (~> 3.0)
16+
shakapacker (>= 6.0)
17+
718
GEM
819
remote: https://rubygems.org/
920
specs:
@@ -289,12 +300,6 @@ GEM
289300
ffi (~> 1.0)
290301
rdoc (6.7.0)
291302
psych (>= 4.0.0)
292-
react_on_rails (14.1.0.rc.0)
293-
addressable
294-
connection_pool
295-
execjs (~> 2.5)
296-
rails (>= 5.2)
297-
rainbow (~> 3.0)
298303
redcarpet (3.6.0)
299304
redis (5.3.0)
300305
redis-client (>= 0.22.0)
@@ -473,7 +478,7 @@ DEPENDENCIES
473478
rails-html-sanitizer
474479
rails_best_practices
475480
rainbow
476-
react_on_rails (= 14.1.0.rc.0)
481+
react_on_rails!
477482
redcarpet
478483
redis (~> 5.0)
479484
rspec-rails (~> 6.0.0)

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# You can run these commands in separate shells
33
rescript: yarn res:dev
44
redis: redis-server
5-
rails: bundle exec rails s -p 3000
5+
rails: bin/rails s -p 3000
66
wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server
77
wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# You can run these commands in separate shells
2-
web: rails s -p 3000
2+
web: bin/rails s -p 3001
33
redis: redis-server
44

55
# Next line runs a watch process with webpack to compile the changed files.

Procfile.dev-static-assets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# You can run these commands in separate shells
2+
web: bin/rails s -p 3000
3+
redis: redis-server
4+
5+
# Next line runs a watch process with webpack to compile the changed files.
6+
# When making frequent changes to client side assets, you will prefer building webpack assets
7+
# upon saving rather than when you refresh your browser page.
8+
# Note, if using React on Rails localization you will need to run
9+
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
10+
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w'

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ See package.json and Gemfile for versions
143143
### Basic Command Line
144144
- Run all linters and tests: `rake`
145145
- See all npm commands: `yarn run`
146-
- To start all development processes: `foreman start -f Procfile.dev`
147-
- To start only all Rails development processes: `foreman start -f Procfile.hot`
146+
- To start development with HMR: `./bin/dev` (or `./bin/dev hmr`)
147+
- To start with static assets: `./bin/dev static`
148+
- To start with production-like assets: `./bin/dev prod`
149+
- For help with options: `./bin/dev help`
148150

149151
## Rails Integration
150152
**We're now using Webpack for all Sass and JavaScript assets so we can do CSS Modules within Rails!**
@@ -162,7 +164,7 @@ See package.json and Gemfile for versions
162164
163165
+ Be sure to see [Integration Test Notes](./docs/integration-test-notes.md) for advice on running your integration tests.
164166
165-
+ **Testing Mode**: When running tests, it is useful to run `foreman start -f Procfile.spec` in order to have webpack automatically recompile the static bundles. Rspec is configured to automatically check whether or not this process is running. If it is not, it will automatically rebuild the webpack bundle to ensure you are not running tests on stale client code. This is achieved via the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)`
167+
+ **Testing Mode**: When running tests, it is useful to run `./bin/dev static` in order to have webpack automatically recompile the static bundles. Rspec is configured to automatically check whether or not this process is running. If it is not, it will automatically rebuild the webpack bundle to ensure you are not running tests on stale client code. This is achieved via the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)`
166168
line in the `rails_helper.rb` file. If you are using this project as an example and are not using RSpec, you may want to implement similar logic in your own project.
167169
168170
## Webpack
@@ -203,12 +205,31 @@ export default class CommentBox extends React.Component {
203205
The tutorial makes use of a custom font OpenSans-Light. We're doing this to show how to add assets for the CSS processing. The font files are located under [client/app/assets/fonts](client/app/assets/fonts) and are loaded by both the Rails asset pipeline and the Webpack HMR server.
204206

205207
## Process management during development
208+
209+
**Recommended approach** using the enhanced `bin/dev` script:
210+
211+
```bash
212+
./bin/dev # HMR development (default)
213+
./bin/dev static # Static assets development
214+
./bin/dev prod # Production-like assets
215+
./bin/dev help # See all options
216+
```
217+
218+
**Advanced options:**
219+
```bash
220+
./bin/dev --route=comments # Custom route in URLs
221+
./bin/dev prod --rails-env=production # Full production environment
222+
```
223+
224+
**Alternative approach** using foreman directly:
206225
```
207226
bundle exec foreman start -f <Procfile>
208227
```
209228

210-
1. [`Procfile.dev`](Procfile.dev): Starts the Webpack Dev Server and Rails with Hot Reloading.
211-
1. [`Procfile.static`](Procfile.dev-static): Starts the Rails server and generates static assets that are used for tests.
229+
Available Procfiles:
230+
1. [`Procfile.dev`](Procfile.dev): Webpack Dev Server and Rails with Hot Reloading
231+
1. [`Procfile.dev-static-assets`](Procfile.dev-static-assets): Rails server with static asset generation
232+
1. [`Procfile.dev-prod-assets`](Procfile.dev-prod-assets): Rails server with production-optimized assets
212233

213234
## Contributors
214235
[The Shaka Code team!](http://www.shakacode.com/about/), led by [Justin Gordon](https://github.com/justin808/), along with with many others. See [contributors.md](docs/contributors.md)

bin/dev

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

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")
920

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"
1828
end
1929

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)

bin/dev-static

Lines changed: 0 additions & 30 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"react": "^19.0.0",
7979
"react-dom": "^19.0.0",
8080
"react-intl": "^6.4.4",
81-
"react-on-rails": "14.0.3",
81+
"react-on-rails": "file:.yalc/react-on-rails",
8282
"react-redux": "^8.1.0",
8383
"react-router": "^6.13.0",
8484
"react-router-dom": "^6.13.0",

yarn.lock

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,6 @@
10061006
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
10071007
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
10081008

1009-
"@babel/runtime-corejs3@^7.12.5":
1010-
version "7.22.10"
1011-
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.22.10.tgz#5ecc3d32faa70009f084cc2e087d79e5f5cdcca9"
1012-
integrity sha512-IcixfV2Jl3UrqZX4c81+7lVg5++2ufYJyAFW3Aux/ZTvY6LVYYhJ9rMgnbX0zGVq6eqfVpnoatTjZdVki/GmWA==
1013-
dependencies:
1014-
core-js-pure "^3.30.2"
1015-
regenerator-runtime "^0.14.0"
1016-
10171009
"@babel/runtime@^7.12.1":
10181010
version "7.26.0"
10191011
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
@@ -3263,7 +3255,7 @@ core-js-compat@^3.31.0:
32633255
dependencies:
32643256
browserslist "^4.21.9"
32653257

3266-
core-js-pure@^3.23.3, core-js-pure@^3.30.2:
3258+
core-js-pure@^3.23.3:
32673259
version "3.32.0"
32683260
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.32.0.tgz#5d79f85da7a4373e9a06494ccbef995a4c639f8b"
32693261
integrity sha512-qsev1H+dTNYpDUEURRuOXMvpdtAnNEvQWS/FMJ2Vb5AY8ZP4rAPQldkE27joykZPJTe0+IVgHZYh1P5Xu1/i1g==
@@ -7276,12 +7268,8 @@ react-is@^18.0.0:
72767268
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
72777269
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
72787270

7279-
react-on-rails@14.0.3:
7280-
version "14.0.3"
7281-
resolved "https://registry.yarnpkg.com/react-on-rails/-/react-on-rails-14.0.3.tgz#5a870644c0fbfd0a4f4adcc62623573a40de8ad8"
7282-
integrity sha512-BGvnvSI871K63JXg72KgMy73izKYralp9rrf40VSiR+OvusnXJkwVa4gaUP21226R835gzU7VSbbf64L7H9GhQ==
7283-
dependencies:
7284-
"@babel/runtime-corejs3" "^7.12.5"
7271+
"react-on-rails@file:.yalc/react-on-rails":
7272+
version "16.0.0"
72857273

72867274
react-proxy@^1.1.7:
72877275
version "1.1.8"

0 commit comments

Comments
 (0)