Add --pro and --rsc flags to install generator#2284
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds --pro and --rsc generator flags and standalone Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant InstallGen as InstallGenerator
participant ProGen as ProGenerator
participant RscGen as RscGenerator
participant FS as FileSystem
participant NPM as NPM/PackageManager
User->>InstallGen: run generator (--pro / --rsc)
InstallGen->>InstallGen: validate prerequisites (pro gem, react version)
InstallGen->>ProGen: invoke pro flow (if use_pro?)
ProGen->>FS: create initializer, client/node-renderer.js, patch Procfile.dev, update server webpack
ProGen->>NPM: add Pro npm packages
InstallGen->>RscGen: invoke rsc flow (if use_rsc?)
RscGen->>FS: create rscWebpackConfig, HelloServer components, controller/view, add routes, append RSC watcher
RscGen->>NPM: add RSC npm packages
InstallGen->>NPM: finalize remaining JS dependencies
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
506aab7 to
5913009
Compare
5913009 to
2fa0366
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7cc057b to
56525a4
Compare
This commit implements Phase 1 of the Pro/RSC generator feature: Generator flags: - --pro: Install React on Rails Pro with Node Renderer - --rsc: Install React Server Components support (implies --pro) Prerequisite validation: - Checks if react_on_rails_pro gem is installed when flags are used - Shows friendly error message with installation instructions - Includes free trial messaging to lower friction React version validation (RSC only): - Warns if React version is not 19.0.x (required for RSC) - Warns about security vulnerabilities (CVE-2025-55182, CVE-2025-67779) if React version is below 19.0.3 UX improvements: - Added blank lines between generator messages for readability - Improved license messaging ("Try Pro free!") Code quality: - Extracted gem_in_lockfile? helper to eliminate duplication - Fixed memoization pattern in pro_gem_installed? - Reused existing version parsing patterns from VersionChecker 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Test coverage for: - missing_pro_gem? validation (5 tests) - --pro without gem → blocks with error - --rsc without gem → blocks with error - --pro with gem in loaded_specs → allows - --pro with gem in lockfile → allows - no flag → skips check - detect_react_version parsing (4 tests) - standard version, caret prefix, workspace protocol, nil - warn_about_react_version_for_rsc (5 tests) - React 19.0.3 → no warning - React 19.1.x/18.x → incompatibility warning - React 19.0.0-19.0.2 → CVE security warning - no --rsc → skips check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Creates files and configuration for React on Rails Pro when --pro flag is used: Files created: - config/initializers/react_on_rails_pro.rb - Pro configuration - client/node-renderer.js - Node Renderer bootstrap Procfile.dev: - Appends node-renderer process (idempotent) NPM packages: - react-on-rails-pro - react-on-rails-pro-node-renderer Implementation: - setup_pro orchestrates Pro file generation - Idempotency checks skip existing files - Pro dependencies added in add_js_dependencies flow (single npm install) - RSC config conditionally included when --rsc flag used Templates based on: - react_on_rails_pro/spec/dummy/ (actual patterns) - react_on_rails_pro/docs/installation.md (config options) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
When users upgrade from the base React on Rails to Pro: - The validation now provides clear upgrade instructions with the REACT_ON_RAILS_SKIP_VALIDATION=true command - The generator automatically removes the base 'react-on-rails' npm package when installing Pro, since Pro includes all base functionality This enables a smooth upgrade path: 1. Add react_on_rails_pro gem to Gemfile 2. Run: REACT_ON_RAILS_SKIP_VALIDATION=true rails g react_on_rails:install --pro 3. Generator removes base package and installs Pro packages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests cover: - Pro initializer creation with NodeRenderer configuration - node-renderer.js bootstrap file generation - Procfile.dev node-renderer process addition - Pro npm dependencies installation - Flag combinations: --pro --redux, --pro --typescript, --pro --rspack - Idempotency: existing Pro files are not overwritten - Unit tests for add_pro_to_procfile behavior This completes the test coverage for the Pro generator implementation (Phase 2 of the --pro/--rsc generator feature). Part of #2277 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
… bundle support Aligns webpack config naming with Pro ecosystem convention. The rename affects the generated config file and all require() references. Adds RSC (React Server Components) three-bundle architecture support: - RSC conditionals in ServerClientOrBoth.js for third bundle - New rscWebpackConfig.js template that extends server config - RSC_BUNDLE_ONLY env var for building RSC bundle separately The RSC webpack config: - Clones server webpack config - Renames entry to rsc-bundle - Adds react-on-rails-rsc/WebpackLoader after JS loader - Adds react-server condition for RSC bundle identification - Aliases react-dom/server to false (not needed for RSC payload) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Adds setup_rsc method that runs when --rsc flag is used: - Creates rscWebpackConfig.js from template - Adds RSC bundle watcher to Procfile.dev Adds react-on-rails-rsc npm package to RSC_DEPENDENCIES in JsDependencyManager, installed alongside other dependencies during generator run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- serverWebpackConfig: Add target=node, libraryTarget, RSCWebpackPlugin, extractLoader, node=false for Pro mode - clientWebpackConfig: Add RSCWebpackPlugin for RSC mode - ServerClientOrBoth: Use destructured import for Pro mode - rscWebpackConfig: Use destructured import from serverWebpackConfig - base_generator: Add pro/rsc class options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The --pro and --rsc combination contexts (--redux, --typescript, --rspack) each duplicated the same Pro/RSC assertions inline with inconsistent depth. Extract shared examples following the established pattern: - pro_common_files: initializer (with NodeRenderer check), node-renderer.js (with content check), Procfile.dev (with port check). Combo contexts that previously had shallow or missing assertions now inherit full coverage. - rsc_common_files: 5-file common files array + Pro initializer with all RSC config values (enable_rsc_support, rsc_bundle_js_file, rsc_payload_generation_url_path). Replaces 4 identical inline blocks. Also reuse shared examples in standalone generator specs: - pro_generator_spec.rb: use pro_common_files - rsc_generator_spec.rb: use rsc_hello_server_files (levels up weak controller/view assertions to include layout, Stream, and no-prerender checks) Remove stale TODO at install_generator_spec.rb that referenced "when --rsc tests are added" — those tests were added in the same PR (#2284). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
## Summary - Remove no-op `prerender: true` from RSC generator template — `stream_react_component` always performs server-side rendering and ignores this option; the comment also falsely claimed it enabled streaming - Extract inline `render_label` conditional in `generator_messages.rb` into a `build_render_label` private method, consistent with the existing `build_render_example` pattern - Replace four identical `HelloServerController` inline `it` blocks (base `--rsc` and the three combination contexts) with a shared example `rsc_hello_server_files`, which also adds view coverage to the combination contexts for free - Remove unused `let(:expected)` in the "with helpful message" spec context - Extract `pro_common_files` shared example (initializer + node-renderer + Procfile) — replaces inline duplicates in `--pro --redux`, `--pro --typescript`, `--pro --rspack` contexts and `pro_generator_spec.rb`; combo contexts gain Procfile coverage they previously lacked - Extract `rsc_common_files` shared example (common files + Pro initializer with RSC config) — replaces inline duplicates in all four `--rsc` contexts; combo contexts gain full RSC config assertions they previously lacked - Remove stale TODO referencing "when --rsc tests are added" — those tests were added in the same PR (#2284) - Reuse `rsc_hello_server_files` in `rsc_generator_spec.rb`, leveling up weak controller/view assertions to include layout, Stream, and no-prerender checks ## Test Plan - [x] CI passes (generator specs, RuboCop) - [x] `rsc_hello_server_files` shared example runs in all four RSC contexts + standalone RSC generator spec - [x] `pro_common_files` shared example runs in three Pro combo contexts + standalone Pro generator spec - [x] `rsc_common_files` shared example runs in all four RSC contexts --------- Co-authored-by: Justin Gordon <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
- Remove no-op `prerender: true` from RSC generator template — `stream_react_component` always performs server-side rendering and ignores this option; the comment also falsely claimed it enabled streaming - Extract inline `render_label` conditional in `generator_messages.rb` into a `build_render_label` private method, consistent with the existing `build_render_example` pattern - Replace four identical `HelloServerController` inline `it` blocks (base `--rsc` and the three combination contexts) with a shared example `rsc_hello_server_files`, which also adds view coverage to the combination contexts for free - Remove unused `let(:expected)` in the "with helpful message" spec context - Extract `pro_common_files` shared example (initializer + node-renderer + Procfile) — replaces inline duplicates in `--pro --redux`, `--pro --typescript`, `--pro --rspack` contexts and `pro_generator_spec.rb`; combo contexts gain Procfile coverage they previously lacked - Extract `rsc_common_files` shared example (common files + Pro initializer with RSC config) — replaces inline duplicates in all four `--rsc` contexts; combo contexts gain full RSC config assertions they previously lacked - Remove stale TODO referencing "when --rsc tests are added" — those tests were added in the same PR (#2284) - Reuse `rsc_hello_server_files` in `rsc_generator_spec.rb`, leveling up weak controller/view assertions to include layout, Stream, and no-prerender checks - [x] CI passes (generator specs, RuboCop) - [x] `rsc_hello_server_files` shared example runs in all four RSC contexts + standalone RSC generator spec - [x] `pro_common_files` shared example runs in three Pro combo contexts + standalone Pro generator spec - [x] `rsc_common_files` shared example runs in all four RSC contexts --------- Co-authored-by: Justin Gordon <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
- Remove no-op `prerender: true` from RSC generator template — `stream_react_component` always performs server-side rendering and ignores this option; the comment also falsely claimed it enabled streaming - Extract inline `render_label` conditional in `generator_messages.rb` into a `build_render_label` private method, consistent with the existing `build_render_example` pattern - Replace four identical `HelloServerController` inline `it` blocks (base `--rsc` and the three combination contexts) with a shared example `rsc_hello_server_files`, which also adds view coverage to the combination contexts for free - Remove unused `let(:expected)` in the "with helpful message" spec context - Extract `pro_common_files` shared example (initializer + node-renderer + Procfile) — replaces inline duplicates in `--pro --redux`, `--pro --typescript`, `--pro --rspack` contexts and `pro_generator_spec.rb`; combo contexts gain Procfile coverage they previously lacked - Extract `rsc_common_files` shared example (common files + Pro initializer with RSC config) — replaces inline duplicates in all four `--rsc` contexts; combo contexts gain full RSC config assertions they previously lacked - Remove stale TODO referencing "when --rsc tests are added" — those tests were added in the same PR (#2284) - Reuse `rsc_hello_server_files` in `rsc_generator_spec.rb`, leveling up weak controller/view assertions to include layout, Stream, and no-prerender checks - [x] CI passes (generator specs, RuboCop) - [x] `rsc_hello_server_files` shared example runs in all four RSC contexts + standalone RSC generator spec - [x] `pro_common_files` shared example runs in three Pro combo contexts + standalone Pro generator spec - [x] `rsc_common_files` shared example runs in all four RSC contexts --------- Co-authored-by: Justin Gordon <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Summary
Adds
--proand--rscflags torails g react_on_rails:install, plus standalone generators for upgrading existing apps.New commands:
Closes #2277
What's Included
Pro Generator (
--pro)config/initializers/react_on_rails_pro.rbwith Node Renderer configclient/node-renderer.jsbootstrap fileProcfile.devreact-on-rails-proandreact-on-rails-pro-node-renderernpm packagesreact-on-railspackage when installing Pro)RSC Generator (
--rsc)config/webpack/rscWebpackConfig.jsfor React Server Components bundleHelloServerControllerand viewrsc_payload_route,hello_server)react-on-rails-rscnpm package~19.0.4(security: CVE-2025-55182, CVE-2025-67779, CVE-2026-23864)react_on_rails_pro.rbinitializerStandalone Generators
react_on_rails:pro— upgrades an existing React on Rails app to Proreact_on_rails:rsc— upgrades an existing Pro app to RSCWebpack Config Transforms
generateWebpackConfigs.js→ServerClientOrBoth.jswith RSC bundle supportrscBundleparameter toserverWebpackConfig.jsfor RSC buildsDocumentation
docs/api-reference/generator-details.mdreact_on_rails_pro/docs/installation.mdTesting
--pro,--rsc, and all flag combinations (--typescript,--redux,--rspack)proandrscgeneratorsDesign Decisions
ProSetupandRscSetupmodules, shared between install flags and standalone generators--typescript,--redux,--rspack~19.0.4(not latest 19.x) because RSC support requires 19.0.x specificallyTest Plan
bundle exec rspec spec/react_on_rails/generators/— all generator tests passrspec-package-tests,markdown-link-check, pre-commit hooks🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests