Commit 691ae70
Automate Pro generator gem/package swap and import updates (#2822)
## Summary
- Add first-class `--rsc-pro` install mode to the generator, unifying
`--rsc --pro` into a single flag with matched Pro/RSC defaults,
verification checklist, and recovery commands
- Extend standalone `react_on_rails:pro` upgrade flow to automate
Gemfile gem swap (`react_on_rails` → `react_on_rails_pro`) with
mode-aware version requirements (`~>` for standard Pro, exact pin in RSC
Pro mode when applicable), plus `bundle install` after swap and
automatic rollback on failure
- Rewrite JS/TS/Vue/Svelte imports from `react-on-rails` to
`react-on-rails-pro` across common frontend roots using atomic file
writes, with full comment-aware parsing (block comments, multiline
imports, and inline template-literal masking to avoid false rewrites
inside template strings)
- Improve `package_json` add return handling — treat `nil` as success
instead of falsy failure
- Pin RSC dependencies to explicit versions (`react`/`react-dom` to
`~19.0.4`, `react-on-rails-rsc` to `19.0.4`) with fallback to unpinned
install when pinned install fails
- Improve Pro flag detection: `use_pro?` and `use_rsc?` now respect
`--rsc-pro`, and new `use_rsc_pro_mode?` helper controls RSC
Pro–specific behavior
- Add Pro gem version requirement helper (`pro_gem_version_requirement`)
— exact pin for RSC Pro mode, pessimistic (`~>`) for standard Pro
- Add prerelease messaging for RSC Pro mode when the gem version is a
prerelease
- Add RSC Pro post-install verification message with
startup/streaming/hydration checklist
Closes #2626
## Test Plan
- `bundle exec rspec
react_on_rails/spec/react_on_rails/generators/pro_generator_spec.rb`
- `bundle exec rspec
react_on_rails/spec/react_on_rails/generators/generator_helper_spec.rb`
- `bundle exec rspec
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb`
- `bundle exec rspec
react_on_rails/spec/react_on_rails/generators/js_dependency_manager_spec.rb`
- `bundle exec rubocop
react_on_rails/lib/generators/react_on_rails/pro_generator.rb
react_on_rails/lib/generators/react_on_rails/pro_setup.rb
react_on_rails/lib/generators/react_on_rails/install_generator.rb`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk: generator behavior now mutates `Gemfile`/runs `bundle
install`, pins RSC/Pro versions, and rewrites frontend imports, which
could impact existing apps if edge cases in parsing or version
constraints are missed.
>
> **Overview**
> Adds a first-class `--rsc-pro` installation mode (and
`use_rsc_pro_mode?` helper) so install flows, sub-generator invocation,
recovery commands, prerequisite errors, and post-install messaging treat
RSC+Pro as a single, consistent mode.
>
> Enhances dependency handling by treating `package_json` `add`
returning `nil` as success, pinning RSC React versions to `~19.0.4`,
pinning `react-on-rails-rsc` to `19.0.4` with retry-to-latest fallback,
and making Pro gem version requirements exact in RSC Pro mode.
>
> Extends `react_on_rails:pro` to automatically swap `react_on_rails` →
`react_on_rails_pro` in `Gemfile` (with atomic writes, `bundle install`,
and rollback on failure) and to rewrite JS/TS/Vue/Svelte imports from
`react-on-rails` to `react-on-rails-pro`, with extensive spec coverage
for edge cases.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7c0ecb8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added `--rsc-pro` CLI option to enable first-class React Server
Components with Pro features in a single installation command.
* Automatic Gemfile gem swap from `react_on_rails` to
`react_on_rails_pro` with bundler integration.
* Automatic rewriting of module imports from `react-on-rails` to
`react-on-rails-pro` across JavaScript/TypeScript files.
* Introduced React version pinning (~19.0.4) for RSC installations.
* **Bug Fixes**
* Improved npm dependency installation return value handling to
correctly interpret `nil` responses as successful.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 7f18189 commit 691ae70
9 files changed
Lines changed: 2235 additions & 32 deletions
File tree
- react_on_rails
- lib/generators/react_on_rails
- spec/react_on_rails/generators
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
155 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
156 | 165 | | |
157 | 166 | | |
158 | 167 | | |
159 | | - | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
163 | | - | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
167 | | - | |
| 176 | + | |
168 | 177 | | |
169 | 178 | | |
170 | 179 | | |
| |||
Lines changed: 35 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| |||
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
| 99 | + | |
| 100 | + | |
91 | 101 | | |
92 | 102 | | |
93 | 103 | | |
| |||
190 | 200 | | |
191 | 201 | | |
192 | 202 | | |
193 | | - | |
| 203 | + | |
194 | 204 | | |
195 | 205 | | |
196 | 206 | | |
| |||
202 | 212 | | |
203 | 213 | | |
204 | 214 | | |
205 | | - | |
| 215 | + | |
206 | 216 | | |
207 | 217 | | |
208 | 218 | | |
| |||
274 | 284 | | |
275 | 285 | | |
276 | 286 | | |
| 287 | + | |
277 | 288 | | |
278 | | - | |
| 289 | + | |
279 | 290 | | |
280 | 291 | | |
281 | | - | |
| 292 | + | |
282 | 293 | | |
283 | 294 | | |
284 | 295 | | |
| |||
382 | 393 | | |
383 | 394 | | |
384 | 395 | | |
385 | | - | |
| 396 | + | |
386 | 397 | | |
387 | 398 | | |
388 | 399 | | |
| |||
463 | 474 | | |
464 | 475 | | |
465 | 476 | | |
466 | | - | |
| 477 | + | |
467 | 478 | | |
468 | 479 | | |
469 | | - | |
| 480 | + | |
470 | 481 | | |
471 | 482 | | |
472 | 483 | | |
| |||
478 | 489 | | |
479 | 490 | | |
480 | 491 | | |
| 492 | + | |
481 | 493 | | |
482 | 494 | | |
483 | 495 | | |
| |||
491 | 503 | | |
492 | 504 | | |
493 | 505 | | |
494 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
495 | 509 | | |
496 | 510 | | |
497 | 511 | | |
| |||
500 | 514 | | |
501 | 515 | | |
502 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
503 | 528 | | |
504 | 529 | | |
505 | 530 | | |
| |||
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
221 | | - | |
| 225 | + | |
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
| |||
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
386 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
387 | 407 | | |
388 | 408 | | |
389 | 409 | | |
390 | 410 | | |
391 | 411 | | |
392 | | - | |
| 412 | + | |
393 | 413 | | |
394 | 414 | | |
395 | 415 | | |
| |||
400 | 420 | | |
401 | 421 | | |
402 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
403 | 429 | | |
404 | 430 | | |
405 | 431 | | |
| |||
0 commit comments