Commit 2cdeaef
Replace fragile regex validation with Shakapacker 9.0+ integration
Addresses code review feedback about fragile regex matching by implementing
a proper integration with Shakapacker 9.0+ private_output_path.
**Key Changes:**
**1. Auto-Detection from Shakapacker (configuration.rb)**
- New `auto_detect_server_bundle_path_from_shakapacker` method
- Automatically reads `private_output_path` from Shakapacker 9.0+ config
- Only applies if user hasn't explicitly set `server_bundle_output_path`
- Gracefully falls back to default if detection fails
- Logs info message when auto-detection succeeds
**2. Removed Fragile Regex Validation (doctor.rb)**
- Removed `validate_server_bundle_path_sync` method (regex matching)
- Removed `extract_webpack_output_path` method (pattern detection)
- Removed `normalize_path` method (no longer needed)
- Replaced with `check_shakapacker_private_output_path` method
**3. Recommendation-Based Doctor Checks (doctor.rb)**
- Detects Shakapacker version and capabilities
- Pre-9.0: Recommends upgrading for better DX
- 9.0+ without config: Shows how to configure private_output_path
- 9.0+ with config matching: Success message
- 9.0+ with config mismatch: Warning with fix instructions
- No Shakapacker: Informs about manual configuration
**4. Updated Generator Templates**
- **React on Rails initializer**: Documents Shakapacker 9.0+ approach first
- **Webpack config**: Shows config.privateOutputPath pattern
- Both templates emphasize single source of truth in shakapacker.yml
- Clear migration path for older Shakapacker versions
**5. Comprehensive Test Coverage (8 new tests)**
- Shakapacker not defined scenario
- Pre-9.0 Shakapacker (no private_output_path support)
- 9.0+ with matching config
- 9.0+ with mismatched config
- 9.0+ without config
- Error handling
- All tests passing
**Benefits:**
- No fragile regex parsing of webpack configs
- Single source of truth in shakapacker.yml
- Automatic configuration for Shakapacker 9.0+ users
- Backward compatible with older Shakapacker versions
- Clear upgrade path and recommendations
- Robust error handling
**Breaking Changes:** None
- Existing configurations continue to work
- Auto-detection only applies to default values
- Explicit user configuration always takes precedence
Addresses: @justin's feedback on PR #1967
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent c83529c commit 2cdeaef
File tree
5 files changed
+165
-234
lines changed- lib
- generators/react_on_rails/templates/base/base/config
- initializers
- webpack
- react_on_rails
- spec/lib/react_on_rails
5 files changed
+165
-234
lines changedLines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | 48 | | |
51 | | - | |
52 | | - | |
| 49 | + | |
53 | 50 | | |
54 | | - | |
55 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| |||
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
260 | 290 | | |
261 | 291 | | |
262 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
692 | | - | |
| 691 | + | |
| 692 | + | |
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| |||
1405 | 1405 | | |
1406 | 1406 | | |
1407 | 1407 | | |
1408 | | - | |
1409 | | - | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
1415 | 1413 | | |
1416 | 1414 | | |
1417 | 1415 | | |
1418 | | - | |
1419 | | - | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
1420 | 1420 | | |
1421 | | - | |
1422 | | - | |
| 1421 | + | |
| 1422 | + | |
1423 | 1423 | | |
1424 | | - | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
1425 | 1431 | | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1429 | 1435 | | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
| 1436 | + | |
| 1437 | + | |
1435 | 1438 | | |
1436 | | - | |
1437 | | - | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
1438 | 1445 | | |
1439 | | - | |
1440 | | - | |
| 1446 | + | |
| 1447 | + | |
1441 | 1448 | | |
1442 | | - | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
1443 | 1456 | | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
| 1457 | + | |
| 1458 | + | |
1447 | 1459 | | |
1448 | | - | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1449 | 1464 | | |
1450 | 1465 | | |
1451 | 1466 | | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
1461 | | - | |
1462 | | - | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
1471 | | - | |
1472 | | - | |
| 1467 | + | |
1473 | 1468 | | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
1481 | | - | |
1482 | | - | |
1483 | | - | |
1484 | | - | |
1485 | | - | |
1486 | | - | |
1487 | | - | |
1488 | | - | |
1489 | | - | |
1490 | | - | |
1491 | | - | |
1492 | 1469 | | |
| 1470 | + | |
1493 | 1471 | | |
1494 | 1472 | | |
1495 | 1473 | | |
0 commit comments