angularangular-schematics

What is packageGroup in ng-update object?


I am doing analysis around ng-update command in angular to run custom logic after ng-update.

I came across an ng-update object's property packageGroup of which I did not find detailed explanation.

Explanation provided in angular docs -

A list of npm packages that are to be grouped together. When running the update schematic it will automatically include all packages as part of the packageGroup in the update (if the user also installed them).

Link to the docs - https://github.com/angular/angular-cli/blob/master/docs/specifications/update.md

Can anybody who have used it explain what it actually does?


Solution

  • If we use packageGroup inside ng-update object of package.json and if we mention some dependencies inside packageGroup, then the ng update command will update the packageGroup packages with the same version as targeted by ng update command.

    Example -

    Suppose if you are running ng update somePackage@5.0.0 and it's package.json contains packageGroup like below

    {
      ...
      "ng-update": {
        "migrations": "./migrations.json",
        "packageGroup": [
          "package1",
          "package2",
          "package3"
        ]
      },
      ...
    }
    

    then after running ng update command, packages mentioned inside packageGroup will also get updated to 5.0.0 version as mentioned in ng update command.