From ceba7739cc72835d080a3c2246209a635212a607 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 13 Feb 2025 08:07:44 +0000 Subject: [PATCH] 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 09f5006b5ca208a4a9d3692223ca78f8c0226bc8) --- .../cli/src/commands/update/schematic/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/angular/cli/src/commands/update/schematic/index.ts b/packages/angular/cli/src/commands/update/schematic/index.ts index 9b56ec01d363..26d2d06836b4 100644 --- a/packages/angular/cli/src/commands/update/schematic/index.ts +++ b/packages/angular/cli/src/commands/update/schematic/index.ts @@ -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; }