Closed Nikhil-Vats closed 4 years ago
Hey @Nikhil-Vats, This requires a few changes:
You are creating multiple files and directories (like webpack.config.js
) but only checking for the existence of component-dist
folder. Let's step back and tweak our workflow a bit for a better experience. Instead of asking the user to manually create a new directory and run the generator there, let's do this:
Add a command line arg which would be the wrapper folder (basically the test-biojs-generator
folder user is creating manually now).
yo biojs-generator ./test-biojs-generator
or yo biojs-generator test-biojs-generator
creates a new folder test-biojs-generator
(do check if it already exists and ask user to enter name again in case of conflict) and then puts all the files into ityo biojs-generator
(no output arg) creates a new folder webcomponent
and puts the files in ityo biojs-generator .
creates the files in the same folder only (the procedure right now). Let's check for only component-dist
here right now.
Checkout https://www.npmjs.com/package/command-line-args
Do update the docs accordingly.If there is a conflict, it asks for the URL of build file again and the option to write "skip" is against the build file question. Here, you should offer the user to either rename (rename the folder through CLI only) or merge. Give two options, not a warning - this should solve the URL problem I think.
Let me know what you think! :smiley:
@sarthak-sehgal
You are creating multiple files and directories (like webpack.config.js) but only checking for the existence of component-dist folder. Let's step back and tweak our workflow a bit for a better experience.
I am only checking if component-dist exists because, for all the other files, yeoman checks and give users the standard ynaxdH
options.
The other three points you mentioned about running the generator with args seems a great idea and I will send a separate PR for that soon.
And regarding the last point about the URL of build file - I forgot to add the functionality of renaming or overwriting in the npm flow, I will add it and update this PR.
@sarthak-sehgal I have updated the PR and added overwrite or renaming option in npm flow.
@Nikhil-Vats, it still seems weird. Why do I have to remove the URL and write "skip" there and then again enter the URL at a later step? Also, since we are giving the options to rename or overwrite now, we don't need to give the warning saying "Please move...or enter skip..."
Something like this should do:
Also, after renaming, are you checking again if that directory exists by chance (see workflow above)?
Giving a thought about the component-dist
directory - if it only contains the build file, why do we need a separate directory?
Are we expecting some more files to be added to it in future?
@sarthak-sehgal
we don't need to give the warning saying "Please move...or enter skip..."
Yes, I will remove it.
Giving a thought about the component-dist directory - if it only contains the build file, why do we need a separate directory?
Yes, some of the components may require more than just the build file. So, it will be helpful to put all the necessary files in one folder.
@Nikhil-Vats, it still seems weird. Why do I have to remove the URL and write "skip" there and then again enter the URL at a later step?
Because the code is in the validator function which should return if everything works fine and then the next prompt will be shown, if there is an error validator should return false and it will ask the same prompt again. So, there's no way to show different prompts based on what happens in the validator, we can only control if we want to show the same prompt or move on to the next one. Thus the generator asks user to enter skip
and then it shows different prompts based on user's answer -
If user enters a URL and everything works fine - Move on to the next prompt which is asking for toolNameComputer.
If user enters a URL and the URL is wrong - ask user to enter again.
If component-dist exists, ask the user to enter skip and don't show the prompt for toolNameComputer just yet rather show user the options to rename/overwrite and so on.
I hope this makes sense.
Also, since we are giving the options to rename or overwrite now, we don't need to give the warning saying "Please move...or enter skip..."
I have updated the PR with the changed warning.
Thus the generator asks user to enter
skip
and then it shows different prompts based on user's answer
We won't need any additional user input like "skip" with the workflow I attached above. Once the user enters the URL, let's store it in global scope and if there is a conflict with file names, we will ask the user a question having three options (see workflow) and once he/she answers, we can access the URL stored earlier.
Let me know if you have any query regarding the workflow.
Description
Adds option to rename the build directory or overwrite the content of component-build if it already exists in local workflow. It also adds test for the new prompts. See the final workflow below.
Checklist