Commit 3ec77e3
authored
Add rake shakapacker:doctor command for configuration checks (#609)
This PR introduces a comprehensive diagnostic tool for Shakapacker configurations,
addressing the increased complexity after removing peer dependencies in v9.0.0.
Key Features:
- Validates JavaScript transpiler dependencies (Babel, SWC, esbuild)
- Checks package manager availability and lock file consistency
- Verifies Node.js version compatibility (>=18.0.0)
- Detects missing entry points and validates manifest.json
- Checks asset compilation freshness
- Validates shakapacker.yml configuration
- Detects version mismatches between gem and npm package
- Provides migration guidance from deprecated options
- Platform-specific issue detection (Windows, CI environments)
Implementation Details:
- Created Shakapacker::Doctor class with modular check methods
- Added nested Reporter class for formatted output
- Implemented secure command execution using Open3
- Added performance optimizations with early exits and caching
- Comprehensive test suite with 66 test cases
- Support for all package managers (npm, yarn, pnpm, bun)
Security Improvements:
- Replaced backticks with Open3.capture3 for command execution
- Added proper error handling for all external commands
- Validated file paths before operations
Impact on Users:
- New installations: Helps verify correct setup after v9 migration
- Existing installations: Assists in troubleshooting configuration issues
- Migration from v8: Provides specific guidance on dependency changes
- All users: Proactive detection of common configuration problems
The doctor command is especially valuable for v9 users adapting to the new
peer dependency model and SWC as the default JavaScript transpiler.1 parent 405c2bf commit 3ec77e3
6 files changed
Lines changed: 1761 additions & 0 deletions
File tree
- lib
- shakapacker
- tasks
- shakapacker
- spec/shakapacker
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
0 commit comments