Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular/cli): remove the need to specify --migrate-only when --name is used during ng update #26082

Merged
merged 1 commit into from Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions packages/angular/cli/src/commands/update/cli.ts
Expand Up @@ -107,23 +107,21 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
})
.option('name', {
description:
'The name of the migration to run. ' +
`Only available with a single package being updated, and only with 'migrate-only' option.`,
'The name of the migration to run. Only available when a single package is updated.',
type: 'string',
implies: ['migrate-only'],
conflicts: ['to', 'from'],
})
.option('from', {
description:
'Version from which to migrate from. ' +
`Only available with a single package being updated, and only with 'migrate-only'.`,
`Only available when a single package is updated, and only with 'migrate-only'.`,
type: 'string',
implies: ['migrate-only'],
conflicts: ['name'],
})
.option('to', {
describe:
'Version up to which to apply migrations. Only available with a single package being updated, ' +
'Version up to which to apply migrations. Only available when a single package is updated, ' +
`and only with 'migrate-only' option. Requires 'from' to be specified. Default to the installed version detected.`,
type: 'string',
implies: ['from', 'migrate-only'],
Expand All @@ -146,6 +144,14 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
alias: ['C'],
default: false,
})
.middleware((argv) => {
if (argv.name) {
argv['migrate-only'] = true;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
return argv as any;
})
.check(({ packages, 'allow-dirty': allowDirty, 'migrate-only': migrateOnly }) => {
const { logger } = this.context;

Expand Down Expand Up @@ -1082,9 +1088,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
for (const migration of optionalMigrations) {
const { title } = getMigrationTitleAndDescription(migration);
logger.info(colors.cyan(colors.symbols.pointer) + ' ' + colors.bold(title));
logger.info(
colors.gray(` ng update ${packageName} --migration-only --name ${migration.name}`),
);
logger.info(colors.gray(` ng update ${packageName} --name ${migration.name}`));
logger.info(''); // Extra trailing newline.
}

Expand Down