-
Notifications
You must be signed in to change notification settings - Fork 220
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
Npm: download the required binaries during installation #188
Npm: download the required binaries during installation #188
Conversation
33280fb
to
8af695a
Compare
c6598c3
to
d0e8d2e
Compare
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.
Hello! Thank you for your contribution and sorry for the late review!
Recently we had discussions on whether we should change packaging to download binaries on install or not and finally decided that we should. So your pull request is just in time!
However, there are some issues that should be addressed first:
-
Download is broken on Linux and MacOS: file has wrong name due to incorrect filename extension detection and missing executable bit.
-
In case if download failed, error message is unclear:
[5/5] Rebuilding all packages... error /home/envek/test/node_modules/@arkweid/lefthook: Command failed. Exit code: 1 Command: node postinstall.js Arguments: Directory: /home/envek/test/node_modules/@arkweid/lefthook Output: events.js:292 throw er; // Unhandled 'error' event ^ Error: Response status was 404 at ClientRequest.<anonymous> (/home/envek/evl.ms/test/node_modules/node-downloader-helper/dist/index.js:1:7153) at Object.onceWrapper (events.js:422:26) …
To help users to understand what is going wrong (and to help us debug it), error message (
Response status was 404
in this example) should be prefixed with details about what and when failed. Something like this:Failed to download lefthook_0.7.5_Linux_x86_64: Response status was 404 while fetching https://github.com/evilmartians/lefthook/releases/download/v0.7.5/lefthook_0.7.5_Linux_x86_64
Thank you. I addressed the comments. |
32ee663
to
743fde3
Compare
Yes, we know that. In that case other installation methods can be used instead. I wish that NPM supported platform-specific packages, but in current form it is already way too heavy, |
Co-authored-by: Andrey Novikov <envek@envek.name>
This commit has been extracted from #188
I extracted everything about executable extension into separate commit and pushed it to master, so here we can focus on NPM package (no action needed). |
Perhaps a net install (this PR) vs full install (current package) could be maintained then. Alternatively it appears there is options to handle this using OS dependencies: https://stackoverflow.com/questions/15176082/npm-package-json-os-specific-dependency |
You could make a fork, and add proxy support similar to prebuild-install |
Proxy support does not address organizations that forbid external downloads by policy and/or block external internet access other than via npm mirror. Do what you want, I'm just telling you have this will break some workflows and it appears I'm not the first to raise this concern. |
If the company blocks the internet, it should mock it using its proxy server. |
We probably would like to support two packages (one with bundled executables and one that downloads them), but it requires changing how hook scripts invoke lefthook binary. |
…tly failed" This reverts commit c7b3bbb.
Because, well, all we have is that binary executable
This commit has been extracted from #188
This commit has been extracted from #188
Thank you! We will release it soon. Maybe next week. |
Thanks! 🎉 |
Since this fetches binaries from GitHub, I want to raise the concern that this could interfere with environments that rely on a npm proxy registry (originally raised here). I think this issue is more relevant than it appears. Many environments use a npm proxy in case npm goes down or becomes inaccessible (eg. CI deploys, China, etc). In the case where GitHub becomes unavailable, (which happens more than it should...), this will break npm install. I think this can be easily addressed by publishing the binaries to npm and downloading from npm instead of GitHub (like playwright-chromium). |
Any plan to release this? |
Sorry, hadn't a chance to prepare a release (it is pretty big compared to previous ones), so it is postponed until I will have a day or two to polish things out. Can't say any specific date or time now. |
Bundled NPM package was here before, installer was implemented in #188
It finally was released in 0.8.0 and now available as Thank you very much for you contribution and sorry for such a long delay. |
The binaries are now downloaded upon installation. This reduces the package size significantly, which is very important for open-source repositories.
Fixes finding the binaries on Windows inside the hooks. Previously the code fell back to using
npx
Closes #43