Skip to content
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

init command validations #315

Closed
dhruvdutt opened this issue Mar 7, 2018 · 9 comments
Closed

init command validations #315

dhruvdutt opened this issue Mar 7, 2018 · 9 comments

Comments

@dhruvdutt
Copy link
Member

Type: Feature/bug

What is the current behavior?

  • When using init command, we ask for an entry path file as an input for scaffolding but we don't check if any file actually exists at that path.
  • Also, we allow values like "src/index" instead of "./src/index" which passes silently while scaffolding but causes errors at a later stage when webpack is executed.

What is the expected behavior?

  • Check if the file and path exist when taking input, pop an error (if the file it doesn't exist) and ask for input again.
  • Validate path and prefix "./" in cases when the input is "src/index". (Also validate path existence check after adding prefix)

Steps to reproduce

mkdir test-dir && cd test-dir;
webpack-cli init && webpack-cli --config webpack.prod.js

Affected question

Which module will be the first to enter the application? [example: './src/index']

@Symphoria
Copy link

Hi! I am new here and would like to contribute. Can I take a crack at this?

@dhruvdutt
Copy link
Member Author

dhruvdutt commented Mar 7, 2018

@Symphoria We can surely do it together. ✌️
I'll ping you on Gitter once a core member approves the proposed fix.

@Symphoria
Copy link

Got it.

@montogeek
Copy link
Member

Completely agree:

  1. In the case of entry module it should also specify that your input should be a relative path.
  2. We also are not setting mode by default, it should setted to Are you going to use this in production? answer.
  3. It would be great to support a -y flag similar to yarn init -y flag that provides sensible defaults to all options, making it more compatible with zero configuration objective.

@ematipico
Copy link
Contributor

Check if the file and path exist when taking input, pop an error (if the file it doesn't exist) and ask for input again

Actually, I would propose to prompt to the user if it's ok to override the file. It's just for usability reasons, instead of having an error, delete the file and running the command again, we could do it for them! What do you think?

@dhruvdutt
Copy link
Member Author

dhruvdutt commented Mar 8, 2018

@ematipico

Actually, I would propose to prompt to the user if it's ok to override the file. It's just for usability reasons, instead of having an error, delete the file and running the command again, we could do it for them! What do you think?

Overriding the file with what value? Don't we just need a file to exist at the entry path specified? And why would we need to delete the entry file?
Are you referring to the entry file or webpack config file?

@evenstensberg
Copy link
Member

Scenario is that people add the file later, so I don't know if we should support it. Makes sense to do npm init && webpack init, then add files accordingly.

@sendilkumarn
Copy link
Member

I have mixed feeling about this. Usability wise it is nice to have. But if we do it, technically it will be a little bit cumbersome and will have one or two edge cases.

Makes sense to do npm init && webpack init, then add files accordingly.

I would also like to have this approach in general and let the addon-authors to deal with this. And we can very well add it to the readme or show a message when generating (when the files are not there)

@evenstensberg
Copy link
Member

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants