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

prompt support for value type number #12927

Closed
wants to merge 2 commits into from

Conversation

nweldev
Copy link
Contributor

@nweldev nweldev commented Nov 11, 2018

Permit to support x-prompt for a schematic parameter definition if its type is set to number.

Previously, if used with type 'number', the prompt was trap in a loop as input never was considered correct.

The part on the cli will also need to be reproduced on schematics-cli after #12814.

Related to #12163.

Root causes

angular-devkit/core & ajv

Type number wasn't set, and the value wasn't converted to a number if needed in the prompt validator.

angular-devkit/cli & inquirer

Inquirer doesn't convert it result to a number even if definition type is set to 'number' following SBoudrias/Inquirer.js#663

Reproduction steps

You can reproduce the previous behavior by using the @angular-buddies/prettier@1.0.0-alpha.2:prettier-config schematic.

https://github.com/angular-buddies/angular-buddies/blob/v1.0.0-alpha.2/packages/prettier/src/config/schema.json#L14-L19

As the ajv self validator was expecting a number, and the prompt delivered a string to the
validator, the user was stuck in a loop with an impossible expectation.
Now, the value from the prompt is converted to a number if required before validation.
Convert the inquirer result to a number iff the schematic option type is 'number'.
@clydin
Copy link
Member

clydin commented Jan 9, 2019

Thank you for the contribution. We haven't forgotten about this PR. We are working on some infrastructure improvements to prompts that should simplify what is being attempt here. We'll update this thread once the PR is out.

@clydin clydin removed the state: WIP label Nov 16, 2020
@clydin
Copy link
Member

clydin commented Jan 15, 2021

Closing as the CLI currently supports the use of a schema property's type when validating and returning the value from a prompt. This includes both the number and integer types.
However, thank you for the contribution.

@clydin clydin closed this Jan 15, 2021
@clydin clydin removed their request for review January 15, 2021 18:39
@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 Feb 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants