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

feat: add ability to scaffold in non-empty directories #230

Closed
AlexanderHott opened this issue Jul 20, 2022 · 7 comments · Fixed by #375
Closed

feat: add ability to scaffold in non-empty directories #230

AlexanderHott opened this issue Jul 20, 2022 · 7 comments · Fixed by #375
Labels
📌 area: cli Relates to the CLI 🔰 good first issue Good for newcomers 🌟 enhancement New feature or request

Comments

@AlexanderHott
Copy link

Describe the bug
I can't initialize create-t3-app inside of a git worktree folder because it already contains a .git file.

To Reproduce
create a repo on github

cd project
git clone git@github.com/user/repo --bare . 
git worktree add main
cd main

pnpx create-t3-app@latest
# select no for "initialize git repo"

It will abort because the directory is not empty.

Expected behavior
The script should continue because the .git file does not interfere with other files.

@juliusmarminge
Copy link
Member

I think what you are describing is a bit of an edgecase, and only warn when certain directories exists would be complicated.

What I could see here is modifying the existing prompt to allow for something like:

Directory is not empty, how would you
like to proceed?
> Abort installation
> Clear the directory and continue installation
> Continue installation and overwrite conflicting files

What do you think?

@AlexanderHott
Copy link
Author

That’s a great solution

@AlexanderHott
Copy link
Author

I don’t know how much work this would be, but listing the conflicting files would be useful.

@juliusmarminge
Copy link
Member

Feel free to PR this. I dont have much time for coding currently.

@juliusmarminge juliusmarminge added 🌟 enhancement New feature or request 🔰 good first issue Good for newcomers labels Jul 21, 2022
@drewradcliff
Copy link
Contributor

It only aborts if you are creating a new directory with the same name, right?

I think what you are describing is a bit of an edgecase, and only warn when certain directories exists would be complicated.

What I could see here is modifying the existing prompt to allow for something like:

Directory is not empty, how would you
like to proceed?
> Abort installation
> Clear the directory and continue installation
> Continue installation and overwrite conflicting files

What do you think?

Wouldn't this solution cause this warning to happen the majority of the time you are using the cli (e.g. in a folder with other projects)?

@juliusmarminge
Copy link
Member

Wouldn't this solution cause this warning to happen the majority of the time you are using the cli (e.g. in a folder with other projects)?

It shouldn't. This prompt only shows up if it detects that the directory you have entered to scaffold in isn't empty. This behavior should not change. What's proposed is to have more options when this occurs. Currently we only have cancel or empty directory, the proposal is to have an option to continue without emptying and just overwriting the conflicting files and let the rest remain.

@juliusmarminge juliusmarminge linked a pull request Jul 23, 2022 that will close this issue
2 tasks
@juliusmarminge juliusmarminge added the 📌 area: cli Relates to the CLI label Aug 15, 2022
@juliusmarminge
Copy link
Member

For anyone wanting to pick this up, I think we should satisfy with my suggestion above and just let the fs calls overwrite.

Explicitly saying what files conflict seems scary and bad if we get it "wrong" (indicated by the amount of edge cases I could think this seems quite likely).

@juliusmarminge juliusmarminge changed the title Can't use create-t3-app inside of git bare repo worktree folder feat: add ability to scaffold in non-empty directories Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📌 area: cli Relates to the CLI 🔰 good first issue Good for newcomers 🌟 enhancement New feature or request
Projects
None yet
3 participants