-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Creating a new app in the current directory #368
Conversation
@gaearon how to fix this test?
|
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore | ||
// See: https://github.com/npm/npm/issues/1862 | ||
fs.move(path.join(appPath, 'gitignore'), path.join(appPath, '.gitignore'), []); | ||
var gitignoreExists = pathExists.sync(path.join(appPath, '.gitignore')); |
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.
This is why I originally wanted to only support the non existing folder case. Now we get in this situation where we have some files that already exist and need to be somehow merged. We can no longer be sure that all the configs that we have all work well together.
Could we check all the files that would be copied over and if any of them is already there then abort.
Honestly, i'm not sure it's worth the complexity, but I could be convinced otherwise
Following is the context I saw in the latest CI console (build 423.2)
Checking in your |
Yep, this would only work with npm 3, but not with npm 2. |
I think we should do the following:
@vjeux Thoughts? |
@gaearon currently in case of existing Sorry, I'm not good with words 😞 |
For the no conflicts, we will only know after spending a minute doing npm install. Do you think it's going to be a good experience? We could check for package.json and node_modules folder early though which may solve a lot of cases. If you init the project via github there's also a change that it creates a dummy README file that may also conflict with our own. For gitignore, what is the scenario when one already exists? When doing git init does it create one? If yes, I'm pretty sure that we do want to override it with ours as it contains a bunch of useful things. |
Let's be more strict and only allow empty directories or directories with I think whatever GitHub creates when you make a new project should be allowed. |
I totally agree we should only stick with checks we can do immediately. |
Okay I chatted with Dan offline and here's the proposal we're happy with:
Thanks for working on this, it's going to be super useful! |
Files we will allow for now:
|
👍 |
@vjeux what about |
Also can you guys help me with a better error message. Currently, I'm showing |
@gaearon we have a |
I usually initial a git repo via web interface before working on a local dev folder. If this is the only use case where we want to initialise an app in an existing folder, how about use the following command?
With this workflow, we may not need to worry about the following 2 problems
We don't need a prompt in global-cli because we don't need to ask user's opinion when working on an almost empty folder. As for the original README.md, we could let user know that the tool renamed it as README.old.md. Users will appreciate our detailed instructions in README. It is not much work to merge the initial short README to the new one. another thoughtone alternative is adding the following 2 steps to the current init process
We then even saved users a few minutes of visiting github webpage. |
For DSStore and the windows one, good call, we should add them to the list of things that are okay of a fresh install. I like the suggestion of renaming README.md into README.old.md, it lets us avoid adding a prompt, let's do that. For a --git command or automatically calling git init, we should consider it but it is out of scope for this pull request, could you open an issue about it so we can discuss it properly? Thanks! |
From the discussion so far, especially from the following rules @vjeux and @gaearon set. I am very convinced that CRA should be able to generated app in a freshly created git repo. In deed, I couldn't agree more that code should be managed using git. I am happy to make the process of setting git repo as easy as possible for users.
Apart from generating app in a freshly created git repo, I don't come up with other practical use cases that users want to generate app in an existing directory, but @torifat may have good ideas. @torifat , if you had some use cases in your mind, could you share with us because some of those use cases may be useful but not fit the rules above. |
@torifat , Good job and many thanks for the work. With your work, I don't really need a |
if (err) { | ||
// Append if there's already a `.gitignore` file there | ||
if (err.code === 'EEXIST') { | ||
fs.readFile(path.join(appPath, 'gitignore'), (err, data) => { |
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.
Please use readFileSync, otherwise we may run into race conditions as the rest of the file is going to run concurrently
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.
Since we do nothing with that file later, so I thought it would be ok. Changing it.
Looks really good! Let's fix the small nits and i'll merge it ;) |
@vjeux fixed. |
Yay, thanks! |
Hi,
|
Why not ignore all dot files? |
Travis is configured via a dot file, as are many other systems, so we can't just blanket ignore all dot files. |
Sounds good to me, let’s do it. 👍 |
* Creating a new app in the current directory * Fixed style mistakes
* Creating a new app in the current directory * Fixed style mistakes
This still errors out when you use an .iml file instead of a .idea folder. |
@tofagerl latest IDEA (2016.3.2RC) should work ok with that |
Great! :) |
global-cli/index.js
Outdated
|
||
function isGitHubBoilerplate(root) { | ||
var validFiles = [ | ||
'.DS_Store', 'Thumbs.db', '.git', '.gitignore', 'README.md', 'LICENSE' |
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.
Can we add 'CNAME' to the the validFiles array? https://help.github.com/articles/adding-or-removing-a-custom-domain-for-your-github-pages-site/
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.
Can you open a new issue with this request please? It's a little difficult to track in an issue like this.
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.
this essentially makes it impossible to use another collaboration/versioning product eg subversion, or some other IDE such as eclipse to register the project. I am trying to co-locate my project in eclipse and use subversion for collaboration. Eclipse creates a ".project" file, and subversion creates ".svn" directories.
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.
Please open another issue to discuss this. Comments on old issues aren't very actionable.
This fixes #334