Socket
Socket
Sign inDemoInstall

prebuild-install

Package Overview
Dependencies
13
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc