prebuild-install
Advanced tools
Comparing version 1.1.0 to 2.0.0
48
bin.js
@@ -8,4 +8,6 @@ #!/usr/bin/env node | ||
var rc = require('./rc') | ||
var pkg = require(path.resolve('package.json')) | ||
var rc = require('./rc')(pkg) | ||
var download = require('./download') | ||
var util = require('./util') | ||
@@ -23,4 +25,2 @@ var prebuildClientVersion = require('./package.json').version | ||
log.level = 'verbose' | ||
} else if (process.env.npm_config_loglevel) { | ||
log.level = process.env.npm_config_loglevel | ||
} | ||
@@ -33,4 +33,2 @@ | ||
var pkg = require(path.resolve('package.json')) | ||
if (rc.help) { | ||
@@ -45,23 +43,23 @@ console.error(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf-8')) | ||
if (opts.download) { | ||
if (!(typeof pkg._from === 'string')) { | ||
log.info('install', 'installing inside prebuild-install directory, skipping download.') | ||
process.exit(1) | ||
} else if (pkg._from.length > 4 && pkg._from.substr(0, 4) === 'git+') { | ||
log.info('install', 'installing from git repository, skipping download.') | ||
process.exit(1) | ||
} | ||
var execPath = process.env.npm_execpath || process.env.NPM_CLI_JS | ||
if (opts.prebuild === false) { | ||
log.info('install', '--no-prebuild specified, not attempting download.') | ||
process.exit(1) | ||
if (util.isYarnPath(execPath) && /node_modules/.test(process.cwd())) { | ||
// From yarn repository | ||
} else if (!(typeof pkg._from === 'string')) { | ||
log.info('install', 'installing inside prebuild-install directory, skipping download.') | ||
process.exit(1) | ||
} else if (pkg._from.length > 4 && pkg._from.substr(0, 4) === 'git+') { | ||
log.info('install', 'installing from git repository, skipping download.') | ||
process.exit(1) | ||
} else if (opts.compile === true || opts.prebuild === false) { | ||
log.info('install', '--build-from-source specified, not attempting download.') | ||
process.exit(1) | ||
} | ||
download(opts, function (err) { | ||
if (err) { | ||
log.warn('install', err.message) | ||
return process.exit(1) | ||
} | ||
download(opts, function (err) { | ||
if (err) { | ||
log.warn('install', err.message) | ||
return process.exit(1) | ||
} | ||
log.info('install', 'Prebuild successfully installed!') | ||
}) | ||
} | ||
log.info('install', 'Prebuild successfully installed!') | ||
}) |
@@ -10,2 +10,4 @@ var path = require('path') | ||
var error = require('./error') | ||
var url = require('url') | ||
var tunnel = require('tunnel-agent') | ||
@@ -45,3 +47,21 @@ function downloadPrebuild (opts, cb) { | ||
log.http('request', 'GET ' + downloadUrl) | ||
var req = get(downloadUrl, function (err, res) { | ||
var reqOpts = { url: downloadUrl } | ||
var proxy = opts['https-proxy'] || opts.proxy | ||
if (proxy) { | ||
var parsedDownloadUrl = url.parse(downloadUrl) | ||
var parsedProxy = url.parse(proxy) | ||
var uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http') | ||
var proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http') | ||
var tunnelFnName = [uriProtocol, proxyProtocol].join('Over') | ||
reqOpts.agent = tunnel[tunnelFnName]({ | ||
proxy: { | ||
host: parsedProxy.hostname, | ||
port: +parsedProxy.port, | ||
proxyAuth: parsedProxy.auth | ||
} | ||
}) | ||
} | ||
var req = get(reqOpts, function (err, res) { | ||
if (err) return onerror(err) | ||
@@ -84,33 +104,22 @@ log.http(res.statusCode, downloadUrl) | ||
log.info('unpacking @', cachedPrebuild) | ||
var options = { | ||
readable: true, | ||
writable: true, | ||
hardlinkAsFilesFallback: true | ||
} | ||
var extract = tfs.extract(opts.path, options).on('entry', updateName) | ||
pump(fs.createReadStream(cachedPrebuild), zlib.createGunzip(), extract, | ||
function (err) { | ||
pump(fs.createReadStream(cachedPrebuild), zlib.createGunzip(), tfs.extract(opts.path, {readable: true, writable: true}).on('entry', updateName), function (err) { | ||
if (err) return cb(err) | ||
if (!binaryName) return cb(error.invalidArchive()) | ||
var resolved | ||
if (binaryName) { | ||
try { | ||
resolved = path.resolve(opts.path || '.', binaryName) | ||
} catch (err) { | ||
return cb(err) | ||
} | ||
log.info('unpack', 'resolved to ' + resolved) | ||
if (opts.abi === process.versions.modules) { | ||
try { | ||
resolved = path.resolve(opts.path || '.', binaryName) | ||
require(resolved) | ||
} catch (err) { | ||
return cb(err) | ||
} | ||
log.info('unpack', 'resolved to ' + resolved) | ||
if (opts.abi === process.versions.modules) { | ||
try { | ||
require(resolved) | ||
} catch (err) { | ||
return cb(err) | ||
} | ||
log.info('unpack', 'required ' + resolved + ' successfully') | ||
} | ||
log.info('unpack', 'required ' + resolved + ' successfully') | ||
} | ||
cb(null, resolved) | ||
@@ -117,0 +126,0 @@ }) |
@@ -5,2 +5,3 @@ exports.noPrebuilts = function (opts) { | ||
'(target=' + opts.target, | ||
'runtime=' + opts.runtime, | ||
'arch=' + opts.arch, | ||
@@ -7,0 +8,0 @@ 'platform=' + opts.platform + ')' |
prebuild-install [options] | ||
--download -d [url] (download prebuilds, no url means github) | ||
--no-prebuild (skip prebuild download) | ||
--target -t version (version to install for) | ||
--runtime -r runtime (Node runtime [node or electron] to build or install for, default is node) | ||
--path -p path (make a prebuild-install here) | ||
--build-from-source (skip prebuild download) | ||
--verbose (log verbosely) | ||
--libc (use provided libc rather than system default) | ||
--debug (set Debug or Release configuration) | ||
--version (print prebuild-install version and exit) |
{ | ||
"name": "prebuild-install", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform", | ||
@@ -25,8 +25,10 @@ "scripts": { | ||
"minimist": "^1.2.0", | ||
"node-abi": "^1.0.3", | ||
"noop-logger": "^0.1.1", | ||
"npmlog": "^2.0.3", | ||
"npmlog": "^4.0.1", | ||
"os-homedir": "^1.0.1", | ||
"pump": "^1.0.1", | ||
"rc": "^1.1.6", | ||
"simple-get": "^2.0.0", | ||
"simple-get": "^1.4.2", | ||
"tunnel-agent": "^0.4.3", | ||
"tar-fs": "^1.13.0", | ||
@@ -39,3 +41,3 @@ "xtend": "4.0.1" | ||
"rimraf": "^2.5.2", | ||
"standard": "^7.1.0", | ||
"standard": "^8.6.0", | ||
"tape": "^4.5.1" | ||
@@ -55,3 +57,4 @@ }, | ||
"Jesús Leganés Combarro <piranna@gmail.com> (https://github.com/piranna)", | ||
"Mathias Küsel <mathiask@hotmail.de> (https://github.com/mathiask88)" | ||
"Mathias Küsel <mathiask@hotmail.de> (https://github.com/mathiask88)", | ||
"Lukas Geiger <lukas.geiger94@gmail.com> (https://github.com/lgeiger)" | ||
], | ||
@@ -58,0 +61,0 @@ "license": "MIT", |
62
rc.js
var minimist = require('minimist') | ||
var getAbi = require('node-abi').getAbi | ||
if (process.env.npm_config_argv) { | ||
var npmargs = ['prebuild', 'debug'] | ||
var npmargs = ['prebuild', 'compile', 'build-from-source', 'debug'] | ||
try { | ||
@@ -18,3 +19,3 @@ var npmArgv = JSON.parse(process.env.npm_config_argv).cooked | ||
var npmconfigs = ['proxy', 'https-proxy', 'local-address'] | ||
var npmconfigs = ['proxy', 'https-proxy', 'local-address', 'target', 'runtime', 'platform'] | ||
for (var j = 0; j < npmconfigs.length; ++j) { | ||
@@ -28,29 +29,42 @@ var envname = 'npm_config_' + npmconfigs[j].replace('-', '_') | ||
var rc = module.exports = require('rc')('prebuild-install', { | ||
target: process.version, | ||
arch: process.arch, | ||
platform: process.platform, | ||
abi: process.versions.modules, | ||
debug: false, | ||
verbose: false, | ||
prebuild: true, | ||
path: '.', | ||
proxy: process.env['HTTP_PROXY'], | ||
'https-proxy': process.env['HTTPS_PROXY'] | ||
}, minimist(process.argv, { | ||
alias: { | ||
arch: 'a', | ||
path: 'p', | ||
help: 'h', | ||
version: 'v', | ||
download: 'd' | ||
module.exports = function (pkg) { | ||
var pkgConf = pkg.config || {} | ||
var rc = require('rc')('prebuild-install', { | ||
target: pkgConf.target || process.versions.node, | ||
runtime: pkgConf.runtime || 'node', | ||
arch: pkgConf.arch || process.arch, | ||
libc: process.env.LIBC, | ||
platform: process.platform, | ||
debug: false, | ||
verbose: false, | ||
prebuild: true, | ||
compile: false, | ||
path: '.', | ||
proxy: process.env['HTTP_PROXY'], | ||
'https-proxy': process.env['HTTPS_PROXY'] | ||
}, minimist(process.argv, { | ||
alias: { | ||
target: 't', | ||
runtime: 'r', | ||
help: 'h', | ||
arch: 'a', | ||
path: 'p', | ||
version: 'v', | ||
download: 'd', | ||
'build-from-source': 'compile', | ||
compile: 'c' | ||
} | ||
})) | ||
if (rc.path === true) { | ||
delete rc.path | ||
} | ||
})) | ||
if (rc.path === true) { | ||
delete rc.path | ||
rc.abi = getAbi(rc.target, rc.runtime) | ||
return rc | ||
} | ||
if (!module.parent) { | ||
console.log(JSON.stringify(module.exports, null, 2)) | ||
console.log(JSON.stringify(module.exports({}), null, 2)) | ||
} |
@@ -13,3 +13,3 @@ # prebuild-install [![Build Status](https://travis-ci.org/mafintosh/prebuild-install.svg?branch=master)](https://travis-ci.org/mafintosh/prebuild-install) | ||
"scripts": { | ||
"install": "prebuild-install -d || node-gyp rebuild" | ||
"install": "prebuild-install || node-gyp rebuild" | ||
} | ||
@@ -28,6 +28,9 @@ ... | ||
--download -d [url] (download prebuilds, no url means github) | ||
--no-prebuild (skip prebuild download) | ||
--target -t version (version to install for) | ||
--runtime -r runtime (Node runtime [node or electron] to build or install for, default is node) | ||
--path -p path (make a prebuild-install here) | ||
--build-from-source (skip prebuild download) | ||
--verbose (log verbosely) | ||
--libc (use provided libc rather than system default) | ||
--debug (set Debug or Release configuration) | ||
--verbose (log verbosely) | ||
--version (print prebuild-install version and exit) | ||
@@ -34,0 +37,0 @@ ``` |
@@ -19,4 +19,6 @@ var path = require('path') | ||
node_abi: process.versions.modules, | ||
runtime: opts.runtime || 'node', | ||
platform: opts.platform, | ||
arch: opts.arch, | ||
libc: opts.libc || process.env.LIBC || '', | ||
configuration: (opts.debug ? 'Debug' : 'Release'), | ||
@@ -32,3 +34,3 @@ module_name: opts.pkg.binary && opts.pkg.binary.module_name | ||
var packageName = '{name}-v{version}-node-v{abi}-{platform}-{arch}.tar.gz' | ||
var packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz' | ||
if (opts.pkg.binary) { | ||
@@ -70,2 +72,6 @@ return [ | ||
function isYarnPath (execPath) { | ||
return execPath ? /^yarn/.test(path.basename(execPath)) : false | ||
} | ||
exports.getDownloadUrl = getDownloadUrl | ||
@@ -78,1 +84,2 @@ exports.urlTemplate = urlTemplate | ||
exports.tempFile = tempFile | ||
exports.isYarnPath = isYarnPath |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
40
16
1
15903
13
13
322
+ Addednode-abi@^1.0.3
+ Addedtunnel-agent@^0.4.3
+ Addedansi-regex@2.1.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addednode-abi@1.3.3(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsimple-get@1.4.3(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedunzip-response@1.0.2(transitive)
+ Addedwide-align@1.1.5(transitive)
- Removedansi@0.3.1(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removedgauge@1.2.7(transitive)
- Removedlodash.pad@4.5.1(transitive)
- Removedlodash.padend@4.6.1(transitive)
- Removedlodash.padstart@4.6.1(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removednpmlog@2.0.4(transitive)
- Removedsimple-concat@1.0.1(transitive)
- Removedsimple-get@2.8.2(transitive)
Updatednpmlog@^4.0.1
Updatedsimple-get@^1.4.2