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( {