diff --git a/packages/angular/cli/commands/update-impl.ts b/packages/angular/cli/commands/update-impl.ts index 6b26df6efc8a..b119baa1651a 100644 --- a/packages/angular/cli/commands/update-impl.ts +++ b/packages/angular/cli/commands/update-impl.ts @@ -307,6 +307,20 @@ export class UpdateCommand extends Command<UpdateCommandSchema> { ); } + if (options.all) { + const updateCmd = this.packageManager === PackageManager.Yarn + ? `'yarn upgrade-interactive' or 'yarn upgrade'` + : `'${this.packageManager} update'`; + + this.logger.warn(` + '--all' functionality has been removed as updating multiple packages at once is not recommended. + To update packages which don’t provide 'ng update' capabilities in your workspace 'package.json' use ${updateCmd} instead. + Run the package manager update command after updating packages which provide 'ng update' capabilities. + `); + + return 0; + } + const packages: PackageIdentifier[] = []; for (const request of options['--'] || []) { try { @@ -342,15 +356,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> { } } - if (options.all && packages.length > 0) { - this.logger.error('Cannot specify packages when using the "all" option.'); - - return 1; - } else if (options.all && options.migrateOnly) { - this.logger.error('Cannot use "all" option with "migrate-only" option.'); - - return 1; - } else if (!options.migrateOnly && (options.from || options.to)) { + if (!options.migrateOnly && (options.from || options.to)) { this.logger.error('Can only use "from" or "to" options with "migrate-only" option.'); return 1; @@ -358,8 +364,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> { // If not asking for status then check for a clean git repository. // This allows the user to easily reset any changes from the update. - const statusCheck = packages.length === 0 && !options.all; - if (!statusCheck && !this.checkCleanGit()) { + if (packages.length && !this.checkCleanGit()) { if (options.allowDirty) { this.logger.warn( 'Repository is not clean. Update changes will be mixed with pre-existing changes.', @@ -379,7 +384,6 @@ export class UpdateCommand extends Command<UpdateCommandSchema> { if ( options.migrateOnly === undefined && options.from === undefined && - !options.all && packages.length === 1 && packages[0].name === '@angular/cli' && this.workspace.configFile && @@ -395,25 +399,14 @@ export class UpdateCommand extends Command<UpdateCommandSchema> { this.logger.info(`Found ${rootDependencies.size} dependencies.`); - if (options.all) { - // 'all' option and a zero length packages have already been checked. - // Add all direct dependencies to be updated - for (const dep of rootDependencies.keys()) { - const packageIdentifier = npa(dep); - if (options.next) { - packageIdentifier.fetchSpec = 'next'; - } - - packages.push(packageIdentifier); - } - } else if (packages.length === 0) { + if (packages.length === 0) { // Show status const { success } = await this.executeSchematic('@schematics/update', 'update', { force: options.force || false, next: options.next || false, verbose: options.verbose || false, packageManager: this.packageManager, - packages: options.all ? rootDependencies.keys() : [], + packages: [], }); return success ? 0 : 1; diff --git a/packages/angular/cli/commands/update.json b/packages/angular/cli/commands/update.json index 3cc2e9ad0ccd..0d1205c86078 100644 --- a/packages/angular/cli/commands/update.json +++ b/packages/angular/cli/commands/update.json @@ -35,7 +35,8 @@ "all": { "description": "Whether to update all packages in package.json.", "default": false, - "type": "boolean" + "type": "boolean", + "x-deprecated": true }, "next": { "description": "Use the prerelease version, including beta and RCs.", diff --git a/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts b/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts index 33dddb8d50a2..8e2a3f668c65 100644 --- a/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts +++ b/tests/legacy-cli/e2e/tests/misc/update-git-clean-subdirectory.ts @@ -18,7 +18,7 @@ export default async function() { await writeFile('../added.ts', 'console.log(\'created\');\n'); await silentGit('add', '../added.ts'); - const { stderr } = await ng('update', '--all', '--force'); + const { stderr } = await ng('update', '@angular/cli'); if (stderr && stderr.includes('Repository is not clean.')) { throw new Error('Expected clean repository'); } diff --git a/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts b/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts index 04345b4441ec..0026fff5c537 100644 --- a/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts +++ b/tests/legacy-cli/e2e/tests/misc/update-git-clean.ts @@ -5,7 +5,7 @@ import { expectToFail } from '../../utils/utils'; export default async function() { await appendToFile('src/main.ts', 'console.log(\'changed\');\n'); - const { message } = await expectToFail(() => ng('update', '--all')); + const { message } = await expectToFail(() => ng('update', '@angular/cli')); if (!message || !message.includes('Repository is not clean.')) { throw new Error('Expected unclean repository'); }