binwrap icon indicating copy to clipboard operation
binwrap copied to clipboard

Drop `request` and `request-promise` deps

Open rtfeldman opened this issue 7 years ago β€’ 3 comments

See https://github.com/elm-lang/elm-platform/issues/231 for motivation! This would drop about 4MB off every installer that uses it, which in turn would make them install faster. πŸš€

This originally replaced request and request-promise with request-stream, which is more lightweight than either. It's a tiny wrapper around Node's built-in http and https modules which adds support for passing in URLs (Node's core lib requires separately specifying hostname, port, protocol, etc) and for following redirects, and that's about it.

Then I took it a step further and removed request-stream in favor of directly using the built-in http and https modules. This has the downside of not following redirects, but it's not much work (or much code) to re-add support for that if it seems important. (I defaulted to assuming it's not, based on how binwrap is used in practice.)

Here are the dependencies post-PR:

β”œβ”€β”€ [email protected]
β”œβ”€β”¬ [email protected]
β”‚ β”œβ”€β”¬ [email protected]
β”‚ β”‚ └── [email protected] deduped
β”‚ β”œβ”€β”¬ [email protected]
β”‚ β”‚ β”œβ”€β”€ [email protected]
β”‚ β”‚ β”œβ”€β”€ [email protected] deduped
β”‚ β”‚ β”œβ”€β”€ [email protected] deduped
β”‚ β”‚ └─┬ [email protected]
β”‚ β”‚   └─┬ [email protected]
β”‚ β”‚     β”œβ”€β”€ [email protected]
β”‚ β”‚     β”œβ”€β”¬ [email protected]
β”‚ β”‚     β”‚ β”œβ”€β”€ [email protected] deduped
β”‚ β”‚     β”‚ └── [email protected]
β”‚ β”‚     β”œβ”€β”€ [email protected] deduped
β”‚ β”‚     β”œβ”€β”¬ [email protected]
β”‚ β”‚     β”‚ └─┬ [email protected]
β”‚ β”‚     β”‚   β”œβ”€β”€ [email protected]
β”‚ β”‚     β”‚   └── [email protected]
β”‚ β”‚     β”œβ”€β”¬ [email protected]
β”‚ β”‚     β”‚ └── [email protected] deduped
β”‚ β”‚     └── [email protected]
β”‚ └── [email protected]
└─┬ [email protected]
  β”œβ”€β”¬ [email protected]
  β”‚ β”œβ”€β”€ [email protected]
  β”‚ └─┬ [email protected]
  β”‚   └── [email protected]
  └─┬ [email protected]
    └── [email protected]

I recommend viewing this PR with ?w=1.

rtfeldman avatar Aug 20 '18 02:08 rtfeldman

@avh4 Added redirect logic (it will follow up to 10 redirects; easy to adjust if desired) and some tests!

rtfeldman avatar Sep 18 '18 01:09 rtfeldman

I tried fixing the merge conflicts and got a failing test now:

  1) binwrap
       passes tests when specified URLs do exist:
     ChildProcessError: Command failed: (cd test_app && npm test)
TypeError: Cannot read property 'on' of undefined
    at /Users/avh4/workspace/binwrap/test.js:61:17
    at new Promise (<anonymous>)
    at /Users/avh4/workspace/binwrap/test.js:58:18
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
npm ERR! Test failed.  See above for more details.
 `(cd test_app && npm test)` (exited with error code 1)
      at callback (node_modules/child-process-promise/lib/index.js:33:27)
      at ChildProcess.exithandler (child_process.js:296:5)
      at maybeClose (internal/child_process.js:962:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)

avh4 avatar May 09 '19 04:05 avh4

Do we need to β€œhandle HTTPS_PROXY and NO_PROXY for people with corporate firewalls”?

https://github.com/elm/compiler/commit/41ec49ed921a2409afda483eb9e29197e262fe27#diff-234dbb95568376fa69c8c8f02316f97a

EDIT: Interesting module: https://github.com/gajus/global-agent EDIT2: That module is 1.12MB… EDIT3: What if we spawned curl instead? curl (and tar!) is available on Windows these days. We could fall back to wget on Linuxes without curl.

lydell avatar May 30 '20 12:05 lydell