Skip to content

Add --pro support to create-react-on-rails-app CLI#2818

Merged
justin808 merged 5 commits intomainfrom
jg-codex/2437-cli-pro-flag
Mar 24, 2026
Merged

Add --pro support to create-react-on-rails-app CLI#2818
justin808 merged 5 commits intomainfrom
jg-codex/2437-cli-pro-flag

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Mar 24, 2026

Summary

  • add --pro CLI option to create-react-on-rails-app
  • thread pro through CliOptions and generator arg building
  • install react_on_rails_pro for both --pro and --rsc
  • keep --rsc precedence when both flags are provided
  • extend test coverage for --pro generator args and app creation flow

Closes #2437

Testing

  • pnpm --filter create-react-on-rails-app test
  • pnpm --filter create-react-on-rails-app type-check

Note

Medium Risk
Moderate risk because it changes scaffolding behavior and gem installation flow for new apps, including new flag precedence rules between --pro and --rsc. Impact is limited to the create-react-on-rails-app CLI and is covered by expanded unit tests.

Overview
Adds explicit --pro mode to create-react-on-rails-app, wiring it through CLI parsing, CliOptions, and generator arg construction (with --rsc taking precedence when both are provided).

Updates app creation to install react_on_rails_pro for both --pro and --rsc, adjusts progress messaging/error cleanup guidance accordingly, and extends help text and tests to cover the new mode and precedence behavior. Also documents the new flag in CHANGELOG.md.

Written by Cursor Bugbot for commit 9af72eb. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

Warning

Rate limit exceeded

@justin808 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13075e72-a1f6-41a4-8326-694d5f77bad0

📥 Commits

Reviewing files that changed from the base of the PR and between 4f3eab0 and 9af72eb.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • packages/create-react-on-rails-app/src/create-app.ts
  • packages/create-react-on-rails-app/src/index.ts
  • packages/create-react-on-rails-app/src/types.ts
  • packages/create-react-on-rails-app/tests/create-app.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/2437-cli-pro-flag

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 24, 2026

Review Summary

The PR is a clean, focused addition that wires --pro through all the right layers (types, CLI parsing, generator args, gem installation, step counting, log messages). The core logic is correct and the test coverage for the happy path is solid.

A few issues worth addressing:

Minor issues

  1. Redundant help text entry (index.ts line 121): The --pro URL listed in the help text is identical to the default (hello_world). This could mislead users into thinking the flag does nothing visible. See inline comment.

  2. Silent flag suppression when --pro + --rsc are both set (index.ts line 48): The precedence logic is correct, but users who accidentally pass both flags get no feedback that --pro was ignored. A single logInfo warning would prevent confusion. See inline comment.

  3. Long ternary chain in log message (index.ts line 80): Already getting unwieldy; extracting a modeDesc variable would improve readability. See inline comment.

Test coverage gaps (create-app.test.ts line 289)

  • No createApp test for the --pro --rsc combination — buildGeneratorArgs has this covered but the full createApp call sequence (gem install order, generator flags) is untested for that combination.
  • No --rspack --pro combined test analogous to the existing RSC all-flags test.

No security or performance concerns with this change.

Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 24, 2026

Greptile Summary

This PR adds a --pro CLI flag to create-react-on-rails-app, allowing users to scaffold a React on Rails Pro setup without also enabling React Server Components (--rsc). It correctly threads pro through CliOptions, buildGeneratorArgs (with --rsc taking precedence over --pro when both are set), and createApp (shared proRequested / proModeLabel guards), and extends test coverage for the new flag.

Key changes:

  • types.ts: pro: boolean added to CliOptions
  • create-app.ts: buildGeneratorArgs emits --pro only when pro && !rsc; createApp installs react_on_rails_pro for both --pro and --rsc via the shared proRequested flag
  • index.ts: New --pro Commander option, updated info messages and help text; help text contains a duplicate URL entry for --pro (same hello_world route as default)
  • tests/create-app.test.ts: New generator-args and full createApp flow tests for --pro, plus --rsc-over---pro precedence test; existing tests for local gem path, missing gem path, and install failure only exercise --rsc, leaving the equivalent --pro branches untested

Confidence Score: 4/5

  • PR is safe to merge; all logic is correct and the primary user path is well-tested.
  • The implementation is clean and the precedence logic (--rsc over --pro) is correctly enforced in both buildGeneratorArgs and createApp. The only gaps are a minor help-text redundancy and missing sibling tests for the --pro-only variants of three existing edge-case tests (local gem path, missing path exit, install-failure cleanup) — none of which affect correctness in production.
  • tests/create-app.test.ts — three existing edge-case tests cover the shared code path only via --rsc; --pro equivalents are missing.

