Skip to content

Commit

Permalink
Introduce NODEJS_ORG_MIRROR and IOJS_ORG_MIRROR
Browse files Browse the repository at this point in the history
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: #878
Reviewed-By: ralphtheninja
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
rvagg committed Feb 16, 2016
1 parent d1e4cc4 commit 818d854
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 9 deletions.
24 changes: 20 additions & 4 deletions lib/process-release.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')
}
}
}


Expand Down
31 changes: 26 additions & 5 deletions test/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -126,18 +131,34 @@ 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 &&
NVM_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\"
"

# 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 &&
NVM_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\"
"

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
116 changes: 116 additions & 0 deletions test/test-process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

0 comments on commit 818d854

Please sign in to comment.