From f924929fd31332511a6ef47978f4aaceaaec3bfd Mon Sep 17 00:00:00 2001 From: Darcy Clarke Date: Tue, 3 Mar 2020 12:22:32 -0500 Subject: [PATCH] node-gyp@5.1.0 --- .../.github/workflows/Python_tests.yml | 40 +++++++ node_modules/node-gyp/.travis.yml | 71 ++++++----- node_modules/node-gyp/CHANGELOG.md | 18 +++ node_modules/node-gyp/README.md | 8 +- node_modules/node-gyp/gyp/pylib/gyp/input.py | 2 +- .../node-gyp/lib/Find-VisualStudio.cs | 9 +- node_modules/node-gyp/lib/find-python.js | 2 +- node_modules/node-gyp/lib/install.js | 6 +- node_modules/node-gyp/lib/node-gyp.js | 1 + node_modules/node-gyp/lib/proxy.js | 92 ++++++++++++++ node_modules/node-gyp/macOS_Catalina.md | 49 ++++---- node_modules/node-gyp/package.json | 22 ++-- node_modules/node-gyp/test/docker.sh | 112 ------------------ node_modules/node-gyp/test/test-download.js | 97 ++++++++++++++- package-lock.json | 6 +- package.json | 2 +- 16 files changed, 348 insertions(+), 189 deletions(-) create mode 100644 node_modules/node-gyp/.github/workflows/Python_tests.yml create mode 100644 node_modules/node-gyp/lib/proxy.js delete mode 100755 node_modules/node-gyp/test/docker.sh diff --git a/node_modules/node-gyp/.github/workflows/Python_tests.yml b/node_modules/node-gyp/.github/workflows/Python_tests.yml new file mode 100644 index 0000000000000..dba9d10933cbf --- /dev/null +++ b/node_modules/node-gyp/.github/workflows/Python_tests.yml @@ -0,0 +1,40 @@ +# TODO: Line 15, enable python-version: 3.5 +# TODO: Line 36, enable pytest --doctest-modules + +name: Python_tests +on: [push, pull_request] +jobs: + Python_tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + max-parallel: 15 + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [2.7, 3.6, 3.7, 3.8] # 3.5, + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest # -r requirements.txt + - name: Lint with flake8 + if: matrix.os == 'ubuntu-latest' + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest (Linux and macOS) + if: matrix.os != 'windows-latest' + run: pytest + - name: Test with pytest (Windows) + if: matrix.os == 'windows-latest' + shell: bash + run: GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" pytest + # - name: Run doctests with pytest + # run: pytest --doctest-modules diff --git a/node_modules/node-gyp/.travis.yml b/node_modules/node-gyp/.travis.yml index e43ba548fb784..22f7bc12fc349 100644 --- a/node_modules/node-gyp/.travis.yml +++ b/node_modules/node-gyp/.travis.yml @@ -1,33 +1,17 @@ dist: xenial language: python cache: pip -matrix: +addons: + homebrew: + update: true + packages: + - npm + - pyenv +jobs: include: - name: "Python 2.7 on Linux" env: NODE_GYP_FORCE_PYTHON=python2 python: 2.7 - - name: "Python 2.7 on macOS" - os: osx - osx_image: xcode11.2 - language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python2 - before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew install npm - - name: "Node.js 6 & Python 2.7 on Windows" - os: windows - language: node_js - node_js: 6 # node - env: >- - PATH=/c/Python27:/c/Python27/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe - before_install: choco install python2 - - name: "Node.js 12 & Python 2.7 on Windows" - os: windows - language: node_js - node_js: 12 # node - env: >- - PATH=/c/Python27:/c/Python27/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe - before_install: choco install python2 - name: "Node.js 6 & Python 3.8 on Linux" python: 3.8 @@ -58,12 +42,36 @@ matrix: env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 12 - - name: "Python 3.7 on macOS" + - name: "Python 2.7 on macOS" os: osx osx_image: xcode11.2 language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python3 - before_install: HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade npm || true + env: NODE_GYP_FORCE_PYTHON=python2 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=2.7.17 + before_install: pyenv install $PYENV_VERSION + - name: "Python 3.8 on macOS" + os: osx + osx_image: xcode11.2 + language: shell # 'language: python' is not yet supported on macOS + env: NODE_GYP_FORCE_PYTHON=python3 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=3.8.0 + before_install: pyenv install $PYENV_VERSION + + - name: "Node.js 6 & Python 2.7 on Windows" + os: windows + language: node_js + node_js: 6 # node + env: >- + PATH=/c/Python27:/c/Python27/Scripts:$PATH + NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe + before_install: choco install python2 + - name: "Node.js 12 & Python 2.7 on Windows" + os: windows + language: node_js + node_js: 12 # node + env: >- + PATH=/c/Python27:/c/Python27/Scripts:$PATH + NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe + before_install: choco install python2 + - name: "Node.js 12 & Python 3.7 on Windows" os: windows language: node_js @@ -82,20 +90,19 @@ matrix: before_install: choco install python install: - #- pip install -r requirements.txt - - pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python + - python -m pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python before_script: - - flake8 --version + - python -m flake8 --version # stop the build if there are Python syntax errors or undefined names - - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. Two space indentation is OK. The GitHub editor is 127 chars wide - - flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics + - python -m flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics - npm install - npm list script: - node -e 'require("npmlog").level="verbose"; require("./lib/find-python")(null,()=>{})' - npm test - - GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" pytest + - GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" python -m pytest notifications: on_success: change on_failure: change # `always` will be the setting once code changes slow down diff --git a/node_modules/node-gyp/CHANGELOG.md b/node_modules/node-gyp/CHANGELOG.md index 28f523779841d..5dc6bb4d47069 100644 --- a/node_modules/node-gyp/CHANGELOG.md +++ b/node_modules/node-gyp/CHANGELOG.md @@ -1,3 +1,21 @@ +v5.1.0 2020-02-05 +================= + +* [[`f37a8b40d0`](https://github.com/nodejs/node-gyp/commit/f37a8b40d0)] - **doc**: add GitHub Actions badge (#1994) (Rod Vagg) [#1994](https://github.com/nodejs/node-gyp/pull/1994) +* [[`cb3f6aae5e`](https://github.com/nodejs/node-gyp/commit/cb3f6aae5e)] - **doc**: update macOS\_Catalina.md (#1992) (James Home) [#1992](https://github.com/nodejs/node-gyp/pull/1992) +* [[`0607596a4c`](https://github.com/nodejs/node-gyp/commit/0607596a4c)] - **doc**: fix typo in README.md (#1985) (Suraneti Rodsuwan) [#1985](https://github.com/nodejs/node-gyp/pull/1985) +* [[`0d5a415a14`](https://github.com/nodejs/node-gyp/commit/0d5a415a14)] - **doc**: add travis badge (Rod Vagg) [#1971](https://github.com/nodejs/node-gyp/pull/1971) +* [[`103740cd95`](https://github.com/nodejs/node-gyp/commit/103740cd95)] - **gyp**: list(dict) so we can del dict(key) while iterating (Christian Clauss) [#2009](https://github.com/nodejs/node-gyp/pull/2009) +* [[`278dcddbdd`](https://github.com/nodejs/node-gyp/commit/278dcddbdd)] - **lib**: ignore VS instances that cause COMExceptions (Andrew Casey) [#2018](https://github.com/nodejs/node-gyp/pull/2018) +* [[`1694907bbf`](https://github.com/nodejs/node-gyp/commit/1694907bbf)] - **lib**: compatibility with semver ≥ 7 (`new` for semver.Range) (Xavier Guimard) [#2006](https://github.com/nodejs/node-gyp/pull/2006) +* [[`a3f1143514`](https://github.com/nodejs/node-gyp/commit/a3f1143514)] - **(SEMVER-MINOR)** **lib**: noproxy support, match proxy detection to `request` (Matias Lopez) [#1978](https://github.com/nodejs/node-gyp/pull/1978) +* [[`52365819c7`](https://github.com/nodejs/node-gyp/commit/52365819c7)] - **test**: remove old docker test harness (#1993) (Rod Vagg) [#1993](https://github.com/nodejs/node-gyp/pull/1993) +* [[`bc509c511d`](https://github.com/nodejs/node-gyp/commit/bc509c511d)] - **test**: add Windows to GitHub Actions testing (#1996) (Christian Clauss) [#1996](https://github.com/nodejs/node-gyp/pull/1996) +* [[`91ee26dd48`](https://github.com/nodejs/node-gyp/commit/91ee26dd48)] - **test**: fix typo in header download test (#2001) (Richard Lau) [#2001](https://github.com/nodejs/node-gyp/pull/2001) +* [[`0923f344c9`](https://github.com/nodejs/node-gyp/commit/0923f344c9)] - **test**: direct python invocation & simpler pyenv (Matias Lopez) [#1979](https://github.com/nodejs/node-gyp/pull/1979) +* [[`32c8744b34`](https://github.com/nodejs/node-gyp/commit/32c8744b34)] - **test**: fix macOS Travis on Python 2.7 & 3.7 (Christian Clauss) [#1979](https://github.com/nodejs/node-gyp/pull/1979) +* [[`fd4b1351e4`](https://github.com/nodejs/node-gyp/commit/fd4b1351e4)] - **test**: initial Github Actions with Ubuntu & macOS (Christian Clauss) [#1985](https://github.com/nodejs/node-gyp/pull/1985) + v5.0.7 2019-12-16 ================= diff --git a/node_modules/node-gyp/README.md b/node_modules/node-gyp/README.md index e39c5de8ea045..79abf4ba71fe3 100644 --- a/node_modules/node-gyp/README.md +++ b/node_modules/node-gyp/README.md @@ -1,5 +1,8 @@ # `node-gyp` - Node.js native addon build tool +[![Travis CI](https://travis-ci.com/nodejs/node-gyp.svg?branch=master)](https://travis-ci.com/nodejs/node-gyp) +[![Build Status](https://github.com/nodejs/node-gyp/workflows/Python_tests/badge.svg)](https://github.com/nodejs/node-gyp/actions?workflow=Python_tests) + `node-gyp` is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It contains a fork of the [gyp](https://gyp.gsrc.io) project that was previously used by the Chromium @@ -14,7 +17,7 @@ etc.), regardless of what version of Node.js is actually installed on your syste ## Features * The same build commands work on any of the supported platforms - * Supports the targetting of different versions of Node.js + * Supports the targeting of different versions of Node.js ## Installation @@ -191,7 +194,8 @@ Some additional resources for Node.js native addons and writing `gyp` configurat | `--devdir=$path` | SDK download directory (default is OS cache directory) | `--ensure` | Don't reinstall headers if already present | `--dist-url=$url` | Download header tarball from custom URL -| `--proxy=$url` | Set HTTP proxy for downloading header tarball +| `--proxy=$url` | Set HTTP(S) proxy for downloading header tarball +| `--noproxy=$urls` | Set urls to ignore proxies when downloading header tarball | `--cafile=$cafile` | Override default CA chain (to download tarball) | `--nodedir=$path` | Set the path to the node source code | `--python=$path` | Set path to the Python binary diff --git a/node_modules/node-gyp/gyp/pylib/gyp/input.py b/node_modules/node-gyp/gyp/pylib/gyp/input.py index 2973c078fc82b..d1742800ac507 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/input.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/input.py @@ -2286,7 +2286,7 @@ def SetUpConfigurations(target, target_dict): merged_configurations[configuration]) # Now drop all the abstract ones. - for configuration in target_dict['configurations'].keys(): + for configuration in list(target_dict['configurations']): old_configuration_dict = target_dict['configurations'][configuration] if old_configuration_dict.get('abstract'): del target_dict['configurations'][configuration] diff --git a/node_modules/node-gyp/lib/Find-VisualStudio.cs b/node_modules/node-gyp/lib/Find-VisualStudio.cs index 0a533f42d6a4f..d2e45a76275f5 100644 --- a/node_modules/node-gyp/lib/Find-VisualStudio.cs +++ b/node_modules/node-gyp/lib/Find-VisualStudio.cs @@ -205,7 +205,14 @@ public static void PrintJson() return; } - instances.Add(InstanceJson(rgelt[0])); + try + { + instances.Add(InstanceJson(rgelt[0])); + } + catch (COMException) + { + // Ignore instances that can't be queried. + } } } diff --git a/node_modules/node-gyp/lib/find-python.js b/node_modules/node-gyp/lib/find-python.js index e79bc50d5a1d5..fabc4630f15d4 100644 --- a/node_modules/node-gyp/lib/find-python.js +++ b/node_modules/node-gyp/lib/find-python.js @@ -226,7 +226,7 @@ PythonFinder.prototype = { } this.addLog(`- version is "${version}"`) - const range = semver.Range(this.semverRange) + const range = new semver.Range(this.semverRange) var valid = false try { valid = range.test(version) diff --git a/node_modules/node-gyp/lib/install.js b/node_modules/node-gyp/lib/install.js index f68cd7fd6d2a5..c919c1058811e 100644 --- a/node_modules/node-gyp/lib/install.js +++ b/node_modules/node-gyp/lib/install.js @@ -11,6 +11,7 @@ const request = require('request') const mkdir = require('mkdirp') const processRelease = require('./process-release') const win = process.platform === 'win32' +const getProxyFromURI = require('./proxy') function install (fs, gyp, argv, callback) { var release = processRelease(argv, gyp, process.version, process.release) @@ -410,10 +411,7 @@ function download (gyp, env, url) { } // basic support for a proxy server - var proxyUrl = gyp.opts.proxy || - env.http_proxy || - env.HTTP_PROXY || - env.npm_config_proxy + var proxyUrl = getProxyFromURI(gyp, env, url) if (proxyUrl) { if (/^https?:\/\//i.test(proxyUrl)) { log.verbose('download', 'using proxy url: "%s"', proxyUrl) diff --git a/node_modules/node-gyp/lib/node-gyp.js b/node_modules/node-gyp/lib/node-gyp.js index 9d24103900f70..81fc590919ba8 100644 --- a/node_modules/node-gyp/lib/node-gyp.js +++ b/node_modules/node-gyp/lib/node-gyp.js @@ -67,6 +67,7 @@ proto.configDefs = { ensure: Boolean, // 'install' solution: String, // 'build' (windows only) proxy: String, // 'install' + noproxy: String, // 'install' devdir: String, // everywhere nodedir: String, // 'configure' loglevel: String, // everywhere diff --git a/node_modules/node-gyp/lib/proxy.js b/node_modules/node-gyp/lib/proxy.js new file mode 100644 index 0000000000000..92d9ed2f7f085 --- /dev/null +++ b/node_modules/node-gyp/lib/proxy.js @@ -0,0 +1,92 @@ +'use strict' +// Taken from https://github.com/request/request/blob/212570b/lib/getProxyFromURI.js + +const url = require('url') + +function formatHostname (hostname) { + // canonicalize the hostname, so that 'oogle.com' won't match 'google.com' + return hostname.replace(/^\.*/, '.').toLowerCase() +} + +function parseNoProxyZone (zone) { + zone = zone.trim().toLowerCase() + + var zoneParts = zone.split(':', 2) + var zoneHost = formatHostname(zoneParts[0]) + var zonePort = zoneParts[1] + var hasPort = zone.indexOf(':') > -1 + + return { hostname: zoneHost, port: zonePort, hasPort: hasPort } +} + +function uriInNoProxy (uri, noProxy) { + var port = uri.port || (uri.protocol === 'https:' ? '443' : '80') + var hostname = formatHostname(uri.hostname) + var noProxyList = noProxy.split(',') + + // iterate through the noProxyList until it finds a match. + return noProxyList.map(parseNoProxyZone).some(function (noProxyZone) { + var isMatchedAt = hostname.indexOf(noProxyZone.hostname) + var hostnameMatched = ( + isMatchedAt > -1 && + (isMatchedAt === hostname.length - noProxyZone.hostname.length) + ) + + if (noProxyZone.hasPort) { + return (port === noProxyZone.port) && hostnameMatched + } + + return hostnameMatched + }) +} + +function getProxyFromURI (gyp, env, uri) { + // If a string URI/URL was given, parse it into a URL object + if (typeof uri === 'string') { + // eslint-disable-next-line + uri = url.parse(uri) + } + + // Decide the proper request proxy to use based on the request URI object and the + // environmental variables (NO_PROXY, HTTP_PROXY, etc.) + // respect NO_PROXY environment variables (see: https://lynx.invisible-island.net/lynx2.8.7/breakout/lynx_help/keystrokes/environments.html) + + var noProxy = gyp.opts.noproxy || env.NO_PROXY || env.no_proxy || env.npm_config_noproxy || '' + + // if the noProxy is a wildcard then return null + + if (noProxy === '*') { + return null + } + + // if the noProxy is not empty and the uri is found return null + + if (noProxy !== '' && uriInNoProxy(uri, noProxy)) { + return null + } + + // Check for HTTP or HTTPS Proxy in environment Else default to null + + if (uri.protocol === 'http:') { + return gyp.opts.proxy || + env.HTTP_PROXY || + env.http_proxy || + env.npm_config_proxy || null + } + + if (uri.protocol === 'https:') { + return gyp.opts.proxy || + env.HTTPS_PROXY || + env.https_proxy || + env.HTTP_PROXY || + env.http_proxy || + env.npm_config_proxy || null + } + + // if none of that works, return null + // (What uri protocol are you using then?) + + return null +} + +module.exports = getProxyFromURI diff --git a/node_modules/node-gyp/macOS_Catalina.md b/node_modules/node-gyp/macOS_Catalina.md index 5f02face57d96..530cbf25c38dd 100644 --- a/node_modules/node-gyp/macOS_Catalina.md +++ b/node_modules/node-gyp/macOS_Catalina.md @@ -1,39 +1,37 @@ # Installation notes for macOS Catalina (v10.15) -_This document specifically refers to upgrades from previous versions of macOS to Catalina (10.15). It should be removed from the source repository when Catalina ceases to be the latest macOS version or updated to deal with challenges involved in upgrades to the next version of macOS._ +_This document specifically refers to upgrades from previous versions of macOS to Catalina (10.15). It should be removed from the source repository when Catalina ceases to be the latest macOS version or when future Catalina versions no longer raise these issues._ -Lessons learned from: -* https://github.com/nodejs/node-gyp/issues/1779 -* https://github.com/nodejs/node-gyp/issues/1861 -* https://github.com/nodejs/node-gyp/issues/1927 and elsewhere - -Installing `node-gyp` on macOS can be found at https://github.com/nodejs/node-gyp#on-macos - -However, upgrading to macOS Catalina changes some settings that may cause normal `node-gyp` installations to fail. +**Upgrading to macOS Catalina may cause normal `node-gyp` installations to fail.** ### Is my Mac running macOS Catalina? -Let's make first make sure that your Mac is currently running Catalina: -% `sw_vers` +Let's first make sure that your Mac is running Catalina: +``` +% sw_vers ProductName: Mac OS X ProductVersion: 10.15 BuildVersion: 19A602 +``` +If `ProductVersion` is less then `10.15` then this document is not for you. Normal install docs for `node-gyp` on macOS can be found at https://github.com/nodejs/node-gyp#on-macos -If `ProductVersion` is less then `10.15` then this document is not really for you. ### The acid test -Next, lets see if `Xcode Command Line Tools` are installed: +To see if `Xcode Command Line Tools` is installed in a way that will work with `node-gyp`, run: 1. `/usr/sbin/pkgutil --packages | grep CL` - * If nothing is listed, then [skip to the next section](#Two-roads). - * If `com.apple.pkg.CLTools_Executables` is listed then try: + * `com.apple.pkg.CLTools_Executables` should be listed. If it isn't, this test failed. 2. `/usr/sbin/pkgutil --pkg-info com.apple.pkg.CLTools_Executables` - * If `version: 11.0.0` or later is listed then _you are done_! Your Mac should be ready to install `node-gyp`. Doing `clang -v` should show `Apple clang version 11.0.0` or later. + * `version: 11.0.0` (or later) should be listed. If it isn't, this test failed. + +If both tests succeeded, _you are done_! You should be ready to install `node-gyp`. + +If either test failed, there is a problem with your Xcode Command Line Tools installation. [Continue to Solutions](#Solutions). -As you go through the remainder of this document, at anytime you can try these `acid test` commands. If they pass then your Mac should be ready to install `node-gyp`. +### Solutions +There are three ways to install the Xcode libraries `node-gyp` needs on macOS. People running Catalina have had success with some but not others in a way that has been unpredictable. -### Two roads -There are two main ways to install `node-gyp` on macOS: 1. With the full Xcode (~7.6 GB download) from the `App Store` app. 2. With the _much_ smaller Xcode Command Line Tools via `xcode-select --install` +3. With the _much_ smaller Xcode Command Line Tools via manual download. **For people running the latest version of Catalina (10.15.2 at the time of this writing), this has worked when the other two solutions haven't.** ### Installing `node-gyp` using the full Xcode 1. `xcodebuild -version` should show `Xcode 11.1` or later. @@ -52,7 +50,7 @@ There are two main ways to install `node-gyp` on macOS: 10. `sudo xcode-select --reset` # Enter root password. No output is normal. 11. Repeat step 7 above. Is the path different this time? Repeat the _acid test_. -### Installing `node-gyp` using the Xcode Command Line Tools +### Installing `node-gyp` using the Xcode Command Line Tools via `xcode-select --install` 1. If the _acid test_ has not succeeded, then try `xcode-select --install` 2. Wait until the install process is _complete_. 3. `softwareupdate -l` # No listing is a good sign. @@ -64,6 +62,11 @@ There are two main ways to install `node-gyp` on macOS: 8. `sudo xcode-select --reset` # Enter root password. No output is normal. 9. Repeat step 5 above. Is the path different this time? Repeat the _acid test_. +### Installing `node-gyp` using the Xcode Command Line Tools via manual download +1. Download the appropriate version of the "Command Line Tools for Xcode" for your version of Catalina from developer.apple.com/download. As of MacOS 10.15.2, that's Command_Line_Tools_for_Xcode_11.3.dmg +2. Install the package. +3. Run the _acid test_. + ### I did all that and the acid test still does not pass :-( 1. `sudo rm -rf $(xcode-select -print-path)` # Enter root password. No output is normal. 2. `xcode-select --install` @@ -72,3 +75,9 @@ There are two main ways to install `node-gyp` on macOS: 5. `npm explore npm -g -- npm explore npm-lifecycle -- npm install node-gyp@latest` 6. If the _acid test_ still does _not_ pass then... 7. Add a comment to https://github.com/nodejs/node-gyp/issues/1927 so we can improve. + +Lessons learned from: +* https://github.com/nodejs/node-gyp/issues/1779 +* https://github.com/nodejs/node-gyp/issues/1861 +* https://github.com/nodejs/node-gyp/issues/1927 and elsewhere +* Thanks to @rrrix for discovering Solution 3 diff --git a/node_modules/node-gyp/package.json b/node_modules/node-gyp/package.json index afa45f3969095..4638db5a3f4a3 100644 --- a/node_modules/node-gyp/package.json +++ b/node_modules/node-gyp/package.json @@ -1,29 +1,29 @@ { - "_from": "node-gyp@5.0.7", - "_id": "node-gyp@5.0.7", + "_from": "node-gyp@5.1.0", + "_id": "node-gyp@5.1.0", "_inBundle": false, - "_integrity": "sha512-K8aByl8OJD51V0VbUURTKsmdswkQQusIvlvmTyhHlIT1hBvaSxzdxpSle857XuXa7uc02UEZx9OR5aDxSWS5Qw==", + "_integrity": "sha512-OUTryc5bt/P8zVgNUmC6xdXiDJxLMAW8cF5tLQOT9E5sOQj+UeQxnnPy74K3CLCa/SOjjBlbuzDLR8ANwA+wmw==", "_location": "/node-gyp", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "node-gyp@5.0.7", + "raw": "node-gyp@5.1.0", "name": "node-gyp", "escapedName": "node-gyp", - "rawSpec": "5.0.7", + "rawSpec": "5.1.0", "saveSpec": null, - "fetchSpec": "5.0.7" + "fetchSpec": "5.1.0" }, "_requiredBy": [ "#USER", "/", "/npm-lifecycle" ], - "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.7.tgz", - "_shasum": "dd4225e735e840cf2870e4037c2ed9c28a31719e", - "_spec": "node-gyp@5.0.7", - "_where": "/Users/mperrotte/npminc/cli", + "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.1.0.tgz", + "_shasum": "8e31260a7af4a2e2f994b0673d4e0b3866156332", + "_spec": "node-gyp@5.1.0", + "_where": "/Users/darcyclarke/Documents/Repos/npm/cli", "author": { "name": "Nathan Rajlich", "email": "nathan@tootallnate.net", @@ -84,5 +84,5 @@ "lint": "standard */*.js test/**/*.js", "test": "npm run lint && tap --timeout=120 test/test-*" }, - "version": "5.0.7" + "version": "5.1.0" } diff --git a/node_modules/node-gyp/test/docker.sh b/node_modules/node-gyp/test/docker.sh deleted file mode 100755 index 67014209d0003..0000000000000 --- a/node_modules/node-gyp/test/docker.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash - -#set -e - -test_node_versions="6.17.0 8.15.1 10.15.3 11.12.0" - -myuid=$(id -u) -mygid=$(id -g) -__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -dot_node_gyp=${__dirname}/.node-gyp/ - -# borrows from https://github.com/rvagg/dnt/ - -# Simple setup function for a container: -# setup_container(image id, base image, commands to run to set up) -setup_container() { - local container_id="$1" - local base_container="$2" - local run_cmd="$3" - - # Does this image exist? If yes, ignore - docker inspect "$container_id" &> /dev/null - if [[ $? -eq 0 ]]; then - echo "Found existing container [$container_id]" - else - # No such image, so make it - echo "Did not find container [$container_id], creating..." - docker run -i $base_container /bin/bash -c "$run_cmd" - sleep 2 - docker commit $(docker ps -l -q) $container_id - fi -} - -# Run tests inside each of the versioned containers, copy cwd into npm's copy of node-gyp -# so it'll be invoked by npm when a compile is needed -# run_tests(version, test-commands) -run_tests() { - local version="$1" - local run_cmd="$2" - - run_cmd="rsync -aAXx --delete --exclude .git --exclude build /node-gyp-src/ /usr/lib/node_modules/npm/node_modules/node-gyp/; - /bin/su -s /bin/bash node-gyp -c 'cd && ${run_cmd}'" - - rm -rf $dot_node_gyp - mkdir $dot_node_gyp - - docker run \ - --rm -i \ - -v ~/.npm/:/node-gyp/.npm/ \ - -v ${dot_node_gyp}:/node-gyp/.node-gyp/ \ - -v $(pwd):/node-gyp-src/:ro \ - node-gyp-test/${version} /bin/bash -c "${run_cmd}" -} - -# A base image with build tools and a user account -setup_container "node-gyp-test/base" "ubuntu:14.04" " - adduser --gecos node-gyp --home /node-gyp/ --disabled-login node-gyp --uid $myuid && - echo "node-gyp:node-gyp" | chpasswd && - apt-get update && - apt-get install -y build-essential python git rsync curl -" - -# An image on top of the base containing clones of repos we want to use for testing -setup_container "node-gyp-test/clones" "node-gyp-test/base" " - cd /node-gyp/ && git clone https://github.com/justmoon/node-bignum.git && - cd /node-gyp/ && git clone https://github.com/bnoordhuis/node-buffertools.git && - chown -R node-gyp.node-gyp /node-gyp/ -" - -# An image for each of the node versions we want to test with that version installed and the latest npm -for v in $test_node_versions; do - setup_container "node-gyp-test/${v}" "node-gyp-test/clones" " - curl -sL https://nodejs.org/dist/v${v}/node-v${v}-linux-x64.tar.gz | tar -zxv --strip-components=1 -C /usr/ && - npm install npm@latest -g && - node -v && npm -v - " -done - -# Test use of --target=x.y.z to compile against alternate versions -test_download_node_version() { - local run_with_ver="$1" - local expected_dir="$2" - local expected_ver="$3" - run_tests $run_with_ver "cd node-buffertools && npm install --loglevel=info --target=${expected_ver}" - local node_ver=$(cat "${dot_node_gyp}${expected_dir}/node_version.h" | grep '#define NODE_\w*_VERSION [0-9]*$') - node_ver=$(echo $node_ver | sed 's/#define NODE_[A-Z]*_VERSION //g' | sed 's/ /./g') - if [ "X$(echo $node_ver)" != "X${expected_ver}" ]; then - echo "Did not download v${expected_ver} using --target, instead got: $(echo $node_ver)" - exit 1 - fi - echo "Verified correct download of [v${node_ver}]" -} - -test_download_node_version "0.12.7" "0.10.30/src" "0.10.30" -# should download the headers file -test_download_node_version "4.3.0" "4.3.0/include/node" "4.3.0" -test_download_node_version "5.6.0" "5.6.0/include/node" "5.6.0" - -# TODO: test --dist-url by starting up a localhost server and serving up tarballs - -# testing --dist-url, using simple-proxy.js to make localhost work as a distribution -# point for tarballs -# we can test whether it uses the proxy because after 2 connections the proxy will -# die and therefore should not be running at the end of the test, `nc` can tell us this -run_tests "0.12.7" " - (node /node-gyp-src/test/simple-proxy.js 8080 /boombar/ https://nodejs.org/dist/ &) && - cd node-buffertools && - NODEJS_ORG_MIRROR=http://localhost:8080/boombar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild && - nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" -" - -rm -rf $dot_node_gyp diff --git a/node_modules/node-gyp/test/test-download.js b/node_modules/node-gyp/test/test-download.js index 738a43f276b09..fe373e3280ce6 100644 --- a/node_modules/node-gyp/test/test-download.js +++ b/node_modules/node-gyp/test/test-download.js @@ -90,6 +90,101 @@ test('download over https with custom ca', function (t) { }) }) +test('download over http with proxy', function (t) { + t.plan(2) + + var server = http.createServer(function (req, res) { + t.strictEqual(req.headers['user-agent'], + 'node-gyp v42 (node ' + process.version + ')') + res.end('ok') + pserver.close(function () { + server.close() + }) + }) + + var pserver = http.createServer(function (req, res) { + t.strictEqual(req.headers['user-agent'], + 'node-gyp v42 (node ' + process.version + ')') + res.end('proxy ok') + server.close(function () { + pserver.close() + }) + }) + + var host = 'localhost' + server.listen(0, host, function () { + var port = this.address().port + pserver.listen(port + 1, host, function () { + var gyp = { + opts: { + proxy: 'http://' + host + ':' + (port + 1) + }, + version: '42' + } + var url = 'http://' + host + ':' + port + var req = install.test.download(gyp, {}, url) + req.on('response', function (res) { + var body = '' + res.setEncoding('utf8') + res.on('data', function (data) { + body += data + }) + res.on('end', function () { + t.strictEqual(body, 'proxy ok') + }) + }) + }) + }) +}) + +test('download over http with noproxy', function (t) { + t.plan(2) + + var server = http.createServer(function (req, res) { + t.strictEqual(req.headers['user-agent'], + 'node-gyp v42 (node ' + process.version + ')') + res.end('ok') + pserver.close(function () { + server.close() + }) + }) + + var pserver = http.createServer(function (req, res) { + t.strictEqual(req.headers['user-agent'], + 'node-gyp v42 (node ' + process.version + ')') + res.end('proxy ok') + server.close(function () { + pserver.close() + }) + }) + + var host = 'localhost' + server.listen(0, host, function () { + var port = this.address().port + pserver.listen(port + 1, host, function () { + var gyp = { + opts: { + proxy: 'http://' + host + ':' + (port + 1), + noproxy: 'localhost' + }, + version: '42' + } + var url = 'http://' + host + ':' + port + var req = install.test.download(gyp, {}, url) + req.on('response', function (res) { + var body = '' + res.setEncoding('utf8') + res.on('data', function (data) { + body += data + }) + res.on('end', function () { + t.strictEqual(body, 'ok') + }) + }) + }) + }) +}) + test('download with missing cafile', function (t) { t.plan(1) var gyp = { @@ -116,7 +211,7 @@ test('download headers (actual)', function (t) { process.release.name !== 'node' || semver.prerelease(process.version) !== null || semver.satisfies(process.version, '<10')) { - return t.skip('Skipping acutal download of headers due to test environment configuration') + return t.skip('Skipping actual download of headers due to test environment configuration') } t.plan(17) diff --git a/package-lock.json b/package-lock.json index 7cc82d4bb4822..761da8271a850 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3715,9 +3715,9 @@ } }, "node-gyp": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.0.7.tgz", - "integrity": "sha512-K8aByl8OJD51V0VbUURTKsmdswkQQusIvlvmTyhHlIT1hBvaSxzdxpSle857XuXa7uc02UEZx9OR5aDxSWS5Qw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-5.1.0.tgz", + "integrity": "sha512-OUTryc5bt/P8zVgNUmC6xdXiDJxLMAW8cF5tLQOT9E5sOQj+UeQxnnPy74K3CLCa/SOjjBlbuzDLR8ANwA+wmw==", "requires": { "env-paths": "^2.2.0", "glob": "^7.1.4", diff --git a/package.json b/package.json index 89f0f1830edef..3885f57facdd5 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "mississippi": "^3.0.0", "mkdirp": "~0.5.1", "move-concurrently": "^1.0.1", - "node-gyp": "^5.0.7", + "node-gyp": "^5.1.0", "nopt": "~4.0.1", "normalize-package-data": "^2.5.0", "npm-audit-report": "^1.3.2",