Skip to content

Commit

Permalink
fix(@angular/cli): prefer installed package as fallback when listing …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
alan-agius4 committed Feb 13, 2025
1 parent 5c56cdb commit ceba773
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/angular/cli/src/commands/update/schematic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,19 +471,24 @@ function _usageMessage(
)
.map(({ name, info, version, tag, target }) => {
// Look for packageGroup.
const packageGroup = target['ng-update']?.['packageGroup'];
const ngUpdate = target['ng-update'];
const packageGroup = ngUpdate?.['packageGroup'];
if (packageGroup) {
const packageGroupNames = Array.isArray(packageGroup)
? packageGroup
: Object.keys(packageGroup);
const packageGroupName =
ngUpdate?.['packageGroupName'] || packageGroupNames.find((n) => infoMap.has(n));

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

packageGroupNames.forEach((x: string) => packageGroups.set(x, packageGroupName));
for (const groupName of packageGroupNames) {
packageGroups.set(groupName, packageGroupName);
}

packageGroups.set(packageGroupName, packageGroupName);
name = packageGroupName;
}
Expand Down

0 comments on commit ceba773

Please sign in to comment.