Skip to content

Conversation

ihabadham
Copy link
Contributor

@ihabadham ihabadham commented Sep 29, 2025

Summary

Fixes two rake tasks that were broken/discovered after the workspace structure changes in PR #1830:

node_package.rake: Fixed yalc publishyarn yalc publish to work with private workspace root
shakapacker_examples.rake: Fixed missing space in rails command + updated to use npm install instead of yarn

Issues Found

  1. yalc publish fails with private workspace root: After PR Phase 3: Prepare core package for workspace structure #1830 made root package.json private (standard practice), yalc publish fails with "Will not publish package with private: true"

    • Fix: Use yarn yalc publish which delegates to the publishable workspace package
  2. Rails command syntax error: Missing space in rails_options += "--skip-javascript" caused webpack--skip-javascript

    • Fix: Add space: rails_options += " --skip-javascript"
  3. Package manager mismatch: Rake task runs yarn but Shakapacker now defaults to npm when no lockfiles exist

    • Fix: Use npm install to match Shakapacker's choice

Test Plan

  • rake node_package - Successfully builds and publishes with yalc
  • rake shakapacker_examples:gen_basic - Successfully generates Rails app with React on Rails
  • Manual testing confirmed all three fixes work together

Root Cause

The workspace restructuring in PR #1830 was correct and follows standard practices. These rake tasks simply needed updates to work with the new structure.

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Bug Fixes

    • Fixed example generator so CLI options (e.g., skipping JavaScript) are applied reliably during project creation.
  • Chores

    • Switched example project dependency installation from Yarn to npm for consistency.
    • Standardized package publishing to run via Yarn after the build step.

These updates improve example generation reliability and align tooling across workflows.

  Use yarn yalc publish instead of yalc publish to work with
  private workspace root introduced in PR #1830.

  �� Generated with Claude Code
  Co-Authored-By: Claude <noreply@anthropic.com>
  - Add missing space in rails_options concatenation
  - Use npm install instead of yarn to match Shakapacker's default

  🤖 Generated with Claude Code
  Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

Updated two Rake tasks: node_package:build now runs yarn yalc publish after the build; shakapacker examples generation appends --skip-javascript directly to the rails new command and switches dependency installation from yarn to npm install.

Changes

Cohort / File(s) Summary
Node package build task
rakelib/node_package.rake
After building the package, the publish step now runs yarn yalc publish instead of invoking yalc publish directly; no other flow or error handling changes.
Shakapacker examples generation
rakelib/shakapacker_examples.rake
Removed in-place modification of example_type.rails_options; --skip-javascript is appended directly to the rails new command. Replaced yarn install step with npm install.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Rake as Rake Task: node_package:build
  participant Build as Build Tooling
  participant Yalc as yalc via yarn

  Dev->>Rake: Invoke node_package:build
  Rake->>Build: Build package
  Build-->>Rake: Build complete
  Rake->>Yalc: yarn yalc publish
  Yalc-->>Rake: Publish result
  Rake-->>Dev: Task done
Loading
sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Rake as Rake Task: shakapacker_examples GENERATE
  participant Rails as rails new
  participant PM as npm

  Dev->>Rake: Run GENERATE
  Rake->>Rake: Compose rails command (append " --skip-javascript")
  Rake->>Rails: rails new ... --skip-javascript
  Rails-->>Rake: App scaffolded
  Rake->>PM: npm install
  PM-->>Rake: Dependencies installed
  Rake-->>Dev: Example generated
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

bug

Suggested reviewers

  • justin808
  • G-Rath

Poem

I twitch my whiskers, changes stitched tight,
Yarn calls yalc, then npm takes flight.
A tiny space, a flag in place,
Rails dances on with steady grace.
Hop, package, hop — into the night. 🐇✨

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 succinctly summarizes the primary change—updating broken rake tasks caused by the workspace structure merge from PR #1830—without extraneous detail or ambiguity.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/rake-tasks-post-workspace-merge-pr1830

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 330ba11 and 9444768.

