Commit a63799b
committed
refactor(@angular/cli): optimize and harden list_projects tool
This commit significantly improves the `list_projects` tool's performance, robustness, and code quality.
The key changes include:
- Parallelizing Workspace Processing: The `createListProjectsHandler` now collects all `angular.json` file paths first, then processes them concurrently using `Promise.all`. This speeds up the tool for repositories containing multiple workspaces.
- Robust Duplicate Handling: A Map-based deduplication strategy ensures each `angular.json` is processed only once. It selects the "best" (shortest) search root for each unique workspace, guaranteeing optimal framework version detection regardless of the input `searchRoots` order.
- Enhanced package.json Parsing Safety: `findAngularCoreVersion` now specifically catches and reports `SyntaxError` for malformed `package.json` files, providing clearer error messages.
- Improved Type Safety and Readability: `loadAndParseWorkspace` now returns a discriminated union, ensuring `workspace` is non-null when no `error` is present. This removed a redundant null check and `seenPaths` arguments from helper functions, simplifying the codebase.1 parent 3480966 commit a63799b
1 file changed
+39
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
| |||
454 | 461 | | |
455 | 462 | | |
456 | 463 | | |
457 | | - | |
458 | | - | |
| 464 | + | |
459 | 465 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | | - | |
512 | 511 | | |
513 | 512 | | |
514 | 513 | | |
515 | 514 | | |
516 | 515 | | |
517 | 516 | | |
518 | | - | |
| 517 | + | |
519 | 518 | | |
520 | 519 | | |
521 | 520 | | |
522 | 521 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | 522 | | |
528 | 523 | | |
529 | 524 | | |
| |||
549 | 544 | | |
550 | 545 | | |
551 | 546 | | |
552 | | - | |
553 | 547 | | |
554 | 548 | | |
555 | 549 | | |
| |||
574 | 568 | | |
575 | 569 | | |
576 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
577 | 576 | | |
578 | 577 | | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
594 | 583 | | |
595 | 584 | | |
596 | 585 | | |
597 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
598 | 606 | | |
599 | 607 | | |
600 | 608 | | |
| |||
0 commit comments