With this change we fix two analytics collection bugs:
- We now collect the usage of options defined in the workspace config (angular.json).
- We now also collect values set via schematic prompts.
Closes: #17900
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.
Currently, upon execution `ng` will load all description files AND code for all available commands. This requires a large amount of unnecessary file access and processing since only at most one command will be executed. This change limits the loading to only command being executed in the common case and a subset of commands in the event an alias is used. The help command now loads all commands during its execution which is needed to gather command description information. Further improvements are possible by only loading the necessary metadata instead of the execution code (and its dependencies) as well.
This change allows for savings of ~250ms per execution.
Examples:
Before -- `./node_modules/.bin/ng version 0.99s user 0.17s system 113% cpu 1.020 total`
After -- `./node_modules/.bin/ng version 0.70s user 0.13s system 110% cpu 0.749 total`
Before -- `./node_modules/.bin/ng g c a 1.91s user 0.30s system 111% cpu 1.996 total`
After -- `./node_modules/.bin/ng g c a 1.62s user 0.27s system 110% cpu 1.715 total`
--help now accepts a value which can be a boolean or a string. If the value
is not understood we simply show a message to the user that it was invalid.
SubCommands are not tied to the option that triggers them. They
contain a subset of a CommandDescription interface, with at least
a short and long description and usage notes. These are generated
from the subcommand schema (e.g. schematics in case of generate).