Skip to content

Commit 824add1

Browse files
committed
fix(@angular/cli): no-op ng update --all
'--all' functionality has been removed from `ng update` as updating multiple packages at once is not recommended. To update the depencencies in your workspace 'package.json' use the update command of your package manager. Closes #15278 Closes #13095 Closes #12261 Closes #12243 Closes #18813
1 parent c78a460 commit 824add1

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

packages/angular/cli/commands/update-impl.ts

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,20 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
307307
);
308308
}
309309

310+
if (options.all) {
311+
const updateCmd = this.packageManager === PackageManager.Yarn
312+
? `'yarn upgrade-interactive' or 'yarn upgrade'`
313+
: `'${this.packageManager} update'`;
314+
315+
this.logger.warn(`
316+
'--all' functionality has been removed as updating multiple packages at once is not recommended.
317+
To update packages which don’t provide 'ng update' capabilities in your workspace 'package.json' use ${updateCmd} instead.
318+
Run the package manager update command after updating packages which provide 'ng update' capabilities.
319+
`);
320+
321+
return 0;
322+
}
323+
310324
const packages: PackageIdentifier[] = [];
311325
for (const request of options['--'] || []) {
312326
try {
@@ -342,24 +356,15 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
342356
}
343357
}
344358

345-
if (options.all && packages.length > 0) {
346-
this.logger.error('Cannot specify packages when using the "all" option.');
347-
348-
return 1;
349-
} else if (options.all && options.migrateOnly) {
350-
this.logger.error('Cannot use "all" option with "migrate-only" option.');
351-
352-
return 1;
353-
} else if (!options.migrateOnly && (options.from || options.to)) {
359+
if (!options.migrateOnly && (options.from || options.to)) {
354360
this.logger.error('Can only use "from" or "to" options with "migrate-only" option.');
355361

356362
return 1;
357363
}
358364

359365
// If not asking for status then check for a clean git repository.
360366
// This allows the user to easily reset any changes from the update.
361-
const statusCheck = packages.length === 0 && !options.all;
362-
if (!statusCheck && !this.checkCleanGit()) {
367+
if (packages.length && !this.checkCleanGit()) {
363368
if (options.allowDirty) {
364369
this.logger.warn(
365370
'Repository is not clean. Update changes will be mixed with pre-existing changes.',
@@ -379,7 +384,6 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
379384
if (
380385
options.migrateOnly === undefined &&
381386
options.from === undefined &&
382-
!options.all &&
383387
packages.length === 1 &&
384388
packages[0].name === '@angular/cli' &&
385389
this.workspace.configFile &&
@@ -395,25 +399,14 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
395399

396400
this.logger.info(`Found ${rootDependencies.size} dependencies.`);
397401

398-
if (options.all) {
399-
// 'all' option and a zero length packages have already been checked.
400-
// Add all direct dependencies to be updated
401-
for (const dep of rootDependencies.keys()) {
402-
const packageIdentifier = npa(dep);
403-
if (options.next) {
404-
packageIdentifier.fetchSpec = 'next';
405-
}
406-
407-
packages.push(packageIdentifier);
408-
}
409-
} else if (packages.length === 0) {
402+
if (packages.length === 0) {
410403
// Show status
411404
const { success } = await this.executeSchematic('@schematics/update', 'update', {
412405
force: options.force || false,
413406
next: options.next || false,
414407
verbose: options.verbose || false,
415408
packageManager: this.packageManager,
416-
packages: options.all ? rootDependencies.keys() : [],
409+
packages: [],
417410
});
418411

419412
return success ? 0 : 1;

packages/angular/cli/commands/update.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"all": {
3636
"description": "Whether to update all packages in package.json.",
3737
"default": false,
38-
"type": "boolean"
38+
"type": "boolean",
39+
"x-deprecated": true
3940
},
4041
"next": {
4142
"description": "Use the prerelease version, including beta and RCs.",

tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function() {
1818
await writeFile('../added.ts', 'console.log(\'created\');\n');
1919
await silentGit('add', '../added.ts');
2020

21-
const { stderr } = await ng('update', '--all', '--force');
21+
const { stderr } = await ng('update', '@angular/cli');
2222
if (stderr && stderr.includes('Repository is not clean.')) {
2323
throw new Error('Expected clean repository');
2424
}

tests/legacy-cli/e2e/tests/misc/update-git-clean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expectToFail } from '../../utils/utils';
55
export default async function() {
66
await appendToFile('src/main.ts', 'console.log(\'changed\');\n');
77

8-
const { message } = await expectToFail(() => ng('update', '--all'));
8+
const { message } = await expectToFail(() => ng('update', '@angular/cli'));
99
if (!message || !message.includes('Repository is not clean.')) {
1010
throw new Error('Expected unclean repository');
1111
}

0 commit comments

Comments
 (0)