Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@angular/cli): replace command line arguments parser #22778

Merged
merged 8 commits into from
Mar 9, 2022
Merged

refactor(@angular/cli): replace command line arguments parser #22778

merged 8 commits into from
Mar 9, 2022

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Feb 28, 2022

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 CHANGES:

  • 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 , closes #17191 and closes #16241

@alan-agius4 alan-agius4 added the target: major This PR is targeted for the next major release label Feb 28, 2022
@alan-agius4
Copy link
Collaborator Author

Validation failure should be fixed by angular/dev-infra#436

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'],
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the coerce yargs functionality on migrate-only be used to allow for a deprecation time period of the --migrate-only <string> scenario?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@alan-agius4 alan-agius4 requested a review from clydin March 9, 2022 08:39
…provements

This PR brings a number of small refactors to improve code quality in the new args parser implementation.
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 9, 2022
@alan-agius4 alan-agius4 merged commit 92528b1 into angular:master Mar 9, 2022
@alan-agius4 alan-agius4 deleted the cli-change-parser branch March 9, 2022 16:18
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
PiyushAgrawal1243 pushed a commit to PiyushAgrawal1243/angular that referenced this pull request Mar 30, 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
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
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker flag: breaking change target: major This PR is targeted for the next major release
Projects
None yet
2 participants