Allowlist relevant flags for CLI2 passthrough#743
Merged
Conversation
Contributor
|
We detected some changes at packages/*/src and there are no updates in the .changeset. |
c28d664 to
0d434ec
Compare
5 tasks
5 tasks
gonzaloriestra
approved these changes
Nov 11, 2022
Contributor
gonzaloriestra
left a comment
There was a problem hiding this comment.
Thanks for taking care of this, 👌
| // Exclude flags that are only for CLI3 but will cause errors if passed to CLI2 | ||
| exclude?: string[] | ||
| // Only pass on flags that are relevant to CLI2 | ||
| relevantFlags?: string[] |
Contributor
There was a problem hiding this comment.
I think allowedFlags would be more accurate, but it's just a suggestion.
|
|
||
| export default abstract class ThemeCommand extends Command { | ||
| passThroughFlags(flags: FlagValues, {exclude}: PassThroughFlagsOptions): string[] { | ||
| passThroughFlags(flags: FlagValues, {relevantFlags}: PassThroughFlagsOptions): string[] { |
Contributor
There was a problem hiding this comment.
What about adding the default value here?
Suggested change
| passThroughFlags(flags: FlagValues, {relevantFlags}: PassThroughFlagsOptions): string[] { | |
| passThroughFlags(flags: FlagValues, {relevantFlags: Array = []}: PassThroughFlagsOptions): string[] { |
Contributor
Author
There was a problem hiding this comment.
This doesn't work as cleanly with TypeScript, I believe we'd have to do:
Suggested change
| passThroughFlags(flags: FlagValues, {relevantFlags}: PassThroughFlagsOptions): string[] { | |
| passThroughFlags(flags: FlagValues, {relevantFlags}: PassThroughFlagsOptions = {relevantFlags: []}): string[] { |
Also note it's a default value for the whole object, so if {} is passed then relevantFlags would still be undefined.
| const passThroughFlags: string[] = [] | ||
| for (const [label, value] of Object.entries(flags)) { | ||
| if ((exclude ?? []).includes(label)) { | ||
| if (!(relevantFlags ?? []).includes(label)) { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (!(relevantFlags ?? []).includes(label)) { | |
| if (!relevantFlags.includes(label)) { |
4 tasks
Poitrin
reviewed
Nov 11, 2022
2 tasks
0d434ec to
30967ff
Compare
30967ff to
ad85ea3
Compare
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.
WHY are these changes introduced?
Fixes #672 and prevents further similar issues
WHAT is this pull request doing?
We are passing through all CLI3 flags to CLI2, which means any new global flags need to be mentioned in theme commands.
Better to take an allowlist approach since the per-command flags won't change that much and will only need updates in 1 place.
How to test your changes?
All the commands should still work!
Measuring impact
How do we know this change was effective? Please choose one:
Checklist
devordeployhave been reflected in the internal flowchart.