Skip to content

Order of parameters not preserved when using x-prompt #14402

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

Closed
Wintermoose opened this issue May 10, 2019 · 2 comments · Fixed by #14408
Closed

Order of parameters not preserved when using x-prompt #14402

Wintermoose opened this issue May 10, 2019 · 2 comments · Fixed by #14408
Labels
area: @angular-devkit/core freq1: low Only reported by a handful of users who observe it rarely severity2: inconvenient type: bug/fix
Milestone

Comments

@Wintermoose
Copy link

🐞 Bug report

Command (mark with an x)

- [X] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [X] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

When Angular CLI is asking for parameters specified with x-prompt in a schematics, the order should be preserved. This seems to be true for small number of prompts, but breaks when more are used.

The likely culprit is the sort on top of _applyPrompts in https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/core/src/json/schema/registry.ts

It seems that older V8 versions didn't implement stable sort. I don't follow exactly the Node releases, so it's possible this is fixed in the absolutely newest one.

Seeing that the priorities are currently not configurable, maybe commenting-out the sort call is the quickest fix.

🔬 Minimal Reproduction

  • define schema.json with larger number of parameters and x-prompt (our is currently using 13)
  • run ng new or ng generate without providing the parameters, thus triggering the interactive prompts

🌍 Your Environment


Angular CLI: 7.3.8
Node: 10.15.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.8
@angular-devkit/core         7.3.8
@angular-devkit/schematics   7.3.8
@schematics/angular          7.3.8
@schematics/update           0.13.8
rxjs                         6.3.3
typescript                   3.2.4
@clydin
Copy link
Member

clydin commented May 10, 2019

The versions of V8 used within Node.js 10 and earlier use an unstable quicksort for arrays with a length larger than 10. Node.js 11/12+ use V8 7.0+ which implements a stable sort instead.

clydin added a commit to clydin/angular-cli that referenced this issue May 13, 2019
Node.js versions prior to 11 used an unstable sort for arrays with a length greater than 10.  This caused the prompt order of a schematic with more than 10 prompts to be inconsistent the the content of the file and the same schematic with several of the prompts removed.  Since priorities were never fully implemented and property dependencies will most likely be used at a higher level instead, the underlying elements have been removed with this change.

Fixes angular#14402
clydin added a commit to clydin/angular-cli that referenced this issue May 13, 2019
Node.js versions prior to 11 used an unstable sort for arrays with a length greater than 10.  This caused the prompt order of a schematic with more than 10 prompts to be inconsistent with the content of the file and the same schematic with several of the prompts removed.  Since priorities were never fully implemented and property dependencies will most likely be used at a higher level instead, the underlying elements have been removed with this change.

Fixes angular#14402
@filipesilva filipesilva added area: @angular-devkit/core freq1: low Only reported by a handful of users who observe it rarely severity2: inconvenient type: bug/fix labels May 13, 2019
@ngbot ngbot bot added this to the Backlog milestone May 13, 2019
@filipesilva filipesilva modified the milestones: Backlog, 8.0 May 13, 2019
@ngbot ngbot bot modified the milestones: 8.0, Backlog May 13, 2019
kyliau pushed a commit that referenced this issue May 13, 2019
Node.js versions prior to 11 used an unstable sort for arrays with a length greater than 10.  This caused the prompt order of a schematic with more than 10 prompts to be inconsistent with the content of the file and the same schematic with several of the prompts removed.  Since priorities were never fully implemented and property dependencies will most likely be used at a higher level instead, the underlying elements have been removed with this change.

Fixes #14402
kyliau pushed a commit that referenced this issue May 13, 2019
Node.js versions prior to 11 used an unstable sort for arrays with a length greater than 10.  This caused the prompt order of a schematic with more than 10 prompts to be inconsistent with the content of the file and the same schematic with several of the prompts removed.  Since priorities were never fully implemented and property dependencies will most likely be used at a higher level instead, the underlying elements have been removed with this change.

Fixes #14402
@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/core freq1: low Only reported by a handful of users who observe it rarely severity2: inconvenient type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants