first commit
This commit is contained in:
10
build/node_modules/prebuild-install/.travis.yml
generated
vendored
Normal file
10
build/node_modules/prebuild-install/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '9'
|
||||
- '8'
|
||||
- '7'
|
||||
- '6'
|
||||
- '5'
|
||||
- '4'
|
||||
- '0.12'
|
||||
- '0.10'
|
||||
8
build/node_modules/prebuild-install/CONTRIBUTING.md
generated
vendored
Normal file
8
build/node_modules/prebuild-install/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Contributing to prebuild
|
||||
|
||||
* no commits direct to master
|
||||
* all commits as pull requests (one or several per PR)
|
||||
* each commit solves one identifiable problem
|
||||
* never merge one's own PRs, another contributor does this
|
||||
|
||||
|
||||
21
build/node_modules/prebuild-install/LICENSE
generated
vendored
Normal file
21
build/node_modules/prebuild-install/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Mathias Buus
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
58
build/node_modules/prebuild-install/README.md
generated
vendored
Normal file
58
build/node_modules/prebuild-install/README.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# prebuild-install
|
||||
|
||||
[](https://travis-ci.org/prebuild/prebuild-install)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
> A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform.
|
||||
|
||||
`prebuild-install` supports installing prebuilt binaries from GitHub by default.
|
||||
|
||||
## Usage
|
||||
|
||||
Change your package.json install script to:
|
||||
```
|
||||
...
|
||||
"scripts": {
|
||||
"install": "prebuild-install || node-gyp rebuild"
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
### Requirements
|
||||
|
||||
You need to provide prebuilds made by [prebuild](https://github.com/mafintosh/prebuild)
|
||||
|
||||
### Help
|
||||
```
|
||||
prebuild-install [options]
|
||||
|
||||
--download -d [url] (download prebuilds, no url means github)
|
||||
--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)
|
||||
```
|
||||
|
||||
When `prebuild-install` is run via an `npm` script, options
|
||||
`--build-from-source`, `--debug` and `--download`, may be passed through via
|
||||
arguments given to the `npm` command.
|
||||
|
||||
### Custom binaries
|
||||
The end user can override binary download location through environment variables in their .npmrc file.
|
||||
The variable needs to meet the mask `% your package name %_binary_host` or `% your package name %_binary_host_mirror`. For example:
|
||||
```
|
||||
leveldown_binary_host=http://overriden-host.com/overriden-path
|
||||
```
|
||||
Note that the package version subpath and file name will still be appended.
|
||||
So if you are installing `leveldown@1.2.3` the resulting url will be:
|
||||
```
|
||||
http://overriden-host.com/overriden-path/v1.2.3/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
64
build/node_modules/prebuild-install/bin.js
generated
vendored
Executable file
64
build/node_modules/prebuild-install/bin.js
generated
vendored
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var path = require('path')
|
||||
var log = require('npmlog')
|
||||
var fs = require('fs')
|
||||
var extend = require('xtend')
|
||||
|
||||
var pkg = require(path.resolve('package.json'))
|
||||
var rc = require('./rc')(pkg)
|
||||
var download = require('./download')
|
||||
var util = require('./util')
|
||||
|
||||
var prebuildClientVersion = require('./package.json').version
|
||||
if (rc.version) {
|
||||
console.log(prebuildClientVersion)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
if (rc.path) process.chdir(rc.path)
|
||||
|
||||
log.heading = 'prebuild-install'
|
||||
if (rc.verbose) {
|
||||
log.level = 'verbose'
|
||||
}
|
||||
|
||||
if (!fs.existsSync('package.json')) {
|
||||
log.error('setup', 'No package.json found. Aborting...')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (rc.help) {
|
||||
console.error(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf-8'))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
log.info('begin', 'Prebuild-install version', prebuildClientVersion)
|
||||
|
||||
var opts = extend(rc, {pkg: pkg, log: log})
|
||||
|
||||
var execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
|
||||
|
||||
if (util.isYarnPath(execPath) && /node_modules/.test(process.cwd())) {
|
||||
// From yarn repository
|
||||
} else if (opts.force) {
|
||||
log.warn('install', 'prebuilt binaries enforced with --force!')
|
||||
log.warn('install', 'prebuilt binaries may be out of date!')
|
||||
} else if (!(typeof pkg._from === 'string')) {
|
||||
log.info('install', 'installing standalone, 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)
|
||||
}
|
||||
log.info('install', 'Successfully installed prebuilt binary!')
|
||||
})
|
||||
170
build/node_modules/prebuild-install/download.js
generated
vendored
Normal file
170
build/node_modules/prebuild-install/download.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var get = require('simple-get')
|
||||
var pump = require('pump')
|
||||
var tfs = require('tar-fs')
|
||||
var extend = require('xtend')
|
||||
var noop = extend({
|
||||
http: function () {},
|
||||
silly: function () {}
|
||||
}, require('noop-logger'))
|
||||
var zlib = require('zlib')
|
||||
var util = require('./util')
|
||||
var error = require('./error')
|
||||
var url = require('url')
|
||||
var tunnel = require('tunnel-agent')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
||||
function downloadPrebuild (opts, cb) {
|
||||
var downloadUrl = util.getDownloadUrl(opts)
|
||||
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
|
||||
var localPrebuild = util.localPrebuild(downloadUrl)
|
||||
var tempFile = util.tempFile(cachedPrebuild)
|
||||
|
||||
var log = opts.log || noop
|
||||
|
||||
if (opts.nolocal) return download()
|
||||
|
||||
log.info('looking for local prebuild @', localPrebuild)
|
||||
fs.exists(localPrebuild, function (exists) {
|
||||
if (exists) {
|
||||
log.info('found local prebuild')
|
||||
cachedPrebuild = localPrebuild
|
||||
return unpack()
|
||||
}
|
||||
|
||||
download()
|
||||
})
|
||||
|
||||
function download () {
|
||||
ensureNpmCacheDir(function (err) {
|
||||
if (err) return onerror(err)
|
||||
|
||||
log.info('looking for cached prebuild @', cachedPrebuild)
|
||||
fs.exists(cachedPrebuild, function (exists) {
|
||||
if (exists) {
|
||||
log.info('found cached prebuild')
|
||||
return unpack()
|
||||
}
|
||||
|
||||
log.http('request', 'GET ' + downloadUrl)
|
||||
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
|
||||
}
|
||||
})
|
||||
log.http('request', 'Proxy setup detected (Host: ' +
|
||||
parsedProxy.hostname + ', Port: ' +
|
||||
parsedProxy.port + ', Authentication: ' +
|
||||
(parsedProxy.auth ? 'Yes' : 'No') + ')' +
|
||||
' Tunneling with ' + tunnelFnName)
|
||||
}
|
||||
|
||||
var req = get(reqOpts, function (err, res) {
|
||||
if (err) return onerror(err)
|
||||
log.http(res.statusCode, downloadUrl)
|
||||
if (res.statusCode !== 200) return onerror()
|
||||
mkdirp(util.prebuildCache(), function () {
|
||||
log.info('downloading to @', tempFile)
|
||||
pump(res, fs.createWriteStream(tempFile), function (err) {
|
||||
if (err) return onerror(err)
|
||||
fs.rename(tempFile, cachedPrebuild, function (err) {
|
||||
if (err) return cb(err)
|
||||
log.info('renaming to @', cachedPrebuild)
|
||||
unpack()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.setTimeout(30 * 1000, function () {
|
||||
req.abort()
|
||||
})
|
||||
})
|
||||
|
||||
function onerror (err) {
|
||||
fs.unlink(tempFile, function () {
|
||||
cb(err || error.noPrebuilts(opts))
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function unpack () {
|
||||
var binaryName
|
||||
|
||||
var updateName = opts.updateName || function (entry) {
|
||||
if (/\.node$/i.test(entry.name)) binaryName = entry.name
|
||||
}
|
||||
|
||||
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) {
|
||||
if (err) return cb(err)
|
||||
|
||||
var resolved
|
||||
if (binaryName) {
|
||||
try {
|
||||
resolved = path.resolve(opts.path || '.', binaryName)
|
||||
} catch (err) {
|
||||
return cb(err)
|
||||
}
|
||||
log.info('unpack', 'resolved to ' + resolved)
|
||||
|
||||
if (opts.platform === process.platform && opts.abi === process.versions.modules) {
|
||||
try {
|
||||
require(resolved)
|
||||
} catch (err) {
|
||||
return cb(err)
|
||||
}
|
||||
log.info('unpack', 'required ' + resolved + ' successfully')
|
||||
}
|
||||
}
|
||||
|
||||
cb(null, resolved)
|
||||
})
|
||||
}
|
||||
|
||||
function ensureNpmCacheDir (cb) {
|
||||
var cacheFolder = util.npmCache()
|
||||
if (fs.access) {
|
||||
fs.access(cacheFolder, fs.R_OK | fs.W_OK, function (err) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
return makeNpmCacheDir()
|
||||
}
|
||||
cb(err)
|
||||
})
|
||||
} else {
|
||||
fs.exists(cacheFolder, function (exists) {
|
||||
if (!exists) return makeNpmCacheDir()
|
||||
cb()
|
||||
})
|
||||
}
|
||||
|
||||
function makeNpmCacheDir () {
|
||||
log.info('npm cache directory missing, creating it...')
|
||||
mkdirp(cacheFolder, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = downloadPrebuild
|
||||
13
build/node_modules/prebuild-install/error.js
generated
vendored
Normal file
13
build/node_modules/prebuild-install/error.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
exports.noPrebuilts = function (opts) {
|
||||
return new Error([
|
||||
'No prebuilt binaries found',
|
||||
'(target=' + opts.target,
|
||||
'runtime=' + opts.runtime,
|
||||
'arch=' + opts.arch,
|
||||
'platform=' + opts.platform + ')'
|
||||
].join(' '))
|
||||
}
|
||||
|
||||
exports.invalidArchive = function () {
|
||||
return new Error('Missing .node file in archive')
|
||||
}
|
||||
12
build/node_modules/prebuild-install/help.txt
generated
vendored
Normal file
12
build/node_modules/prebuild-install/help.txt
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
prebuild-install [options]
|
||||
|
||||
--download -d [url] (download prebuilds, no url means github)
|
||||
--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)
|
||||
--force (always use prebuilt binaries when available)
|
||||
--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)
|
||||
1
build/node_modules/prebuild-install/index.js
generated
vendored
Normal file
1
build/node_modules/prebuild-install/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exports.download = require('./download')
|
||||
125
build/node_modules/prebuild-install/package.json
generated
vendored
Normal file
125
build/node_modules/prebuild-install/package.json
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"prebuild-install@2.4.1",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "prebuild-install@2.4.1",
|
||||
"_id": "prebuild-install@2.4.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-99TyEFYTTkBWANT+mwSptmLb9ZCLQ6qKIUE36fXSIOtShB0JNprL2hzBD8F1yIuT9btjFrFEwbRHXhqDi1HmRA==",
|
||||
"_location": "/prebuild-install",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "prebuild-install@2.4.1",
|
||||
"name": "prebuild-install",
|
||||
"escapedName": "prebuild-install",
|
||||
"rawSpec": "2.4.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.4.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/iltorb"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.4.1.tgz",
|
||||
"_spec": "2.4.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Mathias Buus",
|
||||
"url": "@mafintosh"
|
||||
},
|
||||
"bin": {
|
||||
"prebuild-install": "./bin.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/prebuild-install/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Julian Gruber",
|
||||
"email": "julian@juliangruber.com",
|
||||
"url": "https://github.com/juliangruber"
|
||||
},
|
||||
{
|
||||
"name": "Brett Lawson",
|
||||
"email": "brett19@gmail.com",
|
||||
"url": "https://github.com/brett19"
|
||||
},
|
||||
{
|
||||
"name": "Pieter Hintjens",
|
||||
"email": "ph@imatix.com",
|
||||
"url": "https://github.com/hintjens"
|
||||
},
|
||||
{
|
||||
"name": "Lars-Magnus Skog",
|
||||
"email": "ralphtheninja@riseup.net",
|
||||
"url": "https://github.com/ralphtheninja"
|
||||
},
|
||||
{
|
||||
"name": "Jesús Leganés Combarro",
|
||||
"email": "piranna@gmail.com",
|
||||
"url": "https://github.com/piranna"
|
||||
},
|
||||
{
|
||||
"name": "Mathias Küsel",
|
||||
"email": "mathiask@hotmail.de",
|
||||
"url": "https://github.com/mathiask88"
|
||||
},
|
||||
{
|
||||
"name": "Lukas Geiger",
|
||||
"email": "lukas.geiger94@gmail.com",
|
||||
"url": "https://github.com/lgeiger"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"expand-template": "^1.0.2",
|
||||
"github-from-package": "0.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-abi": "^2.1.1",
|
||||
"noop-logger": "^0.1.1",
|
||||
"npmlog": "^4.0.1",
|
||||
"os-homedir": "^1.0.1",
|
||||
"pump": "^1.0.1",
|
||||
"rc": "^1.1.6",
|
||||
"simple-get": "^1.4.2",
|
||||
"tar-fs": "^1.13.0",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"xtend": "4.0.1"
|
||||
},
|
||||
"description": "A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform",
|
||||
"devDependencies": {
|
||||
"a-native-module": "^1.0.0",
|
||||
"nsp": "^2.3.0",
|
||||
"rimraf": "^2.5.2",
|
||||
"standard": "^8.6.0",
|
||||
"tape": "^4.5.1"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/prebuild-install",
|
||||
"keywords": [
|
||||
"prebuilt",
|
||||
"binaries",
|
||||
"native",
|
||||
"addon",
|
||||
"module",
|
||||
"c",
|
||||
"c++",
|
||||
"bindings",
|
||||
"devops"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "prebuild-install",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mafintosh/prebuild-install.git"
|
||||
},
|
||||
"scripts": {
|
||||
"audit": "nsp check",
|
||||
"lint": "standard",
|
||||
"test": "tape test/*-test.js && npm run audit && npm run lint"
|
||||
},
|
||||
"version": "2.4.1"
|
||||
}
|
||||
69
build/node_modules/prebuild-install/rc.js
generated
vendored
Normal file
69
build/node_modules/prebuild-install/rc.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
var minimist = require('minimist')
|
||||
var getAbi = require('node-abi').getAbi
|
||||
|
||||
var env = process.env
|
||||
|
||||
// Get `prebuild-install` arguments that were passed to the `npm` command
|
||||
if (env.npm_config_argv) {
|
||||
var npmargs = ['prebuild', 'compile', 'build-from-source', 'debug']
|
||||
try {
|
||||
var npmArgv = JSON.parse(env.npm_config_argv).cooked
|
||||
for (var i = 0; i < npmargs.length; ++i) {
|
||||
if (npmArgv.indexOf('--' + npmargs[i]) !== -1) {
|
||||
process.argv.push('--' + npmargs[i])
|
||||
}
|
||||
if (npmArgv.indexOf('--no-' + npmargs[i]) !== -1) {
|
||||
process.argv.push('--no-' + npmargs[i])
|
||||
}
|
||||
}
|
||||
if ((i = npmArgv.indexOf('--download')) !== -1) {
|
||||
process.argv.push(npmArgv[i], npmArgv[i + 1])
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
// Get the configuration
|
||||
module.exports = function (pkg) {
|
||||
var pkgConf = pkg.config || {}
|
||||
var rc = require('rc')('prebuild-install', {
|
||||
target: pkgConf.target || env.npm_config_target || process.versions.node,
|
||||
runtime: pkgConf.runtime || env.npm_config_runtime || 'node',
|
||||
arch: pkgConf.arch || env.npm_config_arch || process.arch,
|
||||
libc: env.LIBC,
|
||||
platform: env.npm_config_platform || process.platform,
|
||||
debug: false,
|
||||
force: false,
|
||||
verbose: false,
|
||||
prebuild: true,
|
||||
compile: false,
|
||||
path: '.',
|
||||
proxy: env.npm_config_proxy || env['HTTP_PROXY'],
|
||||
'https-proxy': env.npm_config_https_proxy || env['HTTPS_PROXY'],
|
||||
'local-address': env.npm_config_local_address
|
||||
}, 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
|
||||
}
|
||||
|
||||
rc.abi = getAbi(rc.target, rc.runtime)
|
||||
|
||||
return rc
|
||||
}
|
||||
|
||||
// Print the configuration values when executed standalone for testing purposses
|
||||
if (!module.parent) {
|
||||
console.log(JSON.stringify(module.exports({}), null, 2))
|
||||
}
|
||||
94
build/node_modules/prebuild-install/util.js
generated
vendored
Normal file
94
build/node_modules/prebuild-install/util.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
var path = require('path')
|
||||
var github = require('github-from-package')
|
||||
var home = require('os-homedir')
|
||||
var expandTemplate = require('expand-template')()
|
||||
|
||||
function getDownloadUrl (opts) {
|
||||
var pkgName = opts.pkg.name.replace(/^@\w+\//, '')
|
||||
return expandTemplate(urlTemplate(opts), {
|
||||
name: pkgName,
|
||||
package_name: pkgName,
|
||||
version: opts.pkg.version,
|
||||
major: opts.pkg.version.split('.')[0],
|
||||
minor: opts.pkg.version.split('.')[1],
|
||||
patch: opts.pkg.version.split('.')[2],
|
||||
prerelease: opts.pkg.version.split('-')[1],
|
||||
build: opts.pkg.version.split('+')[1],
|
||||
abi: opts.abi || process.versions.modules,
|
||||
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'),
|
||||
module_name: opts.pkg.binary && opts.pkg.binary.module_name
|
||||
})
|
||||
}
|
||||
|
||||
function urlTemplate (opts) {
|
||||
if (typeof opts.download === 'string') {
|
||||
return opts.download
|
||||
}
|
||||
|
||||
var packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz'
|
||||
var hostMirrorUrl = getHostMirrorUrl(opts)
|
||||
|
||||
if (hostMirrorUrl) {
|
||||
return hostMirrorUrl + '/v{version}/' + packageName
|
||||
}
|
||||
|
||||
if (opts.pkg.binary) {
|
||||
return [
|
||||
opts.pkg.binary.host,
|
||||
opts.pkg.binary.remote_path,
|
||||
opts.pkg.binary.package_name || packageName
|
||||
].map(function (path) {
|
||||
return trimSlashes(path)
|
||||
}).filter(Boolean).join('/')
|
||||
}
|
||||
|
||||
return github(opts.pkg) + '/releases/download/v{version}/' + packageName
|
||||
}
|
||||
|
||||
function getHostMirrorUrl (opts) {
|
||||
var propName = 'npm_config_' + opts.pkg.name + '_binary_host'
|
||||
return process.env[propName] || process.env[propName + '_mirror']
|
||||
}
|
||||
|
||||
function trimSlashes (str) {
|
||||
if (str) return str.replace(/^\.\/|^\/|\/$/g, '')
|
||||
}
|
||||
|
||||
function cachedPrebuild (url) {
|
||||
return path.join(prebuildCache(), url.replace(/[^a-zA-Z0-9.]+/g, '-'))
|
||||
}
|
||||
|
||||
function npmCache () {
|
||||
var env = process.env
|
||||
return env.npm_config_cache || (env.APPDATA ? path.join(env.APPDATA, 'npm-cache') : path.join(home(), '.npm'))
|
||||
}
|
||||
|
||||
function prebuildCache () {
|
||||
return path.join(npmCache(), '_prebuilds')
|
||||
}
|
||||
|
||||
function tempFile (cached) {
|
||||
return cached + '.' + process.pid + '-' + Math.random().toString(16).slice(2) + '.tmp'
|
||||
}
|
||||
|
||||
function localPrebuild (url) {
|
||||
return path.join('prebuilds', path.basename(url))
|
||||
}
|
||||
|
||||
function isYarnPath (execPath) {
|
||||
return execPath ? /^yarn/.test(path.basename(execPath)) : false
|
||||
}
|
||||
|
||||
exports.getDownloadUrl = getDownloadUrl
|
||||
exports.urlTemplate = urlTemplate
|
||||
exports.cachedPrebuild = cachedPrebuild
|
||||
exports.localPrebuild = localPrebuild
|
||||
exports.prebuildCache = prebuildCache
|
||||
exports.npmCache = npmCache
|
||||
exports.tempFile = tempFile
|
||||
exports.isYarnPath = isYarnPath
|
||||
Reference in New Issue
Block a user