Skip to content
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

Auto-download of binaries on install #95

Closed
guillaumervls opened this issue Oct 23, 2018 · 12 comments
Closed

Auto-download of binaries on install #95

guillaumervls opened this issue Oct 23, 2018 · 12 comments
Labels
enhancement help wanted released Pull Request released | Issue is fixed

Comments

@guillaumervls
Copy link
Contributor

Hi and thanks for this module,

I use the downloadDir options in my code, so my home folder stays clean of .mongodb-binaries. However the postinstall script is not aware of that and downloads in my home folder. Shouldn't the downloading of binaries after npm install be optional ? (I mean opt-in instead of opt-out)

Am I missing something ?

Cheers

@AJRdev
Copy link
Collaborator

AJRdev commented Oct 23, 2018

@guillaumervls You should use the environnement variable MONGOMS_DOWNLOAD_DIR that specify a path where to download the mongodb binaries instead of the downloadDir option, because it will be used in the postinstall script as well :)

@guillaumervls
Copy link
Contributor Author

Yes I saw that, I find it weird that I'd have to add env vars to opt-out of this. It breaks the simple git clone + npm install... Switching this behavior from opt-out (MONGOMS_DISABLE_POSTINSTALL=1) to opt-in (with something like MONGOMS_ENABLE_POSTINSTALL=1) wouldn't be breaking anything (download of binaries has to be done at some time anyway), and wouldn't pollute home dir by default.

@nodkz
Copy link
Owner

nodkz commented Oct 23, 2018

In some cases, mongod binary may download about 1 minute the first time.

Most developers don't know how to increase timeouts in test runners. And by default after 5 seconds tests halts.

So for making testing without additional configuration, I decide to download latest version on postinstall script. It allows starting testing with zero configuration.

@nodkz
Copy link
Owner

nodkz commented Oct 23, 2018

Disabling downloading via MONGOMS_DISABLE_POSTINSTALL env variable is less evil.

@guillaumervls
Copy link
Contributor Author

Ok then isn't there a more appropriate place to download them (more local to the project) ?

@guillaumervls
Copy link
Contributor Author

Or read a setting from package.json ? Setting an environment variable puts this responsibility on the users of the package using this lib, forcing them to use MONGOMS_DISABLE_POSTINSTALL=1 npm install. With a setting in package.json they could just npm install.

@nodkz
Copy link
Owner

nodkz commented Oct 23, 2018

Sounds sweet if we can provide some vars via package.json or even .dot file.

Any proposal how it can be implemented? Need to use expierence from jest, babel, ts or any other implementation.

I feel your tension and dissapoinment about current ways of configuration. no one has raised this problem yet and you are the first! So let's solve this problem.

@guillaumervls
Copy link
Contributor Author

guillaumervls commented Oct 23, 2018

Cool ! From what I've seen popular modules like Husky, Babel, and Jest, use a package.json key matching their npm name (babel, husky, jest). Only ESLint uses eslintConfig. In our case it could be mongodb-memory-server.

IMHO, special config files like .babelrc should be used if they were so many config options that it could bloat package.json. It may not be necessary for the 7 options available here (the 7 MONGOMS_XXX env vars).

To implement this, I suggest the use of https://www.npmjs.com/package/pkg-conf which seems quite popular, and does exactly what we want.

@nodkz
Copy link
Owner

nodkz commented Oct 24, 2018

@guillaumervls if you have free time you may implement this feature with mongodb-memory-server key in package.json.

My current bandwidth till the end of year does not allow to do it myself 😞

And I will be very glad if somebody takes care about this feature. 🙏
Thanks.

@guillaumervls
Copy link
Contributor Author

@nodkz Just found this : https://www.npmjs.com/package/find-cache-dir (it's even more popular than
https://www.npmjs.com/package/pkg-conf)

Wouldn't it be even simpler to just use this instead of %HOME/.mongodb-binaries as the default ? Is would solve the problem of polluting the HOME folder and wouldn't require any config !

What do you think ?

@nodkz
Copy link
Owner

nodkz commented Nov 5, 2018

@nodkz
Copy link
Owner

nodkz commented Nov 5, 2018

🎉 This issue has been resolved in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nodkz nodkz added the released Pull Request released | Issue is fixed label Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted released Pull Request released | Issue is fixed
Projects
None yet
Development

No branches or pull requests

3 participants