Skip to content

Commit ceba773

Browse files
committed
fix(@angular/cli): prefer installed package as fallback when listing package groups
Previously, the package group name defaulted to the first item in the list. This update prioritizes an installed package as the fallback instead. Closes #29627 (cherry picked from commit 09f5006)
1 parent 5c56cdb commit ceba773

File tree

1 file changed

+8
-3
lines changed
  • packages/angular/cli/src/commands/update/schematic

1 file changed

+8
-3
lines changed

packages/angular/cli/src/commands/update/schematic/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -471,19 +471,24 @@ function _usageMessage(
471471
)
472472
.map(({ name, info, version, tag, target }) => {
473473
// Look for packageGroup.
474-
const packageGroup = target['ng-update']?.['packageGroup'];
474+
const ngUpdate = target['ng-update'];
475+
const packageGroup = ngUpdate?.['packageGroup'];
475476
if (packageGroup) {
476477
const packageGroupNames = Array.isArray(packageGroup)
477478
? packageGroup
478479
: Object.keys(packageGroup);
480+
const packageGroupName =
481+
ngUpdate?.['packageGroupName'] || packageGroupNames.find((n) => infoMap.has(n));
479482

480-
const packageGroupName = target['ng-update']?.['packageGroupName'] || packageGroupNames[0];
481483
if (packageGroupName) {
482484
if (packageGroups.has(name)) {
483485
return null;
484486
}
485487

486-
packageGroupNames.forEach((x: string) => packageGroups.set(x, packageGroupName));
488+
for (const groupName of packageGroupNames) {
489+
packageGroups.set(groupName, packageGroupName);
490+
}
491+
487492
packageGroups.set(packageGroupName, packageGroupName);
488493
name = packageGroupName;
489494
}

0 commit comments

Comments
 (0)