Skip to content

[Schematics CLI] Numeric strings in schematics options #24360

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

Open
1 task
dgp1130 opened this issue Dec 1, 2022 · 4 comments
Open
1 task

[Schematics CLI] Numeric strings in schematics options #24360

dgp1130 opened this issue Dec 1, 2022 · 4 comments
Labels
area: @angular-devkit/schematics-cli freq1: low Only reported by a handful of users who observe it rarely type: bug/fix

Comments

@dgp1130
Copy link
Collaborator

dgp1130 commented Dec 1, 2022

Command

generate

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

From http://b/196605664.

Apparently you can't pass in a numeric value into a string argument in schematics. This appears to be interpreted as number and leads to a validation error.

Minimal Reproduction

$ schematics run test --stringValue "1234"
Schematic input does not validate against the Schema: {"stringValue":1234}
Errors:

  Data path ".stringValue" should be string.

Minimist seems to interpret "1234" as a number instead of a string, and schematics treats that as a type mismatch.

Exception or Error

No response

Your Environment

See http://b/196605664.

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

In schematics CLI we don’t really configure the parser based on the schematics schema.

We could probably port this logic from the Angular CLI. (Maybe have the logic in a shared ts_libraary) when the legacy build system is removed.

@dgp1130
Copy link
Collaborator Author

dgp1130 commented Dec 1, 2022

Yeah, I know minimist doesn't work that way. We'd probably have to change argument parser to actually declare specific options with specific types based on the schematics schema for the ideal solution. Not sure if there's a simpler fix worth exploring, but it's a relatively minor bug so I'm not too worried.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Dec 1, 2022

Just for the record we no longer use minimist. We use yargs-parser.

Note: this would also solve #12152

@alan-agius4 alan-agius4 added area: @angular-devkit/schematics-cli freq1: low Only reported by a handful of users who observe it rarely and removed area: @angular-devkit/schematics labels Dec 1, 2022
@alan-agius4 alan-agius4 changed the title Numeric strings in schematics options [Schematics CLI] Numeric strings in schematics options Dec 1, 2022
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Dec 1, 2022

Same root cause/resolution of #16320.

We could combine these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: @angular-devkit/schematics-cli freq1: low Only reported by a handful of users who observe it rarely type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants