Is this correct, ng update --all only shows the upgrade options available?
Asked Answered
B

3

6

If I run the command

ng update

I see a listing of items such as
@angular/cdk  6.4.7 > 8.2.0   ng update @angular/cdk
...
...

There might be additional packages that are outdated.

Or run ng update --all to try and update all at the same time.

It does not appear that the command by itself ng update makes any changes.

So, does the execution of the ng update --all make changes?

I just want to see ALL packages are detected to need updating.

Bruis answered 25/9, 2019 at 15:13 Comment(0)
V
2

Note: The ng update command allows for packages separated by spaces to be specified with additional arguments:

ng update [packages] [options]

Check out the ng update command docs for more info.


This is because by default, the ng update command when specified without any arguments/packages will try to update all of the packages if possible.

Here's the portion of the code of the update command which checks if no packages were specified:

if (options.all || packages.length === 0) {
      // Either update all packages or show status
      return this.runSchematic({
        collectionName: '@schematics/update',
        schematicName: 'update',
        dryRun: !!options.dryRun,
        showNothingDone: false,
        additionalOptions: {
          force: options.force || false,
          next: options.next || false,
          verbose: options.verbose || false,
          packageManager,
          packages: options.all ? Object.keys(rootDependencies) : [],
        },
      });
    }

From the code above, this also means that either specifying the --all option or not specifying any options at all will try to update all of the packages.


Note: You can view the entire source code of the update command to see how the command works.

Vandalism answered 25/9, 2019 at 15:31 Comment(1)
"the ng update command when specified without any arguments/packages will try to update all of the packages if possible." This is not what the current documentation says, "Without additional arguments, ng update lists the updates that are available to you and provides recommended steps to update your application to the most current version." Has this command changed? If so, that's quite a big change from updating everything to updating nothing.Darwinism
O
9

If you willing to upgrade to major version of angular you should refer to this site: https://update.angular.io/

Angular 11+: use the update command of your package manager:
NPM: npm update source
YARN: yarn upgrade source

Prior to angular 11:

In early 2020, ng update --all simply updates all packages.

Around late 2020, the --all flag is deprecated:

--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

Oft answered 10/7, 2020 at 22:3 Comment(1)
Output for me: '--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 'npm update' instead. Run the package manager update command after updating packages which provide 'ng update' capabilities.Tillford
V
2

Note: The ng update command allows for packages separated by spaces to be specified with additional arguments:

ng update [packages] [options]

Check out the ng update command docs for more info.


This is because by default, the ng update command when specified without any arguments/packages will try to update all of the packages if possible.

Here's the portion of the code of the update command which checks if no packages were specified:

if (options.all || packages.length === 0) {
      // Either update all packages or show status
      return this.runSchematic({
        collectionName: '@schematics/update',
        schematicName: 'update',
        dryRun: !!options.dryRun,
        showNothingDone: false,
        additionalOptions: {
          force: options.force || false,
          next: options.next || false,
          verbose: options.verbose || false,
          packageManager,
          packages: options.all ? Object.keys(rootDependencies) : [],
        },
      });
    }

From the code above, this also means that either specifying the --all option or not specifying any options at all will try to update all of the packages.


Note: You can view the entire source code of the update command to see how the command works.

Vandalism answered 25/9, 2019 at 15:31 Comment(1)
"the ng update command when specified without any arguments/packages will try to update all of the packages if possible." This is not what the current documentation says, "Without additional arguments, ng update lists the updates that are available to you and provides recommended steps to update your application to the most current version." Has this command changed? If so, that's quite a big change from updating everything to updating nothing.Darwinism
K
1

On new versions of Angular this is no longer included, but you can replicate it mostly with:

ng update --force $(jq -r '.dependencies * .devDependencies | keys | map(select(startswith("@angular"))) | @tsv' package.json)

(then run: ncu -ux '/typescript|rxjs/')

My issue to bring the functionality back: https://github.com/angular/angular-cli/issues/23261

Kylstra answered 24/3, 2023 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.