Repository navigation
fix: options for init command have required arguments - #1324
jamesgeorge007 wants to merge 2 commits into
Conversation
|
e2e tests are failing |
Fixed. |
9aa9861 to
bbfe60a
Compare
|
BTW, we could've just set Do we have a list of all breaking changes between |
|
Also, keep in mind that removing That said, I would accept a quick fix that just adds |
|
I'm also hesitant on merging this at the moment. @grabbou suggestion is a good way to unblock ourselves for now, and once we hit a stable release we can bump commander after testing it thoroughly |
2b937db to
997ab33
Compare
|
|
367f3e5 to
8d996ea
Compare
|
Ah, of course - arguments are different than options! Anyway, I got a bit confused here - please help me out by answering my comments and I hope we can get through this! |
|
|
||
| if (!option.required) { | ||
| // Early return if the option is not required | ||
| if (!opt.required) { |
There was a problem hiding this comment.
So, the thing is... const option = new Option(opt.name); creates an Option object from the name, e.g. --version <string> or --version [string].
Depending on <> or [] used, the option.required will be true or false.
We shouldn't be adding required to CommandOption interface and doing an early return here - that's my bad, I got you confused in my other comment.
The way it works is that commander creates an Option object with required based on the name, but it doesn't do the actual validation and early returns in case the value is missing. That's what this code handles here.
In other words, we the code was fine as is. If we're handling arguments, we should be looking into a different place.
There was a problem hiding this comment.
The current implementation is misleading; having a required key would be better IMO. The intended way would be to use requiredOption() once we bump commander.js.
|
Technically, when we set Another technical detail, The quickest way to do it would be to go here cli/packages/cli/src/commands/init/init.ts Line 180 in aad25b3 options.template is String. If it's string, it's at least 1 character long.
|
6b73b21 to
ce46d40
Compare
88283a1 to
1cfd232
Compare
1cfd232 to
805bd39
Compare
|
Looks good. I'll apply a tiny naming tweak and ship it. Thanks! |
|
Unfortunately, while testing your PR, I have found out that we do support this feature out of the box without any additional work. All we have to do is to correct I have sent a follow-up PR to do it: #1328 I am really sorry that we have found this out THAT LATE in the process. I really appreciate your time and contributions and while this PR didn't get merged, we have brainstormed some interesting ideas together and have found out a better way to address the underlying problem! |
In fact, this was the initial approach #1324 (comment) |
Summary:
closes #1323
Test Plan: