Skip to content

Commit 724b02b

Browse files
committed
refactor: convert Procfile templates from dynamic to static shakapacker references
Replace ERB template processing with static Procfiles using 'shakapacker' directly instead of dynamic <%= config[:packer_type] %> detection, per Justin's feedback. **Templates → Static Files:** - Convert Procfile.dev.tt → Procfile.dev (static shakapacker references) - Convert Procfile.dev-static.tt → Procfile.dev-static (static shakapacker references) - Add Procfile.dev-static-assets (for bin/dev static mode) - Add Procfile.dev-prod-assets (for bin/dev production-asset mode) **Generator Updates:** - Update base_generator.rb to copy Procfiles as static files instead of templates - Remove dependency on ReactOnRails::PackerUtils.packer_type for Procfiles **Script Updates:** - Update bin/dev scripts to reference Procfile.dev-static-assets for static mode - Update dummy app bin/dev to match generator template **Test Updates:** - Update dev_spec.rb to expect new Procfile names - Update shared examples to verify all 4 Procfiles are generated - Update test dummy files to use correct Procfile references Addresses feedback from PR review about updating Procfiles to match react_on_rails-demo-v15-ssr-auto-registration-bundle-splitting repo.
1 parent 736f60d commit 724b02b

File tree

10 files changed

+33
-19
lines changed

10 files changed

+33
-19
lines changed

lib/generators/react_on_rails/base_generator.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ def create_react_directories
2929
def copy_base_files
3030
base_path = "base/base/"
3131
base_files = %w[app/controllers/hello_world_controller.rb
32-
app/views/layouts/hello_world.html.erb]
33-
base_templates = %w[config/initializers/react_on_rails.rb
34-
Procfile.dev
35-
Procfile.dev-static]
32+
app/views/layouts/hello_world.html.erb
33+
Procfile.dev
34+
Procfile.dev-static
35+
Procfile.dev-static-assets
36+
Procfile.dev-prod-assets]
37+
base_templates = %w[config/initializers/react_on_rails.rb]
3638
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
3739
base_templates.each do |file|
3840
template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type })

lib/generators/react_on_rails/bin/dev

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def run_static_development
6868
generate_packs
6969

7070
if installed? "overmind"
71-
system "overmind start -f Procfile.dev-static"
71+
system "overmind start -f Procfile.dev-static-assets"
7272
elsif installed? "foreman"
73-
system "foreman start -f Procfile.dev-static"
73+
system "foreman start -f Procfile.dev-static-assets"
7474
else
7575
warn <<~MSG
7676
NOTICE:
@@ -81,7 +81,7 @@ def run_static_development
8181
rescue Errno::ENOENT
8282
warn <<~MSG
8383
ERROR:
84-
Please ensure `Procfile.dev-static` exists in your project!
84+
Please ensure `Procfile.dev-static-assets` exists in your project!
8585
MSG
8686
exit!
8787
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Procfile for development using HMR
2+
# You can run these commands in separate shells
3+
rails: bundle exec rails s -p 3000
4+
wp-client: bin/shakapacker-dev-server
5+
wp-server: SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Procfile for development with production assets
2+
# Uses production-optimized, precompiled assets with development environment
3+
# Uncomment additional processes as needed for your app
4+
5+
rails: bundle exec rails s -p 3001
6+
# sidekiq: bundle exec sidekiq -C config/sidekiq.yml
7+
# redis: redis-server
8+
# mailcatcher: mailcatcher --foreground

lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt renamed to lib/generators/react_on_rails/templates/base/base/Procfile.dev-static

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ web: rails s -p 3000
55
# When making frequent changes to client side assets, you will prefer building webpack assets
66
# upon saving rather than when you refresh your browser page.
77
# Note, if using React on Rails localization you will need to run
8-
# `bundle exec rake react_on_rails:locale` before you run bin/<%= config[:packer_type] %>
9-
webpack: sh -c 'rm -rf public/packs/* || true && bin/<%= config[:packer_type] %> -w'
8+
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
9+
webpack: sh -c 'rm -rf public/packs/* || true && bin/shakapacker -w'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: bin/rails server -p 3000
2+
js: bin/shakapacker --watch

lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt

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

spec/dummy/bin/dev

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def run_static_development
6868
generate_packs
6969

7070
if installed? "overmind"
71-
system "overmind start -f Procfile.dev-static"
71+
system "overmind start -f Procfile.dev-static-assets"
7272
elsif installed? "foreman"
73-
system "foreman start -f Procfile.dev-static"
73+
system "foreman start -f Procfile.dev-static-assets"
7474
else
7575
warn <<~MSG
7676
NOTICE:
@@ -81,7 +81,7 @@ def run_static_development
8181
rescue Errno::ENOENT
8282
warn <<~MSG
8383
ERROR:
84-
Please ensure `Procfile.dev-static` exists in your project!
84+
Please ensure `Procfile.dev-static-assets` exists in your project!
8585
MSG
8686
exit!
8787
end

spec/react_on_rails/binstubs/dev_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup_script_execution
3333
it "supports static development mode" do
3434
script_content = File.read(script_path)
3535
expect(script_content).to include("run_static_development")
36-
expect(script_content).to include("Procfile.dev-static")
36+
expect(script_content).to include("Procfile.dev-static-assets")
3737
end
3838

3939
it "supports production-like mode" do

spec/react_on_rails/support/shared_examples/base_generator_examples.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
app/javascript/bundles/HelloWorld/components/HelloWorld.jsx
2121
config/initializers/react_on_rails.rb
2222
Procfile.dev
23-
Procfile.dev-static].each { |file| assert_file(file) }
23+
Procfile.dev-static
24+
Procfile.dev-static-assets
25+
Procfile.dev-prod-assets].each { |file| assert_file(file) }
2426
end
2527
end

0 commit comments

Comments
 (0)