Important Files Changed

Filename Overview
packages/create-react-on-rails-app/src/types.ts Adds pro: boolean field to CliOptions interface — minimal and correct.
packages/create-react-on-rails-app/src/create-app.ts Threads --pro through buildGeneratorArgs (with --rsc precedence) and createApp (shared proRequested / proModeLabel); logic is sound, but test coverage for --pro-only edge cases (local gem path, install failure) is sparse.
packages/create-react-on-rails-app/src/index.ts Wires --pro into Commander option, info messages, and creation log correctly; help text includes a redundant duplicate URL for --pro that mirrors the default.
packages/create-react-on-rails-app/tests/create-app.test.ts Adds --pro generator-args tests and a full createApp flow test; existing tests for local gem path and install failure only exercise --rsc, leaving the identical --pro code paths untested.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[npx create-react-on-rails-app my-app] --> B{Flags provided?}
    B -->|--pro| C[proRequested = true\nproModeLabel = '--pro']
    B -->|--rsc| D[proRequested = true\nproModeLabel = '--rsc']
    B -->|--pro + --rsc| E[proRequested = true\nproModeLabel = '--rsc'\nrsc takes precedence]
    B -->|none| F[proRequested = false]

    C --> G[Step 1: rails new]
    D --> G
    E --> G
    F --> G

    G --> H[Step 2: bundle add react_on_rails]

    H --> I{proRequested?}
    I -->|Yes| J[Step 3: bundle add react_on_rails_pro]
    I -->|No| K[Step 3: run generator]

    J --> L[Step 4: run generator\nwith --pro or --rsc flag]

    K --> M{options.rsc?}
    L --> M

    M -->|Yes| N[Visit /hello_server]
    M -->|No| O[Visit /hello_world]
Loading

Comments Outside Diff (1)

  1. packages/create-react-on-rails-app/tests/create-app.test.ts, line 534-547 (link)

    P2 Missing --pro coverage for local gem path and install-failure tests

    Three existing tests exercise the shared proRequested code path only via rsc: true, leaving the equivalent pro: true flows untested:

    • 'uses local pro path when REACT_ON_RAILS_PRO_GEM_PATH is set' (line 534) — uses { ...baseOptions, rsc: true }
    • 'exits early when local react_on_rails_pro path does not exist' (line 561) — uses { ...baseOptions, rsc: true }
    • 'cleans up app directory when react_on_rails_pro add fails' (line 468) — uses { ...baseOptions, rsc: true }

    Since proRequested = options.pro || options.rsc, each of these should also have a sibling test with { ...baseOptions, pro: true } to confirm the --pro path through localGemPath, missing-path exit, and cleanup-on-failure all behave correctly.

Reviews (1): Last reviewed commit: "Document create-react-on-rails-app --pro..." | Re-trigger Greptile

Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 24, 2026

size-limit report 📦

Path Size
react-on-rails/client bundled (gzip) 62.63 KB (0%)
react-on-rails/client bundled (gzip) (time) 62.63 KB (0%)
react-on-rails/client bundled (brotli) 53.7 KB (0%)
react-on-rails/client bundled (brotli) (time) 53.7 KB (0%)
react-on-rails-pro/client bundled (gzip) 63.65 KB (0%)
react-on-rails-pro/client bundled (gzip) (time) 63.65 KB (0%)
react-on-rails-pro/client bundled (brotli) 54.67 KB (0%)
react-on-rails-pro/client bundled (brotli) (time) 54.67 KB (0%)
registerServerComponent/client bundled (gzip) 127.46 KB (0%)
registerServerComponent/client bundled (gzip) (time) 127.46 KB (0%)
registerServerComponent/client bundled (brotli) 61.65 KB (0%)
registerServerComponent/client bundled (brotli) (time) 61.65 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (gzip) (time) 122.02 KB (0%)
wrapServerComponentRenderer/client bundled (brotli) 56.77 KB (-0.02% 🔽)
wrapServerComponentRenderer/client bundled (brotli) (time) 56.77 KB (0%)

Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/src/create-app.ts
Comment thread analysis/open-issue-deep-dive/wave-1-active.md
@justin808 justin808 force-pushed the jg-codex/2437-cli-pro-flag branch from d702419 to 866c494 Compare March 24, 2026 00:24
Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/src/index.ts Outdated
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
Comment thread packages/create-react-on-rails-app/src/create-app.ts
@justin808
Copy link
Copy Markdown
Member Author

