Prepares the E2E tests 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`.
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.
When using ramdisk we now get different errors some times
```
ERROR: The process with PID 3804 (child process of PID 7516) could not be terminated.
Reason: The operation attempted is not supported.
```
We don't need to include all applications code to verify disk cache existence.
This reduces the test duration of `disk-cache.ts` by a whopping `~65s` since this tests runs `ng build` 5 times and `disk-cache-purge.ts` by `~13s`.
These timings were gathered using gLinux and is expected that the gain is more significant on Circle CI Linux and Windows executors.
This test does a large number of builds by spliting the tests, in CI we can reduce the blocking time for other tests. Locally this tests take ~3 mins in CI.
When using `waitForMatch` the promise is resolved prior to the process being killed which in some cases caused a race condition because `treekill` would to be invoked for a process which in the meantime will be killed gracefully.
This is picked up by the TS language server which improves DX when writing and debugging tests. Previously, the default TS options were used which results in discrepancies such as strict mode is not enabled.
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.
Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
To support this case, legacy peer dependency mode is enabled for snapshot builds.
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.