With this commit the builder and schematic names are added as page title to page events.
Also, we address a bug where during a watch or error in some cases analytics where not flushed. Examples when the builder has a watch mode.
The global require function is not present in Node.js ESM mode. To support
the eventual transition of the `@angular/cli` package to ESM, usage of the
`require.resolve` function has been converted to use locally created `require`
functions via `createRequire` from the `module` builtin.
Prior to this change during update deprecated packages that satisfied the version range constrain where being favored over the non-deprecated versions if the version of the deprecated version is greater. Ex: if `14.3.1` is deprecated and `14.3.0` is not the former was being installed.
With this change we now change the logic to favor non deprecated version of the package and only use the deprecated package when no satisfying version is found.
This fix is needed as in some cases a package which cannot be unpublished from NPM will gave to be to be deprecated, if the version is for a reason or another broken.
BREAKING CHANGE: The 'path' option in schematics schema no longer has a special meaning. Use 'workingDirectory' smart default provider should be used instead.
Prefixing options with `no` in schema definitions appears to be used more widely than initially thought.
The `noOption` can also be provided in the `angular.json` which makes this property definition less ambiguous, since boolean options don't get prefixed with `no` in the JSON config. Therefore, in order to reduce the community changes we remove the deprecation warning for such options and change the interim solution to permanent one.
None-the-less, it's still recommended that options are defined without the `no` prefix.
Previously when having completion enabled and the current workspaces has an older version of the Angular CLI installed in the terminal the below errors is show. This is because the older versions of the CLI do not implement this command. Now we exit gracefully.
```
The specified command ("completion") is invalid. For a list of available options,
run "ng help".
Did you mean "analytics"?
```
Closes#23518
With this change we improve the error message when a project for command cannot be determined
```
Error: Cannot determine project for command.
This is a multi-project workspace and more than one project supports this command. Run "ng build [project]" to execute the command for a specific project or change the current working directory to a project directory.
Available projects are:
- project-name-0
- project-name-1
- project-name-2
- project-name-3
- project-name-4
- project-name-5
- project-name-6
- project-name-7
- project-name-8
- project-name-9
```
Closes#23481
- Prevent additional properties being set in cli subproperties (i.e. cli.warnings.zzzz).
- Create cliGlobalOptions definition and reference in the global.cli schema.
- Use global.cli schema to validate changes made with --global flag.
- Add test coverage for validating global/local-only changes.
- Add test coverage for setting invalid properties and sub-properties.
With this commit we introduce an interim solution for options prefixed with `no` in `schema.json`
Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.
Closes#23397
Running autocompletion with `14.0.1` installed globally in a `14.0.0` project logs the version warning in a very annoying fashion:
```
$ ng verYour global Angular CLI version (14.0.1) is greater than your local version (14.0.0). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
sion
```
This adds an exception for `ng completion` commands to avoid this edge case.
Currently, we don't register all available commands. For instance, when the CLI is ran inside a workspace the `new` command is not registered. Thus, this will cause a confusing error message when `ng new` is ran inside a workspace.
Example:
```
$ ng new
Error: Unknown command. Did you mean e?
```
With this commit we change this by registering all the commands and valid the command scope during the command building phase which is only triggered once the command is invoked but prior to the execution phase.
Prepares the `@angular/cli` package for the eventual change of enabling the
TypeScript `useUnknownInCatchVariables` option. This option provides additional
code safety by ensuring that the catch clause variable is the proper type before
attempting to access its properties. Similar changes will be needed in the other
packages in the repository prior to enabling `useUnknownInCatchVariables`.
When the workspace has multiple projects and we the project to use cannot be determined from the current working directory, we now issue an actionable error message.
Angular CLI versions prior to v14 may not exit correctly if not forcibly exited
via `process.exit`. When the local CLI version is less than v14, the CLI will now
use `process.exit` to ensure the process exits with these older CLI versions.
Fixes#23289
In certain situations the existing console logger created via `@angular-devkit/core` `createConsoleLogger`
could try to write to a closed stdout pipe stream. This would result in an error during
execution. For cases such as the completion script command, this would also prevent the
command from functioning. To mitigate these cases, `createConsoleLogger` is no longer used
and instead a logger instance is directly created within the CLI that uses `Console.log`
and `Console.error` to write output. Exiting the CLI also now waits for messages to be
logged before proceeding with the exit.
Previously, when a global configuration was not found on disk we forcefully created it even when it was not needed.
This causes issues in CI when multiple `ng` commands would run in parallel as it caused a read/write race conditions.
See: https://angular-team.slack.com/archives/C46U16D4Z/p1654089933910829
With this change we add a footer to indicate that more commands are available when running the CLI in a different context. Ie inside or outside of a workspace.
The package manager `--force` option is only relevant to npm 7+ wherein the option controls
the strictness of the npm 7+ peer dependency resolution. Yarn 2+ does not support a `--force`
option. When the `ng update` `--force` option was used, `ng update` was incorrectly
applying the package manager `--force` option to Yarn which lead to an installation failure.
This has now been corrected and the package manager `--force` option is now only applied to npm 7+.