Skip to content

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

Closed
@Wintermoose

Description

@Wintermoose

🐞 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions