-
Notifications
You must be signed in to change notification settings - Fork 161
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
Renames near.gitignore to .gitignore during project creation #67
Conversation
This person proposes the idea of "whitelisting" files. Something to think about: |
BTW, for now I've just changed |
Interesting. So perhaps the |
do we still need this? |
I personally think it's pretty important to ship a default |
So this is the most important doc I found about this: If we want someone to use the generator command(s) OR We should whitelist the files as described there.
This will create a tarball that can be extracted and you'll see exactly what you'd get after running the generator command. |
blank_react_project/package.json
Outdated
@@ -26,7 +26,8 @@ | |||
"deploy:pages": "gh-pages -d build", | |||
"deploy": "npm run deploy:contract && npm run deploy:pages", | |||
"build": "react-scripts build && gulp", | |||
"dev:deploy:contract": "near dev-deploy ./out/main.wasm" | |||
"dev:deploy:contract": "near dev-deploy ./out/main.wasm", | |||
"postinstall": "mv near.gitignore .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.
Not sure how this should work. Like this is a script for template project, my understanding is that it won't be executed during project generation. It would be executed when someone installs generated project though. But we want .gitignore
at time of project generation.
@mikedotexe I think the easiest solution is just name file differently in repo (e.g. Symlinks won't work on Windows I think and aren't very critical as generally there shouldn't be keys created inside of templates folders when developing this project. |
I like this approach. Thanks for pointing me to that function, @vgrichina. I just pushed up that change. This PR is ready for a re-review |
index.js
Outdated
@@ -61,6 +61,20 @@ const create_Project = async function(options) { | |||
} | |||
}); | |||
}); | |||
// rename proper (non-excluded by npm) default gitignore file to .gitignore | |||
const gitignoreFile = `${projectDir}/near.gitignore`; | |||
fs.access(gitignoreFile, fs.constants.F_OK | fs.constants.W_OK, (err, second) => { |
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.
it's best to use promise-based API in async function
https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_promises_api
current implementation doesn't wait properly for operations to complete before logging console.log('Copying project files complete.');
@mikedotexe please rebase on |
7d92285
to
827885d
Compare
… symlink .gitignores » near.gitignores
260f9b6
to
820cab7
Compare
This is good to go if tests are not passing simply due to flakiness as mentioned. I would re-run trying to make sure that's the case, then merge away. |
Note: I'd like some guidance with folks familiar with publishing this to npm. I'm not aware of how to "test" this yet without publishing.
From my understanding (see links below) the
.gitignore
files we have created are not being created when using the generator commands likenpx create-near-app…
.This is not good as end users may accidentally commit sensitive info, like in the
neardev
directory.For context, here's two links discussing the missing
.gitignore
files in folks' generators.npm/npm#1862
npm/npm#3763
Reading through those, there's discussion of adding a
.npmignore
file, but I don't think those threads are on track with our issue here.My solution here is to add a new file,
near.gitignore
that will not be omitted during the process of publishing to npm. Then in thepackage.json
files under thescripts
key addingpostinstall
and simply renaming it after thenpm install
. (renamenear.gitignore
to.gitignore
)Then when it comes to our own development, we'd like a normal
.gitignore
file, so I've created a symlink (.gitignore
»near.gitignore
) so we don't have to maintain two of those files.While I couldn't test the
npx
command, I did locally remove thenode_modules
directory andnpm i
and see that this works, and that git uses the symlink like I hoped it would.