From ac29ecbba2dc70191a6c83e264ecdc8b6edd5c5d Mon Sep 17 00:00:00 2001 From: MeAkib Date: Thu, 5 Nov 2026 23:58:34 +0600 Subject: [PATCH] fix(@angular/cli): use the workspace package manager in catalog update guidance When `ng update` aborts because a package uses the `catalog:` protocol, the manual migration steps hardcode pnpm and yarn: the install step suggests 'pnpm install' for every package manager except yarn, and the catalog file hint only names pnpm-workspace.yaml and .yarnrc.yml. Bun workspaces also support catalogs, so a bun workspace is told to run 'pnpm install' and to look for files it does not have. Build the install command from the detected package manager and name the catalog location it actually uses: pnpm-workspace.yaml for pnpm, .yarnrc.yml for yarn, and the 'workspaces.catalog' field in the root package.json for bun. The previous generic text is kept as a fallback when the package manager is unknown. The new spec fails without the fix: with `packageManager: 'bun'`, the guidance suggested 'pnpm install' and the pnpm/yarn file names. --- .../src/commands/update/update-resolver.ts | 14 +++++++--- .../commands/update/update-resolver_spec.ts | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/packages/angular/cli/src/commands/update/update-resolver.ts b/packages/angular/cli/src/commands/update/update-resolver.ts index 30231ad48dbb..bbd5af654d44 100644 --- a/packages/angular/cli/src/commands/update/update-resolver.ts +++ b/packages/angular/cli/src/commands/update/update-resolver.ts @@ -832,8 +832,16 @@ async function checkCatalogUpdates( } if (catalogUpdates.length > 0) { - const packageManagerName = options.packageManager ?? 'your package manager'; - const installCmd = packageManagerName === 'yarn' ? 'yarn install' : 'pnpm install'; + const packageManagerName = options.packageManager; + const installCmd = packageManagerName ? `${packageManagerName} install` : 'pnpm install'; + const catalogLocations: Record = { + pnpm: 'pnpm-workspace.yaml', + yarn: '.yarnrc.yml', + bun: `the 'workspaces.catalog' field in the root package.json`, + }; + const catalogLocation = + (packageManagerName && catalogLocations[packageManagerName]) || + 'e.g., pnpm-workspace.yaml or .yarnrc.yml'; const updatesList = catalogUpdates .map((pkg) => ` - ${pkg.name} (${pkg.specifier}) -> Target version: ${pkg.target}`) @@ -853,7 +861,7 @@ async function checkCatalogUpdates( `Because catalogs are shared across the monorepo, 'ng update' cannot modify them directly.\n` + `Please perform the following steps to update:\n` + ` 1. Manually update the versions for these packages in your catalog configuration file ` + - `(e.g., pnpm-workspace.yaml or .yarnrc.yml).\n` + + `(${catalogLocation}).\n` + ` 2. Run '${installCmd}' to install the updated versions.\n` + ` 3. Run the following command(s) from the workspace root to execute the migration schematics:\n` + `${migrationCommands}`, diff --git a/packages/angular/cli/src/commands/update/update-resolver_spec.ts b/packages/angular/cli/src/commands/update/update-resolver_spec.ts index a5074ea1bfec..d9a34d5ef6ae 100644 --- a/packages/angular/cli/src/commands/update/update-resolver_spec.ts +++ b/packages/angular/cli/src/commands/update/update-resolver_spec.ts @@ -544,6 +544,33 @@ Please perform the following steps to update: ).toBeRejectedWithError(new RegExp(expectedError)); }); + it('uses the workspace package manager in the catalog update guidance', async () => { + createMockWorkspace( + { + name: 'blah', + dependencies: { + '@angular/core': 'catalog:', + }, + }, + { + '@angular/core': { version: '5.1.0' }, + }, + ); + + const expectedError = + ` 1\\. Manually update the versions for these packages in your catalog configuration ` + + `file \\(the 'workspaces\\.catalog' field in the root package\\.json\\)\\.\n` + + ` 2\\. Run 'bun install' to install the updated versions\\.`; + + await expectAsync( + resolvePlan({ + packages: ['@angular/core'], + workspaceRoot: tempRoot, + packageManager: 'bun', + }), + ).toBeRejectedWithError(new RegExp(expectedError)); + }); + it('rejects updates for catalog packages specified with a version suffix', async () => { createMockWorkspace( {