First development of the deploy action (#6)
Some checks failed
Lint / pre-commit Linting (push) Has been cancelled
Some checks failed
Lint / pre-commit Linting (push) Has been cancelled
Deploy js code to an instance of screeps. Some debugging tools are implemented. Reviewed-on: #6 Co-authored-by: Philipp Horstenkamp <philipp@horstenkamp.de> Co-committed-by: Philipp Horstenkamp <philipp@horstenkamp.de>
This commit is contained in:
12
node_modules/prebuild-install/.travis.yml
generated
vendored
Normal file
12
node_modules/prebuild-install/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
language: node_js
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
node_js:
|
||||
- 10
|
||||
- 9
|
||||
- 8
|
||||
- 6
|
||||
- 4
|
8
node_modules/prebuild-install/CONTRIBUTING.md
generated
vendored
Normal file
8
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
node_modules/prebuild-install/LICENSE
generated
vendored
Normal file
21
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.
|
101
node_modules/prebuild-install/README.md
generated
vendored
Normal file
101
node_modules/prebuild-install/README.md
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
# prebuild-install
|
||||
|
||||
> A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform.
|
||||
|
||||
[](https://www.npmjs.com/package/prebuild-install)
|
||||

|
||||
[](https://travis-ci.org/prebuild/prebuild-install)
|
||||
[](https://ci.appveyor.com/project/mathiask88/prebuild-install)
|
||||
[](https://david-dm.org/prebuild/prebuild-install)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
`prebuild-install` supports installing prebuilt binaries from GitHub by default.
|
||||
|
||||
## Usage
|
||||
|
||||
Change your package.json install script to:
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"install": "prebuild-install || node-gyp rebuild"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Requirements
|
||||
|
||||
You need to provide prebuilds made by [`prebuild`](https://github.com/prebuild/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)
|
||||
--token -T gh-token (github token for private repos)
|
||||
--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.
|
||||
|
||||
### Private Repositories
|
||||
|
||||
`prebuild-install` supports downloading prebuilds from private GitHub repositories using the `-T <github-token>`:
|
||||
|
||||
```
|
||||
$ prebuild-install -T <github-token>
|
||||
```
|
||||
|
||||
If you don't want to use the token on cli you can put it in `~/.prebuild-installrc`:
|
||||
|
||||
```
|
||||
token=<github-token>
|
||||
```
|
||||
|
||||
Alternatively you can specify it in the `prebuild-install_token` environment variable.
|
||||
|
||||
Note that using a GitHub token uses the API to resolve the correct release meaning that you are subject to the ([GitHub Rate Limit](https://developer.github.com/v3/rate_limit/)).
|
||||
|
||||
### Create GitHub Token
|
||||
|
||||
To create a token:
|
||||
|
||||
* Go to [this page](https://github.com/settings/tokens)
|
||||
* Click the `Generate new token` button
|
||||
* Give the token a name and click the `Generate token` button, see below
|
||||
|
||||

|
||||
|
||||
The default scopes should be fine.
|
||||
|
||||
### 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
|
||||
```
|
||||
|
||||
### Cache
|
||||
|
||||
All prebuilt binaries are cached to minimize traffic. So first `prebuild-install` picks binaries from the cache and if no binary could be found, it will be downloaded. Depending on the environment, the cache folder is determined in the following order:
|
||||
|
||||
* `${npm_config_cache}/_prebuilds`
|
||||
* `${APP_DATA}/npm-cache/_prebuilds`
|
||||
* `${HOME}/.npm/_prebuilds`
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
40
node_modules/prebuild-install/appveyor.yml
generated
vendored
Normal file
40
node_modules/prebuild-install/appveyor.yml
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
# Don't actually build
|
||||
build: off
|
||||
|
||||
# Skip tag builds
|
||||
skip_tags: true
|
||||
|
||||
# Set build version format
|
||||
version: "{build}"
|
||||
|
||||
# Set up build environment
|
||||
environment:
|
||||
# Test against these versions of Node.js
|
||||
matrix:
|
||||
- nodejs_version: "10"
|
||||
- nodejs_version: "9"
|
||||
- nodejs_version: "8"
|
||||
- nodejs_version: "6"
|
||||
- nodejs_version: "4"
|
||||
|
||||
# Build on both platforms
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
# Install scripts (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest version of $env:nodejs_version
|
||||
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform
|
||||
# Output useful info for debugging
|
||||
- node --version
|
||||
- npm --version
|
||||
# Install modules
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts
|
||||
test_script:
|
||||
# Run module tests
|
||||
- npm test
|
48
node_modules/prebuild-install/asset.js
generated
vendored
Normal file
48
node_modules/prebuild-install/asset.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
var get = require('simple-get')
|
||||
var util = require('./util')
|
||||
var proxy = require('./proxy')
|
||||
var noop = Object.assign({
|
||||
http: function () {},
|
||||
silly: function () {}
|
||||
}, require('noop-logger'))
|
||||
|
||||
function findAssetId (opts, cb) {
|
||||
var downloadUrl = util.getDownloadUrl(opts)
|
||||
var apiUrl = util.getApiUrl(opts)
|
||||
var log = opts.log || noop
|
||||
|
||||
log.http('request', 'GET ' + apiUrl)
|
||||
var reqOpts = proxy({
|
||||
url: apiUrl,
|
||||
json: true,
|
||||
headers: {
|
||||
'User-Agent': 'simple-get',
|
||||
Authorization: 'token ' + opts.token
|
||||
}
|
||||
}, opts)
|
||||
|
||||
var req = get.concat(reqOpts, function (err, res, data) {
|
||||
if (err) return cb(err)
|
||||
log.http(res.statusCode, apiUrl)
|
||||
if (res.statusCode !== 200) return cb(err)
|
||||
|
||||
// Find asset id in release
|
||||
for (var release of data) {
|
||||
if (release.tag_name === 'v' + opts.pkg.version) {
|
||||
for (var asset of release.assets) {
|
||||
if (asset.browser_download_url === downloadUrl) {
|
||||
return cb(null, asset.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cb(new Error('Could not find GitHub release for version'))
|
||||
}
|
||||
})
|
||||
|
||||
req.setTimeout(30 * 1000, function () {
|
||||
req.abort()
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = findAssetId
|
76
node_modules/prebuild-install/bin.js
generated
vendored
Normal file
76
node_modules/prebuild-install/bin.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var whichPmRuns = require('which-pm-runs')
|
||||
|
||||
var pkg = require(path.resolve('package.json'))
|
||||
var rc = require('./rc')(pkg)
|
||||
var log = require('./log')(rc, process.env)
|
||||
var download = require('./download')
|
||||
var asset = require('./asset')
|
||||
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)
|
||||
|
||||
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 = Object.assign({}, rc, {pkg: pkg, log: log})
|
||||
|
||||
var pm = whichPmRuns()
|
||||
var isNpm = !pm || pm.name === 'npm'
|
||||
|
||||
if (!isNpm && /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)
|
||||
}
|
||||
|
||||
var startDownload = function (downloadUrl) {
|
||||
download(downloadUrl, opts, function (err) {
|
||||
if (err) {
|
||||
log.warn('install', err.message)
|
||||
return process.exit(1)
|
||||
}
|
||||
log.info('install', 'Successfully installed prebuilt binary!')
|
||||
})
|
||||
}
|
||||
|
||||
if (opts.token) {
|
||||
asset(opts, function (err, assetId) {
|
||||
if (err) {
|
||||
log.warn('install', err.message)
|
||||
return process.exit(1)
|
||||
}
|
||||
|
||||
startDownload(util.getAssetUrl(opts, assetId))
|
||||
})
|
||||
} else {
|
||||
startDownload(util.getDownloadUrl(opts))
|
||||
}
|
130
node_modules/prebuild-install/download.js
generated
vendored
Normal file
130
node_modules/prebuild-install/download.js
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var get = require('simple-get')
|
||||
var pump = require('pump')
|
||||
var tfs = require('tar-fs')
|
||||
var noop = Object.assign({
|
||||
http: function () {},
|
||||
silly: function () {}
|
||||
}, require('noop-logger'))
|
||||
var zlib = require('zlib')
|
||||
var util = require('./util')
|
||||
var error = require('./error')
|
||||
var proxy = require('./proxy')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
||||
function downloadPrebuild (downloadUrl, opts, cb) {
|
||||
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
|
||||
var tempFile = util.tempFile(cachedPrebuild)
|
||||
var log = opts.log || noop
|
||||
|
||||
ensureNpmCacheDir(function (err) {
|
||||
if (err) return onerror(err)
|
||||
|
||||
log.info('looking for cached prebuild @', cachedPrebuild)
|
||||
fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
|
||||
if (!(err && err.code === 'ENOENT')) {
|
||||
log.info('found cached prebuild')
|
||||
return unpack()
|
||||
}
|
||||
|
||||
log.http('request', 'GET ' + downloadUrl)
|
||||
var reqOpts = proxy({ url: downloadUrl }, opts)
|
||||
|
||||
if (opts.token) {
|
||||
reqOpts.url += '?access_token=' + opts.token
|
||||
reqOpts.headers = {
|
||||
'User-Agent': 'simple-get',
|
||||
'Accept': 'application/octet-stream'
|
||||
}
|
||||
}
|
||||
|
||||
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.runtime === 'node' && 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()
|
||||
fs.access(cacheFolder, fs.R_OK | fs.W_OK, function (err) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
return makeNpmCacheDir()
|
||||
}
|
||||
cb(err)
|
||||
})
|
||||
|
||||
function makeNpmCacheDir () {
|
||||
log.info('npm cache directory missing, creating it...')
|
||||
mkdirp(cacheFolder, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = downloadPrebuild
|
13
node_modules/prebuild-install/error.js
generated
vendored
Normal file
13
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')
|
||||
}
|
13
node_modules/prebuild-install/help.txt
generated
vendored
Normal file
13
node_modules/prebuild-install/help.txt
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
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)
|
||||
--token -T gh-token (github token for private repos)
|
||||
--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
node_modules/prebuild-install/index.js
generated
vendored
Normal file
1
node_modules/prebuild-install/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
exports.download = require('./download')
|
13
node_modules/prebuild-install/log.js
generated
vendored
Normal file
13
node_modules/prebuild-install/log.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
var log = require('npmlog')
|
||||
|
||||
module.exports = function (rc, env) {
|
||||
log.heading = 'prebuild-install'
|
||||
|
||||
if (rc.verbose) {
|
||||
log.level = 'verbose'
|
||||
} else {
|
||||
log.level = env.npm_config_loglevel || 'notice'
|
||||
}
|
||||
|
||||
return log
|
||||
}
|
70
node_modules/prebuild-install/package.json
generated
vendored
Normal file
70
node_modules/prebuild-install/package.json
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "prebuild-install",
|
||||
"version": "4.0.0",
|
||||
"description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
|
||||
"scripts": {
|
||||
"test": "verify-travis-appveyor && tape test/*-test.js && npm run audit && npm run lint",
|
||||
"audit": "nsp check",
|
||||
"lint": "standard"
|
||||
},
|
||||
"keywords": [
|
||||
"prebuilt",
|
||||
"binaries",
|
||||
"native",
|
||||
"addon",
|
||||
"module",
|
||||
"c",
|
||||
"c++",
|
||||
"bindings",
|
||||
"devops"
|
||||
],
|
||||
"dependencies": {
|
||||
"detect-libc": "^1.0.3",
|
||||
"expand-template": "^1.0.2",
|
||||
"github-from-package": "0.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-abi": "^2.2.0",
|
||||
"noop-logger": "^0.1.1",
|
||||
"npmlog": "^4.0.1",
|
||||
"os-homedir": "^1.0.1",
|
||||
"pump": "^2.0.1",
|
||||
"rc": "^1.1.6",
|
||||
"simple-get": "^2.7.0",
|
||||
"tar-fs": "^1.13.0",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"which-pm-runs": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"a-native-module": "^1.0.0",
|
||||
"nock": "^9.2.5",
|
||||
"nsp": "^2.3.0",
|
||||
"rimraf": "^2.5.2",
|
||||
"standard": "^10.0.3",
|
||||
"tape": "^4.5.1",
|
||||
"verify-travis-appveyor": "^2.0.1"
|
||||
},
|
||||
"bin": "./bin.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/prebuild/prebuild-install.git"
|
||||
},
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"contributors": [
|
||||
"Julian Gruber <julian@juliangruber.com> (https://github.com/juliangruber)",
|
||||
"Brett Lawson <brett19@gmail.com> (https://github.com/brett19)",
|
||||
"Pieter Hintjens <ph@imatix.com> (https://github.com/hintjens)",
|
||||
"Lars-Magnus Skog <ralphtheninja@riseup.net> (https://github.com/ralphtheninja)",
|
||||
"Jesús Leganés Combarro <piranna@gmail.com> (https://github.com/piranna)",
|
||||
"Mathias Küsel <mathiask@hotmail.de> (https://github.com/mathiask88)",
|
||||
"Lukas Geiger <lukas.geiger94@gmail.com> (https://github.com/lgeiger)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/prebuild/prebuild-install/issues"
|
||||
},
|
||||
"homepage": "https://github.com/prebuild/prebuild-install",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
}
|
36
node_modules/prebuild-install/proxy.js
generated
vendored
Normal file
36
node_modules/prebuild-install/proxy.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
var url = require('url')
|
||||
var tunnel = require('tunnel-agent')
|
||||
var noop = Object.assign({
|
||||
http: function () {},
|
||||
silly: function () {}
|
||||
}, require('noop-logger'))
|
||||
|
||||
function applyProxy (reqOpts, opts) {
|
||||
var log = opts.log || noop
|
||||
|
||||
var proxy = opts['https-proxy'] || opts.proxy
|
||||
|
||||
if (proxy) {
|
||||
var parsedDownloadUrl = url.parse(reqOpts.url)
|
||||
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)
|
||||
}
|
||||
|
||||
return reqOpts
|
||||
}
|
||||
|
||||
module.exports = applyProxy
|
73
node_modules/prebuild-install/rc.js
generated
vendored
Normal file
73
node_modules/prebuild-install/rc.js
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
var minimist = require('minimist')
|
||||
var getAbi = require('node-abi').getAbi
|
||||
var detectLibc = require('detect-libc')
|
||||
|
||||
var env = process.env
|
||||
|
||||
var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
|
||||
|
||||
// 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: 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',
|
||||
token: 'T'
|
||||
}
|
||||
}))
|
||||
|
||||
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))
|
||||
}
|
96
node_modules/prebuild-install/util.js
generated
vendored
Normal file
96
node_modules/prebuild-install/util.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
var path = require('path')
|
||||
var github = require('github-from-package')
|
||||
var home = require('os-homedir')
|
||||
var crypto = require('crypto')
|
||||
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 getApiUrl (opts) {
|
||||
return github(opts.pkg).replace('github.com', 'api.github.com/repos') + '/releases'
|
||||
}
|
||||
|
||||
function getAssetUrl (opts, assetId) {
|
||||
return getApiUrl(opts) + '/assets/' + assetId
|
||||
}
|
||||
|
||||
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) {
|
||||
var digest = crypto.createHash('md5').update(url).digest('hex').slice(0, 6)
|
||||
return path.join(prebuildCache(), digest + '-' + path.basename(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'
|
||||
}
|
||||
|
||||
exports.getDownloadUrl = getDownloadUrl
|
||||
exports.getApiUrl = getApiUrl
|
||||
exports.getAssetUrl = getAssetUrl
|
||||
exports.urlTemplate = urlTemplate
|
||||
exports.cachedPrebuild = cachedPrebuild
|
||||
exports.prebuildCache = prebuildCache
|
||||
exports.npmCache = npmCache
|
||||
exports.tempFile = tempFile
|
Reference in New Issue
Block a user