-
Notifications
You must be signed in to change notification settings - Fork 907
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
Init for current/existing folders #1446
Init for current/existing folders #1446
Conversation
Cool, thanks! Linter and unit tests are not happy |
@@ -9372,6 +9377,15 @@ plist@^3.0.1: | |||
xmlbuilder "^9.0.7" | |||
xmldom "0.1.x" | |||
|
|||
plist@^3.0.2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why the deps changed 🤔
How is this different from #1421? Any chance we can join this into a single PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I decided to close the other PR due to inactivity and also, after taking another pass at this PR, I like this solution.
I left a review to help you move forward with this PR. Please let me know if you're still interested in working on this PR.
|
||
const readdir = promisify(fs.readdir); | ||
|
||
export async function getDirectoryFilesRecursive( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about executing a simple find ${dir} -print
command? For example, running find ios -print
on my React Native project gave me the following:
ios
ios/react-native-hello-world-generated.mm
ios/HelloWorld.h
ios/HelloWorld.mm
ios/react-native-hello-world.h
ios/HelloWorld.xcodeproj
ios/HelloWorld.xcodeproj/project.pbxproj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to simplify this function as it looks a bit complex (while it certainly gets the job done).
} | ||
if (conflictingFiles.length > 0) { | ||
throw new ConflictingFilesError(projectDirectory, conflictingFiles); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a conceptual suggestion.
How about we move all this code into a function checkDirectoryForConflictingFiles
(name is just a recommendation) and call it from an else
block of this conditional: https://github.com/react-native-community/cli/pull/1446/files#diff-5b5591728aa944b7a0f0a9a01b281bdf3e9f51bded73219124ace0edad8afd7eR48
Basically, I want to minimise the number of files affected. If directory exists - validate for conflicts - otherwise - create it. Everything stays in a single conditional.
I am going to close this PR due to inactivity and the PR review that remains unanswered for some time. I would be happy to accept a new PR with the requests addressed. Thank you! |
Summary:
This PR brings the ability to create new apps in existing and/or current folder.
Issue: #1418.
TBD:
Test Plan:
Current empty folder:
mkdir TestApp1
.cd TestApp1
.react-native init TestApp1 --directory .
TestApp1
folder.Non-current empty existing folder:
mkdir TestApp2
.react-native init TestApp2 --directory TestApp2
TestApp2
folder.Current folder with conflicting files:
mkdir TestApp3
.cd TestApp3
.mkdir android && touch android/gradlew && touch App.js && touch package.json
.react-native init TestApp3 --directory .