Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/angular/cli/src/commands/update/update-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> = {
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}`)
Expand All @@ -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}`,
Expand Down
27 changes: 27 additions & 0 deletions packages/angular/cli/src/commands/update/update-resolver_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Loading