-
-
Notifications
You must be signed in to change notification settings - Fork 638
Update preinstall script to enable use as a Git dependency #1873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis PR updates changelog and contributor documentation to document Git dependency installation, refactors the preinstall workflow in react_on_rails_pro from inline commands to a dedicated Node script for improved modularity and error handling, and adjusts related package configuration. Changes
Sequence DiagramsequenceDiagram
autonumber
actor User
participant npm/yarn as npm/yarn install
participant pkg.json as package.json<br/>(preinstall)
participant script as preinstall.js
participant cmds as link-source &<br/>yalc commands
User->>npm/yarn: npm/yarn install
npm/yarn->>pkg.json: trigger preinstall hook
pkg.json->>script: node ./script/preinstall.js
rect rgb(240, 248, 255)
note right of script: Guard check
script->>script: if in node_modules?
script->>script: exit 0 (skip)
end
rect rgb(240, 248, 255)
note right of script: Execute commands
script->>cmds: yarn run link-source
cmds-->>script: success/error
script->>cmds: yalc add --link<br/>react-on-rails
cmds-->>script: success/error
end
rect rgb(240, 248, 255)
note right of script: Error handling
alt Any command fails
script->>script: log error, exit 0
else All succeed
script->>script: complete
end
end
script-->>npm/yarn: exit code 0
npm/yarn-->>User: install complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Rationale: The diff spans diverse file types (documentation, configuration, new script) with mixed complexity. CONTRIBUTING.md is large but consists of consistent documentation rewrites and example updates. The preinstall.js is new but straightforward with clear error-handling logic. The package.json change is minimal. The heterogeneous nature (documentation + script refactoring) and moderate scope warrant careful review of the script's error-handling assumptions and documentation accuracy, but no dense logic or structural complexity is present. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.{js,jsx,ts,tsx,css,scss,json,yml,yaml,md}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-10-23T17:22:01.064ZApplied to files:
🪛 LanguageToolCONTRIBUTING.md[style] ~95-~95: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing. (REP_NEED_TO_VB) [style] ~106-~106: Consider shortening or rephrasing this to strengthen your wording. (MAKE_CHANGES) [grammar] ~137-~137: Use a hyphen to join words. (QB_NEW_EN_HYPHEN) 🪛 markdownlint-cli2 (0.18.1)CONTRIBUTING.md97-97: Fenced code blocks should have a language specified (MD040, fenced-code-language) 109-109: Fenced code blocks should have a language specified (MD040, fenced-code-language) 165-165: Bare URL used (MD034, no-bare-urls) 173-173: Bare URL used (MD034, no-bare-urls) 181-181: Bare URL used (MD034, no-bare-urls) ⏰ 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). (1)
🔇 Additional comments (11)
Comment |
Code Review: PR #1873 - Update preinstall script to enable use as a Git dependencySummaryThis PR refactors the preinstall script from inline shell commands to a dedicated Node.js script, enabling the package to work properly when installed as a Git dependency. ✅ Strengths1. Code Quality
2. Implementation
🔍 Issues & RecommendationsCritical: Inconsistent Error HandlingLocation: react_on_rails_pro/script/preinstall.js:14-18 The runCommand function throws errors on failure, but the catch block at line 26 catches them and exits with code 0. This creates inconsistent behavior where exceptions are used for control flow. Recommendation: Since these commands are optional, consider removing the throws from runCommand and returning a boolean status instead. This makes the intent clearer and avoids using exceptions for control flow. Minor: Edge Case - Missing __dirnameLocation: preinstall.js:6 The fallback to process.cwd() is good defensive coding, but __dirname should always be defined in CommonJS scripts. This fallback might mask a real problem if __dirname is ever undefined. Recommendation: Consider adding a comment explaining when this fallback would be needed, or remove it if it's unnecessary. Minor: Error Object LoggingLocation: preinstall.js:29 Logging the entire error object may produce unclear output. Consider logging just the message for better readability. 🔒 Security Considerations✅ No security concerns identified
⚡ Performance Considerations✅ Performance is appropriate
🧪 Test CoverageWhile install scripts are notoriously difficult to test, consider:
📝 Documentation✅ PR description mentions documentation updates
🎯 Final RecommendationApprove with minor suggestions The PR successfully solves the Git dependency installation issue with a clean, cross-platform solution. The main concerns are around code clarity and error handling patterns rather than functional issues. Before merging:
Alignment with CLAUDE.md
Great work on improving the developer experience for Git dependency usage! 🚀 |
Code Review - PR #1873SummaryThis PR refactors the preinstall script to enable the react_on_rails_pro package to work as a Git dependency by moving the logic from a shell command string to a dedicated Node.js script. Positive Aspects
Code Quality Issues
The new file is missing a trailing newline character, which will cause CI to fail per the CLAUDE.md requirements. Fix: Add a newline after the final closing brace on line 31.
The check for node_modules could incorrectly match if someone has node_modules anywhere in their directory path. Recommendation: Use a more robust check that looks for node_modules as a directory boundary.
The fallback to process.cwd() is unnecessary since __dirname is always defined in regular Node.js scripts.
The generic error catch makes debugging harder. Consider adding more specific error information including the error message and code. Testing ConcernsIssue: The PR checklist shows test coverage is not complete. Recommendation: Consider adding tests for:
Security ConsiderationsNo security concerns identified. The script:
Performance ConsiderationsPerformance impact is minimal:
Additional Recommendations
Must Fix Before Merge
Overall AssessmentThis is a well-intentioned change that solves a real problem (Git dependency support). The code structure is clean and the approach is sound. However, there are critical formatting issues that will cause CI to fail, and some edge cases in the detection logic that should be addressed. Recommendation: Request changes to fix the critical formatting issue and improve the path detection logic before merging. Review generated by Claude Code following repository conventions from CLAUDE.md |
1b62ceb to
8d54e33
Compare
Code Review: PR #1873This PR successfully enables Git dependency support by refactoring the preinstall script. Overall assessment: Approve with minor suggestions Strengths
Issues & RecommendationsMinor: Node Modules Detection Edge CaseLocation: preinstall.js:7 The check could produce false positives if 'node_modules' appears anywhere in the directory path. Consider using a more robust check that verifies node_modules is a direct parent directory. Severity: Low Minor: Redundant FallbackLocation: preinstall.js:6 The fallback to process.cwd() is unnecessary since __dirname is always defined in CommonJS modules. Severity: Very Low Code Style: Exception Control FlowLocation: preinstall.js:14-18, 26-31 The runCommand function throws errors which are then caught and ignored. Consider refactoring to return status objects instead. Severity: Low (stylistic preference) Security & Performance
CLAUDE.md ComplianceBefore merging, verify:
Impact Assessment
Great work on improving the Git dependency support! Review by Claude Code following CLAUDE.md conventions |
Pull Request Review: Update preinstall script to enable use as a Git dependencySummaryThis PR successfully enables React on Rails packages to be installed as Git dependencies, which is valuable for development and testing. The changes are well-documented and the implementation is thoughtful. Code Quality & Best PracticesStrengths ✅
Areas for Improvement 🔍
Potential Bugs or IssuesMedium Priority
Performance Considerations
Security ConcernsLow Risk ✅
Recommendations
Test CoverageConcerns
|
8d54e33 to
b21f860
Compare
b21f860 to
6a040ee
Compare
|
A better long-term solution is to make |
Summary
Documented use as a Git dependency and fixed an issue with the Pro Node renderer there.
Pull Request checklist
This change is
Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation