Skip to content

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Nov 16, 2025

Summary

Replaces the spec/dummy/bin/dev symlink with a wrapper script that passes --route=/ to the base dev script.

Problem

The spec/dummy/bin/dev was a symlink to the template script at lib/generators/react_on_rails/templates/base/base/bin/dev, which defaults to DEFAULT_ROUTE = "hello_world". This is incorrect for the dummy app which needs to use the root route /.

Solution

Replace the symlink with a wrapper script that:

  • Calls the base dev script
  • Forces --route=/ for the dummy app
  • Passes through all other command-line arguments

Test Plan

  • Verified bundle exec rubocop passes with no offenses
  • Verified bin/dev --help works correctly in spec/dummy
  • Verified file is executable and has correct permissions

Generated with Claude Code (https://claude.com/claude-code)


This change is Reviewable

Summary by CodeRabbit

  • Chores
    • Updated internal development script configuration to improve development environment setup.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Warning

Rate limit exceeded

@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 35 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.

📥 Commits

Reviewing files that changed from the base of the PR and between e87d221 and ad5d849.

📒 Files selected for processing (4)
  • knip.ts (2 hunks)
  • react_on_rails_pro/spec/dummy/bin/dev (1 hunks)
  • spec/dummy/bin/dev (0 hunks)
  • spec/dummy/bin/dev (1 hunks)

Walkthrough

A new development script is introduced at spec/dummy/bin/dev that wraps a base dev script execution, automatically fixing the route parameter to "/" and delegating any additional arguments to the underlying dev runner.

Changes

Cohort / File(s) Summary
Development Script Wrapper
spec/dummy/bin/dev
New Ruby script that delegates to a base dev script with a fixed --route=/ parameter, enabling frozen_string_literal and forwarding original arguments via absolute path construction

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Verify the shebang is correct and consistent with project standards
  • Confirm the absolute path construction logic is sound and handles edge cases
  • Check that the hardcoded route "/" is intentional and appropriate for the dummy app context

Suggested labels

bug, review-needed

Poem

🐰 A new dev script hops into place,
With "/" routes set at steady pace,
Through frozen strings and paths so true,
The base script's work comes shining through!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix spec/dummy bin/dev to use correct route' directly reflects the main change: replacing a symlink with a wrapper script that forces the correct root route for the dummy app.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@claude
Copy link

claude bot commented Nov 16, 2025

Code Review

Summary

This PR successfully addresses the issue of the dummy app's bin/dev script using the wrong default route. The change from a symlink to a wrapper script is a clean solution.


✅ Strengths

  1. Correct Approach: Replacing the symlink with a wrapper script that forces --route=/ is the right solution for the dummy app, which uses root "pages#index" (spec/dummy/config/routes.rb:8)

  2. Proper Argument Handling: The use of *ARGV correctly passes through all additional command-line arguments to the base script

  3. File Permissions: File is properly executable (755 permissions verified)

  4. Code Style:

    • Includes required shebang and frozen_string_literal comment
    • Has descriptive comment explaining purpose
    • Clean, minimal implementation
  5. Path Resolution: The relative path ../../../lib/generators/react_on_rails/templates/base/base/bin/dev correctly resolves to the base script


🔍 Observations

  1. exec vs system: Using exec is correct here - it replaces the current process rather than spawning a subprocess, which is appropriate for a wrapper script

  2. Argument Precedence: The wrapper passes --route=/ before *ARGV. Since the base script checks if --route is already present (lib/generators/react_on_rails/templates/base/base/bin/dev:32), this means:

    • bin/dev → uses --route=/ (correct)
    • bin/dev --route=/custom → uses --route=/custom (user override works)

    Wait, there's a potential issue here! Looking at line 32 of the base script:

    argv_with_defaults.push("--route", DEFAULT_ROUTE) unless argv_with_defaults.any? { |arg| arg.start_with?("--route") }

    The base script checks if ANY argument starts with --route. Since the wrapper already passes --route=/, the base script won't add its default. This means:

    • spec/dummy/bin/dev["--route=/", ...user_args] → ✅ uses /
    • spec/dummy/bin/dev --route=/custom["--route=/", "--route=/custom", ...user_args]⚠️ has TWO --route arguments

    The question is: which one wins? This depends on how the argument parser handles duplicates. Let me check...

  3. Argument Parser Behavior: Looking at ReactOnRails::Dev::ServerManager, it likely uses OptionParser or similar, which typically uses the last occurrence of a flag. This means:

    • bin/dev --route=/custom would result in ["--route=/", "--route=/custom"]
    • The last value (/custom) would win
    • ✅ This is the correct behavior (user override works)

🎯 Potential Improvements (Optional)

  1. Test Coverage: Consider adding a test to verify the wrapper script behavior:

    • Test that it passes --route=/ by default
    • Test that user-provided --route overrides work
    • Could be added to spec/react_on_rails/binstubs/dev_spec.rb
  2. Documentation: The inline comment is good, but could mention that user-provided --route options will override the default:

    # This script calls the base dev script with a fixed route for the dummy app.
    # Users can still override with: bin/dev --route=/custom

🔒 Security

No security concerns. This is a development-only script.


⚡ Performance

No performance impact. exec is efficient as it replaces the process rather than forking.


🧪 Test Coverage

  • ✅ Manual testing mentioned in PR description
  • ✅ Linting passes
  • ⚠️ No automated tests specifically for the dummy app's wrapper script (but base script has tests in spec/react_on_rails/binstubs/dev_spec.rb)

📋 Changelog

According to CLAUDE.md, this change does not require a CHANGELOG entry as it's an internal fix to the test/dummy app, not a user-visible change to the gem.


✅ Final Verdict

LGTM - This is a clean, minimal solution that correctly addresses the problem. The code is well-written and follows project conventions.

Minor suggestion: Consider adding a brief test to verify the wrapper behavior, but this is optional as the base script is already well-tested.


Note: CI failure in "build-dummy-app-webpack-test-bundles (false, false, false)" appears unrelated to this change (build/dependency issue, not a code issue with bin/dev).

Change spec/dummy/bin/dev from a symlink to a wrapper script that calls
the template bin/dev with --route=/ argument. This ensures the dummy app
always uses the root route instead of the default hello_world route.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@justin808 justin808 force-pushed the justin808/fix-bin-dev-for-spec-dummy branch from e87d221 to 757d1f7 Compare November 17, 2025 05:27
justin808 and others added 3 commits November 16, 2025 20:14
- Replace spec/dummy/bin/dev symlink with wrapper script
- Replace react_on_rails_pro/spec/dummy/bin/dev bash script with wrapper
- Both wrappers call the base dev script with --route=/ for their respective dummy apps
- Use File.expand_path for proper path resolution

This ensures both dummy apps use the root route (/) instead of the default
hello_world route from the template.

Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Remove 'nps' from ignoreBinaries (detected by Knip now)
- Add spec/dummy client directories to ignore (dynamically loaded by React on Rails)
- Add runtime dependencies to ignoreDependencies (needed in production mode)

This fixes the failing "Detect dead code" CI check that was also failing on master.

Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Both methods work, but File.join is simpler and was the original implementation.
File.expand_path unnecessarily resolves to an absolute path when a relative
path with .. segments works fine with exec.
@justin808
Copy link
Member Author

@claude review this PR

@claude
Copy link

claude bot commented Nov 17, 2025

Claude finished @justin808's task —— View job


Code Review for PR #2029

Todo List:

  • Read changed files to understand implementation
  • Read base dev script to understand wrapper behavior
  • Review code for correctness and potential issues
  • Check alignment with CLAUDE.md requirements
  • Provide comprehensive review feedback

Summary

This PR successfully replaces the spec/dummy/bin/dev symlink with a wrapper script that fixes the default route for the dummy app. The implementation is clean, minimal, and correct. LGTM with minor suggestions.


✅ Strengths

  1. Correct Solution: The wrapper script approach is the right fix. The dummy app uses root "pages#index" (spec/dummy/config/routes.rb:8), so passing --route=/ is correct instead of the base script's default --route=hello_world.

  2. Proper Implementation:

    • Uses exec (correct - replaces process rather than spawning subprocess)
    • Passes --route=/ before *ARGV (allows user overrides to work)
    • File has correct permissions (executable)
    • Includes required shebang and frozen_string_literal pragma
    • Descriptive comment explaining purpose
  3. Consistent Pattern: Both OSS and Pro dummy apps now use the same wrapper pattern (react_on_rails_pro/spec/dummy/bin/dev:5).

  4. Path Resolution: The relative path ../../../lib/generators/react_on_rails/templates/base/base/bin/dev correctly resolves to the base script.

  5. Latest Commit Improvement: Commit ad5d849 correctly switched from File.expand_path to File.join for simplicity and consistency.


🔍 Code Analysis

Argument Handling Behavior

The wrapper passes --route=/ before *ARGV. Looking at the base script (lib/generators/react_on_rails/templates/base/base/bin/dev:32):

argv_with_defaults.push("--route", DEFAULT_ROUTE) unless argv_with_defaults.any? { |arg| arg.start_with?("--route") }

This means:

  • bin/dev["--route=/"] → ✅ Uses /
  • bin/dev --route=/custom["--route=/", "--route=/custom"] → ✅ User override works (last value wins in argument parsers)

Behavior is correct: User can override the default route if needed.


📊 File Changes

spec/dummy/bin/dev

  • Change: File.expand_pathFile.join
  • Rationale: Simpler, avoids unnecessary absolute path resolution
  • Status: ✅ Correct

react_on_rails_pro/spec/dummy/bin/dev

  • Change: Same pattern with correct relative path (../../../../lib/...)
  • Status: ✅ Correct

knip.ts

  • Changes: Reorganized ignoreDependencies with better comments
  • Status: ✅ Good improvement - better organization and clarity

🎯 Suggestions (Optional)

  1. Documentation Enhancement: Consider adding a comment about user overrides:

    # This script calls the base dev script with a fixed route for the dummy app.
    # User-provided --route options will override this default.
  2. Test Coverage: Consider adding a test to verify wrapper behavior:

    • Test that default route is /
    • Test that user overrides work
    • Could be added to existing binstub tests

⚡ CLAUDE.md Compliance

  • File endings: Both files end with newlines (verified in file reads)
  • RuboCop: Should pass (standard Ruby syntax, frozen_string_literal pragma present)
  • Formatting: Code follows Ruby conventions
  • ⚠️ Changelog: According to CLAUDE.md, this is an internal fix to test/dummy apps and likely doesn't require a CHANGELOG entry (not a user-visible gem change)

🔒 Security & Performance

  • ✅ No security concerns (development-only script)
  • ✅ No performance impact (exec is efficient)

✅ Final Verdict

LGTM - This is a well-executed fix that:

  • Solves the problem correctly
  • Uses the right approach (wrapper vs symlink)
  • Maintains consistency across OSS and Pro
  • Has clean, readable code
  • Follows project conventions

The latest commit improving File.join usage shows good attention to code quality. Ready to merge!


📝 Minor Note

The knip.ts changes appear to be refactoring/cleanup (reorganizing comments and dependencies). This is a positive improvement for maintainability but doesn't directly relate to the bin/dev fix - consider whether these should be in a separate commit for cleaner git history in future PRs.


|

@justin808 justin808 merged commit af32746 into master Nov 17, 2025
25 checks passed
@justin808 justin808 deleted the justin808/fix-bin-dev-for-spec-dummy branch November 17, 2025 07:05
justin808 added a commit that referenced this pull request Nov 17, 2025
## Summary

Replaces the `spec/dummy/bin/dev` symlink with a wrapper script that
passes `--route=/` to the base dev script.

## Problem

The `spec/dummy/bin/dev` was a symlink to the template script at
`lib/generators/react_on_rails/templates/base/base/bin/dev`, which
defaults to `DEFAULT_ROUTE = "hello_world"`. This is incorrect for the
dummy app which needs to use the root route `/`.

## Solution

Replace the symlink with a wrapper script that:
- Calls the base dev script
- Forces `--route=/` for the dummy app
- Passes through all other command-line arguments

## Test Plan

- Verified `bundle exec rubocop` passes with no offenses
- Verified `bin/dev --help` works correctly in spec/dummy
- Verified file is executable and has correct permissions

Generated with Claude Code (https://claude.com/claude-code)

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2029)
<!-- Reviewable:end -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated internal development script configuration to improve
development environment setup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <[email protected]>
justin808 added a commit that referenced this pull request Nov 18, 2025
## Summary

Replaces the `spec/dummy/bin/dev` symlink with a wrapper script that
passes `--route=/` to the base dev script.

## Problem

The `spec/dummy/bin/dev` was a symlink to the template script at
`lib/generators/react_on_rails/templates/base/base/bin/dev`, which
defaults to `DEFAULT_ROUTE = "hello_world"`. This is incorrect for the
dummy app which needs to use the root route `/`.

## Solution

Replace the symlink with a wrapper script that:
- Calls the base dev script
- Forces `--route=/` for the dummy app
- Passes through all other command-line arguments

## Test Plan

- Verified `bundle exec rubocop` passes with no offenses
- Verified `bin/dev --help` works correctly in spec/dummy
- Verified file is executable and has correct permissions

Generated with Claude Code (https://claude.com/claude-code)

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/2029)
<!-- Reviewable:end -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated internal development script configuration to improve
development environment setup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants