cli
cli copied to clipboard
WIP: feat: Init for currently exising folders
Summary:
Hey, guys. So, this is a third attempt at implementing project init in the existing folder. Basically, I took #1446 and implement fixes from @grabbou code-review.
Then I realized that we should take underscored file names from templates into account and implemented it too. And then I realized that we also change the template placeholder on the project name, including the renaming of folders and files, so we probably should take this into account as well.
But just now I came across this reply, and now I'm confused — do we even have to worry about any conflicts? If so, why?
So now it's more of an issue for discussion rather than PR to review because it most certainly will have some finalization or complete rewriting.
Test Plan:
Current empty folder:
- Create an empty folder
mkdir TestApp1
.- Go to a newly created folder
cd TestApp1
.- Init a new app
react-native init TestApp1 --directory .
- As a result a new app gets created in
TestApp1
folder.Non-current empty existing folder:
- Create an empty folder
mkdir TestApp2
.- Init a new app
react-native init TestApp2 --directory TestApp2
- As a result a new app gets created in
TestApp2
folder.Current folder with conflicting files:
- Create an empty folder
mkdir TestApp3
.- Go to a newly created folder
cd TestApp3
.- Create some conflicting files
mkdir android && touch android/gradlew && touch App.js && touch package.json
.- Init a new app
react-native init TestApp3 --directory .
- As a result get a crash with corresponding error saying that some files are conflicting.
![]()