Repository navigation
fix(@angular/cli): keep schematic positional arguments in index order - #34445
Merged
Merged
Conversation
sort checked `positional` for truthiness, so argument at index 0 was ordered like plain option and help showed it after index 1 when that argument has `x-prompt` both are optional for yargs and values go to wrong argumnets, now positionals are sorted by index
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the JSON schema option parser where positional arguments with an index of 0 were incorrectly sorted because 0 is falsy. The sorting logic has been updated to explicitly check for undefined rather than relying on truthiness. Additionally, unit and E2E tests have been added to verify that positional arguments are sorted correctly by their index. There are no review comments, and I have no feedback to provide.
alan-agius4
reviewed
Oct 20, 2026
alan-agius4
reviewed
Oct 20, 2026
alan-agius4
approved these changes
Oct 20, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
Issue Number: N/A
My library ngwr ships
pageschematic with two positionals,presetat index 0 (required, hasx-prompt) andnameat index 1Command from its docs fails on 22.2.3:
Help prints
page [name] [preset]Sort at end of
parseJsonSchemaToOptionschecksa.positionalfor truthiness, so index 0 is ordered like plain option and lands after index 1, andgeneratebuilds its comand string from that orderWith
x-promptboth positionals are optional for yargs and values get swapped, without it only help order is wrong since yargs fills<required>firstWhat is the new behavior?
Positionals are sorted by index (checked with
!== undefined), plain options stay sorted by name after themng g ngwr:page form signupworks and help printspage [preset] [name]New case in
json-schema_spec.tshaspresetat index 0 withx-promptandnameat index 1, it fails on mainAlso added
fake-reversedschematic togenerate/help-output.tse2e, it gets[a] <b>on mainExisting
<a> [b]case passes on main only becasue index order and alphabetical order are same thereDoes this PR introduce a breaking change?
Other information
In
@schematics/angularonlyinterfacehas two positionals (name0,type1), they already sort same way, so nothing changes thereBuilt CLI from this branch and ran documented
ngwr:pagecommands with--dry-run, all pass