With this change we now check if the current CLI version is the latest published version. If it is not, we install a temporary version to run the `ng update` with.
With this change the CLI offers a way for a package authors to specify if during `ng add` the package should be saved as a `dependencies`, `devDependencies` or not saved at all.
Such config needs to be specified in `package.json`
Example:
```json
"ng-add": {
"save": false
}
```
Possible values are;
- false - Don't add the package to `package.json`
- true - Add the package to the `dependencies`
- `dependencies` - Add the package to the `dependencies`
- `devDependencies` - Add the package to the `devDependencies`
Closes#12003 , closes#15764 and closes#13237
At the moment there is no way to turn on the verbose logging for `ng update` and `ng add`. This is useful for use so that when users report issues such as npmrc is not read we can see the lookup locations.
This also removes some reduncant that were being provided in `executeSchematic`.
Related to https://github.com/angular/angular-cli/issues/14993
Some commands (like schematics) need to have custom reporting for
analytics. Schematics and Architect commands need to verify if the
schematic/architect builder run is in the safelist, for example.
ng-add checks if a specified collection is installed, and if not it'd
proceed to install the package. However, `isPackageInstalled` would, by
default, resolve the main field or the index of the package. Not all NPM
packages specify the main field or provide an index file. It should
be sufficient to just check the presence of `package.json` to detect
whether a package is installed or not.
For example, `ng add @angular/bazel` should not install the package if
it's already installed locally. `@angular/bazel` does not specify a main
field not an index file in its `package.json`.
If no version specifier is supplied `ng add` will now try to find the most recent version of the package that has peer dependencies that match the package versions supplied in the project's package.json