biojs / generator-biojs-webcomponents

Generate all the boilerplate for your next BioJS tool!
http://training.biojs.net
MIT License
9 stars 2 forks source link

Added option to overwrite or rename if build directory exists #29

Closed Nikhil-Vats closed 4 years ago

Nikhil-Vats commented 5 years ago

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.

Final workflow

Checklist

sarthak-sehgal commented 5 years ago

Hey @Nikhil-Vats, This requires a few changes:

Let me know what you think! :smiley:

Nikhil-Vats commented 5 years ago

@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.

Nikhil-Vats commented 5 years ago

@sarthak-sehgal I have updated the PR and added overwrite or renaming option in npm flow.

sarthak-sehgal commented 5 years ago

Screen Recording 2019-07-17 at 12 06 51 PM

@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: Generator upgrade component workflow (2)

Also, after renaming, are you checking again if that directory exists by chance (see workflow above)?

sarthak-sehgal commented 5 years ago

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?

Nikhil-Vats commented 5 years ago

@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 -

  1. If user enters a URL and everything works fine - Move on to the next prompt which is asking for toolNameComputer.

  2. If user enters a URL and the URL is wrong - ask user to enter again.

  3. 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.

Nikhil-Vats commented 5 years ago

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.

sarthak-sehgal commented 5 years ago

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.