Uh oh!
There was an error while loading. Please reload this page.
Validation for multiple arguments if specified for create-react-app - #6080
Conversation
henryarihoona
commented
Dec 22, 2018
Waooo |
e393df0 to
6693904Comparec7b347a to
082724bCompare88d8331 to
c741b76Compare@mrmckeb What do you think? |
mrmckeb
commented
Jan 15, 2019
Hi @jamesgeorge007, sorry for the delay. A side note, we recommend to raise an issue before raising a PR, as that way we can have a discussion about the merits of the work before - we want to avoid people spending their time on a PR that won't be accepted. It also helps make that PR more visible :)
I think what you're proposing makes sense. Some thoughts:
|
jamesgeorge007
commented
Jan 15, 2019
@mrmckeb So, shall I update it so that help shows up if the user fires in multiple arguments. |
I would suggest that it's better to just say something like (as an example): The other question is, do we want to Thanks for your work here by the way, again, sorry it took so long to get to review. |
cb28d2a to
2524e2eComparejamesgeorge007
commented
Jan 15, 2019
@mrmckeb Updated the warning message as you suggested. |
jamesgeorge007
commented
Jan 15, 2019
@mrmckeb What about a warning message:
And the process continues without exiting. What are your thoughts? |
mrmckeb
commented
Jan 16, 2019
Let's use a message that matches the format here: For the help text, I would leverage this: So, yellow font, and tell the user: Something else to work on - and I'm sorry I didn't raise this earlier - is that there are other valid options that don't start with We need to be very careful here, as breaking this can mean that people can't build new apps ;) |
2524e2e to
8c1307cCompare
mrmckeb
left a comment
There was a problem hiding this comment.
Thanks @jamesgeorge007.
The reason I directed you here (https://github.com/facebook/create-react-app/pull/6080/files#diff-f9867c1e09ced1328f2ccdac4afac4a5R178) was that there is a program name in use there.
I think the check we're doing now is still a little risky. There's also the possibility that someone passes in --scripts-version without the actual package name, which would cause the test to fail.
Can I suggest:
- The test might be safest if it looks only at the the immediate option after where we expect
<project-directory>, and if it is not an option (--) then we place this warning. I can't see any other ways to do this safely. - The message as it is now is good. It would be best if included in this block, https://github.com/facebook/create-react-app/pull/6080/files#diff-f9867c1e09ced1328f2ccdac4afac4a5R175, then we can just share the help messaging:
if (typeof projectName === 'undefined' || multipleProjectNameArgs) {
Sorry this PR is complicated, it's because you're working on the first thing people see when they start with CRA, so we need to keep this stable and consistent.
191cf52 to
e10ab92Comparejamesgeorge007
commented
Jan 17, 2019
Kindly correct me if I'm wrong. Are you trying to say that I should move those validations here |
mrmckeb
commented
Jan 20, 2019
Sorry, you're right, what you've done is safe (I've tested today) as CRA fails without an argument for
I'd strongly suggest that just simplifying this by checking for args up until the first For example: I hope that all makes sense, sorry I wasn't clearer earlier. If you can make that move, I think we're ready to merge! |
a41b5a8 to
26a9126Comparejamesgeorge007
commented
Jan 26, 2019
@mrmckeb Is it fine now? |
3c2c60d to
4a44d69Comparejamesgeorge007
commented
Jan 29, 2019
@mrmckeb I haven't heard from you for a while 🤔 |
jamesgeorge007
commented
Feb 1, 2019
mrmckeb
commented
Feb 1, 2019
I'm very sorry @jamesgeorge007, I was out of action for a week and a half. I'll take another quick look tonight or tomorrow and merge this in :) |
Exclude options while validating 🎉 Fix linting errors 🚧 remove unwanted typecasting 🚧
Remove package-lock 🚧
4a44d69 to
e11b675Comparemrmckeb
commented
Feb 3, 2019
@jamesgeorge007 Are you OK with the clean-up I made with this commit? There were a few styling issues, and I simplified the test a little. If that's OK, let's get this in :) |
jamesgeorge007
commented
Feb 3, 2019
@mrmckeb It can be simplified further by using |
mrmckeb
commented
Feb 3, 2019
That would be a great addition for future work, thanks for the suggestion @jamesgeorge007. |
mrmckeb
commented
Feb 3, 2019
Thanks again @jamesgeorge007, and congrats on your first contribution. Sorry it was a tricky one. |
@mrmckeb I guess this change doesn't take into consideration, all those arguments given after the For instance, Using an argument parser like |
Correct, and that was intentional as this PR was meant to prevent multiple arguments for the name (as I understood it). Adding more validation is a good idea, but I'd prefer to use a tool (as doing it by hand means we'll likely make a mistake). Your suggesting sounds good to me, I'd love to see how that looks. |
As per now
create-react-app <project-name> arg1works ignoring any arguments provided after the<project-name>without any sort of warnings.