refactor(@angular/cli): replace command line arguments parser #22778
Merged
alan-agius4 merged 8 commits intoangular:masterfrom Mar 9, 2022
alan-agius4:cli-change-parser
Merged
refactor(@angular/cli): replace command line arguments parser #22778alan-agius4 merged 8 commits intoangular:masterfrom alan-agius4:cli-change-parser
alan-agius4 merged 8 commits intoangular:masterfrom
alan-agius4:cli-change-parser
Conversation
Collaborator
Author
|
Validation failure should be fixed by angular/dev-infra#436 |
clydin
requested changes
Mar 8, 2022
packages/angular/cli/src/command-builder/architect-base-command-module.ts
Outdated
Show resolved
Hide resolved
packages/angular/cli/src/command-builder/architect-base-command-module.ts
Outdated
Show resolved
Hide resolved
packages/angular/cli/src/command-builder/architect-base-command-module.ts
Outdated
Show resolved
Hide resolved
packages/angular/cli/src/command-builder/utilities/json-help.ts
Outdated
Show resolved
Hide resolved
clydin
reviewed
Mar 8, 2022
Comment on lines
+56
to
+65
| .option('migrate-only', { | ||
| description: 'Only perform a migration, do not update the installed version.', | ||
| type: 'boolean', | ||
| }) | ||
| .option('name', { | ||
| description: 'The name of the migration to run.', | ||
| type: 'string', | ||
| implies: ['migrate-only'], | ||
| conflicts: ['to', 'from'], | ||
| }) |
Member
There was a problem hiding this comment.
Could the coerce yargs functionality on migrate-only be used to allow for a deprecation time period of the --migrate-only <string> scenario?
Collaborator
Author
There was a problem hiding this comment.
Unfortunately not, since the type of the option is boolean, the value will be covered to a boolean by the parser which happens way before coerce being triggered.
With this change we refactor the Angular CLI and replace the underlying args parser and command builder. We choose to use Yargs as our parser and command builder of choice. The main advantages of Yargs over other command builders are; - Highly configurable. - We already use it in other packages such as the compiler-cli/dev-infra etc.. - Commands and options can be added during runtime. This is a requirement that is needed to support architect and schematics commands. - Outstanding documentation. - The possibility to parse args without parser configuration (Free form). - Commands are built lazily based on the arguments passed. BREAKING CHANGE: Several changes in the Angular CLI commands and arguments handling. - `ng help` has been removed in favour of the `—-help` option. - `ng —-version` has been removed in favour of `ng version` and `ng v`. - Deprecated camel cased arguments are no longer supported. Ex. using `—-sourceMap` instead of `—-source-map` will result in an error. - `ng update`, `—-migrate-only` option no longer accepts a string of migration name, instead use `—-migrate-only -—name <migration-name>`. - `—-help json` help has been removed. Closes #20976, closes #16614 and closes #16241
With this change we update yargs help method to output help in JSON format which is needed to generate the documents that are used to generate AIO man pages.
With this change we update the UA usage script to read schemas directly insteads of relying on JSON help.
This temporary until the old command modules are removed.
…provements This PR brings a number of small refactors to improve code quality in the new args parser implementation.
clydin
approved these changes
Mar 9, 2022
atscott
pushed a commit
to angular/angular
that referenced
this pull request
Mar 10, 2022
…er and folder structure (#45225) The underlying parser that the CLI uses changed which caused minor changes in the generated JSON helps especially for subcommands. The folder structure of the Angular CLI repo also changed slightly. More context: angular/angular-cli#22778 PR Close #45225
josmar-crwdstffng
pushed a commit
to josmar-crwdstffng/angular
that referenced
this pull request
Apr 8, 2022
…er and folder structure (angular#45225) The underlying parser that the CLI uses changed which caused minor changes in the generated JSON helps especially for subcommands. The folder structure of the Angular CLI repo also changed slightly. More context: angular/angular-cli#22778 PR Close angular#45225
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this change we refactor the Angular CLI and replace the underlying args parser and command builder. We choose to use Yargs as our parser and command builder of choice. The main advantages of Yargs over other command builders are;
BREAKING CHANGES:
ng helphas been removed in favour of the—-helpoption.ng —-versionhas been removed in favour ofng versionandng v.—-sourceMapinstead of—-source-mapwill result in an error.ng update,—-migrate-onlyoption no longer accepts a string of migration name, instead use-—migrate-only -—name <migration-name>.-—help jsonhelp has been removed.Closes #20976, closes #16614 , closes #17191 and closes #16241