-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation for multiple arguments if specified for create-react-app #6080
Validation for multiple arguments if specified for create-react-app #6080
Conversation
Waooo |
e393df0
to
6693904
Compare
c7b347a
to
082724b
Compare
88d8331
to
c741b76
Compare
@mrmckeb What do you think? |
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:
|
@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
2524e2e
Compare
@mrmckeb Updated the warning message as you suggested. |
@mrmckeb What about a warning message:
And the process continues without exiting. What are your thoughts? |
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
8c1307c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
e10ab92
Compare
Kindly correct me if I'm wrong. Are you trying to say that I should move those validations here |
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
26a9126
Compare
@mrmckeb Is it fine now? |
3c2c60d
to
4a44d69
Compare
@mrmckeb I haven't heard from you for a while 🤔 |
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
e11b675
Compare
@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 :) |
@mrmckeb It can be simplified further by using |
That would be a great addition for future work, thanks for the suggestion @jamesgeorge007. |
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> arg1
works ignoring any arguments provided after the<project-name>
without any sort of warnings.