-
-
Notifications
You must be signed in to change notification settings - Fork 638
Open
Labels
Description
Summary
Improve the React on Rails install generator to be more robust with better error handling, validation, and package manager detection.
Background
PR #1896 contained several generator improvements that should be extracted and applied to current master.
Proposed Changes
1. Better Package Manager Detection
- Improve detection of npm vs yarn vs pnpm
- Handle edge cases where package manager isn't obvious
- Add validation that chosen package manager is actually available
2. Smarter Validation Skipping
- Skip version validation when react-on-rails package not yet installed
- Avoid false errors during initial installation
- Better error messages when validation does fail
3. Webpack Safety Checks
- Add checks before modifying webpack config
- Validate webpack config exists before attempting modifications
- Better error messages for webpack-related issues
4. Exact Version Specifications
- Use exact versions where needed to avoid dependency conflicts
- Document why certain packages need exact versions
- Provide clear upgrade path
5. Better Error Messages
- Provide actionable error messages
- Include suggestions for common issues
- Link to troubleshooting documentation
Files to Update
From PR #1896 as reference:
lib/generators/react_on_rails/base_generator.rblib/generators/react_on_rails/generator_helper.rblib/generators/react_on_rails/install_generator.rb- Generator templates in
lib/generators/react_on_rails/templates/
Testing
- Test generator with npm, yarn, and pnpm
- Test in fresh Rails app
- Test in existing Rails app with react-on-rails
- Test error scenarios (missing dependencies, etc.)
- Verify all generator tests pass
Related
- Extracted from closed PR Upgrade Shakapacker to 9.3.0 #1896
- Complements smart error messages work in feat: Add smart error messages with actionable solutions #1834
Labels
enhancement, generator