create-t3-app icon indicating copy to clipboard operation
create-t3-app copied to clipboard

Can't use create-t3-app inside of git bare repo worktree folder

Open AlexanderHott opened this issue 2 years ago • 6 comments

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 [email protected]/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.

AlexanderHott avatar Jul 20 '22 00:07 AlexanderHott

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?

juliusmarminge avatar Jul 20 '22 09:07 juliusmarminge

That’s a great solution

AlexanderHott avatar Jul 21 '22 00:07 AlexanderHott

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

AlexanderHott avatar Jul 21 '22 00:07 AlexanderHott

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

juliusmarminge avatar Jul 21 '22 14:07 juliusmarminge

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)?

drewradcliff avatar Jul 22 '22 00:07 drewradcliff

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 avatar Jul 22 '22 09:07 juliusmarminge

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 avatar Aug 25 '22 19:08 juliusmarminge