Addressed review feedback in latest push:

  • Added explicit user-facing note when both --pro and --rsc are provided (--rsc precedence).
  • Refactored creation summary mode suffix into a dedicated variable for readability.
  • Clarified help text route line to hello_world (default and --pro).
  • Added maintainer comment in generator arg builder explaining why --rsc supersedes --pro.
  • Expanded tests for requested combinations:
    • buildGeneratorArgs: --rspack --pro
    • createApp: --pro --rsc integration path (ensures generator gets --rsc)
    • createApp: --pro parity tests for local pro gem path, missing pro gem path, and pro gem add failure cleanup.

Local verification:

  • pnpm --filter create-react-on-rails-app test
  • pnpm --filter create-react-on-rails-app type-check
  • pnpm exec prettier --check packages/create-react-on-rails-app/src/index.ts packages/create-react-on-rails-app/src/create-app.ts packages/create-react-on-rails-app/tests/create-app.test.ts

Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
Comment thread packages/create-react-on-rails-app/src/index.ts
Comment thread packages/create-react-on-rails-app/src/index.ts
@justin808
Copy link
Copy Markdown
Member Author

Follow-up push applied: added explicit --rspack --pro command example in CLI help text so --pro parity is visible alongside --rsc combinations.

Re-verified locally:

  • pnpm exec prettier --check packages/create-react-on-rails-app/src/index.ts
  • pnpm --filter create-react-on-rails-app test
  • pnpm --filter create-react-on-rails-app type-check

Comment thread packages/create-react-on-rails-app/src/create-app.ts Outdated
Comment thread CHANGELOG.md
Comment thread packages/create-react-on-rails-app/src/create-app.ts
Comment thread packages/create-react-on-rails-app/tests/create-app.test.ts
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 24, 2026

Overall this is a clean, focused implementation that correctly threads the --pro flag through option parsing, generator arg building, and app creation. The Rails generator already had --pro support, so the CLI now correctly maps to it. Test coverage is solid.

A few things worth noting (inline comments posted separately):

proModeLabel computed unconditionally — when neither flag is set, this variable evaluates to '--pro' which is technically wrong (though harmless since it is only used inside if (proRequested)). Moving it inside the guarded block would make the intent clearer.

Cleanup messages when both --rsc and --pro are set — failure messages will say "rerun with --rsc", which may surprise a user who explicitly typed both flags. A small clarification in the message text would help.

Missing --pro --rspack help text example--rspack --rsc is shown but not --pro --rspack, despite the code and tests supporting it.

No createApp integration test for --pro --rspack — there is a buildGeneratorArgs test for this combo but no end-to-end createApp test. Low risk given other coverage, but worth adding.

Help text does not explain what --pro adds vs default — new users won't know when to choose --pro without a brief description of what Pro features are enabled.

All of these are nits or suggestions. The core logic is correct and the important paths are well-tested.

@justin808
Copy link
Copy Markdown
Member Author

Follow-up push (9af72eb) addresses the remaining thread about proModeLabel lifecycle:

  • createApp now computes proModeLabel only when Pro mode is actually requested.
  • This keeps the variable semantics aligned with control flow while preserving existing runtime behavior.

Re-verified locally:

  • pnpm --filter create-react-on-rails-app test
  • pnpm --filter create-react-on-rails-app type-check

@justin808 justin808 merged commit 579878f into main Mar 24, 2026
25 checks passed
@justin808 justin808 deleted the jg-codex/2437-cli-pro-flag branch March 24, 2026 00:53
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 24, 2026

Review: Add --pro support to create-react-on-rails-app CLI

Overall this is a clean, well-structured PR. The implementation correctly threads --pro through the CLI, CliOptions, and generator arg building, and the test coverage is solid — happy paths, error/cleanup paths, local gem path override, and precedence behavior are all exercised.

Confirmed: The underlying Rails generator already accepts --pro (declared as class_option :pro in install_generator.rb), so there's no risk of a runtime flag rejection.

One minor wording issue flagged inline — see comment on index.ts.

if (options.rsc) {
logInfo('Note: --rsc installs react_on_rails_pro and requires that gem to be installable.');
if (options.rsc && options.pro) {
logInfo('Note: --rsc takes precedence over --pro; --pro will be ignored.');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase "will be ignored" is slightly misleading here. --pro is not fully ignored — the react_on_rails_pro gem is still installed (because proRequested = options.pro || options.rsc in create-app.ts). What's actually superseded is only the generator mode flag (--pro--rsc).

A user seeing this message might worry that Pro features won't be set up, when in reality --rsc already includes everything --pro provides (and more). Consider a clearer message:

Suggested change
logInfo('Note: --rsc takes precedence over --pro; --pro will be ignored.');
logInfo('Note: --rsc includes all --pro functionality; the --pro flag is redundant when --rsc is set.');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-react-on-rails-app CLI missing --rsc and --pro flags

1 participant