From 818d854a4dbefd0cc6db7498a667730f1e92b4a6 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 12 Feb 2016 18:00:31 +1100 Subject: [PATCH] Introduce NODEJS_ORG_MIRROR and IOJS_ORG_MIRROR Deprecate NVM_NODEJS_ORG_MIRROR and NVM_IOJS_ORG_MIRROR as they were only ever intended to be internal nvm environment variables. These will be removed in the next semver-major release. PR-URL: https://github.com/nodejs/node-gyp/pull/878 Reviewed-By: ralphtheninja Reviewed-By: Ben Noordhuis --- lib/process-release.js | 24 ++++++-- test/docker.sh | 31 ++++++++-- test/test-process-release.js | 116 +++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 9 deletions(-) diff --git a/lib/process-release.js b/lib/process-release.js index 207435b59c..89eaf9be36 100644 --- a/lib/process-release.js +++ b/lib/process-release.js @@ -1,6 +1,7 @@ var semver = require('semver') , url = require('url') , path = require('path') + , log = require('npmlog') // versions where -headers.tar.gz started shipping , headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42' @@ -52,10 +53,25 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { // check for the nvm.sh standard mirror env variables if (!overrideDistUrl) { - if (isIojs && process.env.NVM_IOJS_ORG_MIRROR) - overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR - else if (process.env.NVM_NODEJS_ORG_MIRROR) - overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR + if (isIojs) { + if (process.env.IOJS_ORG_MIRROR) { + overrideDistUrl = process.env.IOJS_ORG_MIRROR + } else if (process.env.NVM_IOJS_ORG_MIRROR) {// remove on next semver-major + overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR + log.warn('download', + 'NVM_IOJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' + + 'please use IOJS_ORG_MIRROR') + } + } else { + if (process.env.NODEJS_ORG_MIRROR) { + overrideDistUrl = process.env.NODEJS_ORG_MIRROR + } else if (process.env.NVM_NODEJS_ORG_MIRROR) {// remove on next semver-major + overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR + log.warn('download', + 'NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' + + 'please use NODEJS_ORG_MIRROR') + } + } } diff --git a/test/docker.sh b/test/docker.sh index b64b79a376..ac21aa8d75 100755 --- a/test/docker.sh +++ b/test/docker.sh @@ -2,9 +2,11 @@ #set -e -test_node_versions="0.8.28 0.10.40 0.12.7" +test_node_versions="0.8.28 0.10.40 0.12.7 4.3.0 5.6.0" test_iojs_versions="1.8.4 2.4.0 3.3.0" +myuid=$(id -u) +mygid=$(id -g) __dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" dot_node_gyp=${__dirname}/.node-gyp/ @@ -41,6 +43,7 @@ run_tests() { /bin/su -s /bin/bash node-gyp -c 'cd && ${run_cmd}'" rm -rf $dot_node_gyp + mkdir $dot_node_gyp docker run \ --rm -i \ @@ -52,10 +55,10 @@ run_tests() { # 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 && - adduser --gecos node-gyp --home /node-gyp/ --disabled-login node-gyp && - echo "node-gyp:node-gyp" | chpasswd + 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 @@ -111,7 +114,9 @@ test_download_node_version() { test_download_node_version "0.12.7" "0.10.30/src" "0.10.30" test_download_node_version "3.3.0" "iojs-1.8.4/src" "1.8.4" # should download the headers file -test_download_node_version "3.3.0" "iojs-3.2.0/include/node" "3.2.0" +test_download_node_version "3.3.0" "iojs-3.3.0/include/node" "3.3.0" +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 @@ -126,6 +131,7 @@ run_tests "3.3.0" " nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" " +# REMOVE after next semver-major run_tests "3.3.0" " (node /node-gyp-src/test/simple-proxy.js 8080 /doobar/ https://iojs.org/dist/ &) && cd node-buffertools && @@ -133,6 +139,7 @@ run_tests "3.3.0" " nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" " +# REMOVE after next semver-major run_tests "0.12.7" " (node /node-gyp-src/test/simple-proxy.js 8080 /boombar/ https://nodejs.org/dist/ &) && cd node-buffertools && @@ -140,4 +147,18 @@ run_tests "0.12.7" " nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" " +run_tests "3.3.0" " + (node /node-gyp-src/test/simple-proxy.js 8080 /doobar/ https://iojs.org/dist/ &) && + cd node-buffertools && + IOJS_ORG_MIRROR=http://localhost:8080/doobar/ /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\" +" + +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/test/test-process-release.js b/test/test-process-release.js index 32e3a035ed..48411ae0a7 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -519,3 +519,119 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa }) }) +test('test process release - NODEJS_ORG_MIRROR', function (t) { + t.plan(2) + + process.env.NODEJS_ORG_MIRROR = 'http://foo.bar' + + var release = processRelease([], { opts: {} }, 'v4.1.23', { + name: 'node', + headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' + }) + + t.equal(release.semver.version, '4.1.23') + delete release.semver + + t.deepEqual(release, { + version: '4.1.23', + name: 'node', + baseUrl: 'http://foo.bar/v4.1.23/', + tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz', + shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt', + versionDir: '4.1.23', + libUrl32: 'http://foo.bar/v4.1.23/win-x86/node.lib', + libUrl64: 'http://foo.bar/v4.1.23/win-x64/node.lib', + libPath32: 'win-x86/node.lib', + libPath64: 'win-x64/node.lib' + }) + + delete process.env.NODEJS_ORG_MIRROR +}) + +test('test process release - NVM_NODEJS_ORG_MIRROR', function (t) { + t.plan(2) + + process.env.NVM_NODEJS_ORG_MIRROR = 'http://foo.bar' + + var release = processRelease([], { opts: {} }, 'v4.1.23', { + name: 'node', + headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' + }) + + t.equal(release.semver.version, '4.1.23') + delete release.semver + + t.deepEqual(release, { + version: '4.1.23', + name: 'node', + baseUrl: 'http://foo.bar/v4.1.23/', + tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz', + shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt', + versionDir: '4.1.23', + libUrl32: 'http://foo.bar/v4.1.23/win-x86/node.lib', + libUrl64: 'http://foo.bar/v4.1.23/win-x64/node.lib', + libPath32: 'win-x86/node.lib', + libPath64: 'win-x64/node.lib' + }) + + delete process.env.NVM_NODEJS_ORG_MIRROR +}) + +test('test process release - IOJS_ORG_MIRROR', function (t) { + t.plan(2) + + process.env.IOJS_ORG_MIRROR = 'http://foo.bar' + + var release = processRelease([], { opts: {} }, 'v3.2.24', { + name: 'io.js', + headersUrl: 'https://iojs.org/download/release/v3.2.24/iojs-v3.2.24-headers.tar.gz' + }) + + t.equal(release.semver.version, '3.2.24') + delete release.semver + + t.deepEqual(release, { + version: '3.2.24', + name: 'iojs', + baseUrl: 'http://foo.bar/v3.2.24/', + tarballUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz', + shasumsUrl: 'http://foo.bar/v3.2.24/SHASUMS256.txt', + versionDir: 'iojs-3.2.24', + libUrl32: 'http://foo.bar/v3.2.24/win-x86/iojs.lib', + libUrl64: 'http://foo.bar/v3.2.24/win-x64/iojs.lib', + libPath32: 'win-x86/iojs.lib', + libPath64: 'win-x64/iojs.lib' + }) + + delete process.env.IOJS_ORG_MIRROR +}) + + +test('test process release - NVM_IOJS_ORG_MIRROR', function (t) { + t.plan(2) + + process.env.NVM_IOJS_ORG_MIRROR = 'http://foo.bar' + + var release = processRelease([], { opts: {} }, 'v3.2.24', { + name: 'io.js', + headersUrl: 'https://iojs.org/download/release/v3.2.24/iojs-v3.2.24-headers.tar.gz' + }) + + t.equal(release.semver.version, '3.2.24') + delete release.semver + + t.deepEqual(release, { + version: '3.2.24', + name: 'iojs', + baseUrl: 'http://foo.bar/v3.2.24/', + tarballUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz', + shasumsUrl: 'http://foo.bar/v3.2.24/SHASUMS256.txt', + versionDir: 'iojs-3.2.24', + libUrl32: 'http://foo.bar/v3.2.24/win-x86/iojs.lib', + libUrl64: 'http://foo.bar/v3.2.24/win-x64/iojs.lib', + libPath32: 'win-x86/iojs.lib', + libPath64: 'win-x64/iojs.lib' + }) + + delete process.env.NVM_IOJS_ORG_MIRROR +})