nuxt/cli

prompt to override existing directory in `nuxi init`

danielroe opened this issue · 4 comments

if there's already a directory existing when creating a new project, perhaps we could prompt to override rather than throwing an error

pi0 commented

Should we replace the contents or merge them if user answered yes?

Replace, I think.

(But we could offer merge too?)

pi0 commented

Both have their trade-offs indeed. I am mostly worried about developers that mistakenly running/accepting this prompt in a not-version-controlled or backed-up repo and loose all their code.

Maybe we could give an option like this:

The `./project` dir you trying to init a nuxt app already has some contents. What to do?

[ ] Cancel
[ ] Merge
[ ] Create into `./project/nuxt-app`
[x] Replace

Are you really sure to replace the contents? (type YES)

For the merge option, we also need changes in giget. I am wondering is it enough cases that actually benefits for adding this?

If someone wants to start a new project, I can't think of any benefits of merging (although, this might need some feedback!). Instead, what do you think of being able to select a different directory without having to start all over again?

The `./project` directory already exists. What would you like to do?

[x] Replace its contents
[ ] Select different directory
[ ] Cancel

// option 1
Are you sure you would like to proceed? (y/n)

// option 2
Provide the directory:
./project-2 (enter)

(Worth taking into account a scenario when a provided different directory exists too, even multiple times.)