fix: load blueprint options before command validation (fixes #10872)#10879
Open
AyushKashyapII wants to merge 2 commits intoember-cli:masterfrom
Open
fix: load blueprint options before command validation (fixes #10872)#10879AyushKashyapII wants to merge 2 commits intoember-cli:masterfrom
AyushKashyapII wants to merge 2 commits intoember-cli:masterfrom
Conversation
…i#10872) and also handle missing aliases when merging duplicate options
Contributor
|
Needs some work <3 |
Author
|
@NullVoxPopuli Thanks for the review! I have addressed the feedback: |
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.
Description
Fixes #10872.
Currently, commands like
newandaddonvalidate their arguments before loading the options defined in the target blueprint. This causes the CLI to warn that "The option 'x' is not registered" even if the blueprint explicitly defines that option in itsavailableOptions.The Fix
lib/models/command.jsto execute thebeforeRunhook (which callsmergeBlueprintOptions) insidevalidateAndRunbefore the argument validation/parsing occurs.lib/utilities/merge-blueprint-options.js. Sincenoptparsing hasn't happened yet at this stage, the helper now manually parsesrawArgsto find the blueprint name (handling-b,--blueprint, and defaulting toapp/addon), ensuring the correct options are merged.mergeDuplicateOptionthat was exposed by this timing change. Previously, if a blueprint option had undefined aliases,flatMapwould throw an error. Added a fallback|| []to prevent this.Reproduction
--pizzainavailableOptions).ember new my-app --pizza=cheese.The option '--pizza' is not registered with the 'new' command.Testing
tests/unit/models/command-test.jsto verifybeforeRunis called before argument parsing.ember newandember addonno longer emit warnings for valid blueprint flags.