Before only first line end was being replaced.
Also, the replace value was incorrectly escaped.
The CA read from cafile being corrupt resulted in broken updates
when using registry with self-signed certificate.
The workaround till this is merged is to use `ca` or `ca[]` properties in `.npmrc`.
With this change Pacote is updated to version 11.1.13.
This also requires normalization of options because Pacote now passes the options to `npm-registry-fetch` which requires some options to be camelCased.
Partially addresses #19624
Unlike `require.resolve`, the `resolve` package `paths` is only used as a fallback when the package is not resolved from the `basedir`,
Previously this resulted in the temporary version of CLI being resolved here which resulted in `ng update` incorrectly stating that there are no updates.
Previously, the workspace configuration file was found and loaded by individual commands potentially multiple times. This change moves the initial workspace location discovery and loading of the workspace to the CLI startup. It also provides the workspace to each command so that the commands can reuse the already loaded and parsed workspace configuration.
Third party libraries can attempt to write color codes to the output even though the CLI has already determined that color should not be used. The previously implemented color removal code is no longer functional since the update of ansi-colors to 4.1.0. While this appears to be a defect in the aforementioned package, the new CLI removal method not only bypasses the defect but also unneeded execution logic that the CLI does not need in this case.
Fixes: #17053
When an error occurs during ng update we currently discard the stack trace which in some cases made it hard to identify the cause of the error.
Now, we print the stack trace to a log file similarly to unhandled exceptions.
Example of CMD output;
```cmd
** Executing migrations of package '@angular/core' **
> Static flag migration.
Removes the `static` flag from dynamic queries.
As of Angular 9, the "static" flag defaults to false and is no longer required for your view and content queries.
Read more about this here: https://v9.angular.io/guide/migration-dynamic-flag
× Migration failed: x
See "C:\Users\alag\AppData\Local\Temp\ng-NgmC1G\angular-errors.log" for further details.
```
Example of log file contents:
```txt
[error] Error: x
at UpdateCommand.executeSchematic (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:98:19)
at UpdateCommand.executePackageMigrations (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:167:39)
at UpdateCommand.executeMigrations (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:161:21)
at UpdateCommand.run (C:\git\angular-cli\test\node_modules\@angular\cli\commands\update-impl.js:394:38)
at async UpdateCommand.validateAndRun (C:\git\angular-cli\test\node_modules\@angular\cli\models\command.js:134:28)
at async Object.runCommand (C:\git\angular-cli\test\node_modules\@angular\cli\models\command-runner.js:201:24)
at async default_1 (C:\git\angular-cli\test\node_modules\@angular\cli\lib\cli\index.js:62:31)
```
Explained here: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Current change affects reading of global config from `.angular-config.json`. By default it will be created in user's home directory. If user moves it manually to `$HOME/.config/angular/.angular-config.json`, it will be subsequently read from new location.
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
According to [the npm config
docs](https://docs.npmjs.com/misc/config#npmrc-files), a user can
specify the path to their `npmrc` files using the environment
variables `NPM_CONFIG_USERCONFIG` and `NPM_CONFIG_GLOBALCONFIG`. When
set, these variables should override the default paths.
This adds extensive option checking and error handling with the goal to catch user errors as early in the process as possible. Bad option combinations and/or values will result in actionable information and stop the process before network access and processing occurs.
Angular 5.0+ has a full peer dependencies setup (with 6.0+ also having a configurable runtime error check) to ensure that an appropriate version of typescript is available for compilation. Angular CLI 8.0+ does not support Angular versions prior to these and therefore the warning is redundant. For the case where the developer wishes to use an unsupported TypeScript version, the developer would need to adjust two similar but differently name settings in two different configuration files.
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
A Schema is either an Object or a boolean. We could reduce JsonSchema scope further
by adding properties, but a schema is a really complex type so its not worth the
effort.
The feature comes from the "x-deprecated" field in schemas (any schema that is used
to parse arguments), and can be a boolean or a string.
The parser now takes a logger and will warn users when encountering a deprecated
option. These options will also appear in JSON help.