📒 Files selected for processing (1)
  • rakelib/shakapacker_examples.rake (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rakelib/shakapacker_examples.rake
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: dummy-app-integration-tests (3.4, 22)
  • GitHub Check: dummy-app-integration-tests (3.2, 20)
  • GitHub Check: build
  • GitHub Check: rspec-package-tests (3.2, latest)
  • GitHub Check: rspec-package-tests (3.4, latest)
  • GitHub Check: rspec-package-tests (3.4, minimum)
  • GitHub Check: rspec-package-tests (3.2, minimum)
  • GitHub Check: claude-review
  • GitHub Check: build-and-test

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.

Copy link

claude bot commented Sep 29, 2025

Code Review for PR #1839: Fix rake tasks after workspace structure merge

Thank you for quickly addressing the issues introduced by the workspace restructuring in PR #1830. This is a focused fix that correctly addresses three distinct problems.

Strengths

  1. Clear problem identification: Each issue is well-documented with its root cause
  2. Minimal, targeted fixes: Changes are surgical and don't introduce unnecessary modifications
  3. Proper testing: All three rake tasks have been verified to work

🎯 Code Quality Assessment

1. yalc publishyarn yalc publish (node_package.rake)

Correct fix. After PR #1830 made the root package.json private (which is standard for workspaces), running yalc publish directly fails. Using yarn yalc publish properly delegates to the workspace package's yalc script.

2. String concatenation fix (shakapacker_examples.rake)

Good catch. The missing space would have caused rails new to receive malformed options like webpack--skip-javascript.

3. yarnnpm install (shakapacker_examples.rake)

⚠️ Needs consideration. While this works, there's a potential inconsistency:

  • The main project uses Yarn Classic (as specified in CLAUDE.md)
  • Generated examples will now use npm
  • This could lead to confusion or dependency resolution differences

🔍 Potential Issues

  1. Package manager inconsistency: The change from yarn to npm install in generated examples creates a divergence from the main project's tooling. Consider:

    • Will example apps have different dependency resolutions?
    • Should examples maintain consistency with the main project's package manager?
    • Could this affect tutorial/documentation that assumes Yarn?
  2. No automated tests: These rake tasks aren't covered by CI, making regressions possible. Consider adding a simple CI check that runs these tasks.

💡 Suggestions

  1. Document the package manager choice: Add a comment explaining why npm install is used instead of yarn in generated examples
  2. Consider Yarn consistency: If Shakapacker defaults to npm when no lockfile exists, could we pre-create a yarn.lock or pass a flag to force Yarn usage?
  3. Add CI validation: Even a simple smoke test that runs these rake tasks in CI would catch future breakage

Security & Performance

  • No security concerns identified
  • Performance impact is negligible (build-time tasks only)

📊 Overall Assessment

Approved with minor suggestions. The fixes are correct and address real issues. The package manager inconsistency should be documented or reconsidered, but it's not a blocker since it matches Shakapacker's behavior.

Great work on the quick turnaround for these fixes! 🚀

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
rakelib/node_package.rake (2)

9-11: Log message mismatch (nit).

The message says running 'yalc publish', but the command is yarn yalc publish. Consider aligning the log for clarity.


10-10: Explicitly target the package workspace for yalc publish
The current sh "yarn run build && yarn yalc publish" runs in the repo root (a private workspace), which can publish the wrong package depending on Yarn’s CWD and version. Replace it with an explicit workspace or directory invocation, for example:

# Before
sh "yarn run build && yarn yalc publish"

# After (run inside the package dir)
sh_in_dir("path/to/your/package", "yarn yalc publish")

# Or (use Yarn workspace)
sh "yarn workspace react-on-rails-workspace yalc publish"

This guarantees the intended package is published consistently across Yarn v1–v4.

rakelib/shakapacker_examples.rake (1)

41-41: Improve deterministic installs and avoid dual lockfiles

Use npm ci when a lockfile is present, otherwise fall back to npm install, and add flags to disable audit and fund prompts. Also ensure you’re not mixing lockfile formats.

Apply:

-      sh_in_dir(example_type.dir, "npm install")
+      if File.exist?(File.join(example_type.dir, "package-lock.json"))
+        sh_in_dir(example_type.dir, "npm ci --no-audit --fund=false")
+      else
+        sh_in_dir(example_type.dir, "npm install --no-audit --fund=false")
+      end

Manually verify that no yarn.lock (or other lockfiles) remain in the example directories before merging to avoid conflicting lockfiles.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4a9a64 and 330ba11.

📒 Files selected for processing (2)
  • rakelib/node_package.rake (1 hunks)
  • rakelib/shakapacker_examples.rake (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{Gemfile,Rakefile,config.ru,**/*.{rb,rake,gemspec,ru}}

📄 CodeRabbit inference engine (CLAUDE.md)

{Gemfile,Rakefile,config.ru,**/*.{rb,rake,gemspec,ru}}: All Ruby code must pass RuboCop with zero offenses before commit/push
RuboCop is the sole authority for Ruby file formatting; never manually format Ruby files

Files:

  • rakelib/node_package.rake
  • rakelib/shakapacker_examples.rake
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: dummy-app-integration-tests (3.4, 22)
  • GitHub Check: dummy-app-integration-tests (3.2, 20)
  • GitHub Check: rspec-package-tests (3.2, latest)
  • GitHub Check: rspec-package-tests (3.4, minimum)
  • GitHub Check: rspec-package-tests (3.4, latest)
  • GitHub Check: rspec-package-tests (3.2, minimum)
  • GitHub Check: build-and-test

@ihabadham
Copy link
Contributor Author

3. yarnnpm install (shakapacker_examples.rake)

⚠️ Needs consideration. While this works, there's a potential inconsistency:

  • The main project uses Yarn Classic (as specified in CLAUDE.md)
  • Generated examples will now use npm
  • This could lead to confusion or dependency resolution differences

@claude addressing your review comment here.

The main project uses Yarn Classic (as specified in CLAUDE.md)

why is this a problem? these are standalone examples created with rails new and have their own package.json

Generated examples will now use npm

so?

This could lead to confusion or dependency resolution differences

how?

Copy link

claude bot commented Sep 29, 2025

Claude finished @ihabadham's task —— View job


Response to Package Manager Question

You make an excellent point, @ihabadham! I was overthinking this. Let me clarify:

You're absolutely right that:

  1. These are standalone Rails apps - They're created fresh with rails new and have their own independent package.json files. They're not part of the main project's workspace structure.

  2. npm is the appropriate choice - Since Shakapacker defaults to npm when no lockfile exists (as would be the case for a freshly generated Rails app), using npm install is actually the correct approach to avoid any package manager conflicts.

  3. No confusion or resolution issues - Each example is its own isolated project. There's no shared dependency tree or resolution conflicts to worry about.

My original concern was misplaced - I was thinking about these examples as if they were part of the main workspace, but they're not. They're independent Rails applications that users generate to test React on Rails integration.

The change from yarn to npm install is the right fix to align with Shakapacker's default behavior. Thanks for the clarification!

Updated assessment: ✅ All three fixes in this PR are correct and well-reasoned.

PR Status

  • yalc publishyarn yalc publish fix is correct
  • ✅ Rails command spacing fix is correct
  • yarnnpm install change is appropriate for standalone examples
  • ✅ Ready to merge

Great work on these fixes!

…ptions

Follows coderabbit's suggestion to avoid mutating the @rails_options
instance variable, preventing potential option duplication issues.

- More functional/immutable approach
- Cleaner and more explicit intent
- Prevents potential future bugs from state mutation

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai coderabbitai bot added the bug label Sep 29, 2025
Copy link

claude bot commented Sep 29, 2025

Code Review for PR #1839

Thank you for fixing these broken rake tasks after the workspace structure changes! The fixes are well-targeted and address real issues.

Strengths

Code Quality Issues

1. node_package.rake - Workspace targeting ambiguity

The change from yalc publish to yarn yalc publish correctly addresses the private workspace issue. However, there is a potential ambiguity about which package gets published.

Recommendation: Be more explicit about which workspace package to publish by using yarn workspace react-on-rails yalc publish or running from the package directory.

2. shakapacker_examples.rake - Package manager consistency

While switching from yarn to npm install aligns with Shapackers default, this could create inconsistency issues with potential for dual lockfiles and less deterministic installs without npm ci.

Recommendation: Use npm ci when lockfile exists for deterministic installs, and add --no-audit --fund=false flags to reduce noise. Also verify no yarn.lock files remain in generated examples.

Potential Issues

  1. Log message mismatch: Line 9 says running yalc publish but executes yarn yalc publish
  2. The removal of rails_options += --skip-javascript and inline addition is good, but consider if this was meant to be configurable

Security and Performance

  • No security concerns identified
  • Performance impact is minimal (build-time only)

Test Coverage

Test plan looks solid with manual verification. Consider adding automated tests for these rake tasks to catch future regressions.

Overall Assessment

These are necessary fixes that restore functionality broken by the workspace restructuring. The changes are minimal and targeted. With the workspace targeting clarification for yalc and the npm install improvements, this PR will be ready to merge.

Approved with suggestions - The fixes work as-is, but implementing the recommendations above would improve robustness and maintainability.

Copy link

claude bot commented Sep 29, 2025

Code Review for PR #1839

Thank you for fixing the rake tasks broken by the workspace structure changes! I've reviewed the changes and here's my feedback:

Code Quality & Best Practices

The fixes are clean, targeted, and follow the repository's conventions:

  • Minimal changes that directly address the issues
  • Maintains consistency with existing rake task patterns
  • Follows Ruby style conventions

Bug Fixes

All three issues are properly addressed:

  1. yalc publish fix: Using yarn yalc publish correctly delegates to the workspace package, working around the private root package.json
  2. Rails options syntax: The string concatenation issue is fixed by directly including --skip-javascript in the command
  3. Package manager alignment: Switching to npm install aligns with Shakapacker's default behavior

🔍 Potential Considerations

  1. Package Manager Consistency: While switching to npm install aligns with Shakapacker's defaults, consider documenting this change since the rest of the project uses Yarn. This could be confusing for contributors.

  2. Error Handling: Consider adding error handling or checks to ensure yarn yalc publish succeeds, as this is now a critical step in the build process.

Security

No security concerns identified. The changes are limited to build tooling and don't introduce any new dependencies or external commands.

⚠️ Test Coverage

While the manual testing mentioned in the PR description is good, consider:

  • Adding automated tests for these rake tasks if not already present
  • Documenting the expected behavior in comments for future maintainers

💡 Performance

No performance concerns - these are build-time tasks.

Overall Assessment

This is a well-crafted fix that properly addresses the issues introduced by PR #1830's workspace restructuring. The changes are minimal, focused, and maintain backward compatibility. The PR description is excellent - clearly explaining the problems, solutions, and root cause.

Recommendation: ✅ Ready to merge once CI checks pass.

Minor suggestion: Consider adding a comment in the rake files explaining why yarn yalc publish is used instead of direct yalc publish for future maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant