Skip to content

Commit 4427560

Browse files
committed
fix(@angular/cli): remove the need to specify --migrate-only when --name is used during ng update
This commit updates the behaviour of `ng update --migrate-only` to remove the need for `--migrate-only` option to be specified. `--migrate-only` will be set internally. Before ``` ng update @angular/cli --migrate-only --name=migration-name ``` Now ``` ng update @angular/cli --name=migration-name ``` (cherry picked from commit 2c1c676)
1 parent b5d4003 commit 4427560

File tree

1 file changed

+12
-8
lines changed
  • packages/angular/cli/src/commands/update

1 file changed

+12
-8
lines changed

packages/angular/cli/src/commands/update/cli.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,21 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
107107
})
108108
.option('name', {
109109
description:
110-
'The name of the migration to run. ' +
111-
`Only available with a single package being updated, and only with 'migrate-only' option.`,
110+
'The name of the migration to run. Only available when a single package is updated.',
112111
type: 'string',
113-
implies: ['migrate-only'],
114112
conflicts: ['to', 'from'],
115113
})
116114
.option('from', {
117115
description:
118116
'Version from which to migrate from. ' +
119-
`Only available with a single package being updated, and only with 'migrate-only'.`,
117+
`Only available when a single package is updated, and only with 'migrate-only'.`,
120118
type: 'string',
121119
implies: ['migrate-only'],
122120
conflicts: ['name'],
123121
})
124122
.option('to', {
125123
describe:
126-
'Version up to which to apply migrations. Only available with a single package being updated, ' +
124+
'Version up to which to apply migrations. Only available when a single package is updated, ' +
127125
`and only with 'migrate-only' option. Requires 'from' to be specified. Default to the installed version detected.`,
128126
type: 'string',
129127
implies: ['from', 'migrate-only'],
@@ -146,6 +144,14 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
146144
alias: ['C'],
147145
default: false,
148146
})
147+
.middleware((argv) => {
148+
if (argv.name) {
149+
argv['migrate-only'] = true;
150+
}
151+
152+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
153+
return argv as any;
154+
})
149155
.check(({ packages, 'allow-dirty': allowDirty, 'migrate-only': migrateOnly }) => {
150156
const { logger } = this.context;
151157

@@ -1084,9 +1090,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
10841090
for (const migration of optionalMigrations) {
10851091
const { title } = getMigrationTitleAndDescription(migration);
10861092
logger.info(colors.cyan(colors.symbols.pointer) + ' ' + colors.bold(title));
1087-
logger.info(
1088-
colors.gray(` ng update ${packageName} --migration-only --name ${migration.name}`),
1089-
);
1093+
logger.info(colors.gray(` ng update ${packageName} --name ${migration.name}`));
10901094
logger.info(''); // Extra trailing newline.
10911095
}
10921096

0 commit comments

Comments
 (0)