[ini]
This commit is contained in:
commit
94f388eb71
1611 changed files with 229192 additions and 0 deletions
27
.editorconfig
Normal file
27
.editorconfig
Normal file
|
@ -0,0 +1,27 @@
|
|||
# see https://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
trim_trailing_whitespace = true
|
||||
curly_bracket_next_line = false
|
||||
indent_brace_style = K&R
|
||||
spaces_around_operators = true
|
||||
spaces_around_brackets = false
|
||||
quote_type = double
|
||||
|
||||
[*.y{,a}ml{,lint}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/temp/
|
||||
/build/
|
||||
/.geany
|
1
lib/node/node_modules/.bin/color-support
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/color-support
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../color-support/bin.js
|
1
lib/node/node_modules/.bin/mkdirp
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/mkdirp
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../mkdirp/bin/cmd.js
|
1
lib/node/node_modules/.bin/node-gyp
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/node-gyp
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../node-gyp/bin/node-gyp.js
|
1
lib/node/node_modules/.bin/node-pre-gyp
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/node-pre-gyp
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../@mapbox/node-pre-gyp/bin/node-pre-gyp
|
1
lib/node/node_modules/.bin/node-which
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/node-which
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../which/bin/node-which
|
1
lib/node/node_modules/.bin/nopt
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/nopt
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nopt/bin/nopt.js
|
1
lib/node/node_modules/.bin/prebuild-install
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/prebuild-install
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../prebuild-install/bin.js
|
1
lib/node/node_modules/.bin/rc
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/rc
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../rc/cli.js
|
1
lib/node/node_modules/.bin/rimraf
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/rimraf
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../rimraf/bin.js
|
1
lib/node/node_modules/.bin/semver
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/semver
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../semver/bin/semver.js
|
1
lib/node/node_modules/.bin/yaml
generated
vendored
Symbolic link
1
lib/node/node_modules/.bin/yaml
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../yaml/bin.mjs
|
1483
lib/node/node_modules/.package-lock.json
generated
vendored
Normal file
1483
lib/node/node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
10
lib/node/node_modules/@gar/promisify/LICENSE.md
generated
vendored
Normal file
10
lib/node/node_modules/@gar/promisify/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2020-2022 Michael Garvin
|
||||
|
||||
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.
|
||||
|
65
lib/node/node_modules/@gar/promisify/README.md
generated
vendored
Normal file
65
lib/node/node_modules/@gar/promisify/README.md
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
# @gar/promisify
|
||||
|
||||
### Promisify an entire object or class instance
|
||||
|
||||
This module leverages es6 Proxy and Reflect to promisify every function in an
|
||||
object or class instance.
|
||||
|
||||
It assumes the callback that the function is expecting is the last
|
||||
parameter, and that it is an error-first callback with only one value,
|
||||
i.e. `(err, value) => ...`. This mirrors node's `util.promisify` method.
|
||||
|
||||
In order that you can use it as a one-stop-shop for all your promisify
|
||||
needs, you can also pass it a function. That function will be
|
||||
promisified as normal using node's built-in `util.promisify` method.
|
||||
|
||||
[node's custom promisified
|
||||
functions](https://nodejs.org/api/util.html#util_custom_promisified_functions)
|
||||
will also be mirrored, further allowing this to be a drop-in replacement
|
||||
for the built-in `util.promisify`.
|
||||
|
||||
### Examples
|
||||
|
||||
Promisify an entire object
|
||||
|
||||
```javascript
|
||||
|
||||
const promisify = require('@gar/promisify')
|
||||
|
||||
class Foo {
|
||||
constructor (attr) {
|
||||
this.attr = attr
|
||||
}
|
||||
|
||||
double (input, cb) {
|
||||
cb(null, input * 2)
|
||||
}
|
||||
|
||||
const foo = new Foo('baz')
|
||||
const promisified = promisify(foo)
|
||||
|
||||
console.log(promisified.attr)
|
||||
console.log(await promisified.double(1024))
|
||||
```
|
||||
|
||||
Promisify a function
|
||||
|
||||
```javascript
|
||||
|
||||
const promisify = require('@gar/promisify')
|
||||
|
||||
function foo (a, cb) {
|
||||
if (a !== 'bad') {
|
||||
return cb(null, 'ok')
|
||||
}
|
||||
return cb('not ok')
|
||||
}
|
||||
|
||||
const promisified = promisify(foo)
|
||||
|
||||
// This will resolve to 'ok'
|
||||
promisified('good')
|
||||
|
||||
// this will reject
|
||||
promisified('bad')
|
||||
```
|
36
lib/node/node_modules/@gar/promisify/index.js
generated
vendored
Normal file
36
lib/node/node_modules/@gar/promisify/index.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict'
|
||||
|
||||
const { promisify } = require('util')
|
||||
|
||||
const handler = {
|
||||
get: function (target, prop, receiver) {
|
||||
if (typeof target[prop] !== 'function') {
|
||||
return target[prop]
|
||||
}
|
||||
if (target[prop][promisify.custom]) {
|
||||
return function () {
|
||||
return Reflect.get(target, prop, receiver)[promisify.custom].apply(target, arguments)
|
||||
}
|
||||
}
|
||||
return function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
Reflect.get(target, prop, receiver).apply(target, [...arguments, function (err, result) {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
resolve(result)
|
||||
}])
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (thingToPromisify) {
|
||||
if (typeof thingToPromisify === 'function') {
|
||||
return promisify(thingToPromisify)
|
||||
}
|
||||
if (typeof thingToPromisify === 'object') {
|
||||
return new Proxy(thingToPromisify, handler)
|
||||
}
|
||||
throw new TypeError('Can only promisify functions or objects')
|
||||
}
|
32
lib/node/node_modules/@gar/promisify/package.json
generated
vendored
Normal file
32
lib/node/node_modules/@gar/promisify/package.json
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "@gar/promisify",
|
||||
"version": "1.1.3",
|
||||
"description": "Promisify an entire class or object",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/wraithgar/gar-promisify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"lint:fix": "standard --fix",
|
||||
"test": "lab -a @hapi/code -t 100",
|
||||
"posttest": "npm run lint"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"promisify",
|
||||
"all",
|
||||
"class",
|
||||
"object"
|
||||
],
|
||||
"author": "Gar <gar+npm@danger.computer>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@hapi/code": "^8.0.1",
|
||||
"@hapi/lab": "^24.1.0",
|
||||
"standard": "^16.0.3"
|
||||
}
|
||||
}
|
74
lib/node/node_modules/@mapbox/node-pre-gyp/.github/workflows/codeql.yml
generated
vendored
Normal file
74
lib/node/node_modules/@mapbox/node-pre-gyp/.github/workflows/codeql.yml
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ "master" ]
|
||||
schedule:
|
||||
- cron: '24 5 * * 4'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'javascript' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
# - run: |
|
||||
# echo "Run, Build Application using script"
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
510
lib/node/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md
generated
vendored
Normal file
510
lib/node/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,510 @@
|
|||
# node-pre-gyp changelog
|
||||
|
||||
## 1.0.11
|
||||
- Fixes dependabot alert [CVE-2021-44906](https://nvd.nist.gov/vuln/detail/CVE-2021-44906)
|
||||
|
||||
## 1.0.10
|
||||
- Upgraded minimist to 1.2.6 to address dependabot alert [CVE-2021-44906](https://nvd.nist.gov/vuln/detail/CVE-2021-44906)
|
||||
|
||||
## 1.0.9
|
||||
- Upgraded node-fetch to 2.6.7 to address [CVE-2022-0235](https://www.cve.org/CVERecord?id=CVE-2022-0235)
|
||||
- Upgraded detect-libc to 2.0.0 to use non-blocking NodeJS(>=12) Report API
|
||||
|
||||
## 1.0.8
|
||||
- Downgraded npmlog to maintain node v10 and v8 support (https://github.com/mapbox/node-pre-gyp/pull/624)
|
||||
|
||||
## 1.0.7
|
||||
- Upgraded nyc and npmlog to address https://github.com/advisories/GHSA-93q8-gq69-wqmw
|
||||
|
||||
## 1.0.6
|
||||
- Added node v17 to the internal node releases listing
|
||||
- Upgraded various dependencies declared in package.json to latest major versions (node-fetch from 2.6.1 to 2.6.5, npmlog from 4.1.2 to 5.01, semver from 7.3.4 to 7.3.5, and tar from 6.1.0 to 6.1.11)
|
||||
- Fixed bug in `staging_host` parameter (https://github.com/mapbox/node-pre-gyp/pull/590)
|
||||
|
||||
|
||||
## 1.0.5
|
||||
- Fix circular reference warning with node >= v14
|
||||
|
||||
## 1.0.4
|
||||
- Added node v16 to the internal node releases listing
|
||||
|
||||
## 1.0.3
|
||||
- Improved support configuring s3 uploads (solves https://github.com/mapbox/node-pre-gyp/issues/571)
|
||||
- New options added in https://github.com/mapbox/node-pre-gyp/pull/576: 'bucket', 'region', and `s3ForcePathStyle`
|
||||
|
||||
## 1.0.2
|
||||
- Fixed regression in proxy support (https://github.com/mapbox/node-pre-gyp/issues/572)
|
||||
|
||||
## 1.0.1
|
||||
- Switched from mkdirp@1.0.4 to make-dir@3.1.0 to avoid this bug: https://github.com/isaacs/node-mkdirp/issues/31
|
||||
|
||||
## 1.0.0
|
||||
- Module is now name-spaced at `@mapbox/node-pre-gyp` and the original `node-pre-gyp` is deprecated.
|
||||
- New: support for staging and production s3 targets (see README.md)
|
||||
- BREAKING: no longer supporting `node_pre_gyp_accessKeyId` & `node_pre_gyp_secretAccessKey`, use `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` instead to authenticate against s3 for `info`, `publish`, and `unpublish` commands.
|
||||
- Dropped node v6 support, added node v14 support
|
||||
- Switched tests to use mapbox-owned bucket for testing
|
||||
- Added coverage tracking and linting with eslint
|
||||
- Added back support for symlinks inside the tarball
|
||||
- Upgraded all test apps to N-API/node-addon-api
|
||||
- New: support for staging and production s3 targets (see README.md)
|
||||
- Added `node_pre_gyp_s3_host` env var which has priority over the `--s3_host` option or default.
|
||||
- Replaced needle with node-fetch
|
||||
- Added proxy support for node-fetch
|
||||
- Upgraded to mkdirp@1.x
|
||||
|
||||
## 0.17.0
|
||||
- Got travis + appveyor green again
|
||||
- Added support for more node versions
|
||||
|
||||
## 0.16.0
|
||||
|
||||
- Added Node 15 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/520)
|
||||
|
||||
## 0.15.0
|
||||
|
||||
- Bump dependency on `mkdirp` from `^0.5.1` to `^0.5.3` (https://github.com/mapbox/node-pre-gyp/pull/492)
|
||||
- Bump dependency on `needle` from `^2.2.1` to `^2.5.0` (https://github.com/mapbox/node-pre-gyp/pull/502)
|
||||
- Added Node 14 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/501)
|
||||
|
||||
## 0.14.0
|
||||
|
||||
- Defer modules requires in napi.js (https://github.com/mapbox/node-pre-gyp/pull/434)
|
||||
- Bump dependency on `tar` from `^4` to `^4.4.2` (https://github.com/mapbox/node-pre-gyp/pull/454)
|
||||
- Support extracting compiled binary from local offline mirror (https://github.com/mapbox/node-pre-gyp/pull/459)
|
||||
- Added Node 13 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/483)
|
||||
|
||||
## 0.13.0
|
||||
|
||||
- Added Node 12 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/449)
|
||||
|
||||
## 0.12.0
|
||||
|
||||
- Fixed double-build problem with node v10 (https://github.com/mapbox/node-pre-gyp/pull/428)
|
||||
- Added node 11 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/422)
|
||||
|
||||
## 0.11.0
|
||||
|
||||
- Fixed double-install problem with node v10
|
||||
- Significant N-API improvements (https://github.com/mapbox/node-pre-gyp/pull/405)
|
||||
|
||||
## 0.10.3
|
||||
|
||||
- Now will use `request` over `needle` if request is installed. By default `needle` is used for `https`. This should unbreak proxy support that regressed in v0.9.0
|
||||
|
||||
## 0.10.2
|
||||
|
||||
- Fixed rc/deep-extent security vulnerability
|
||||
- Fixed broken reinstall script do to incorrectly named get_best_napi_version
|
||||
|
||||
## 0.10.1
|
||||
|
||||
- Fix needle error event (@medns)
|
||||
|
||||
## 0.10.0
|
||||
|
||||
- Allow for a single-level module path when packing @allenluce (https://github.com/mapbox/node-pre-gyp/pull/371)
|
||||
- Log warnings instead of errors when falling back @xzyfer (https://github.com/mapbox/node-pre-gyp/pull/366)
|
||||
- Add Node.js v10 support to tests (https://github.com/mapbox/node-pre-gyp/pull/372)
|
||||
- Remove retire.js from CI (https://github.com/mapbox/node-pre-gyp/pull/372)
|
||||
- Remove support for Node.js v4 due to [EOL on April 30th, 2018](https://github.com/nodejs/Release/blob/7dd52354049cae99eed0e9fe01345b0722a86fde/schedule.json#L14)
|
||||
- Update appveyor tests to install default NPM version instead of NPM v2.x for all Windows builds (https://github.com/mapbox/node-pre-gyp/pull/375)
|
||||
|
||||
## 0.9.1
|
||||
|
||||
- Fixed regression (in v0.9.0) with support for http redirects @allenluce (https://github.com/mapbox/node-pre-gyp/pull/361)
|
||||
|
||||
## 0.9.0
|
||||
|
||||
- Switched from using `request` to `needle` to reduce size of module deps (https://github.com/mapbox/node-pre-gyp/pull/350)
|
||||
|
||||
## 0.8.0
|
||||
|
||||
- N-API support (@inspiredware)
|
||||
|
||||
## 0.7.1
|
||||
|
||||
- Upgraded to tar v4.x
|
||||
|
||||
## 0.7.0
|
||||
|
||||
- Updated request and hawk (#347)
|
||||
- Dropped node v0.10.x support
|
||||
|
||||
## 0.6.40
|
||||
|
||||
- Improved error reporting if an install fails
|
||||
|
||||
## 0.6.39
|
||||
|
||||
- Support for node v9
|
||||
- Support for versioning on `{libc}` to allow binaries to work on non-glic linux systems like alpine linux
|
||||
|
||||
|
||||
## 0.6.38
|
||||
|
||||
- Maintaining compatibility (for v0.6.x series) with node v0.10.x
|
||||
|
||||
## 0.6.37
|
||||
|
||||
- Solved one part of #276: now now deduce the node ABI from the major version for node >= 2 even when not stored in the abi_crosswalk.json
|
||||
- Fixed docs to avoid mentioning the deprecated and dangerous `prepublish` in package.json (#291)
|
||||
- Add new node versions to crosswalk
|
||||
- Ported tests to use tape instead of mocha
|
||||
- Got appveyor tests passing by downgrading npm and node-gyp
|
||||
|
||||
## 0.6.36
|
||||
|
||||
- Removed the running of `testbinary` during install. Because this was regressed for so long, it is too dangerous to re-enable by default. Developers needing validation can call `node-pre-gyp testbinary` directory.
|
||||
- Fixed regression in v0.6.35 for electron installs (now skipping binary validation which is not yet supported for electron)
|
||||
|
||||
## 0.6.35
|
||||
|
||||
- No longer recommending `npm ls` in `prepublish` (#291)
|
||||
- Fixed testbinary command (#283) @szdavid92
|
||||
|
||||
## 0.6.34
|
||||
|
||||
- Added new node versions to crosswalk, including v8
|
||||
- Upgraded deps to latest versions, started using `^` instead of `~` for all deps.
|
||||
|
||||
## 0.6.33
|
||||
|
||||
- Improved support for yarn
|
||||
|
||||
## 0.6.32
|
||||
|
||||
- Honor npm configuration for CA bundles (@heikkipora)
|
||||
- Add node-pre-gyp and npm versions to user agent (@addaleax)
|
||||
- Updated various deps
|
||||
- Add known node version for v7.x
|
||||
|
||||
## 0.6.31
|
||||
|
||||
- Updated various deps
|
||||
|
||||
## 0.6.30
|
||||
|
||||
- Update to npmlog@4.x and semver@5.3.x
|
||||
- Add known node version for v6.5.0
|
||||
|
||||
## 0.6.29
|
||||
|
||||
- Add known node versions for v0.10.45, v0.12.14, v4.4.4, v5.11.1, and v6.1.0
|
||||
|
||||
## 0.6.28
|
||||
|
||||
- Now more verbose when remote binaries are not available. This is needed since npm is increasingly more quiet by default
|
||||
and users need to know why builds are falling back to source compiles that might then error out.
|
||||
|
||||
## 0.6.27
|
||||
|
||||
- Add known node version for node v6
|
||||
- Stopped bundling dependencies
|
||||
- Documented method for module authors to avoid bundling node-pre-gyp
|
||||
- See https://github.com/mapbox/node-pre-gyp/tree/master#configuring for details
|
||||
|
||||
## 0.6.26
|
||||
|
||||
- Skip validation for nw runtime (https://github.com/mapbox/node-pre-gyp/pull/181) via @fleg
|
||||
|
||||
## 0.6.25
|
||||
|
||||
- Improved support for auto-detection of electron runtime in `node-pre-gyp.find()`
|
||||
- Pull request from @enlight - https://github.com/mapbox/node-pre-gyp/pull/187
|
||||
- Add known node version for 4.4.1 and 5.9.1
|
||||
|
||||
## 0.6.24
|
||||
|
||||
- Add known node version for 5.8.0, 5.9.0, and 4.4.0.
|
||||
|
||||
## 0.6.23
|
||||
|
||||
- Add known node version for 0.10.43, 0.12.11, 4.3.2, and 5.7.1.
|
||||
|
||||
## 0.6.22
|
||||
|
||||
- Add known node version for 4.3.1, and 5.7.0.
|
||||
|
||||
## 0.6.21
|
||||
|
||||
- Add known node version for 0.10.42, 0.12.10, 4.3.0, and 5.6.0.
|
||||
|
||||
## 0.6.20
|
||||
|
||||
- Add known node version for 4.2.5, 4.2.6, 5.4.0, 5.4.1,and 5.5.0.
|
||||
|
||||
## 0.6.19
|
||||
|
||||
- Add known node version for 4.2.4
|
||||
|
||||
## 0.6.18
|
||||
|
||||
- Add new known node versions for 0.10.x, 0.12.x, 4.x, and 5.x
|
||||
|
||||
## 0.6.17
|
||||
|
||||
- Re-tagged to fix packaging problem of `Error: Cannot find module 'isarray'`
|
||||
|
||||
## 0.6.16
|
||||
|
||||
- Added known version in crosswalk for 5.1.0.
|
||||
|
||||
## 0.6.15
|
||||
|
||||
- Upgraded tar-pack (https://github.com/mapbox/node-pre-gyp/issues/182)
|
||||
- Support custom binary hosting mirror (https://github.com/mapbox/node-pre-gyp/pull/170)
|
||||
- Added known version in crosswalk for 4.2.2.
|
||||
|
||||
## 0.6.14
|
||||
|
||||
- Added node 5.x version
|
||||
|
||||
## 0.6.13
|
||||
|
||||
- Added more known node 4.x versions
|
||||
|
||||
## 0.6.12
|
||||
|
||||
- Added support for [Electron](http://electron.atom.io/). Just pass the `--runtime=electron` flag when building/installing. Thanks @zcbenz
|
||||
|
||||
## 0.6.11
|
||||
|
||||
- Added known node and io.js versions including more 3.x and 4.x versions
|
||||
|
||||
## 0.6.10
|
||||
|
||||
- Added known node and io.js versions including 3.x and 4.x versions
|
||||
- Upgraded `tar` dep
|
||||
|
||||
## 0.6.9
|
||||
|
||||
- Upgraded `rc` dep
|
||||
- Updated known io.js version: v2.4.0
|
||||
|
||||
## 0.6.8
|
||||
|
||||
- Upgraded `semver` and `rimraf` deps
|
||||
- Updated known node and io.js versions
|
||||
|
||||
## 0.6.7
|
||||
|
||||
- Fixed `node_abi` versions for io.js 1.1.x -> 1.8.x (should be 43, but was stored as 42) (refs https://github.com/iojs/build/issues/94)
|
||||
|
||||
## 0.6.6
|
||||
|
||||
- Updated with known io.js 2.0.0 version
|
||||
|
||||
## 0.6.5
|
||||
|
||||
- Now respecting `npm_config_node_gyp` (https://github.com/npm/npm/pull/4887)
|
||||
- Updated to semver@4.3.2
|
||||
- Updated known node v0.12.x versions and io.js 1.x versions.
|
||||
|
||||
## 0.6.4
|
||||
|
||||
- Improved support for `io.js` (@fengmk2)
|
||||
- Test coverage improvements (@mikemorris)
|
||||
- Fixed support for `--dist-url` that regressed in 0.6.3
|
||||
|
||||
## 0.6.3
|
||||
|
||||
- Added support for passing raw options to node-gyp using `--` separator. Flags passed after
|
||||
the `--` to `node-pre-gyp configure` will be passed directly to gyp while flags passed
|
||||
after the `--` will be passed directly to make/visual studio.
|
||||
- Added `node-pre-gyp configure` command to be able to call `node-gyp configure` directly
|
||||
- Fix issue with require validation not working on windows 7 (@edgarsilva)
|
||||
|
||||
## 0.6.2
|
||||
|
||||
- Support for io.js >= v1.0.2
|
||||
- Deferred require of `request` and `tar` to help speed up command line usage of `node-pre-gyp`.
|
||||
|
||||
## 0.6.1
|
||||
|
||||
- Fixed bundled `tar` version
|
||||
|
||||
## 0.6.0
|
||||
|
||||
- BREAKING: node odd releases like v0.11.x now use `major.minor.patch` for `{node_abi}` instead of `NODE_MODULE_VERSION` (#124)
|
||||
- Added support for `toolset` option in versioning. By default is an empty string but `--toolset` can be passed to publish or install to select alternative binaries that target a custom toolset like C++11. For example to target Visual Studio 2014 modules like node-sqlite3 use `--toolset=v140`.
|
||||
- Added support for `--no-rollback` option to request that a failed binary test does not remove the binary module leaves it in place.
|
||||
- Added support for `--update-binary` option to request an existing binary be re-installed and the check for a valid local module be skipped.
|
||||
- Added support for passing build options from `npm` through `node-pre-gyp` to `node-gyp`: `--nodedir`, `--disturl`, `--python`, and `--msvs_version`
|
||||
|
||||
## 0.5.31
|
||||
|
||||
- Added support for deducing node_abi for node.js runtime from previous release if the series is even
|
||||
- Added support for --target=0.10.33
|
||||
|
||||
## 0.5.30
|
||||
|
||||
- Repackaged with latest bundled deps
|
||||
|
||||
## 0.5.29
|
||||
|
||||
- Added support for semver `build`.
|
||||
- Fixed support for downloading from urls that include `+`.
|
||||
|
||||
## 0.5.28
|
||||
|
||||
- Now reporting unix style paths only in reveal command
|
||||
|
||||
## 0.5.27
|
||||
|
||||
- Fixed support for auto-detecting s3 bucket name when it contains `.` - @taavo
|
||||
- Fixed support for installing when path contains a `'` - @halfdan
|
||||
- Ported tests to mocha
|
||||
|
||||
## 0.5.26
|
||||
|
||||
- Fix node-webkit support when `--target` option is not provided
|
||||
|
||||
## 0.5.25
|
||||
|
||||
- Fix bundling of deps
|
||||
|
||||
## 0.5.24
|
||||
|
||||
- Updated ABI crosswalk to incldue node v0.10.30 and v0.10.31
|
||||
|
||||
## 0.5.23
|
||||
|
||||
- Added `reveal` command. Pass no options to get all versioning data as json. Pass a second arg to grab a single versioned property value
|
||||
- Added support for `--silent` (shortcut for `--loglevel=silent`)
|
||||
|
||||
## 0.5.22
|
||||
|
||||
- Fixed node-webkit versioning name (NOTE: node-webkit support still experimental)
|
||||
|
||||
## 0.5.21
|
||||
|
||||
- New package to fix `shasum check failed` error with v0.5.20
|
||||
|
||||
## 0.5.20
|
||||
|
||||
- Now versioning node-webkit binaries based on major.minor.patch - assuming no compatible ABI across versions (#90)
|
||||
|
||||
## 0.5.19
|
||||
|
||||
- Updated to know about more node-webkit releases
|
||||
|
||||
## 0.5.18
|
||||
|
||||
- Updated to know about more node-webkit releases
|
||||
|
||||
## 0.5.17
|
||||
|
||||
- Updated to know about node v0.10.29 release
|
||||
|
||||
## 0.5.16
|
||||
|
||||
- Now supporting all aws-sdk configuration parameters (http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) (#86)
|
||||
|
||||
## 0.5.15
|
||||
|
||||
- Fixed installation of windows packages sub directories on unix systems (#84)
|
||||
|
||||
## 0.5.14
|
||||
|
||||
- Finished support for cross building using `--target_platform` option (#82)
|
||||
- Now skipping binary validation on install if target arch/platform do not match the host.
|
||||
- Removed multi-arch validing for OS X since it required a FAT node.js binary
|
||||
|
||||
## 0.5.13
|
||||
|
||||
- Fix problem in 0.5.12 whereby the wrong versions of mkdirp and semver where bundled.
|
||||
|
||||
## 0.5.12
|
||||
|
||||
- Improved support for node-webkit (@Mithgol)
|
||||
|
||||
## 0.5.11
|
||||
|
||||
- Updated target versions listing
|
||||
|
||||
## 0.5.10
|
||||
|
||||
- Fixed handling of `-debug` flag passed directory to node-pre-gyp (#72)
|
||||
- Added optional second arg to `node_pre_gyp.find` to customize the default versioning options used to locate the runtime binary
|
||||
- Failed install due to `testbinary` check failure no longer leaves behind binary (#70)
|
||||
|
||||
## 0.5.9
|
||||
|
||||
- Fixed regression in `testbinary` command causing installs to fail on windows with 0.5.7 (#60)
|
||||
|
||||
## 0.5.8
|
||||
|
||||
- Started bundling deps
|
||||
|
||||
## 0.5.7
|
||||
|
||||
- Fixed the `testbinary` check, which is used to determine whether to re-download or source compile, to work even in complex dependency situations (#63)
|
||||
- Exposed the internal `testbinary` command in node-pre-gyp command line tool
|
||||
- Fixed minor bug so that `fallback_to_build` option is always respected
|
||||
|
||||
## 0.5.6
|
||||
|
||||
- Added support for versioning on the `name` value in `package.json` (#57).
|
||||
- Moved to using streams for reading tarball when publishing (#52)
|
||||
|
||||
## 0.5.5
|
||||
|
||||
- Improved binary validation that also now works with node-webkit (@Mithgol)
|
||||
- Upgraded test apps to work with node v0.11.x
|
||||
- Improved test coverage
|
||||
|
||||
## 0.5.4
|
||||
|
||||
- No longer depends on external install of node-gyp for compiling builds.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
- Reverted fix for debian/nodejs since it broke windows (#45)
|
||||
|
||||
## 0.5.2
|
||||
|
||||
- Support for debian systems where the node binary is named `nodejs` (#45)
|
||||
- Added `bin/node-pre-gyp.cmd` to be able to run command on windows locally (npm creates an .npm automatically when globally installed)
|
||||
- Updated abi-crosswalk with node v0.10.26 entry.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
- Various minor bug fixes, several improving windows support for publishing.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
- Changed property names in `binary` object: now required are `module_name`, `module_path`, and `host`.
|
||||
- Now `module_path` supports versioning, which allows developers to opt-in to using a versioned install path (#18).
|
||||
- Added `remote_path` which also supports versioning.
|
||||
- Changed `remote_uri` to `host`.
|
||||
|
||||
## 0.4.2
|
||||
|
||||
- Added support for `--target` flag to request cross-compile against a specific node/node-webkit version.
|
||||
- Added preliminary support for node-webkit
|
||||
- Fixed support for `--target_arch` option being respected in all cases.
|
||||
|
||||
## 0.4.1
|
||||
|
||||
- Fixed exception when only stderr is available in binary test (@bendi / #31)
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- Enforce only `https:` based remote publishing access.
|
||||
- Added `node-pre-gyp info` command to display listing of published binaries
|
||||
- Added support for changing the directory node-pre-gyp should build in with the `-C/--directory` option.
|
||||
- Added support for S3 prefixes.
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- Added `unpublish` command.
|
||||
- Fixed module path construction in tests.
|
||||
- Added ability to disable falling back to build behavior via `npm install --fallback-to-build=false` which overrides setting in a depedencies package.json `install` target.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Support for packaging all files in `module_path` directory - see `app4` for example
|
||||
- Added `testpackage` command.
|
||||
- Changed `clean` command to only delete `.node` not entire `build` directory since node-gyp will handle that.
|
||||
- `.node` modules must be in a folder of there own since tar-pack will remove everything when it unpacks.
|
27
lib/node/node_modules/@mapbox/node-pre-gyp/LICENSE
generated
vendored
Normal file
27
lib/node/node_modules/@mapbox/node-pre-gyp/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
Copyright (c), Mapbox
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of node-pre-gyp nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
742
lib/node/node_modules/@mapbox/node-pre-gyp/README.md
generated
vendored
Normal file
742
lib/node/node_modules/@mapbox/node-pre-gyp/README.md
generated
vendored
Normal file
|
@ -0,0 +1,742 @@
|
|||
# @mapbox/node-pre-gyp
|
||||
|
||||
#### @mapbox/node-pre-gyp makes it easy to publish and install Node.js C++ addons from binaries
|
||||
|
||||
[](https://travis-ci.com/mapbox/node-pre-gyp)
|
||||
[](https://ci.appveyor.com/project/Mapbox/node-pre-gyp)
|
||||
|
||||
`@mapbox/node-pre-gyp` stands between [npm](https://github.com/npm/npm) and [node-gyp](https://github.com/Tootallnate/node-gyp) and offers a cross-platform method of binary deployment.
|
||||
|
||||
### Special note on previous package
|
||||
|
||||
On Feb 9th, 2021 `@mapbox/node-pre-gyp@1.0.0` was [released](./CHANGELOG.md). Older, unscoped versions that are not part of the `@mapbox` org are deprecated and only `@mapbox/node-pre-gyp` will see updates going forward. To upgrade to the new package do:
|
||||
|
||||
```
|
||||
npm uninstall node-pre-gyp --save
|
||||
npm install @mapbox/node-pre-gyp --save
|
||||
```
|
||||
|
||||
### Features
|
||||
|
||||
- A command line tool called `node-pre-gyp` that can install your package's C++ module from a binary.
|
||||
- A variety of developer targeted commands for packaging, testing, and publishing binaries.
|
||||
- A JavaScript module that can dynamically require your installed binary: `require('@mapbox/node-pre-gyp').find`
|
||||
|
||||
For a hello world example of a module packaged with `node-pre-gyp` see <https://github.com/springmeyer/node-addon-example> and [the wiki ](https://github.com/mapbox/node-pre-gyp/wiki/Modules-using-node-pre-gyp) for real world examples.
|
||||
|
||||
## Credits
|
||||
|
||||
- The module is modeled after [node-gyp](https://github.com/Tootallnate/node-gyp) by [@Tootallnate](https://github.com/Tootallnate)
|
||||
- Motivation for initial development came from [@ErisDS](https://github.com/ErisDS) and the [Ghost Project](https://github.com/TryGhost/Ghost).
|
||||
- Development is sponsored by [Mapbox](https://www.mapbox.com/)
|
||||
|
||||
## FAQ
|
||||
|
||||
See the [Frequently Ask Questions](https://github.com/mapbox/node-pre-gyp/wiki/FAQ).
|
||||
|
||||
## Depends
|
||||
|
||||
- Node.js >= node v8.x
|
||||
|
||||
## Install
|
||||
|
||||
`node-pre-gyp` is designed to be installed as a local dependency of your Node.js C++ addon and accessed like:
|
||||
|
||||
./node_modules/.bin/node-pre-gyp --help
|
||||
|
||||
But you can also install it globally:
|
||||
|
||||
npm install @mapbox/node-pre-gyp -g
|
||||
|
||||
## Usage
|
||||
|
||||
### Commands
|
||||
|
||||
View all possible commands:
|
||||
|
||||
node-pre-gyp --help
|
||||
|
||||
- clean - Remove the entire folder containing the compiled .node module
|
||||
- install - Install pre-built binary for module
|
||||
- reinstall - Run "clean" and "install" at once
|
||||
- build - Compile the module by dispatching to node-gyp or nw-gyp
|
||||
- rebuild - Run "clean" and "build" at once
|
||||
- package - Pack binary into tarball
|
||||
- testpackage - Test that the staged package is valid
|
||||
- publish - Publish pre-built binary
|
||||
- unpublish - Unpublish pre-built binary
|
||||
- info - Fetch info on published binaries
|
||||
|
||||
You can also chain commands:
|
||||
|
||||
node-pre-gyp clean build unpublish publish info
|
||||
|
||||
### Options
|
||||
|
||||
Options include:
|
||||
|
||||
- `-C/--directory`: run the command in this directory
|
||||
- `--build-from-source`: build from source instead of using pre-built binary
|
||||
- `--update-binary`: reinstall by replacing previously installed local binary with remote binary
|
||||
- `--runtime=node-webkit`: customize the runtime: `node`, `electron` and `node-webkit` are the valid options
|
||||
- `--fallback-to-build`: fallback to building from source if pre-built binary is not available
|
||||
- `--target=0.4.0`: Pass the target node or node-webkit version to compile against
|
||||
- `--target_arch=ia32`: Pass the target arch and override the host `arch`. Any value that is [supported by Node.js](https://nodejs.org/api/os.html#osarch) is valid.
|
||||
- `--target_platform=win32`: Pass the target platform and override the host `platform`. Valid values are `linux`, `darwin`, `win32`, `sunos`, `freebsd`, `openbsd`, and `aix`.
|
||||
|
||||
Both `--build-from-source` and `--fallback-to-build` can be passed alone or they can provide values. You can pass `--fallback-to-build=false` to override the option as declared in package.json. In addition to being able to pass `--build-from-source` you can also pass `--build-from-source=myapp` where `myapp` is the name of your module.
|
||||
|
||||
For example: `npm install --build-from-source=myapp`. This is useful if:
|
||||
|
||||
- `myapp` is referenced in the package.json of a larger app and therefore `myapp` is being installed as a dependency with `npm install`.
|
||||
- The larger app also depends on other modules installed with `node-pre-gyp`
|
||||
- You only want to trigger a source compile for `myapp` and the other modules.
|
||||
|
||||
### Configuring
|
||||
|
||||
This is a guide to configuring your module to use node-pre-gyp.
|
||||
|
||||
#### 1) Add new entries to your `package.json`
|
||||
|
||||
- Add `@mapbox/node-pre-gyp` to `dependencies`
|
||||
- Add `aws-sdk` as a `devDependency`
|
||||
- Add a custom `install` script
|
||||
- Declare a `binary` object
|
||||
|
||||
This looks like:
|
||||
|
||||
```js
|
||||
"dependencies" : {
|
||||
"@mapbox/node-pre-gyp": "1.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aws-sdk": "2.x"
|
||||
}
|
||||
"scripts": {
|
||||
"install": "node-pre-gyp install --fallback-to-build"
|
||||
},
|
||||
"binary": {
|
||||
"module_name": "your_module",
|
||||
"module_path": "./lib/binding/",
|
||||
"host": "https://your_module.s3-us-west-1.amazonaws.com"
|
||||
}
|
||||
```
|
||||
|
||||
For a full example see [node-addon-examples's package.json](https://github.com/springmeyer/node-addon-example/blob/master/package.json).
|
||||
|
||||
Let's break this down:
|
||||
|
||||
- Dependencies need to list `node-pre-gyp`
|
||||
- Your devDependencies should list `aws-sdk` so that you can run `node-pre-gyp publish` locally or a CI system. We recommend using `devDependencies` only since `aws-sdk` is large and not needed for `node-pre-gyp install` since it only uses http to fetch binaries
|
||||
- Your `scripts` section should override the `install` target with `"install": "node-pre-gyp install --fallback-to-build"`. This allows node-pre-gyp to be used instead of the default npm behavior of always source compiling with `node-gyp` directly.
|
||||
- Your package.json should contain a `binary` section describing key properties you provide to allow node-pre-gyp to package optimally. They are detailed below.
|
||||
|
||||
Note: in the past we recommended putting `@mapbox/node-pre-gyp` in the `bundledDependencies`, but we no longer recommend this. In the past there were npm bugs (with node versions 0.10.x) that could lead to node-pre-gyp not being available at the right time during install (unless we bundled). This should no longer be the case. Also, for a time we recommended using `"preinstall": "npm install @mapbox/node-pre-gyp"` as an alternative method to avoid needing to bundle. But this did not behave predictably across all npm versions - see https://github.com/mapbox/node-pre-gyp/issues/260 for the details. So we do not recommend using `preinstall` to install `@mapbox/node-pre-gyp`. More history on this at https://github.com/strongloop/fsevents/issues/157#issuecomment-265545908.
|
||||
|
||||
##### The `binary` object has three required properties
|
||||
|
||||
###### module_name
|
||||
|
||||
The name of your native node module. This value must:
|
||||
|
||||
- Match the name passed to [the NODE_MODULE macro](http://nodejs.org/api/addons.html#addons_hello_world)
|
||||
- Must be a valid C variable name (e.g. it cannot contain `-`)
|
||||
- Should not include the `.node` extension.
|
||||
|
||||
###### module_path
|
||||
|
||||
The location your native module is placed after a build. This should be an empty directory without other Javascript files. This entire directory will be packaged in the binary tarball. When installing from a remote package this directory will be overwritten with the contents of the tarball.
|
||||
|
||||
Note: This property supports variables based on [Versioning](#versioning).
|
||||
|
||||
###### host
|
||||
|
||||
A url to the remote location where you've published tarball binaries (must be `https` not `http`).
|
||||
|
||||
It is highly recommended that you use Amazon S3. The reasons are:
|
||||
|
||||
- Various node-pre-gyp commands like `publish` and `info` only work with an S3 host.
|
||||
- S3 is a very solid hosting platform for distributing large files.
|
||||
- We provide detail documentation for using [S3 hosting](#s3-hosting) with node-pre-gyp.
|
||||
|
||||
Why then not require S3? Because while some applications using node-pre-gyp need to distribute binaries as large as 20-30 MB, others might have very small binaries and might wish to store them in a GitHub repo. This is not recommended, but if an author really wants to host in a non-S3 location then it should be possible.
|
||||
|
||||
It should also be mentioned that there is an optional and entirely separate npm module called [node-pre-gyp-github](https://github.com/bchr02/node-pre-gyp-github) which is intended to complement node-pre-gyp and be installed along with it. It provides the ability to store and publish your binaries within your repositories GitHub Releases if you would rather not use S3 directly. Installation and usage instructions can be found [here](https://github.com/bchr02/node-pre-gyp-github), but the basic premise is that instead of using the ```node-pre-gyp publish``` command you would use ```node-pre-gyp-github publish```.
|
||||
|
||||
##### The `binary` object other optional S3 properties
|
||||
|
||||
If you are not using a standard s3 path like `bucket_name.s3(.-)region.amazonaws.com`, you might get an error on `publish` because node-pre-gyp extracts the region and bucket from the `host` url. For example, you may have an on-premises s3-compatible storage server, or may have configured a specific dns redirecting to an s3 endpoint. In these cases, you can explicitly set the `region` and `bucket` properties to tell node-pre-gyp to use these values instead of guessing from the `host` property. The following values can be used in the `binary` section:
|
||||
|
||||
###### host
|
||||
|
||||
The url to the remote server root location (must be `https` not `http`).
|
||||
|
||||
###### bucket
|
||||
|
||||
The bucket name where your tarball binaries should be located.
|
||||
|
||||
###### region
|
||||
|
||||
Your S3 server region.
|
||||
|
||||
###### s3ForcePathStyle
|
||||
|
||||
Set `s3ForcePathStyle` to true if the endpoint url should not be prefixed with the bucket name. If false (default), the server endpoint would be constructed as `bucket_name.your_server.com`.
|
||||
|
||||
##### The `binary` object has optional properties
|
||||
|
||||
###### remote_path
|
||||
|
||||
It **is recommended** that you customize this property. This is an extra path to use for publishing and finding remote tarballs. The default value for `remote_path` is `""` meaning that if you do not provide it then all packages will be published at the base of the `host`. It is recommended to provide a value like `./{name}/v{version}` to help organize remote packages in the case that you choose to publish multiple node addons to the same `host`.
|
||||
|
||||
Note: This property supports variables based on [Versioning](#versioning).
|
||||
|
||||
###### package_name
|
||||
|
||||
It is **not recommended** to override this property unless you are also overriding the `remote_path`. This is the versioned name of the remote tarball containing the binary `.node` module and any supporting files you've placed inside the `module_path` directory. Unless you specify `package_name` in your `package.json` then it defaults to `{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz` which allows your binary to work across node versions, platforms, and architectures. If you are using `remote_path` that is also versioned by `./{module_name}/v{version}` then you could remove these variables from the `package_name` and just use: `{node_abi}-{platform}-{arch}.tar.gz`. Then your remote tarball will be looked up at, for example, `https://example.com/your-module/v0.1.0/node-v11-linux-x64.tar.gz`.
|
||||
|
||||
Avoiding the version of your module in the `package_name` and instead only embedding in a directory name can be useful when you want to make a quick tag of your module that does not change any C++ code. In this case you can just copy binaries to the new version behind the scenes like:
|
||||
|
||||
```sh
|
||||
aws s3 sync --acl public-read s3://mapbox-node-binary/sqlite3/v3.0.3/ s3://mapbox-node-binary/sqlite3/v3.0.4/
|
||||
```
|
||||
|
||||
Note: This property supports variables based on [Versioning](#versioning).
|
||||
|
||||
#### 2) Add a new target to binding.gyp
|
||||
|
||||
`node-pre-gyp` calls out to `node-gyp` to compile the module and passes variables along like [module_name](#module_name) and [module_path](#module_path).
|
||||
|
||||
A new target must be added to `binding.gyp` that moves the compiled `.node` module from `./build/Release/module_name.node` into the directory specified by `module_path`.
|
||||
|
||||
Add a target like this at the end of your `targets` list:
|
||||
|
||||
```js
|
||||
{
|
||||
"target_name": "action_after_build",
|
||||
"type": "none",
|
||||
"dependencies": [ "<(module_name)" ],
|
||||
"copies": [
|
||||
{
|
||||
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
|
||||
"destination": "<(module_path)"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
For a full example see [node-addon-example's binding.gyp](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/binding.gyp).
|
||||
|
||||
#### 3) Dynamically require your `.node`
|
||||
|
||||
Inside the main js file that requires your addon module you are likely currently doing:
|
||||
|
||||
```js
|
||||
var binding = require('../build/Release/binding.node');
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```js
|
||||
var bindings = require('./bindings')
|
||||
```
|
||||
|
||||
Change those lines to:
|
||||
|
||||
```js
|
||||
var binary = require('@mapbox/node-pre-gyp');
|
||||
var path = require('path');
|
||||
var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json')));
|
||||
var binding = require(binding_path);
|
||||
```
|
||||
|
||||
For a full example see [node-addon-example's index.js](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/index.js#L1-L4)
|
||||
|
||||
#### 4) Build and package your app
|
||||
|
||||
Now build your module from source:
|
||||
|
||||
npm install --build-from-source
|
||||
|
||||
The `--build-from-source` tells `node-pre-gyp` to not look for a remote package and instead dispatch to node-gyp to build.
|
||||
|
||||
Now `node-pre-gyp` should now also be installed as a local dependency so the command line tool it offers can be found at `./node_modules/.bin/node-pre-gyp`.
|
||||
|
||||
#### 5) Test
|
||||
|
||||
Now `npm test` should work just as it did before.
|
||||
|
||||
#### 6) Publish the tarball
|
||||
|
||||
Then package your app:
|
||||
|
||||
./node_modules/.bin/node-pre-gyp package
|
||||
|
||||
Once packaged, now you can publish:
|
||||
|
||||
./node_modules/.bin/node-pre-gyp publish
|
||||
|
||||
Currently the `publish` command pushes your binary to S3. This requires:
|
||||
|
||||
- You have installed `aws-sdk` with `npm install aws-sdk`
|
||||
- You have created a bucket already.
|
||||
- The `host` points to an S3 http or https endpoint.
|
||||
- You have configured node-pre-gyp to read your S3 credentials (see [S3 hosting](#s3-hosting) for details).
|
||||
|
||||
You can also host your binaries elsewhere. To do this requires:
|
||||
|
||||
- You manually publish the binary created by the `package` command to an `https` endpoint
|
||||
- Ensure that the `host` value points to your custom `https` endpoint.
|
||||
|
||||
#### 7) Automate builds
|
||||
|
||||
Now you need to publish builds for all the platforms and node versions you wish to support. This is best automated.
|
||||
|
||||
- See [Appveyor Automation](#appveyor-automation) for how to auto-publish builds on Windows.
|
||||
- See [Travis Automation](#travis-automation) for how to auto-publish builds on OS X and Linux.
|
||||
|
||||
#### 8) You're done!
|
||||
|
||||
Now publish your module to the npm registry. Users will now be able to install your module from a binary.
|
||||
|
||||
What will happen is this:
|
||||
|
||||
1. `npm install <your package>` will pull from the npm registry
|
||||
2. npm will run the `install` script which will call out to `node-pre-gyp`
|
||||
3. `node-pre-gyp` will fetch the binary `.node` module and unpack in the right place
|
||||
4. Assuming that all worked, you are done
|
||||
|
||||
If a a binary was not available for a given platform and `--fallback-to-build` was used then `node-gyp rebuild` will be called to try to source compile the module.
|
||||
|
||||
#### 9) One more option
|
||||
|
||||
It may be that you want to work with two s3 buckets, one for staging and one for production; this
|
||||
arrangement makes it less likely to accidentally overwrite a production binary. It also allows the production
|
||||
environment to have more restrictive permissions than staging while still enabling publishing when
|
||||
developing and testing.
|
||||
|
||||
The binary.host property can be set at execution time. In order to do so all of the following conditions
|
||||
must be true.
|
||||
|
||||
- binary.host is falsey or not present
|
||||
- binary.staging_host is not empty
|
||||
- binary.production_host is not empty
|
||||
|
||||
If any of these checks fail then the operation will not perform execution time determination of the s3 target.
|
||||
|
||||
If the command being executed is either "publish" or "unpublish" then the default is set to `binary.staging_host`. In all other cases
|
||||
the default is `binary.production_host`.
|
||||
|
||||
The command-line options `--s3_host=staging` or `--s3_host=production` override the default. If `s3_host`
|
||||
is present and not `staging` or `production` an exception is thrown.
|
||||
|
||||
This allows installing from staging by specifying `--s3_host=staging`. And it requires specifying
|
||||
`--s3_option=production` in order to publish to, or unpublish from, production, making accidental errors less likely.
|
||||
|
||||
## Node-API Considerations
|
||||
|
||||
[Node-API](https://nodejs.org/api/n-api.html#n_api_node_api), which was previously known as N-API, is an ABI-stable alternative to previous technologies such as [nan](https://github.com/nodejs/nan) which are tied to a specific Node runtime engine. Node-API is Node runtime engine agnostic and guarantees modules created today will continue to run, without changes, into the future.
|
||||
|
||||
Using `node-pre-gyp` with Node-API projects requires a handful of additional configuration values and imposes some additional requirements.
|
||||
|
||||
The most significant difference is that an Node-API module can be coded to target multiple Node-API versions. Therefore, an Node-API module must declare in its `package.json` file which Node-API versions the module is designed to run against. In addition, since multiple builds may be required for a single module, path and file names must be specified in way that avoids naming conflicts.
|
||||
|
||||
### The `napi_versions` array property
|
||||
|
||||
A Node-API module must declare in its `package.json` file, the Node-API versions the module is intended to support. This is accomplished by including an `napi-versions` array property in the `binary` object. For example:
|
||||
|
||||
```js
|
||||
"binary": {
|
||||
"module_name": "your_module",
|
||||
"module_path": "your_module_path",
|
||||
"host": "https://your_bucket.s3-us-west-1.amazonaws.com",
|
||||
"napi_versions": [1,3]
|
||||
}
|
||||
```
|
||||
|
||||
If the `napi_versions` array property is *not* present, `node-pre-gyp` operates as it always has. Including the `napi_versions` array property instructs `node-pre-gyp` that this is a Node-API module build.
|
||||
|
||||
When the `napi_versions` array property is present, `node-pre-gyp` fires off multiple operations, one for each of the Node-API versions in the array. In the example above, two operations are initiated, one for Node-API version 1 and second for Node-API version 3. How this version number is communicated is described next.
|
||||
|
||||
### The `napi_build_version` value
|
||||
|
||||
For each of the Node-API module operations `node-pre-gyp` initiates, it ensures that the `napi_build_version` is set appropriately.
|
||||
|
||||
This value is of importance in two areas:
|
||||
|
||||
1. The C/C++ code which needs to know against which Node-API version it should compile.
|
||||
2. `node-pre-gyp` itself which must assign appropriate path and file names to avoid collisions.
|
||||
|
||||
### Defining `NAPI_VERSION` for the C/C++ code
|
||||
|
||||
The `napi_build_version` value is communicated to the C/C++ code by adding this code to the `binding.gyp` file:
|
||||
|
||||
```
|
||||
"defines": [
|
||||
"NAPI_VERSION=<(napi_build_version)",
|
||||
]
|
||||
```
|
||||
|
||||
This ensures that `NAPI_VERSION`, an integer value, is declared appropriately to the C/C++ code for each build.
|
||||
|
||||
> Note that earlier versions of this document recommended defining the symbol `NAPI_BUILD_VERSION`. `NAPI_VERSION` is preferred because it used by the Node-API C/C++ headers to configure the specific Node-API versions being requested.
|
||||
|
||||
### Path and file naming requirements in `package.json`
|
||||
|
||||
Since `node-pre-gyp` fires off multiple operations for each request, it is essential that path and file names be created in such a way as to avoid collisions. This is accomplished by imposing additional path and file naming requirements.
|
||||
|
||||
Specifically, when performing Node-API builds, the `{napi_build_version}` text configuration value *must* be present in the `module_path` property. In addition, the `{napi_build_version}` text configuration value *must* be present in either the `remote_path` or `package_name` property. (No problem if it's in both.)
|
||||
|
||||
Here's an example:
|
||||
|
||||
```js
|
||||
"binary": {
|
||||
"module_name": "your_module",
|
||||
"module_path": "./lib/binding/napi-v{napi_build_version}",
|
||||
"remote_path": "./{module_name}/v{version}/{configuration}/",
|
||||
"package_name": "{platform}-{arch}-napi-v{napi_build_version}.tar.gz",
|
||||
"host": "https://your_bucket.s3-us-west-1.amazonaws.com",
|
||||
"napi_versions": [1,3]
|
||||
}
|
||||
```
|
||||
|
||||
## Supporting both Node-API and NAN builds
|
||||
|
||||
You may have a legacy native add-on that you wish to continue supporting for those versions of Node that do not support Node-API, as you add Node-API support for later Node versions. This can be accomplished by specifying the `node_napi_label` configuration value in the package.json `binary.package_name` property.
|
||||
|
||||
Placing the configuration value `node_napi_label` in the package.json `binary.package_name` property instructs `node-pre-gyp` to build all viable Node-API binaries supported by the current Node instance. If the current Node instance does not support Node-API, `node-pre-gyp` will request a traditional, non-Node-API build.
|
||||
|
||||
The configuration value `node_napi_label` is set by `node-pre-gyp` to the type of build created, `napi` or `node`, and the version number. For Node-API builds, the string contains the Node-API version nad has values like `napi-v3`. For traditional, non-Node-API builds, the string contains the ABI version with values like `node-v46`.
|
||||
|
||||
Here's how the `binary` configuration above might be changed to support both Node-API and NAN builds:
|
||||
|
||||
```js
|
||||
"binary": {
|
||||
"module_name": "your_module",
|
||||
"module_path": "./lib/binding/{node_napi_label}",
|
||||
"remote_path": "./{module_name}/v{version}/{configuration}/",
|
||||
"package_name": "{platform}-{arch}-{node_napi_label}.tar.gz",
|
||||
"host": "https://your_bucket.s3-us-west-1.amazonaws.com",
|
||||
"napi_versions": [1,3]
|
||||
}
|
||||
```
|
||||
|
||||
The C/C++ symbol `NAPI_VERSION` can be used to distinguish Node-API and non-Node-API builds. The value of `NAPI_VERSION` is set to the integer Node-API version for Node-API builds and is set to `0` for non-Node-API builds.
|
||||
|
||||
For example:
|
||||
|
||||
```C
|
||||
#if NAPI_VERSION
|
||||
// Node-API code goes here
|
||||
#else
|
||||
// NAN code goes here
|
||||
#endif
|
||||
```
|
||||
|
||||
### Two additional configuration values
|
||||
|
||||
The following two configuration values, which were implemented in previous versions of `node-pre-gyp`, continue to exist, but have been replaced by the `node_napi_label` configuration value described above.
|
||||
|
||||
1. `napi_version` If Node-API is supported by the currently executing Node instance, this value is the Node-API version number supported by Node. If Node-API is not supported, this value is an empty string.
|
||||
|
||||
2. `node_abi_napi` If the value returned for `napi_version` is non empty, this value is `'napi'`. If the value returned for `napi_version` is empty, this value is the value returned for `node_abi`.
|
||||
|
||||
These values are present for use in the `binding.gyp` file and may be used as `{napi_version}` and `{node_abi_napi}` for text substituion in the `binary` properties of the `package.json` file.
|
||||
|
||||
## S3 Hosting
|
||||
|
||||
You can host wherever you choose but S3 is cheap, `node-pre-gyp publish` expects it, and S3 can be integrated well with [Travis.ci](http://travis-ci.org) to automate builds for OS X and Ubuntu, and with [Appveyor](http://appveyor.com) to automate builds for Windows. Here is an approach to do this:
|
||||
|
||||
First, get setup locally and test the workflow:
|
||||
|
||||
#### 1) Create an S3 bucket
|
||||
|
||||
And have your **key** and **secret key** ready for writing to the bucket.
|
||||
|
||||
It is recommended to create a IAM user with a policy that only gives permissions to the specific bucket you plan to publish to. This can be done in the [IAM console](https://console.aws.amazon.com/iam/) by: 1) adding a new user, 2) choosing `Attach User Policy`, 3) Using the `Policy Generator`, 4) selecting `Amazon S3` for the service, 5) adding the actions: `DeleteObject`, `GetObject`, `GetObjectAcl`, `ListBucket`, `HeadBucket`, `PutObject`, `PutObjectAcl`, 6) adding an ARN of `arn:aws:s3:::bucket/*` (replacing `bucket` with your bucket name), and finally 7) clicking `Add Statement` and saving the policy. It should generate a policy like:
|
||||
|
||||
```js
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "objects",
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:PutObject",
|
||||
"s3:GetObjectAcl",
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:PutObjectAcl"
|
||||
],
|
||||
"Resource": "arn:aws:s3:::your-bucket-name/*"
|
||||
},
|
||||
{
|
||||
"Sid": "bucket",
|
||||
"Effect": "Allow",
|
||||
"Action": "s3:ListBucket",
|
||||
"Resource": "arn:aws:s3:::your-bucket-name"
|
||||
},
|
||||
{
|
||||
"Sid": "buckets",
|
||||
"Effect": "Allow",
|
||||
"Action": "s3:HeadBucket",
|
||||
"Resource": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 2) Install node-pre-gyp
|
||||
|
||||
Either install it globally:
|
||||
|
||||
npm install node-pre-gyp -g
|
||||
|
||||
Or put the local version on your PATH
|
||||
|
||||
export PATH=`pwd`/node_modules/.bin/:$PATH
|
||||
|
||||
#### 3) Configure AWS credentials
|
||||
|
||||
It is recommended to configure the AWS JS SDK v2 used internally by `node-pre-gyp` by setting these environment variables:
|
||||
|
||||
- AWS_ACCESS_KEY_ID
|
||||
- AWS_SECRET_ACCESS_KEY
|
||||
|
||||
But also you can also use the `Shared Config File` mentioned [in the AWS JS SDK v2 docs](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/configuring-the-jssdk.html)
|
||||
|
||||
#### 4) Package and publish your build
|
||||
|
||||
Install the `aws-sdk`:
|
||||
|
||||
npm install aws-sdk
|
||||
|
||||
Then publish:
|
||||
|
||||
node-pre-gyp package publish
|
||||
|
||||
Note: if you hit an error like `Hostname/IP doesn't match certificate's altnames` it may mean that you need to provide the `region` option in your config.
|
||||
|
||||
## Appveyor Automation
|
||||
|
||||
[Appveyor](http://www.appveyor.com/) can build binaries and publish the results per commit and supports:
|
||||
|
||||
- Windows Visual Studio 2013 and related compilers
|
||||
- Both 64 bit (x64) and 32 bit (x86) build configurations
|
||||
- Multiple Node.js versions
|
||||
|
||||
For an example of doing this see [node-sqlite3's appveyor.yml](https://github.com/mapbox/node-sqlite3/blob/master/appveyor.yml).
|
||||
|
||||
Below is a guide to getting set up:
|
||||
|
||||
#### 1) Create a free Appveyor account
|
||||
|
||||
Go to https://ci.appveyor.com/signup/free and sign in with your GitHub account.
|
||||
|
||||
#### 2) Create a new project
|
||||
|
||||
Go to https://ci.appveyor.com/projects/new and select the GitHub repo for your module
|
||||
|
||||
#### 3) Add appveyor.yml and push it
|
||||
|
||||
Once you have committed an `appveyor.yml` ([appveyor.yml reference](http://www.appveyor.com/docs/appveyor-yml)) to your GitHub repo and pushed it AppVeyor should automatically start building your project.
|
||||
|
||||
#### 4) Create secure variables
|
||||
|
||||
Encrypt your S3 AWS keys by going to <https://ci.appveyor.com/tools/encrypt> and hitting the `encrypt` button.
|
||||
|
||||
Then paste the result into your `appveyor.yml`
|
||||
|
||||
```yml
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
secure: Dn9HKdLNYvDgPdQOzRq/DqZ/MPhjknRHB1o+/lVU8MA=
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
secure: W1rwNoSnOku1r+28gnoufO8UA8iWADmL1LiiwH9IOkIVhDTNGdGPJqAlLjNqwLnL
|
||||
```
|
||||
|
||||
NOTE: keys are per account but not per repo (this is difference than Travis where keys are per repo but not related to the account used to encrypt them).
|
||||
|
||||
#### 5) Hook up publishing
|
||||
|
||||
Just put `node-pre-gyp package publish` in your `appveyor.yml` after `npm install`.
|
||||
|
||||
#### 6) Publish when you want
|
||||
|
||||
You might wish to publish binaries only on a specific commit. To do this you could borrow from the [Travis CI idea of commit keywords](http://about.travis-ci.org/docs/user/how-to-skip-a-build/) and add special handling for commit messages with `[publish binary]`:
|
||||
|
||||
SET CM=%APPVEYOR_REPO_COMMIT_MESSAGE%
|
||||
if not "%CM%" == "%CM:[publish binary]=%" node-pre-gyp --msvs_version=2013 publish
|
||||
|
||||
If your commit message contains special characters (e.g. `&`) this method might fail. An alternative is to use PowerShell, which gives you additional possibilities, like ignoring case by using `ToLower()`:
|
||||
|
||||
ps: if($env:APPVEYOR_REPO_COMMIT_MESSAGE.ToLower().Contains('[publish binary]')) { node-pre-gyp --msvs_version=2013 publish }
|
||||
|
||||
Remember this publishing is not the same as `npm publish`. We're just talking about the binary module here and not your entire npm package.
|
||||
|
||||
## Travis Automation
|
||||
|
||||
[Travis](https://travis-ci.org/) can push to S3 after a successful build and supports both:
|
||||
|
||||
- Ubuntu Precise and OS X (64 bit)
|
||||
- Multiple Node.js versions
|
||||
|
||||
For an example of doing this see [node-add-example's .travis.yml](https://github.com/springmeyer/node-addon-example/blob/2ff60a8ded7f042864ad21db00c3a5a06cf47075/.travis.yml).
|
||||
|
||||
Note: if you need 32 bit binaries, this can be done from a 64 bit Travis machine. See [the node-sqlite3 scripts for an example of doing this](https://github.com/mapbox/node-sqlite3/blob/bae122aa6a2b8a45f6b717fab24e207740e32b5d/scripts/build_against_node.sh#L54-L74).
|
||||
|
||||
Below is a guide to getting set up:
|
||||
|
||||
#### 1) Install the Travis gem
|
||||
|
||||
gem install travis
|
||||
|
||||
#### 2) Create secure variables
|
||||
|
||||
Make sure you run this command from within the directory of your module.
|
||||
|
||||
Use `travis-encrypt` like:
|
||||
|
||||
travis encrypt AWS_ACCESS_KEY_ID=${node_pre_gyp_accessKeyId}
|
||||
travis encrypt AWS_SECRET_ACCESS_KEY=${node_pre_gyp_secretAccessKey}
|
||||
|
||||
Then put those values in your `.travis.yml` like:
|
||||
|
||||
```yaml
|
||||
env:
|
||||
global:
|
||||
- secure: F+sEL/v56CzHqmCSSES4pEyC9NeQlkoR0Gs/ZuZxX1ytrj8SKtp3MKqBj7zhIclSdXBz4Ev966Da5ctmcTd410p0b240MV6BVOkLUtkjZJyErMBOkeb8n8yVfSoeMx8RiIhBmIvEn+rlQq+bSFis61/JkE9rxsjkGRZi14hHr4M=
|
||||
- secure: o2nkUQIiABD139XS6L8pxq3XO5gch27hvm/gOdV+dzNKc/s2KomVPWcOyXNxtJGhtecAkABzaW8KHDDi5QL1kNEFx6BxFVMLO8rjFPsMVaBG9Ks6JiDQkkmrGNcnVdxI/6EKTLHTH5WLsz8+J7caDBzvKbEfTux5EamEhxIWgrI=
|
||||
```
|
||||
|
||||
More details on Travis encryption at http://about.travis-ci.org/docs/user/encryption-keys/.
|
||||
|
||||
#### 3) Hook up publishing
|
||||
|
||||
Just put `node-pre-gyp package publish` in your `.travis.yml` after `npm install`.
|
||||
|
||||
##### OS X publishing
|
||||
|
||||
If you want binaries for OS X in addition to linux you can enable [multi-os for Travis](http://docs.travis-ci.com/user/multi-os/#Setting-.travis.yml)
|
||||
|
||||
Use a configuration like:
|
||||
|
||||
```yml
|
||||
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- NODE_VERSION="4"
|
||||
- NODE_VERSION="6"
|
||||
|
||||
before_install:
|
||||
- rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install $NODE_VERSION
|
||||
- nvm use $NODE_VERSION
|
||||
```
|
||||
|
||||
See [Travis OS X Gotchas](#travis-os-x-gotchas) for why we replace `language: node_js` and `node_js:` sections with `language: cpp` and a custom matrix.
|
||||
|
||||
Also create platform specific sections for any deps that need install. For example if you need libpng:
|
||||
|
||||
```yml
|
||||
- if [ $(uname -s) == 'Linux' ]; then apt-get install libpng-dev; fi;
|
||||
- if [ $(uname -s) == 'Darwin' ]; then brew install libpng; fi;
|
||||
```
|
||||
|
||||
For detailed multi-OS examples see [node-mapnik](https://github.com/mapnik/node-mapnik/blob/master/.travis.yml) and [node-sqlite3](https://github.com/mapbox/node-sqlite3/blob/master/.travis.yml).
|
||||
|
||||
##### Travis OS X Gotchas
|
||||
|
||||
First, unlike the Travis Linux machines, the OS X machines do not put `node-pre-gyp` on PATH by default. To do so you will need to:
|
||||
|
||||
```sh
|
||||
export PATH=$(pwd)/node_modules/.bin:${PATH}
|
||||
```
|
||||
|
||||
Second, the OS X machines do not support using a matrix for installing different Node.js versions. So you need to bootstrap the installation of Node.js in a cross platform way.
|
||||
|
||||
By doing:
|
||||
|
||||
```yml
|
||||
env:
|
||||
matrix:
|
||||
- NODE_VERSION="4"
|
||||
- NODE_VERSION="6"
|
||||
|
||||
before_install:
|
||||
- rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install $NODE_VERSION
|
||||
- nvm use $NODE_VERSION
|
||||
```
|
||||
|
||||
You can easily recreate the previous behavior of this matrix:
|
||||
|
||||
```yml
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
```
|
||||
|
||||
#### 4) Publish when you want
|
||||
|
||||
You might wish to publish binaries only on a specific commit. To do this you could borrow from the [Travis CI idea of commit keywords](http://about.travis-ci.org/docs/user/how-to-skip-a-build/) and add special handling for commit messages with `[publish binary]`:
|
||||
|
||||
COMMIT_MESSAGE=$(git log --format=%B --no-merges -n 1 | tr -d '\n')
|
||||
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then node-pre-gyp publish; fi;
|
||||
|
||||
Then you can trigger new binaries to be built like:
|
||||
|
||||
git commit -a -m "[publish binary]"
|
||||
|
||||
Or, if you don't have any changes to make simply run:
|
||||
|
||||
git commit --allow-empty -m "[publish binary]"
|
||||
|
||||
WARNING: if you are working in a pull request and publishing binaries from there then you will want to avoid double publishing when Travis CI builds both the `push` and `pr`. You only want to run the publish on the `push` commit. See https://github.com/Project-OSRM/node-osrm/blob/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/is_pr_merge.sh which is called from https://github.com/Project-OSRM/node-osrm/blob/8eb837abe2e2e30e595093d16e5354bc5c573575/scripts/publish.sh for an example of how to do this.
|
||||
|
||||
Remember this publishing is not the same as `npm publish`. We're just talking about the binary module here and not your entire npm package. To automate the publishing of your entire package to npm on Travis see http://about.travis-ci.org/docs/user/deployment/npm/
|
||||
|
||||
# Versioning
|
||||
|
||||
The `binary` properties of `module_path`, `remote_path`, and `package_name` support variable substitution. The strings are evaluated by `node-pre-gyp` depending on your system and any custom build flags you passed.
|
||||
|
||||
- `node_abi`: The node C++ `ABI` number. This value is available in Javascript as `process.versions.modules` as of [`>= v0.10.4 >= v0.11.7`](https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e) and in C++ as the `NODE_MODULE_VERSION` define much earlier. For versions of Node before this was available we fallback to the V8 major and minor version.
|
||||
- `platform` matches node's `process.platform` like `linux`, `darwin`, and `win32` unless the user passed the `--target_platform` option to override.
|
||||
- `arch` matches node's `process.arch` like `x64` or `ia32` unless the user passes the `--target_arch` option to override.
|
||||
- `libc` matches `require('detect-libc').family` like `glibc` or `musl` unless the user passes the `--target_libc` option to override.
|
||||
- `configuration` - Either 'Release' or 'Debug' depending on if `--debug` is passed during the build.
|
||||
- `module_name` - the `binary.module_name` attribute from `package.json`.
|
||||
- `version` - the semver `version` value for your module from `package.json` (NOTE: ignores the `semver.build` property).
|
||||
- `major`, `minor`, `patch`, and `prelease` match the individual semver values for your module's `version`
|
||||
- `build` - the sevmer `build` value. For example it would be `this.that` if your package.json `version` was `v1.0.0+this.that`
|
||||
- `prerelease` - the semver `prerelease` value. For example it would be `alpha.beta` if your package.json `version` was `v1.0.0-alpha.beta`
|
||||
|
||||
|
||||
The options are visible in the code at <https://github.com/mapbox/node-pre-gyp/blob/612b7bca2604508d881e1187614870ba19a7f0c5/lib/util/versioning.js#L114-L127>
|
||||
|
||||
# Download binary files from a mirror
|
||||
|
||||
S3 is broken in China for the well known reason.
|
||||
|
||||
Using the `npm` config argument: `--{module_name}_binary_host_mirror` can download binary files through a mirror, `-` in `module_name` will be replaced with `_`.
|
||||
|
||||
e.g.: Install [v8-profiler](https://www.npmjs.com/package/v8-profiler) from `npm`.
|
||||
|
||||
```bash
|
||||
$ npm install v8-profiler --profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/
|
||||
```
|
||||
|
||||
e.g.: Install [canvas-prebuilt](https://www.npmjs.com/package/canvas-prebuilt) from `npm`.
|
||||
|
||||
```bash
|
||||
$ npm install canvas-prebuilt --canvas_prebuilt_binary_host_mirror=https://npm.taobao.org/mirrors/canvas-prebuilt/
|
||||
```
|
4
lib/node/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp
generated
vendored
Executable file
4
lib/node/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
require('../lib/main');
|
2
lib/node/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp.cmd
generated
vendored
Normal file
2
lib/node/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp.cmd
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
@echo off
|
||||
node "%~dp0\node-pre-gyp" %*
|
10
lib/node/node_modules/@mapbox/node-pre-gyp/contributing.md
generated
vendored
Normal file
10
lib/node/node_modules/@mapbox/node-pre-gyp/contributing.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Contributing
|
||||
|
||||
|
||||
### Releasing a new version:
|
||||
|
||||
- Ensure tests are passing on travis and appveyor
|
||||
- Run `node scripts/abi_crosswalk.js` and commit any changes
|
||||
- Update the changelog
|
||||
- Tag a new release like: `git tag -a v0.6.34 -m "tagging v0.6.34" && git push --tags`
|
||||
- Run `npm publish`
|
51
lib/node/node_modules/@mapbox/node-pre-gyp/lib/build.js
generated
vendored
Normal file
51
lib/node/node_modules/@mapbox/node-pre-gyp/lib/build.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = build;
|
||||
|
||||
exports.usage = 'Attempts to compile the module by dispatching to node-gyp or nw-gyp';
|
||||
|
||||
const napi = require('./util/napi.js');
|
||||
const compile = require('./util/compile.js');
|
||||
const handle_gyp_opts = require('./util/handle_gyp_opts.js');
|
||||
const configure = require('./configure.js');
|
||||
|
||||
function do_build(gyp, argv, callback) {
|
||||
handle_gyp_opts(gyp, argv, (err, result) => {
|
||||
let final_args = ['build'].concat(result.gyp).concat(result.pre);
|
||||
if (result.unparsed.length > 0) {
|
||||
final_args = final_args.
|
||||
concat(['--']).
|
||||
concat(result.unparsed);
|
||||
}
|
||||
if (!err && result.opts.napi_build_version) {
|
||||
napi.swap_build_dir_in(result.opts.napi_build_version);
|
||||
}
|
||||
compile.run_gyp(final_args, result.opts, (err2) => {
|
||||
if (result.opts.napi_build_version) {
|
||||
napi.swap_build_dir_out(result.opts.napi_build_version);
|
||||
}
|
||||
return callback(err2);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function build(gyp, argv, callback) {
|
||||
|
||||
// Form up commands to pass to node-gyp:
|
||||
// We map `node-pre-gyp build` to `node-gyp configure build` so that we do not
|
||||
// trigger a clean and therefore do not pay the penalty of a full recompile
|
||||
if (argv.length && (argv.indexOf('rebuild') > -1)) {
|
||||
argv.shift(); // remove `rebuild`
|
||||
// here we map `node-pre-gyp rebuild` to `node-gyp rebuild` which internally means
|
||||
// "clean + configure + build" and triggers a full recompile
|
||||
compile.run_gyp(['clean'], {}, (err3) => {
|
||||
if (err3) return callback(err3);
|
||||
configure(gyp, argv, (err4) => {
|
||||
if (err4) return callback(err4);
|
||||
return do_build(gyp, argv, callback);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return do_build(gyp, argv, callback);
|
||||
}
|
||||
}
|
31
lib/node/node_modules/@mapbox/node-pre-gyp/lib/clean.js
generated
vendored
Normal file
31
lib/node/node_modules/@mapbox/node-pre-gyp/lib/clean.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = clean;
|
||||
|
||||
exports.usage = 'Removes the entire folder containing the compiled .node module';
|
||||
|
||||
const rm = require('rimraf');
|
||||
const exists = require('fs').exists || require('path').exists;
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const path = require('path');
|
||||
|
||||
function clean(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
const to_delete = opts.module_path;
|
||||
if (!to_delete) {
|
||||
return callback(new Error('module_path is empty, refusing to delete'));
|
||||
} else if (path.normalize(to_delete) === path.normalize(process.cwd())) {
|
||||
return callback(new Error('module_path is not set, refusing to delete'));
|
||||
} else {
|
||||
exists(to_delete, (found) => {
|
||||
if (found) {
|
||||
if (!gyp.opts.silent_clean) console.log('[' + package_json.name + '] Removing "%s"', to_delete);
|
||||
return rm(to_delete, callback);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
}
|
52
lib/node/node_modules/@mapbox/node-pre-gyp/lib/configure.js
generated
vendored
Normal file
52
lib/node/node_modules/@mapbox/node-pre-gyp/lib/configure.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = configure;
|
||||
|
||||
exports.usage = 'Attempts to configure node-gyp or nw-gyp build';
|
||||
|
||||
const napi = require('./util/napi.js');
|
||||
const compile = require('./util/compile.js');
|
||||
const handle_gyp_opts = require('./util/handle_gyp_opts.js');
|
||||
|
||||
function configure(gyp, argv, callback) {
|
||||
handle_gyp_opts(gyp, argv, (err, result) => {
|
||||
let final_args = result.gyp.concat(result.pre);
|
||||
// pull select node-gyp configure options out of the npm environ
|
||||
const known_gyp_args = ['dist-url', 'python', 'nodedir', 'msvs_version'];
|
||||
known_gyp_args.forEach((key) => {
|
||||
const val = gyp.opts[key] || gyp.opts[key.replace('-', '_')];
|
||||
if (val) {
|
||||
final_args.push('--' + key + '=' + val);
|
||||
}
|
||||
});
|
||||
// --ensure=false tell node-gyp to re-install node development headers
|
||||
// but it is only respected by node-gyp install, so we have to call install
|
||||
// as a separate step if the user passes it
|
||||
if (gyp.opts.ensure === false) {
|
||||
const install_args = final_args.concat(['install', '--ensure=false']);
|
||||
compile.run_gyp(install_args, result.opts, (err2) => {
|
||||
if (err2) return callback(err2);
|
||||
if (result.unparsed.length > 0) {
|
||||
final_args = final_args.
|
||||
concat(['--']).
|
||||
concat(result.unparsed);
|
||||
}
|
||||
compile.run_gyp(['configure'].concat(final_args), result.opts, (err3) => {
|
||||
return callback(err3);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (result.unparsed.length > 0) {
|
||||
final_args = final_args.
|
||||
concat(['--']).
|
||||
concat(result.unparsed);
|
||||
}
|
||||
compile.run_gyp(['configure'].concat(final_args), result.opts, (err4) => {
|
||||
if (!err4 && result.opts.napi_build_version) {
|
||||
napi.swap_build_dir_out(result.opts.napi_build_version);
|
||||
}
|
||||
return callback(err4);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
38
lib/node/node_modules/@mapbox/node-pre-gyp/lib/info.js
generated
vendored
Normal file
38
lib/node/node_modules/@mapbox/node-pre-gyp/lib/info.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = info;
|
||||
|
||||
exports.usage = 'Lists all published binaries (requires aws-sdk)';
|
||||
|
||||
const log = require('npmlog');
|
||||
const versioning = require('./util/versioning.js');
|
||||
const s3_setup = require('./util/s3_setup.js');
|
||||
|
||||
function info(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const opts = versioning.evaluate(package_json, gyp.opts);
|
||||
const config = {};
|
||||
s3_setup.detect(opts, config);
|
||||
const s3 = s3_setup.get_s3(config);
|
||||
const s3_opts = {
|
||||
Bucket: config.bucket,
|
||||
Prefix: config.prefix
|
||||
};
|
||||
s3.listObjects(s3_opts, (err, meta) => {
|
||||
if (err && err.code === 'NotFound') {
|
||||
return callback(new Error('[' + package_json.name + '] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + config.prefix));
|
||||
} else if (err) {
|
||||
return callback(err);
|
||||
} else {
|
||||
log.verbose(JSON.stringify(meta, null, 1));
|
||||
if (meta && meta.Contents) {
|
||||
meta.Contents.forEach((obj) => {
|
||||
console.log(obj.Key);
|
||||
});
|
||||
} else {
|
||||
console.error('[' + package_json.name + '] No objects found at https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + config.prefix);
|
||||
}
|
||||
return callback();
|
||||
}
|
||||
});
|
||||
}
|
235
lib/node/node_modules/@mapbox/node-pre-gyp/lib/install.js
generated
vendored
Normal file
235
lib/node/node_modules/@mapbox/node-pre-gyp/lib/install.js
generated
vendored
Normal file
|
@ -0,0 +1,235 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = install;
|
||||
|
||||
exports.usage = 'Attempts to install pre-built binary for module';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const existsAsync = fs.exists || path.exists;
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const makeDir = require('make-dir');
|
||||
// for fetching binaries
|
||||
const fetch = require('node-fetch');
|
||||
const tar = require('tar');
|
||||
|
||||
let npgVersion = 'unknown';
|
||||
try {
|
||||
// Read own package.json to get the current node-pre-pyp version.
|
||||
const ownPackageJSON = fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8');
|
||||
npgVersion = JSON.parse(ownPackageJSON).version;
|
||||
} catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
function place_binary(uri, targetDir, opts, callback) {
|
||||
log.http('GET', uri);
|
||||
|
||||
// Try getting version info from the currently running npm.
|
||||
const envVersionInfo = process.env.npm_config_user_agent ||
|
||||
'node ' + process.version;
|
||||
|
||||
const sanitized = uri.replace('+', '%2B');
|
||||
const requestOpts = {
|
||||
uri: sanitized,
|
||||
headers: {
|
||||
'User-Agent': 'node-pre-gyp (v' + npgVersion + ', ' + envVersionInfo + ')'
|
||||
},
|
||||
follow_max: 10
|
||||
};
|
||||
|
||||
if (opts.cafile) {
|
||||
try {
|
||||
requestOpts.ca = fs.readFileSync(opts.cafile);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
} else if (opts.ca) {
|
||||
requestOpts.ca = opts.ca;
|
||||
}
|
||||
|
||||
const proxyUrl = opts.proxy ||
|
||||
process.env.http_proxy ||
|
||||
process.env.HTTP_PROXY ||
|
||||
process.env.npm_config_proxy;
|
||||
let agent;
|
||||
if (proxyUrl) {
|
||||
const ProxyAgent = require('https-proxy-agent');
|
||||
agent = new ProxyAgent(proxyUrl);
|
||||
log.http('download', 'proxy agent configured using: "%s"', proxyUrl);
|
||||
}
|
||||
|
||||
fetch(sanitized, { agent })
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new Error(`response status ${res.status} ${res.statusText} on ${sanitized}`);
|
||||
}
|
||||
const dataStream = res.body;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let extractions = 0;
|
||||
const countExtractions = (entry) => {
|
||||
extractions += 1;
|
||||
log.info('install', 'unpacking %s', entry.path);
|
||||
};
|
||||
|
||||
dataStream.pipe(extract(targetDir, countExtractions))
|
||||
.on('error', (e) => {
|
||||
reject(e);
|
||||
});
|
||||
dataStream.on('end', () => {
|
||||
resolve(`extracted file count: ${extractions}`);
|
||||
});
|
||||
dataStream.on('error', (e) => {
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
})
|
||||
.then((text) => {
|
||||
log.info(text);
|
||||
callback();
|
||||
})
|
||||
.catch((e) => {
|
||||
log.error(`install ${e.message}`);
|
||||
callback(e);
|
||||
});
|
||||
}
|
||||
|
||||
function extract(to, onentry) {
|
||||
return tar.extract({
|
||||
cwd: to,
|
||||
strip: 1,
|
||||
onentry
|
||||
});
|
||||
}
|
||||
|
||||
function extract_from_local(from, targetDir, callback) {
|
||||
if (!fs.existsSync(from)) {
|
||||
return callback(new Error('Cannot find file ' + from));
|
||||
}
|
||||
log.info('Found local file to extract from ' + from);
|
||||
|
||||
// extract helpers
|
||||
let extractCount = 0;
|
||||
function countExtractions(entry) {
|
||||
extractCount += 1;
|
||||
log.info('install', 'unpacking ' + entry.path);
|
||||
}
|
||||
function afterExtract(err) {
|
||||
if (err) return callback(err);
|
||||
if (extractCount === 0) {
|
||||
return callback(new Error('There was a fatal problem while extracting the tarball'));
|
||||
}
|
||||
log.info('tarball', 'done parsing tarball');
|
||||
callback();
|
||||
}
|
||||
|
||||
fs.createReadStream(from).pipe(extract(targetDir, countExtractions))
|
||||
.on('close', afterExtract)
|
||||
.on('error', afterExtract);
|
||||
}
|
||||
|
||||
function do_build(gyp, argv, callback) {
|
||||
const args = ['rebuild'].concat(argv);
|
||||
gyp.todo.push({ name: 'build', args: args });
|
||||
process.nextTick(callback);
|
||||
}
|
||||
|
||||
function print_fallback_error(err, opts, package_json) {
|
||||
const fallback_message = ' (falling back to source compile with node-gyp)';
|
||||
let full_message = '';
|
||||
if (err.statusCode !== undefined) {
|
||||
// If we got a network response it but failed to download
|
||||
// it means remote binaries are not available, so let's try to help
|
||||
// the user/developer with the info to debug why
|
||||
full_message = 'Pre-built binaries not found for ' + package_json.name + '@' + package_json.version;
|
||||
full_message += ' and ' + opts.runtime + '@' + (opts.target || process.versions.node) + ' (' + opts.node_abi + ' ABI, ' + opts.libc + ')';
|
||||
full_message += fallback_message;
|
||||
log.warn('Tried to download(' + err.statusCode + '): ' + opts.hosted_tarball);
|
||||
log.warn(full_message);
|
||||
log.http(err.message);
|
||||
} else {
|
||||
// If we do not have a statusCode that means an unexpected error
|
||||
// happened and prevented an http response, so we output the exact error
|
||||
full_message = 'Pre-built binaries not installable for ' + package_json.name + '@' + package_json.version;
|
||||
full_message += ' and ' + opts.runtime + '@' + (opts.target || process.versions.node) + ' (' + opts.node_abi + ' ABI, ' + opts.libc + ')';
|
||||
full_message += fallback_message;
|
||||
log.warn(full_message);
|
||||
log.warn('Hit error ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// install
|
||||
//
|
||||
function install(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const source_build = gyp.opts['build-from-source'] || gyp.opts.build_from_source;
|
||||
const update_binary = gyp.opts['update-binary'] || gyp.opts.update_binary;
|
||||
const should_do_source_build = source_build === package_json.name || (source_build === true || source_build === 'true');
|
||||
if (should_do_source_build) {
|
||||
log.info('build', 'requesting source compile');
|
||||
return do_build(gyp, argv, callback);
|
||||
} else {
|
||||
const fallback_to_build = gyp.opts['fallback-to-build'] || gyp.opts.fallback_to_build;
|
||||
let should_do_fallback_build = fallback_to_build === package_json.name || (fallback_to_build === true || fallback_to_build === 'true');
|
||||
// but allow override from npm
|
||||
if (process.env.npm_config_argv) {
|
||||
const cooked = JSON.parse(process.env.npm_config_argv).cooked;
|
||||
const match = cooked.indexOf('--fallback-to-build');
|
||||
if (match > -1 && cooked.length > match && cooked[match + 1] === 'false') {
|
||||
should_do_fallback_build = false;
|
||||
log.info('install', 'Build fallback disabled via npm flag: --fallback-to-build=false');
|
||||
}
|
||||
}
|
||||
let opts;
|
||||
try {
|
||||
opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
} catch (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
opts.ca = gyp.opts.ca;
|
||||
opts.cafile = gyp.opts.cafile;
|
||||
|
||||
const from = opts.hosted_tarball;
|
||||
const to = opts.module_path;
|
||||
const binary_module = path.join(to, opts.module_name + '.node');
|
||||
existsAsync(binary_module, (found) => {
|
||||
if (!update_binary) {
|
||||
if (found) {
|
||||
console.log('[' + package_json.name + '] Success: "' + binary_module + '" already installed');
|
||||
console.log('Pass --update-binary to reinstall or --build-from-source to recompile');
|
||||
return callback();
|
||||
}
|
||||
log.info('check', 'checked for "' + binary_module + '" (not found)');
|
||||
}
|
||||
|
||||
makeDir(to).then(() => {
|
||||
const fileName = from.startsWith('file://') && from.slice('file://'.length);
|
||||
if (fileName) {
|
||||
extract_from_local(fileName, to, after_place);
|
||||
} else {
|
||||
place_binary(from, to, opts, after_place);
|
||||
}
|
||||
}).catch((err) => {
|
||||
after_place(err);
|
||||
});
|
||||
|
||||
function after_place(err) {
|
||||
if (err && should_do_fallback_build) {
|
||||
print_fallback_error(err, opts, package_json);
|
||||
return do_build(gyp, argv, callback);
|
||||
} else if (err) {
|
||||
return callback(err);
|
||||
} else {
|
||||
console.log('[' + package_json.name + '] Success: "' + binary_module + '" is installed via remote');
|
||||
return callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
125
lib/node/node_modules/@mapbox/node-pre-gyp/lib/main.js
generated
vendored
Normal file
125
lib/node/node_modules/@mapbox/node-pre-gyp/lib/main.js
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Set the title.
|
||||
*/
|
||||
|
||||
process.title = 'node-pre-gyp';
|
||||
|
||||
const node_pre_gyp = require('../');
|
||||
const log = require('npmlog');
|
||||
|
||||
/**
|
||||
* Process and execute the selected commands.
|
||||
*/
|
||||
|
||||
const prog = new node_pre_gyp.Run({ argv: process.argv });
|
||||
let completed = false;
|
||||
|
||||
if (prog.todo.length === 0) {
|
||||
if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) {
|
||||
console.log('v%s', prog.version);
|
||||
process.exit(0);
|
||||
} else if (~process.argv.indexOf('-h') || ~process.argv.indexOf('--help')) {
|
||||
console.log('%s', prog.usage());
|
||||
process.exit(0);
|
||||
}
|
||||
console.log('%s', prog.usage());
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// if --no-color is passed
|
||||
if (prog.opts && Object.hasOwnProperty.call(prog, 'color') && !prog.opts.color) {
|
||||
log.disableColor();
|
||||
}
|
||||
|
||||
log.info('it worked if it ends with', 'ok');
|
||||
log.verbose('cli', process.argv);
|
||||
log.info('using', process.title + '@%s', prog.version);
|
||||
log.info('using', 'node@%s | %s | %s', process.versions.node, process.platform, process.arch);
|
||||
|
||||
|
||||
/**
|
||||
* Change dir if -C/--directory was passed.
|
||||
*/
|
||||
|
||||
const dir = prog.opts.directory;
|
||||
if (dir) {
|
||||
const fs = require('fs');
|
||||
try {
|
||||
const stat = fs.statSync(dir);
|
||||
if (stat.isDirectory()) {
|
||||
log.info('chdir', dir);
|
||||
process.chdir(dir);
|
||||
} else {
|
||||
log.warn('chdir', dir + ' is not a directory');
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
log.warn('chdir', dir + ' is not a directory');
|
||||
} else {
|
||||
log.warn('chdir', 'error during chdir() "%s"', e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run() {
|
||||
const command = prog.todo.shift();
|
||||
if (!command) {
|
||||
// done!
|
||||
completed = true;
|
||||
log.info('ok');
|
||||
return;
|
||||
}
|
||||
|
||||
// set binary.host when appropriate. host determines the s3 target bucket.
|
||||
const target = prog.setBinaryHostProperty(command.name);
|
||||
if (target && ['install', 'publish', 'unpublish', 'info'].indexOf(command.name) >= 0) {
|
||||
log.info('using binary.host: ' + prog.package_json.binary.host);
|
||||
}
|
||||
|
||||
prog.commands[command.name](command.args, function(err) {
|
||||
if (err) {
|
||||
log.error(command.name + ' error');
|
||||
log.error('stack', err.stack);
|
||||
errorMessage();
|
||||
log.error('not ok');
|
||||
console.log(err.message);
|
||||
return process.exit(1);
|
||||
}
|
||||
const args_array = [].slice.call(arguments, 1);
|
||||
if (args_array.length) {
|
||||
console.log.apply(console, args_array);
|
||||
}
|
||||
// now run the next command in the queue
|
||||
process.nextTick(run);
|
||||
});
|
||||
}
|
||||
|
||||
process.on('exit', (code) => {
|
||||
if (!completed && !code) {
|
||||
log.error('Completion callback never invoked!');
|
||||
errorMessage();
|
||||
process.exit(6);
|
||||
}
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
log.error('UNCAUGHT EXCEPTION');
|
||||
log.error('stack', err.stack);
|
||||
errorMessage();
|
||||
process.exit(7);
|
||||
});
|
||||
|
||||
function errorMessage() {
|
||||
// copied from npm's lib/util/error-handler.js
|
||||
const os = require('os');
|
||||
log.error('System', os.type() + ' ' + os.release());
|
||||
log.error('command', process.argv.map(JSON.stringify).join(' '));
|
||||
log.error('cwd', process.cwd());
|
||||
log.error('node -v', process.version);
|
||||
log.error(process.title + ' -v', 'v' + prog.package.version);
|
||||
}
|
||||
|
||||
// start running the given commands!
|
||||
run();
|
309
lib/node/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
generated
vendored
Normal file
309
lib/node/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
generated
vendored
Normal file
|
@ -0,0 +1,309 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
// load mocking control function for accessing s3 via https. the function is a noop always returning
|
||||
// false if not mocking.
|
||||
exports.mockS3Http = require('./util/s3_setup').get_mockS3Http();
|
||||
exports.mockS3Http('on');
|
||||
const mocking = exports.mockS3Http('get');
|
||||
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const nopt = require('nopt');
|
||||
const log = require('npmlog');
|
||||
log.disableProgress();
|
||||
const napi = require('./util/napi.js');
|
||||
|
||||
const EE = require('events').EventEmitter;
|
||||
const inherits = require('util').inherits;
|
||||
const cli_commands = [
|
||||
'clean',
|
||||
'install',
|
||||
'reinstall',
|
||||
'build',
|
||||
'rebuild',
|
||||
'package',
|
||||
'testpackage',
|
||||
'publish',
|
||||
'unpublish',
|
||||
'info',
|
||||
'testbinary',
|
||||
'reveal',
|
||||
'configure'
|
||||
];
|
||||
const aliases = {};
|
||||
|
||||
// differentiate node-pre-gyp's logs from npm's
|
||||
log.heading = 'node-pre-gyp';
|
||||
|
||||
if (mocking) {
|
||||
log.warn(`mocking s3 to ${process.env.node_pre_gyp_mock_s3}`);
|
||||
}
|
||||
|
||||
// this is a getter to avoid circular reference warnings with node v14.
|
||||
Object.defineProperty(exports, 'find', {
|
||||
get: function() {
|
||||
return require('./pre-binding').find;
|
||||
},
|
||||
enumerable: true
|
||||
});
|
||||
|
||||
// in the following, "my_module" is using node-pre-gyp to
|
||||
// prebuild and install pre-built binaries. "main_module"
|
||||
// is using "my_module".
|
||||
//
|
||||
// "bin/node-pre-gyp" invokes Run() without a path. the
|
||||
// expectation is that the working directory is the package
|
||||
// root "my_module". this is true because in all cases npm is
|
||||
// executing a script in the context of "my_module".
|
||||
//
|
||||
// "pre-binding.find()" is executed by "my_module" but in the
|
||||
// context of "main_module". this is because "main_module" is
|
||||
// executing and requires "my_module" which is then executing
|
||||
// "pre-binding.find()" via "node-pre-gyp.find()", so the working
|
||||
// directory is that of "main_module".
|
||||
//
|
||||
// that's why "find()" must pass the path to package.json.
|
||||
//
|
||||
function Run({ package_json_path = './package.json', argv }) {
|
||||
this.package_json_path = package_json_path;
|
||||
this.commands = {};
|
||||
|
||||
const self = this;
|
||||
cli_commands.forEach((command) => {
|
||||
self.commands[command] = function(argvx, callback) {
|
||||
log.verbose('command', command, argvx);
|
||||
return require('./' + command)(self, argvx, callback);
|
||||
};
|
||||
});
|
||||
|
||||
this.parseArgv(argv);
|
||||
|
||||
// this is set to true after the binary.host property was set to
|
||||
// either staging_host or production_host.
|
||||
this.binaryHostSet = false;
|
||||
}
|
||||
inherits(Run, EE);
|
||||
exports.Run = Run;
|
||||
const proto = Run.prototype;
|
||||
|
||||
/**
|
||||
* Export the contents of the package.json.
|
||||
*/
|
||||
|
||||
proto.package = require('../package.json');
|
||||
|
||||
/**
|
||||
* nopt configuration definitions
|
||||
*/
|
||||
|
||||
proto.configDefs = {
|
||||
help: Boolean, // everywhere
|
||||
arch: String, // 'configure'
|
||||
debug: Boolean, // 'build'
|
||||
directory: String, // bin
|
||||
proxy: String, // 'install'
|
||||
loglevel: String // everywhere
|
||||
};
|
||||
|
||||
/**
|
||||
* nopt shorthands
|
||||
*/
|
||||
|
||||
proto.shorthands = {
|
||||
release: '--no-debug',
|
||||
C: '--directory',
|
||||
debug: '--debug',
|
||||
j: '--jobs',
|
||||
silent: '--loglevel=silent',
|
||||
silly: '--loglevel=silly',
|
||||
verbose: '--loglevel=verbose'
|
||||
};
|
||||
|
||||
/**
|
||||
* expose the command aliases for the bin file to use.
|
||||
*/
|
||||
|
||||
proto.aliases = aliases;
|
||||
|
||||
/**
|
||||
* Parses the given argv array and sets the 'opts', 'argv',
|
||||
* 'command', and 'package_json' properties.
|
||||
*/
|
||||
|
||||
proto.parseArgv = function parseOpts(argv) {
|
||||
this.opts = nopt(this.configDefs, this.shorthands, argv);
|
||||
this.argv = this.opts.argv.remain.slice();
|
||||
const commands = this.todo = [];
|
||||
|
||||
// create a copy of the argv array with aliases mapped
|
||||
argv = this.argv.map((arg) => {
|
||||
// is this an alias?
|
||||
if (arg in this.aliases) {
|
||||
arg = this.aliases[arg];
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
|
||||
// process the mapped args into "command" objects ("name" and "args" props)
|
||||
argv.slice().forEach((arg) => {
|
||||
if (arg in this.commands) {
|
||||
const args = argv.splice(0, argv.indexOf(arg));
|
||||
argv.shift();
|
||||
if (commands.length > 0) {
|
||||
commands[commands.length - 1].args = args;
|
||||
}
|
||||
commands.push({ name: arg, args: [] });
|
||||
}
|
||||
});
|
||||
if (commands.length > 0) {
|
||||
commands[commands.length - 1].args = argv.splice(0);
|
||||
}
|
||||
|
||||
|
||||
// if a directory was specified package.json is assumed to be relative
|
||||
// to it.
|
||||
let package_json_path = this.package_json_path;
|
||||
if (this.opts.directory) {
|
||||
package_json_path = path.join(this.opts.directory, package_json_path);
|
||||
}
|
||||
|
||||
this.package_json = JSON.parse(fs.readFileSync(package_json_path));
|
||||
|
||||
// expand commands entries for multiple napi builds
|
||||
this.todo = napi.expand_commands(this.package_json, this.opts, commands);
|
||||
|
||||
// support for inheriting config env variables from npm
|
||||
const npm_config_prefix = 'npm_config_';
|
||||
Object.keys(process.env).forEach((name) => {
|
||||
if (name.indexOf(npm_config_prefix) !== 0) return;
|
||||
const val = process.env[name];
|
||||
if (name === npm_config_prefix + 'loglevel') {
|
||||
log.level = val;
|
||||
} else {
|
||||
// add the user-defined options to the config
|
||||
name = name.substring(npm_config_prefix.length);
|
||||
// avoid npm argv clobber already present args
|
||||
// which avoids problem of 'npm test' calling
|
||||
// script that runs unique npm install commands
|
||||
if (name === 'argv') {
|
||||
if (this.opts.argv &&
|
||||
this.opts.argv.remain &&
|
||||
this.opts.argv.remain.length) {
|
||||
// do nothing
|
||||
} else {
|
||||
this.opts[name] = val;
|
||||
}
|
||||
} else {
|
||||
this.opts[name] = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (this.opts.loglevel) {
|
||||
log.level = this.opts.loglevel;
|
||||
}
|
||||
log.resume();
|
||||
};
|
||||
|
||||
/**
|
||||
* allow the binary.host property to be set at execution time.
|
||||
*
|
||||
* for this to take effect requires all the following to be true.
|
||||
* - binary is a property in package.json
|
||||
* - binary.host is falsey
|
||||
* - binary.staging_host is not empty
|
||||
* - binary.production_host is not empty
|
||||
*
|
||||
* if any of the previous checks fail then the function returns an empty string
|
||||
* and makes no changes to package.json's binary property.
|
||||
*
|
||||
*
|
||||
* if command is "publish" then the default is set to "binary.staging_host"
|
||||
* if command is not "publish" the the default is set to "binary.production_host"
|
||||
*
|
||||
* if the command-line option '--s3_host' is set to "staging" or "production" then
|
||||
* "binary.host" is set to the specified "staging_host" or "production_host". if
|
||||
* '--s3_host' is any other value an exception is thrown.
|
||||
*
|
||||
* if '--s3_host' is not present then "binary.host" is set to the default as above.
|
||||
*
|
||||
* this strategy was chosen so that any command other than "publish" or "unpublish" uses "production"
|
||||
* as the default without requiring any command-line options but that "publish" and "unpublish" require
|
||||
* '--s3_host production_host' to be specified in order to *really* publish (or unpublish). publishing
|
||||
* to staging can be done freely without worrying about disturbing any production releases.
|
||||
*/
|
||||
proto.setBinaryHostProperty = function(command) {
|
||||
if (this.binaryHostSet) {
|
||||
return this.package_json.binary.host;
|
||||
}
|
||||
const p = this.package_json;
|
||||
// don't set anything if host is present. it must be left blank to trigger this.
|
||||
if (!p || !p.binary || p.binary.host) {
|
||||
return '';
|
||||
}
|
||||
// and both staging and production must be present. errors will be reported later.
|
||||
if (!p.binary.staging_host || !p.binary.production_host) {
|
||||
return '';
|
||||
}
|
||||
let target = 'production_host';
|
||||
if (command === 'publish' || command === 'unpublish') {
|
||||
target = 'staging_host';
|
||||
}
|
||||
// the environment variable has priority over the default or the command line. if
|
||||
// either the env var or the command line option are invalid throw an error.
|
||||
const npg_s3_host = process.env.node_pre_gyp_s3_host;
|
||||
if (npg_s3_host === 'staging' || npg_s3_host === 'production') {
|
||||
target = `${npg_s3_host}_host`;
|
||||
} else if (this.opts['s3_host'] === 'staging' || this.opts['s3_host'] === 'production') {
|
||||
target = `${this.opts['s3_host']}_host`;
|
||||
} else if (this.opts['s3_host'] || npg_s3_host) {
|
||||
throw new Error(`invalid s3_host ${this.opts['s3_host'] || npg_s3_host}`);
|
||||
}
|
||||
|
||||
p.binary.host = p.binary[target];
|
||||
this.binaryHostSet = true;
|
||||
|
||||
return p.binary.host;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the usage instructions for node-pre-gyp.
|
||||
*/
|
||||
|
||||
proto.usage = function usage() {
|
||||
const str = [
|
||||
'',
|
||||
' Usage: node-pre-gyp <command> [options]',
|
||||
'',
|
||||
' where <command> is one of:',
|
||||
cli_commands.map((c) => {
|
||||
return ' - ' + c + ' - ' + require('./' + c).usage;
|
||||
}).join('\n'),
|
||||
'',
|
||||
'node-pre-gyp@' + this.version + ' ' + path.resolve(__dirname, '..'),
|
||||
'node@' + process.versions.node
|
||||
].join('\n');
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Version number getter.
|
||||
*/
|
||||
|
||||
Object.defineProperty(proto, 'version', {
|
||||
get: function() {
|
||||
return this.package.version;
|
||||
},
|
||||
enumerable: true
|
||||
});
|
73
lib/node/node_modules/@mapbox/node-pre-gyp/lib/package.js
generated
vendored
Normal file
73
lib/node/node_modules/@mapbox/node-pre-gyp/lib/package.js
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = _package;
|
||||
|
||||
exports.usage = 'Packs binary (and enclosing directory) into locally staged tarball';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const existsAsync = fs.exists || path.exists;
|
||||
const makeDir = require('make-dir');
|
||||
const tar = require('tar');
|
||||
|
||||
function readdirSync(dir) {
|
||||
let list = [];
|
||||
const files = fs.readdirSync(dir);
|
||||
|
||||
files.forEach((file) => {
|
||||
const stats = fs.lstatSync(path.join(dir, file));
|
||||
if (stats.isDirectory()) {
|
||||
list = list.concat(readdirSync(path.join(dir, file)));
|
||||
} else {
|
||||
list.push(path.join(dir, file));
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
function _package(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
const from = opts.module_path;
|
||||
const binary_module = path.join(from, opts.module_name + '.node');
|
||||
existsAsync(binary_module, (found) => {
|
||||
if (!found) {
|
||||
return callback(new Error('Cannot package because ' + binary_module + ' missing: run `node-pre-gyp rebuild` first'));
|
||||
}
|
||||
const tarball = opts.staged_tarball;
|
||||
const filter_func = function(entry) {
|
||||
const basename = path.basename(entry);
|
||||
if (basename.length && basename[0] !== '.') {
|
||||
console.log('packing ' + entry);
|
||||
return true;
|
||||
} else {
|
||||
console.log('skipping ' + entry);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
makeDir(path.dirname(tarball)).then(() => {
|
||||
let files = readdirSync(from);
|
||||
const base = path.basename(from);
|
||||
files = files.map((file) => {
|
||||
return path.join(base, path.relative(from, file));
|
||||
});
|
||||
tar.create({
|
||||
portable: false,
|
||||
gzip: true,
|
||||
filter: filter_func,
|
||||
file: tarball,
|
||||
cwd: path.dirname(from)
|
||||
}, files, (err2) => {
|
||||
if (err2) console.error('[' + package_json.name + '] ' + err2.message);
|
||||
else log.info('package', 'Binary staged at "' + tarball + '"');
|
||||
return callback(err2);
|
||||
});
|
||||
}).catch((err) => {
|
||||
return callback(err);
|
||||
});
|
||||
});
|
||||
}
|
34
lib/node/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js
generated
vendored
Normal file
34
lib/node/node_modules/@mapbox/node-pre-gyp/lib/pre-binding.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
const npg = require('..');
|
||||
const versioning = require('../lib/util/versioning.js');
|
||||
const napi = require('../lib/util/napi.js');
|
||||
const existsSync = require('fs').existsSync || require('path').existsSync;
|
||||
const path = require('path');
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
exports.usage = 'Finds the require path for the node-pre-gyp installed module';
|
||||
|
||||
exports.validate = function(package_json, opts) {
|
||||
versioning.validate_config(package_json, opts);
|
||||
};
|
||||
|
||||
exports.find = function(package_json_path, opts) {
|
||||
if (!existsSync(package_json_path)) {
|
||||
throw new Error(package_json_path + 'does not exist');
|
||||
}
|
||||
const prog = new npg.Run({ package_json_path, argv: process.argv });
|
||||
prog.setBinaryHostProperty();
|
||||
const package_json = prog.package_json;
|
||||
|
||||
versioning.validate_config(package_json, opts);
|
||||
let napi_build_version;
|
||||
if (napi.get_napi_build_versions(package_json, opts)) {
|
||||
napi_build_version = napi.get_best_napi_build_version(package_json, opts);
|
||||
}
|
||||
opts = opts || {};
|
||||
if (!opts.module_root) opts.module_root = path.dirname(package_json_path);
|
||||
const meta = versioning.evaluate(package_json, opts, napi_build_version);
|
||||
return meta.module;
|
||||
};
|
81
lib/node/node_modules/@mapbox/node-pre-gyp/lib/publish.js
generated
vendored
Normal file
81
lib/node/node_modules/@mapbox/node-pre-gyp/lib/publish.js
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = publish;
|
||||
|
||||
exports.usage = 'Publishes pre-built binary (requires aws-sdk)';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const s3_setup = require('./util/s3_setup.js');
|
||||
const existsAsync = fs.exists || path.exists;
|
||||
const url = require('url');
|
||||
|
||||
function publish(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
const tarball = opts.staged_tarball;
|
||||
existsAsync(tarball, (found) => {
|
||||
if (!found) {
|
||||
return callback(new Error('Cannot publish because ' + tarball + ' missing: run `node-pre-gyp package` first'));
|
||||
}
|
||||
|
||||
log.info('publish', 'Detecting s3 credentials');
|
||||
const config = {};
|
||||
s3_setup.detect(opts, config);
|
||||
const s3 = s3_setup.get_s3(config);
|
||||
|
||||
const key_name = url.resolve(config.prefix, opts.package_name);
|
||||
const s3_opts = {
|
||||
Bucket: config.bucket,
|
||||
Key: key_name
|
||||
};
|
||||
log.info('publish', 'Authenticating with s3');
|
||||
log.info('publish', config);
|
||||
|
||||
log.info('publish', 'Checking for existing binary at ' + opts.hosted_path);
|
||||
s3.headObject(s3_opts, (err, meta) => {
|
||||
if (meta) log.info('publish', JSON.stringify(meta));
|
||||
if (err && err.code === 'NotFound') {
|
||||
// we are safe to publish because
|
||||
// the object does not already exist
|
||||
log.info('publish', 'Preparing to put object');
|
||||
const s3_put_opts = {
|
||||
ACL: 'public-read',
|
||||
Body: fs.createReadStream(tarball),
|
||||
Key: key_name,
|
||||
Bucket: config.bucket
|
||||
};
|
||||
log.info('publish', 'Putting object', s3_put_opts.ACL, s3_put_opts.Bucket, s3_put_opts.Key);
|
||||
try {
|
||||
s3.putObject(s3_put_opts, (err2, resp) => {
|
||||
log.info('publish', 'returned from putting object');
|
||||
if (err2) {
|
||||
log.info('publish', 's3 putObject error: "' + err2 + '"');
|
||||
return callback(err2);
|
||||
}
|
||||
if (resp) log.info('publish', 's3 putObject response: "' + JSON.stringify(resp) + '"');
|
||||
log.info('publish', 'successfully put object');
|
||||
console.log('[' + package_json.name + '] published to ' + opts.hosted_path);
|
||||
return callback();
|
||||
});
|
||||
} catch (err3) {
|
||||
log.info('publish', 's3 putObject error: "' + err3 + '"');
|
||||
return callback(err3);
|
||||
}
|
||||
} else if (err) {
|
||||
log.info('publish', 's3 headObject error: "' + err + '"');
|
||||
return callback(err);
|
||||
} else {
|
||||
log.error('publish', 'Cannot publish over existing version');
|
||||
log.error('publish', "Update the 'version' field in package.json and try again");
|
||||
log.error('publish', 'If the previous version was published in error see:');
|
||||
log.error('publish', '\t node-pre-gyp unpublish');
|
||||
return callback(new Error('Failed publishing to ' + opts.hosted_path));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
20
lib/node/node_modules/@mapbox/node-pre-gyp/lib/rebuild.js
generated
vendored
Normal file
20
lib/node/node_modules/@mapbox/node-pre-gyp/lib/rebuild.js
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = rebuild;
|
||||
|
||||
exports.usage = 'Runs "clean" and "build" at once';
|
||||
|
||||
const napi = require('./util/napi.js');
|
||||
|
||||
function rebuild(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
let commands = [
|
||||
{ name: 'clean', args: [] },
|
||||
{ name: 'build', args: ['rebuild'] }
|
||||
];
|
||||
commands = napi.expand_commands(package_json, gyp.opts, commands);
|
||||
for (let i = commands.length; i !== 0; i--) {
|
||||
gyp.todo.unshift(commands[i - 1]);
|
||||
}
|
||||
process.nextTick(callback);
|
||||
}
|
19
lib/node/node_modules/@mapbox/node-pre-gyp/lib/reinstall.js
generated
vendored
Normal file
19
lib/node/node_modules/@mapbox/node-pre-gyp/lib/reinstall.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = rebuild;
|
||||
|
||||
exports.usage = 'Runs "clean" and "install" at once';
|
||||
|
||||
const napi = require('./util/napi.js');
|
||||
|
||||
function rebuild(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
let installArgs = [];
|
||||
const napi_build_version = napi.get_best_napi_build_version(package_json, gyp.opts);
|
||||
if (napi_build_version != null) installArgs = [napi.get_command_arg(napi_build_version)];
|
||||
gyp.todo.unshift(
|
||||
{ name: 'clean', args: [] },
|
||||
{ name: 'install', args: installArgs }
|
||||
);
|
||||
process.nextTick(callback);
|
||||
}
|
32
lib/node/node_modules/@mapbox/node-pre-gyp/lib/reveal.js
generated
vendored
Normal file
32
lib/node/node_modules/@mapbox/node-pre-gyp/lib/reveal.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = reveal;
|
||||
|
||||
exports.usage = 'Reveals data on the versioned binary';
|
||||
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
|
||||
function unix_paths(key, val) {
|
||||
return val && val.replace ? val.replace(/\\/g, '/') : val;
|
||||
}
|
||||
|
||||
function reveal(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
let hit = false;
|
||||
// if a second arg is passed look to see
|
||||
// if it is a known option
|
||||
// console.log(JSON.stringify(gyp.opts,null,1))
|
||||
const remain = gyp.opts.argv.remain[gyp.opts.argv.remain.length - 1];
|
||||
if (remain && Object.hasOwnProperty.call(opts, remain)) {
|
||||
console.log(opts[remain].replace(/\\/g, '/'));
|
||||
hit = true;
|
||||
}
|
||||
// otherwise return all options as json
|
||||
if (!hit) {
|
||||
console.log(JSON.stringify(opts, unix_paths, 2));
|
||||
}
|
||||
return callback();
|
||||
}
|
79
lib/node/node_modules/@mapbox/node-pre-gyp/lib/testbinary.js
generated
vendored
Normal file
79
lib/node/node_modules/@mapbox/node-pre-gyp/lib/testbinary.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = testbinary;
|
||||
|
||||
exports.usage = 'Tests that the binary.node can be required';
|
||||
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const cp = require('child_process');
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
|
||||
function testbinary(gyp, argv, callback) {
|
||||
const args = [];
|
||||
const options = {};
|
||||
let shell_cmd = process.execPath;
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
// skip validation for runtimes we don't explicitly support (like electron)
|
||||
if (opts.runtime &&
|
||||
opts.runtime !== 'node-webkit' &&
|
||||
opts.runtime !== 'node') {
|
||||
return callback();
|
||||
}
|
||||
const nw = (opts.runtime && opts.runtime === 'node-webkit');
|
||||
// ensure on windows that / are used for require path
|
||||
const binary_module = opts.module.replace(/\\/g, '/');
|
||||
if ((process.arch !== opts.target_arch) ||
|
||||
(process.platform !== opts.target_platform)) {
|
||||
let msg = 'skipping validation since host platform/arch (';
|
||||
msg += process.platform + '/' + process.arch + ')';
|
||||
msg += ' does not match target (';
|
||||
msg += opts.target_platform + '/' + opts.target_arch + ')';
|
||||
log.info('validate', msg);
|
||||
return callback();
|
||||
}
|
||||
if (nw) {
|
||||
options.timeout = 5000;
|
||||
if (process.platform === 'darwin') {
|
||||
shell_cmd = 'node-webkit';
|
||||
} else if (process.platform === 'win32') {
|
||||
shell_cmd = 'nw.exe';
|
||||
} else {
|
||||
shell_cmd = 'nw';
|
||||
}
|
||||
const modulePath = path.resolve(binary_module);
|
||||
const appDir = path.join(__dirname, 'util', 'nw-pre-gyp');
|
||||
args.push(appDir);
|
||||
args.push(modulePath);
|
||||
log.info('validate', "Running test command: '" + shell_cmd + ' ' + args.join(' ') + "'");
|
||||
cp.execFile(shell_cmd, args, options, (err, stdout, stderr) => {
|
||||
// check for normal timeout for node-webkit
|
||||
if (err) {
|
||||
if (err.killed === true && err.signal && err.signal.indexOf('SIG') > -1) {
|
||||
return callback();
|
||||
}
|
||||
const stderrLog = stderr.toString();
|
||||
log.info('stderr', stderrLog);
|
||||
if (/^\s*Xlib:\s*extension\s*"RANDR"\s*missing\s*on\s*display\s*":\d+\.\d+"\.\s*$/.test(stderrLog)) {
|
||||
log.info('RANDR', 'stderr contains only RANDR error, ignored');
|
||||
return callback();
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
return;
|
||||
}
|
||||
args.push('--eval');
|
||||
args.push("require('" + binary_module.replace(/'/g, '\'') + "')");
|
||||
log.info('validate', "Running test command: '" + shell_cmd + ' ' + args.join(' ') + "'");
|
||||
cp.execFile(shell_cmd, args, options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
return callback(err, { stdout: stdout, stderr: stderr });
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}
|
53
lib/node/node_modules/@mapbox/node-pre-gyp/lib/testpackage.js
generated
vendored
Normal file
53
lib/node/node_modules/@mapbox/node-pre-gyp/lib/testpackage.js
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = testpackage;
|
||||
|
||||
exports.usage = 'Tests that the staged package is valid';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const existsAsync = fs.exists || path.exists;
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const testbinary = require('./testbinary.js');
|
||||
const tar = require('tar');
|
||||
const makeDir = require('make-dir');
|
||||
|
||||
function testpackage(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
const tarball = opts.staged_tarball;
|
||||
existsAsync(tarball, (found) => {
|
||||
if (!found) {
|
||||
return callback(new Error('Cannot test package because ' + tarball + ' missing: run `node-pre-gyp package` first'));
|
||||
}
|
||||
const to = opts.module_path;
|
||||
function filter_func(entry) {
|
||||
log.info('install', 'unpacking [' + entry.path + ']');
|
||||
}
|
||||
|
||||
makeDir(to).then(() => {
|
||||
tar.extract({
|
||||
file: tarball,
|
||||
cwd: to,
|
||||
strip: 1,
|
||||
onentry: filter_func
|
||||
}).then(after_extract, callback);
|
||||
}).catch((err) => {
|
||||
return callback(err);
|
||||
});
|
||||
|
||||
function after_extract() {
|
||||
testbinary(gyp, argv, (err) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
} else {
|
||||
console.log('[' + package_json.name + '] Package appears valid');
|
||||
return callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
41
lib/node/node_modules/@mapbox/node-pre-gyp/lib/unpublish.js
generated
vendored
Normal file
41
lib/node/node_modules/@mapbox/node-pre-gyp/lib/unpublish.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = unpublish;
|
||||
|
||||
exports.usage = 'Unpublishes pre-built binary (requires aws-sdk)';
|
||||
|
||||
const log = require('npmlog');
|
||||
const versioning = require('./util/versioning.js');
|
||||
const napi = require('./util/napi.js');
|
||||
const s3_setup = require('./util/s3_setup.js');
|
||||
const url = require('url');
|
||||
|
||||
function unpublish(gyp, argv, callback) {
|
||||
const package_json = gyp.package_json;
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(package_json, gyp.opts, napi_build_version);
|
||||
const config = {};
|
||||
s3_setup.detect(opts, config);
|
||||
const s3 = s3_setup.get_s3(config);
|
||||
const key_name = url.resolve(config.prefix, opts.package_name);
|
||||
const s3_opts = {
|
||||
Bucket: config.bucket,
|
||||
Key: key_name
|
||||
};
|
||||
s3.headObject(s3_opts, (err, meta) => {
|
||||
if (err && err.code === 'NotFound') {
|
||||
console.log('[' + package_json.name + '] Not found: https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + s3_opts.Key);
|
||||
return callback();
|
||||
} else if (err) {
|
||||
return callback(err);
|
||||
} else {
|
||||
log.info('unpublish', JSON.stringify(meta));
|
||||
s3.deleteObject(s3_opts, (err2, resp) => {
|
||||
if (err2) return callback(err2);
|
||||
log.info(JSON.stringify(resp));
|
||||
console.log('[' + package_json.name + '] Success: removed https://' + s3_opts.Bucket + '.s3.amazonaws.com/' + s3_opts.Key);
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
2602
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.json
generated
vendored
Normal file
2602
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
93
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js
generated
vendored
Normal file
93
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js
generated
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const win = process.platform === 'win32';
|
||||
const existsSync = fs.existsSync || path.existsSync;
|
||||
const cp = require('child_process');
|
||||
|
||||
// try to build up the complete path to node-gyp
|
||||
/* priority:
|
||||
- node-gyp on ENV:npm_config_node_gyp (https://github.com/npm/npm/pull/4887)
|
||||
- node-gyp on NODE_PATH
|
||||
- node-gyp inside npm on NODE_PATH (ignore on iojs)
|
||||
- node-gyp inside npm beside node exe
|
||||
*/
|
||||
function which_node_gyp() {
|
||||
let node_gyp_bin;
|
||||
if (process.env.npm_config_node_gyp) {
|
||||
try {
|
||||
node_gyp_bin = process.env.npm_config_node_gyp;
|
||||
if (existsSync(node_gyp_bin)) {
|
||||
return node_gyp_bin;
|
||||
}
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
try {
|
||||
const node_gyp_main = require.resolve('node-gyp'); // eslint-disable-line node/no-missing-require
|
||||
node_gyp_bin = path.join(path.dirname(
|
||||
path.dirname(node_gyp_main)),
|
||||
'bin/node-gyp.js');
|
||||
if (existsSync(node_gyp_bin)) {
|
||||
return node_gyp_bin;
|
||||
}
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
if (process.execPath.indexOf('iojs') === -1) {
|
||||
try {
|
||||
const npm_main = require.resolve('npm'); // eslint-disable-line node/no-missing-require
|
||||
node_gyp_bin = path.join(path.dirname(
|
||||
path.dirname(npm_main)),
|
||||
'node_modules/node-gyp/bin/node-gyp.js');
|
||||
if (existsSync(node_gyp_bin)) {
|
||||
return node_gyp_bin;
|
||||
}
|
||||
} catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
const npm_base = path.join(path.dirname(
|
||||
path.dirname(process.execPath)),
|
||||
'lib/node_modules/npm/');
|
||||
node_gyp_bin = path.join(npm_base, 'node_modules/node-gyp/bin/node-gyp.js');
|
||||
if (existsSync(node_gyp_bin)) {
|
||||
return node_gyp_bin;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.run_gyp = function(args, opts, callback) {
|
||||
let shell_cmd = '';
|
||||
const cmd_args = [];
|
||||
if (opts.runtime && opts.runtime === 'node-webkit') {
|
||||
shell_cmd = 'nw-gyp';
|
||||
if (win) shell_cmd += '.cmd';
|
||||
} else {
|
||||
const node_gyp_path = which_node_gyp();
|
||||
if (node_gyp_path) {
|
||||
shell_cmd = process.execPath;
|
||||
cmd_args.push(node_gyp_path);
|
||||
} else {
|
||||
shell_cmd = 'node-gyp';
|
||||
if (win) shell_cmd += '.cmd';
|
||||
}
|
||||
}
|
||||
const final_args = cmd_args.concat(args);
|
||||
const cmd = cp.spawn(shell_cmd, final_args, { cwd: undefined, env: process.env, stdio: [0, 1, 2] });
|
||||
cmd.on('error', (err) => {
|
||||
if (err) {
|
||||
return callback(new Error("Failed to execute '" + shell_cmd + ' ' + final_args.join(' ') + "' (" + err + ')'));
|
||||
}
|
||||
callback(null, opts);
|
||||
});
|
||||
cmd.on('close', (code) => {
|
||||
if (code && code !== 0) {
|
||||
return callback(new Error("Failed to execute '" + shell_cmd + ' ' + final_args.join(' ') + "' (" + code + ')'));
|
||||
}
|
||||
callback(null, opts);
|
||||
});
|
||||
};
|
102
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/handle_gyp_opts.js
generated
vendored
Normal file
102
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/handle_gyp_opts.js
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports = handle_gyp_opts;
|
||||
|
||||
const versioning = require('./versioning.js');
|
||||
const napi = require('./napi.js');
|
||||
|
||||
/*
|
||||
|
||||
Here we gather node-pre-gyp generated options (from versioning) and pass them along to node-gyp.
|
||||
|
||||
We massage the args and options slightly to account for differences in what commands mean between
|
||||
node-pre-gyp and node-gyp (e.g. see the difference between "build" and "rebuild" below)
|
||||
|
||||
Keep in mind: the values inside `argv` and `gyp.opts` below are different depending on whether
|
||||
node-pre-gyp is called directory, or if it is called in a `run-script` phase of npm.
|
||||
|
||||
We also try to preserve any command line options that might have been passed to npm or node-pre-gyp.
|
||||
But this is fairly difficult without passing way to much through. For example `gyp.opts` contains all
|
||||
the process.env and npm pushes a lot of variables into process.env which node-pre-gyp inherits. So we have
|
||||
to be very selective about what we pass through.
|
||||
|
||||
For example:
|
||||
|
||||
`npm install --build-from-source` will give:
|
||||
|
||||
argv == [ 'rebuild' ]
|
||||
gyp.opts.argv == { remain: [ 'install' ],
|
||||
cooked: [ 'install', '--fallback-to-build' ],
|
||||
original: [ 'install', '--fallback-to-build' ] }
|
||||
|
||||
`./bin/node-pre-gyp build` will give:
|
||||
|
||||
argv == []
|
||||
gyp.opts.argv == { remain: [ 'build' ],
|
||||
cooked: [ 'build' ],
|
||||
original: [ '-C', 'test/app1', 'build' ] }
|
||||
|
||||
*/
|
||||
|
||||
// select set of node-pre-gyp versioning info
|
||||
// to share with node-gyp
|
||||
const share_with_node_gyp = [
|
||||
'module',
|
||||
'module_name',
|
||||
'module_path',
|
||||
'napi_version',
|
||||
'node_abi_napi',
|
||||
'napi_build_version',
|
||||
'node_napi_label'
|
||||
];
|
||||
|
||||
function handle_gyp_opts(gyp, argv, callback) {
|
||||
|
||||
// Collect node-pre-gyp specific variables to pass to node-gyp
|
||||
const node_pre_gyp_options = [];
|
||||
// generate custom node-pre-gyp versioning info
|
||||
const napi_build_version = napi.get_napi_build_version_from_command_args(argv);
|
||||
const opts = versioning.evaluate(gyp.package_json, gyp.opts, napi_build_version);
|
||||
share_with_node_gyp.forEach((key) => {
|
||||
const val = opts[key];
|
||||
if (val) {
|
||||
node_pre_gyp_options.push('--' + key + '=' + val);
|
||||
} else if (key === 'napi_build_version') {
|
||||
node_pre_gyp_options.push('--' + key + '=0');
|
||||
} else {
|
||||
if (key !== 'napi_version' && key !== 'node_abi_napi')
|
||||
return callback(new Error('Option ' + key + ' required but not found by node-pre-gyp'));
|
||||
}
|
||||
});
|
||||
|
||||
// Collect options that follow the special -- which disables nopt parsing
|
||||
const unparsed_options = [];
|
||||
let double_hyphen_found = false;
|
||||
gyp.opts.argv.original.forEach((opt) => {
|
||||
if (double_hyphen_found) {
|
||||
unparsed_options.push(opt);
|
||||
}
|
||||
if (opt === '--') {
|
||||
double_hyphen_found = true;
|
||||
}
|
||||
});
|
||||
|
||||
// We try respect and pass through remaining command
|
||||
// line options (like --foo=bar) to node-gyp
|
||||
const cooked = gyp.opts.argv.cooked;
|
||||
const node_gyp_options = [];
|
||||
cooked.forEach((value) => {
|
||||
if (value.length > 2 && value.slice(0, 2) === '--') {
|
||||
const key = value.slice(2);
|
||||
const val = cooked[cooked.indexOf(value) + 1];
|
||||
if (val && val.indexOf('--') === -1) { // handle '--foo=bar' or ['--foo','bar']
|
||||
node_gyp_options.push('--' + key + '=' + val);
|
||||
} else { // pass through --foo
|
||||
node_gyp_options.push(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const result = { 'opts': opts, 'gyp': node_gyp_options, 'pre': node_pre_gyp_options, 'unparsed': unparsed_options };
|
||||
return callback(null, result);
|
||||
}
|
205
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/napi.js
generated
vendored
Normal file
205
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/napi.js
generated
vendored
Normal file
|
@ -0,0 +1,205 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
const versionArray = process.version
|
||||
.substr(1)
|
||||
.replace(/-.*$/, '')
|
||||
.split('.')
|
||||
.map((item) => {
|
||||
return +item;
|
||||
});
|
||||
|
||||
const napi_multiple_commands = [
|
||||
'build',
|
||||
'clean',
|
||||
'configure',
|
||||
'package',
|
||||
'publish',
|
||||
'reveal',
|
||||
'testbinary',
|
||||
'testpackage',
|
||||
'unpublish'
|
||||
];
|
||||
|
||||
const napi_build_version_tag = 'napi_build_version=';
|
||||
|
||||
module.exports.get_napi_version = function() {
|
||||
// returns the non-zero numeric napi version or undefined if napi is not supported.
|
||||
// correctly supporting target requires an updated cross-walk
|
||||
let version = process.versions.napi; // can be undefined
|
||||
if (!version) { // this code should never need to be updated
|
||||
if (versionArray[0] === 9 && versionArray[1] >= 3) version = 2; // 9.3.0+
|
||||
else if (versionArray[0] === 8) version = 1; // 8.0.0+
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
module.exports.get_napi_version_as_string = function(target) {
|
||||
// returns the napi version as a string or an empty string if napi is not supported.
|
||||
const version = module.exports.get_napi_version(target);
|
||||
return version ? '' + version : '';
|
||||
};
|
||||
|
||||
module.exports.validate_package_json = function(package_json, opts) { // throws Error
|
||||
|
||||
const binary = package_json.binary;
|
||||
const module_path_ok = pathOK(binary.module_path);
|
||||
const remote_path_ok = pathOK(binary.remote_path);
|
||||
const package_name_ok = pathOK(binary.package_name);
|
||||
const napi_build_versions = module.exports.get_napi_build_versions(package_json, opts, true);
|
||||
const napi_build_versions_raw = module.exports.get_napi_build_versions_raw(package_json);
|
||||
|
||||
if (napi_build_versions) {
|
||||
napi_build_versions.forEach((napi_build_version)=> {
|
||||
if (!(parseInt(napi_build_version, 10) === napi_build_version && napi_build_version > 0)) {
|
||||
throw new Error('All values specified in napi_versions must be positive integers.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (napi_build_versions && (!module_path_ok || (!remote_path_ok && !package_name_ok))) {
|
||||
throw new Error('When napi_versions is specified; module_path and either remote_path or ' +
|
||||
"package_name must contain the substitution string '{napi_build_version}`.");
|
||||
}
|
||||
|
||||
if ((module_path_ok || remote_path_ok || package_name_ok) && !napi_build_versions_raw) {
|
||||
throw new Error("When the substitution string '{napi_build_version}` is specified in " +
|
||||
'module_path, remote_path, or package_name; napi_versions must also be specified.');
|
||||
}
|
||||
|
||||
if (napi_build_versions && !module.exports.get_best_napi_build_version(package_json, opts) &&
|
||||
module.exports.build_napi_only(package_json)) {
|
||||
throw new Error(
|
||||
'The Node-API version of this Node instance is ' + module.exports.get_napi_version(opts ? opts.target : undefined) + '. ' +
|
||||
'This module supports Node-API version(s) ' + module.exports.get_napi_build_versions_raw(package_json) + '. ' +
|
||||
'This Node instance cannot run this module.');
|
||||
}
|
||||
|
||||
if (napi_build_versions_raw && !napi_build_versions && module.exports.build_napi_only(package_json)) {
|
||||
throw new Error(
|
||||
'The Node-API version of this Node instance is ' + module.exports.get_napi_version(opts ? opts.target : undefined) + '. ' +
|
||||
'This module supports Node-API version(s) ' + module.exports.get_napi_build_versions_raw(package_json) + '. ' +
|
||||
'This Node instance cannot run this module.');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function pathOK(path) {
|
||||
return path && (path.indexOf('{napi_build_version}') !== -1 || path.indexOf('{node_napi_label}') !== -1);
|
||||
}
|
||||
|
||||
module.exports.expand_commands = function(package_json, opts, commands) {
|
||||
const expanded_commands = [];
|
||||
const napi_build_versions = module.exports.get_napi_build_versions(package_json, opts);
|
||||
commands.forEach((command)=> {
|
||||
if (napi_build_versions && command.name === 'install') {
|
||||
const napi_build_version = module.exports.get_best_napi_build_version(package_json, opts);
|
||||
const args = napi_build_version ? [napi_build_version_tag + napi_build_version] : [];
|
||||
expanded_commands.push({ name: command.name, args: args });
|
||||
} else if (napi_build_versions && napi_multiple_commands.indexOf(command.name) !== -1) {
|
||||
napi_build_versions.forEach((napi_build_version)=> {
|
||||
const args = command.args.slice();
|
||||
args.push(napi_build_version_tag + napi_build_version);
|
||||
expanded_commands.push({ name: command.name, args: args });
|
||||
});
|
||||
} else {
|
||||
expanded_commands.push(command);
|
||||
}
|
||||
});
|
||||
return expanded_commands;
|
||||
};
|
||||
|
||||
module.exports.get_napi_build_versions = function(package_json, opts, warnings) { // opts may be undefined
|
||||
const log = require('npmlog');
|
||||
let napi_build_versions = [];
|
||||
const supported_napi_version = module.exports.get_napi_version(opts ? opts.target : undefined);
|
||||
// remove duplicates, verify each napi version can actaully be built
|
||||
if (package_json.binary && package_json.binary.napi_versions) {
|
||||
package_json.binary.napi_versions.forEach((napi_version) => {
|
||||
const duplicated = napi_build_versions.indexOf(napi_version) !== -1;
|
||||
if (!duplicated && supported_napi_version && napi_version <= supported_napi_version) {
|
||||
napi_build_versions.push(napi_version);
|
||||
} else if (warnings && !duplicated && supported_napi_version) {
|
||||
log.info('This Node instance does not support builds for Node-API version', napi_version);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (opts && opts['build-latest-napi-version-only']) {
|
||||
let latest_version = 0;
|
||||
napi_build_versions.forEach((napi_version) => {
|
||||
if (napi_version > latest_version) latest_version = napi_version;
|
||||
});
|
||||
napi_build_versions = latest_version ? [latest_version] : [];
|
||||
}
|
||||
return napi_build_versions.length ? napi_build_versions : undefined;
|
||||
};
|
||||
|
||||
module.exports.get_napi_build_versions_raw = function(package_json) {
|
||||
const napi_build_versions = [];
|
||||
// remove duplicates
|
||||
if (package_json.binary && package_json.binary.napi_versions) {
|
||||
package_json.binary.napi_versions.forEach((napi_version) => {
|
||||
if (napi_build_versions.indexOf(napi_version) === -1) {
|
||||
napi_build_versions.push(napi_version);
|
||||
}
|
||||
});
|
||||
}
|
||||
return napi_build_versions.length ? napi_build_versions : undefined;
|
||||
};
|
||||
|
||||
module.exports.get_command_arg = function(napi_build_version) {
|
||||
return napi_build_version_tag + napi_build_version;
|
||||
};
|
||||
|
||||
module.exports.get_napi_build_version_from_command_args = function(command_args) {
|
||||
for (let i = 0; i < command_args.length; i++) {
|
||||
const arg = command_args[i];
|
||||
if (arg.indexOf(napi_build_version_tag) === 0) {
|
||||
return parseInt(arg.substr(napi_build_version_tag.length), 10);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
module.exports.swap_build_dir_out = function(napi_build_version) {
|
||||
if (napi_build_version) {
|
||||
const rm = require('rimraf');
|
||||
rm.sync(module.exports.get_build_dir(napi_build_version));
|
||||
fs.renameSync('build', module.exports.get_build_dir(napi_build_version));
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.swap_build_dir_in = function(napi_build_version) {
|
||||
if (napi_build_version) {
|
||||
const rm = require('rimraf');
|
||||
rm.sync('build');
|
||||
fs.renameSync(module.exports.get_build_dir(napi_build_version), 'build');
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.get_build_dir = function(napi_build_version) {
|
||||
return 'build-tmp-napi-v' + napi_build_version;
|
||||
};
|
||||
|
||||
module.exports.get_best_napi_build_version = function(package_json, opts) {
|
||||
let best_napi_build_version = 0;
|
||||
const napi_build_versions = module.exports.get_napi_build_versions(package_json, opts);
|
||||
if (napi_build_versions) {
|
||||
const our_napi_version = module.exports.get_napi_version(opts ? opts.target : undefined);
|
||||
napi_build_versions.forEach((napi_build_version)=> {
|
||||
if (napi_build_version > best_napi_build_version &&
|
||||
napi_build_version <= our_napi_version) {
|
||||
best_napi_build_version = napi_build_version;
|
||||
}
|
||||
});
|
||||
}
|
||||
return best_napi_build_version === 0 ? undefined : best_napi_build_version;
|
||||
};
|
||||
|
||||
module.exports.build_napi_only = function(package_json) {
|
||||
return package_json.binary && package_json.binary.package_name &&
|
||||
package_json.binary.package_name.indexOf('{node_napi_label}') === -1;
|
||||
};
|
26
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
generated
vendored
Normal file
26
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Node-webkit-based module test</title>
|
||||
<script>
|
||||
function nwModuleTest(){
|
||||
var util = require('util');
|
||||
var moduleFolder = require('nw.gui').App.argv[0];
|
||||
try {
|
||||
require(moduleFolder);
|
||||
} catch(e) {
|
||||
if( process.platform !== 'win32' ){
|
||||
util.log('nw-pre-gyp error:');
|
||||
util.log(e.stack);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(0);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="nwModuleTest()">
|
||||
<h1>Node-webkit-based module test</h1>
|
||||
</body>
|
||||
</html>
|
9
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/package.json
generated
vendored
Normal file
9
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/package.json
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"main": "index.html",
|
||||
"name": "nw-pre-gyp-module-test",
|
||||
"description": "Node-webkit-based module test.",
|
||||
"version": "0.0.1",
|
||||
"window": {
|
||||
"show": false
|
||||
}
|
||||
}
|
163
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js
generated
vendored
Normal file
163
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js
generated
vendored
Normal file
|
@ -0,0 +1,163 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
const url = require('url');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports.detect = function(opts, config) {
|
||||
const to = opts.hosted_path;
|
||||
const uri = url.parse(to);
|
||||
config.prefix = (!uri.pathname || uri.pathname === '/') ? '' : uri.pathname.replace('/', '');
|
||||
if (opts.bucket && opts.region) {
|
||||
config.bucket = opts.bucket;
|
||||
config.region = opts.region;
|
||||
config.endpoint = opts.host;
|
||||
config.s3ForcePathStyle = opts.s3ForcePathStyle;
|
||||
} else {
|
||||
const parts = uri.hostname.split('.s3');
|
||||
const bucket = parts[0];
|
||||
if (!bucket) {
|
||||
return;
|
||||
}
|
||||
if (!config.bucket) {
|
||||
config.bucket = bucket;
|
||||
}
|
||||
if (!config.region) {
|
||||
const region = parts[1].slice(1).split('.')[0];
|
||||
if (region === 'amazonaws') {
|
||||
config.region = 'us-east-1';
|
||||
} else {
|
||||
config.region = region;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.get_s3 = function(config) {
|
||||
|
||||
if (process.env.node_pre_gyp_mock_s3) {
|
||||
// here we're mocking. node_pre_gyp_mock_s3 is the scratch directory
|
||||
// for the mock code.
|
||||
const AWSMock = require('mock-aws-s3');
|
||||
const os = require('os');
|
||||
|
||||
AWSMock.config.basePath = `${os.tmpdir()}/mock`;
|
||||
|
||||
const s3 = AWSMock.S3();
|
||||
|
||||
// wrapped callback maker. fs calls return code of ENOENT but AWS.S3 returns
|
||||
// NotFound.
|
||||
const wcb = (fn) => (err, ...args) => {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
err.code = 'NotFound';
|
||||
}
|
||||
return fn(err, ...args);
|
||||
};
|
||||
|
||||
return {
|
||||
listObjects(params, callback) {
|
||||
return s3.listObjects(params, wcb(callback));
|
||||
},
|
||||
headObject(params, callback) {
|
||||
return s3.headObject(params, wcb(callback));
|
||||
},
|
||||
deleteObject(params, callback) {
|
||||
return s3.deleteObject(params, wcb(callback));
|
||||
},
|
||||
putObject(params, callback) {
|
||||
return s3.putObject(params, wcb(callback));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// if not mocking then setup real s3.
|
||||
const AWS = require('aws-sdk');
|
||||
|
||||
AWS.config.update(config);
|
||||
const s3 = new AWS.S3();
|
||||
|
||||
// need to change if additional options need to be specified.
|
||||
return {
|
||||
listObjects(params, callback) {
|
||||
return s3.listObjects(params, callback);
|
||||
},
|
||||
headObject(params, callback) {
|
||||
return s3.headObject(params, callback);
|
||||
},
|
||||
deleteObject(params, callback) {
|
||||
return s3.deleteObject(params, callback);
|
||||
},
|
||||
putObject(params, callback) {
|
||||
return s3.putObject(params, callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// function to get the mocking control function. if not mocking it returns a no-op.
|
||||
//
|
||||
// if mocking it sets up the mock http interceptors that use the mocked s3 file system
|
||||
// to fulfill reponses.
|
||||
module.exports.get_mockS3Http = function() {
|
||||
let mock_s3 = false;
|
||||
if (!process.env.node_pre_gyp_mock_s3) {
|
||||
return () => mock_s3;
|
||||
}
|
||||
|
||||
const nock = require('nock');
|
||||
// the bucket used for testing, as addressed by https.
|
||||
const host = 'https://mapbox-node-pre-gyp-public-testing-bucket.s3.us-east-1.amazonaws.com';
|
||||
const mockDir = process.env.node_pre_gyp_mock_s3 + '/mapbox-node-pre-gyp-public-testing-bucket';
|
||||
|
||||
// function to setup interceptors. they are "turned off" by setting mock_s3 to false.
|
||||
const mock_http = () => {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function get(uri, requestBody) {
|
||||
const filepath = path.join(mockDir, uri.replace('%2B', '+'));
|
||||
|
||||
try {
|
||||
fs.accessSync(filepath, fs.constants.R_OK);
|
||||
} catch (e) {
|
||||
return [404, 'not found\n'];
|
||||
}
|
||||
|
||||
// the mock s3 functions just write to disk, so just read from it.
|
||||
return [200, fs.createReadStream(filepath)];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
return nock(host)
|
||||
.persist()
|
||||
.get(() => mock_s3) // mock any uri for s3 when true
|
||||
.reply(get);
|
||||
};
|
||||
|
||||
// setup interceptors. they check the mock_s3 flag to determine whether to intercept.
|
||||
mock_http(nock, host, mockDir);
|
||||
// function to turn matching all requests to s3 on/off.
|
||||
const mockS3Http = (action) => {
|
||||
const previous = mock_s3;
|
||||
if (action === 'off') {
|
||||
mock_s3 = false;
|
||||
} else if (action === 'on') {
|
||||
mock_s3 = true;
|
||||
} else if (action !== 'get') {
|
||||
throw new Error(`illegal action for setMockHttp ${action}`);
|
||||
}
|
||||
return previous;
|
||||
};
|
||||
|
||||
// call mockS3Http with the argument
|
||||
// - 'on' - turn it on
|
||||
// - 'off' - turn it off (used by fetch.test.js so it doesn't interfere with redirects)
|
||||
// - 'get' - return true or false for 'on' or 'off'
|
||||
return mockS3Http;
|
||||
};
|
||||
|
||||
|
||||
|
335
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js
generated
vendored
Normal file
335
lib/node/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js
generated
vendored
Normal file
|
@ -0,0 +1,335 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = exports;
|
||||
|
||||
const path = require('path');
|
||||
const semver = require('semver');
|
||||
const url = require('url');
|
||||
const detect_libc = require('detect-libc');
|
||||
const napi = require('./napi.js');
|
||||
|
||||
let abi_crosswalk;
|
||||
|
||||
// This is used for unit testing to provide a fake
|
||||
// ABI crosswalk that emulates one that is not updated
|
||||
// for the current version
|
||||
if (process.env.NODE_PRE_GYP_ABI_CROSSWALK) {
|
||||
abi_crosswalk = require(process.env.NODE_PRE_GYP_ABI_CROSSWALK);
|
||||
} else {
|
||||
abi_crosswalk = require('./abi_crosswalk.json');
|
||||
}
|
||||
|
||||
const major_versions = {};
|
||||
Object.keys(abi_crosswalk).forEach((v) => {
|
||||
const major = v.split('.')[0];
|
||||
if (!major_versions[major]) {
|
||||
major_versions[major] = v;
|
||||
}
|
||||
});
|
||||
|
||||
function get_electron_abi(runtime, target_version) {
|
||||
if (!runtime) {
|
||||
throw new Error('get_electron_abi requires valid runtime arg');
|
||||
}
|
||||
if (typeof target_version === 'undefined') {
|
||||
// erroneous CLI call
|
||||
throw new Error('Empty target version is not supported if electron is the target.');
|
||||
}
|
||||
// Electron guarantees that patch version update won't break native modules.
|
||||
const sem_ver = semver.parse(target_version);
|
||||
return runtime + '-v' + sem_ver.major + '.' + sem_ver.minor;
|
||||
}
|
||||
module.exports.get_electron_abi = get_electron_abi;
|
||||
|
||||
function get_node_webkit_abi(runtime, target_version) {
|
||||
if (!runtime) {
|
||||
throw new Error('get_node_webkit_abi requires valid runtime arg');
|
||||
}
|
||||
if (typeof target_version === 'undefined') {
|
||||
// erroneous CLI call
|
||||
throw new Error('Empty target version is not supported if node-webkit is the target.');
|
||||
}
|
||||
return runtime + '-v' + target_version;
|
||||
}
|
||||
module.exports.get_node_webkit_abi = get_node_webkit_abi;
|
||||
|
||||
function get_node_abi(runtime, versions) {
|
||||
if (!runtime) {
|
||||
throw new Error('get_node_abi requires valid runtime arg');
|
||||
}
|
||||
if (!versions) {
|
||||
throw new Error('get_node_abi requires valid process.versions object');
|
||||
}
|
||||
const sem_ver = semver.parse(versions.node);
|
||||
if (sem_ver.major === 0 && sem_ver.minor % 2) { // odd series
|
||||
// https://github.com/mapbox/node-pre-gyp/issues/124
|
||||
return runtime + '-v' + versions.node;
|
||||
} else {
|
||||
// process.versions.modules added in >= v0.10.4 and v0.11.7
|
||||
// https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e
|
||||
return versions.modules ? runtime + '-v' + (+versions.modules) :
|
||||
'v8-' + versions.v8.split('.').slice(0, 2).join('.');
|
||||
}
|
||||
}
|
||||
module.exports.get_node_abi = get_node_abi;
|
||||
|
||||
function get_runtime_abi(runtime, target_version) {
|
||||
if (!runtime) {
|
||||
throw new Error('get_runtime_abi requires valid runtime arg');
|
||||
}
|
||||
if (runtime === 'node-webkit') {
|
||||
return get_node_webkit_abi(runtime, target_version || process.versions['node-webkit']);
|
||||
} else if (runtime === 'electron') {
|
||||
return get_electron_abi(runtime, target_version || process.versions.electron);
|
||||
} else {
|
||||
if (runtime !== 'node') {
|
||||
throw new Error("Unknown Runtime: '" + runtime + "'");
|
||||
}
|
||||
if (!target_version) {
|
||||
return get_node_abi(runtime, process.versions);
|
||||
} else {
|
||||
let cross_obj;
|
||||
// abi_crosswalk generated with ./scripts/abi_crosswalk.js
|
||||
if (abi_crosswalk[target_version]) {
|
||||
cross_obj = abi_crosswalk[target_version];
|
||||
} else {
|
||||
const target_parts = target_version.split('.').map((i) => { return +i; });
|
||||
if (target_parts.length !== 3) { // parse failed
|
||||
throw new Error('Unknown target version: ' + target_version);
|
||||
}
|
||||
/*
|
||||
The below code tries to infer the last known ABI compatible version
|
||||
that we have recorded in the abi_crosswalk.json when an exact match
|
||||
is not possible. The reasons for this to exist are complicated:
|
||||
|
||||
- We support passing --target to be able to allow developers to package binaries for versions of node
|
||||
that are not the same one as they are running. This might also be used in combination with the
|
||||
--target_arch or --target_platform flags to also package binaries for alternative platforms
|
||||
- When --target is passed we can't therefore determine the ABI (process.versions.modules) from the node
|
||||
version that is running in memory
|
||||
- So, therefore node-pre-gyp keeps an "ABI crosswalk" (lib/util/abi_crosswalk.json) to be able to look
|
||||
this info up for all versions
|
||||
- But we cannot easily predict what the future ABI will be for released versions
|
||||
- And node-pre-gyp needs to be a `bundledDependency` in apps that depend on it in order to work correctly
|
||||
by being fully available at install time.
|
||||
- So, the speed of node releases and the bundled nature of node-pre-gyp mean that a new node-pre-gyp release
|
||||
need to happen for every node.js/io.js/node-webkit/nw.js/atom-shell/etc release that might come online if
|
||||
you want the `--target` flag to keep working for the latest version
|
||||
- Which is impractical ^^
|
||||
- Hence the below code guesses about future ABI to make the need to update node-pre-gyp less demanding.
|
||||
|
||||
In practice then you can have a dependency of your app like `node-sqlite3` that bundles a `node-pre-gyp` that
|
||||
only knows about node v0.10.33 in the `abi_crosswalk.json` but target node v0.10.34 (which is assumed to be
|
||||
ABI compatible with v0.10.33).
|
||||
|
||||
TODO: use semver module instead of custom version parsing
|
||||
*/
|
||||
const major = target_parts[0];
|
||||
let minor = target_parts[1];
|
||||
let patch = target_parts[2];
|
||||
// io.js: yeah if node.js ever releases 1.x this will break
|
||||
// but that is unlikely to happen: https://github.com/iojs/io.js/pull/253#issuecomment-69432616
|
||||
if (major === 1) {
|
||||
// look for last release that is the same major version
|
||||
// e.g. we assume io.js 1.x is ABI compatible with >= 1.0.0
|
||||
while (true) {
|
||||
if (minor > 0) --minor;
|
||||
if (patch > 0) --patch;
|
||||
const new_iojs_target = '' + major + '.' + minor + '.' + patch;
|
||||
if (abi_crosswalk[new_iojs_target]) {
|
||||
cross_obj = abi_crosswalk[new_iojs_target];
|
||||
console.log('Warning: node-pre-gyp could not find exact match for ' + target_version);
|
||||
console.log('Warning: but node-pre-gyp successfully choose ' + new_iojs_target + ' as ABI compatible target');
|
||||
break;
|
||||
}
|
||||
if (minor === 0 && patch === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (major >= 2) {
|
||||
// look for last release that is the same major version
|
||||
if (major_versions[major]) {
|
||||
cross_obj = abi_crosswalk[major_versions[major]];
|
||||
console.log('Warning: node-pre-gyp could not find exact match for ' + target_version);
|
||||
console.log('Warning: but node-pre-gyp successfully choose ' + major_versions[major] + ' as ABI compatible target');
|
||||
}
|
||||
} else if (major === 0) { // node.js
|
||||
if (target_parts[1] % 2 === 0) { // for stable/even node.js series
|
||||
// look for the last release that is the same minor release
|
||||
// e.g. we assume node 0.10.x is ABI compatible with >= 0.10.0
|
||||
while (--patch > 0) {
|
||||
const new_node_target = '' + major + '.' + minor + '.' + patch;
|
||||
if (abi_crosswalk[new_node_target]) {
|
||||
cross_obj = abi_crosswalk[new_node_target];
|
||||
console.log('Warning: node-pre-gyp could not find exact match for ' + target_version);
|
||||
console.log('Warning: but node-pre-gyp successfully choose ' + new_node_target + ' as ABI compatible target');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cross_obj) {
|
||||
throw new Error('Unsupported target version: ' + target_version);
|
||||
}
|
||||
// emulate process.versions
|
||||
const versions_obj = {
|
||||
node: target_version,
|
||||
v8: cross_obj.v8 + '.0',
|
||||
// abi_crosswalk uses 1 for node versions lacking process.versions.modules
|
||||
// process.versions.modules added in >= v0.10.4 and v0.11.7
|
||||
modules: cross_obj.node_abi > 1 ? cross_obj.node_abi : undefined
|
||||
};
|
||||
return get_node_abi(runtime, versions_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports.get_runtime_abi = get_runtime_abi;
|
||||
|
||||
const required_parameters = [
|
||||
'module_name',
|
||||
'module_path',
|
||||
'host'
|
||||
];
|
||||
|
||||
function validate_config(package_json, opts) {
|
||||
const msg = package_json.name + ' package.json is not node-pre-gyp ready:\n';
|
||||
const missing = [];
|
||||
if (!package_json.main) {
|
||||
missing.push('main');
|
||||
}
|
||||
if (!package_json.version) {
|
||||
missing.push('version');
|
||||
}
|
||||
if (!package_json.name) {
|
||||
missing.push('name');
|
||||
}
|
||||
if (!package_json.binary) {
|
||||
missing.push('binary');
|
||||
}
|
||||
const o = package_json.binary;
|
||||
if (o) {
|
||||
required_parameters.forEach((p) => {
|
||||
if (!o[p] || typeof o[p] !== 'string') {
|
||||
missing.push('binary.' + p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (missing.length >= 1) {
|
||||
throw new Error(msg + 'package.json must declare these properties: \n' + missing.join('\n'));
|
||||
}
|
||||
if (o) {
|
||||
// enforce https over http
|
||||
const protocol = url.parse(o.host).protocol;
|
||||
if (protocol === 'http:') {
|
||||
throw new Error("'host' protocol (" + protocol + ") is invalid - only 'https:' is accepted");
|
||||
}
|
||||
}
|
||||
napi.validate_package_json(package_json, opts);
|
||||
}
|
||||
|
||||
module.exports.validate_config = validate_config;
|
||||
|
||||
function eval_template(template, opts) {
|
||||
Object.keys(opts).forEach((key) => {
|
||||
const pattern = '{' + key + '}';
|
||||
while (template.indexOf(pattern) > -1) {
|
||||
template = template.replace(pattern, opts[key]);
|
||||
}
|
||||
});
|
||||
return template;
|
||||
}
|
||||
|
||||
// url.resolve needs single trailing slash
|
||||
// to behave correctly, otherwise a double slash
|
||||
// may end up in the url which breaks requests
|
||||
// and a lacking slash may not lead to proper joining
|
||||
function fix_slashes(pathname) {
|
||||
if (pathname.slice(-1) !== '/') {
|
||||
return pathname + '/';
|
||||
}
|
||||
return pathname;
|
||||
}
|
||||
|
||||
// remove double slashes
|
||||
// note: path.normalize will not work because
|
||||
// it will convert forward to back slashes
|
||||
function drop_double_slashes(pathname) {
|
||||
return pathname.replace(/\/\//g, '/');
|
||||
}
|
||||
|
||||
function get_process_runtime(versions) {
|
||||
let runtime = 'node';
|
||||
if (versions['node-webkit']) {
|
||||
runtime = 'node-webkit';
|
||||
} else if (versions.electron) {
|
||||
runtime = 'electron';
|
||||
}
|
||||
return runtime;
|
||||
}
|
||||
|
||||
module.exports.get_process_runtime = get_process_runtime;
|
||||
|
||||
const default_package_name = '{module_name}-v{version}-{node_abi}-{platform}-{arch}.tar.gz';
|
||||
const default_remote_path = '';
|
||||
|
||||
module.exports.evaluate = function(package_json, options, napi_build_version) {
|
||||
options = options || {};
|
||||
validate_config(package_json, options); // options is a suitable substitute for opts in this case
|
||||
const v = package_json.version;
|
||||
const module_version = semver.parse(v);
|
||||
const runtime = options.runtime || get_process_runtime(process.versions);
|
||||
const opts = {
|
||||
name: package_json.name,
|
||||
configuration: options.debug ? 'Debug' : 'Release',
|
||||
debug: options.debug,
|
||||
module_name: package_json.binary.module_name,
|
||||
version: module_version.version,
|
||||
prerelease: module_version.prerelease.length ? module_version.prerelease.join('.') : '',
|
||||
build: module_version.build.length ? module_version.build.join('.') : '',
|
||||
major: module_version.major,
|
||||
minor: module_version.minor,
|
||||
patch: module_version.patch,
|
||||
runtime: runtime,
|
||||
node_abi: get_runtime_abi(runtime, options.target),
|
||||
node_abi_napi: napi.get_napi_version(options.target) ? 'napi' : get_runtime_abi(runtime, options.target),
|
||||
napi_version: napi.get_napi_version(options.target), // non-zero numeric, undefined if unsupported
|
||||
napi_build_version: napi_build_version || '',
|
||||
node_napi_label: napi_build_version ? 'napi-v' + napi_build_version : get_runtime_abi(runtime, options.target),
|
||||
target: options.target || '',
|
||||
platform: options.target_platform || process.platform,
|
||||
target_platform: options.target_platform || process.platform,
|
||||
arch: options.target_arch || process.arch,
|
||||
target_arch: options.target_arch || process.arch,
|
||||
libc: options.target_libc || detect_libc.familySync() || 'unknown',
|
||||
module_main: package_json.main,
|
||||
toolset: options.toolset || '', // address https://github.com/mapbox/node-pre-gyp/issues/119
|
||||
bucket: package_json.binary.bucket,
|
||||
region: package_json.binary.region,
|
||||
s3ForcePathStyle: package_json.binary.s3ForcePathStyle || false
|
||||
};
|
||||
// support host mirror with npm config `--{module_name}_binary_host_mirror`
|
||||
// e.g.: https://github.com/node-inspector/v8-profiler/blob/master/package.json#L25
|
||||
// > npm install v8-profiler --profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/
|
||||
const validModuleName = opts.module_name.replace('-', '_');
|
||||
const host = process.env['npm_config_' + validModuleName + '_binary_host_mirror'] || package_json.binary.host;
|
||||
opts.host = fix_slashes(eval_template(host, opts));
|
||||
opts.module_path = eval_template(package_json.binary.module_path, opts);
|
||||
// now we resolve the module_path to ensure it is absolute so that binding.gyp variables work predictably
|
||||
if (options.module_root) {
|
||||
// resolve relative to known module root: works for pre-binding require
|
||||
opts.module_path = path.join(options.module_root, opts.module_path);
|
||||
} else {
|
||||
// resolve relative to current working directory: works for node-pre-gyp commands
|
||||
opts.module_path = path.resolve(opts.module_path);
|
||||
}
|
||||
opts.module = path.join(opts.module_path, opts.module_name + '.node');
|
||||
opts.remote_path = package_json.binary.remote_path ? drop_double_slashes(fix_slashes(eval_template(package_json.binary.remote_path, opts))) : default_remote_path;
|
||||
const package_name = package_json.binary.package_name ? package_json.binary.package_name : default_package_name;
|
||||
opts.package_name = eval_template(package_name, opts);
|
||||
opts.staged_tarball = path.join('build/stage', opts.remote_path, opts.package_name);
|
||||
opts.hosted_path = url.resolve(opts.host, opts.remote_path);
|
||||
opts.hosted_tarball = url.resolve(opts.hosted_path, opts.package_name);
|
||||
return opts;
|
||||
};
|
18
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/LICENSE.md
generated
vendored
Normal file
18
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
ISC License
|
||||
|
||||
Copyright npm, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this
|
||||
software for any purpose with or without fee is hereby
|
||||
granted, provided that the above copyright notice and this
|
||||
permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
USE OR PERFORMANCE OF THIS SOFTWARE.
|
208
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/README.md
generated
vendored
Normal file
208
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/README.md
generated
vendored
Normal file
|
@ -0,0 +1,208 @@
|
|||
are-we-there-yet
|
||||
----------------
|
||||
|
||||
Track complex hierarchies of asynchronous task completion statuses. This is
|
||||
intended to give you a way of recording and reporting the progress of the big
|
||||
recursive fan-out and gather type workflows that are so common in async.
|
||||
|
||||
What you do with this completion data is up to you, but the most common use case is to
|
||||
feed it to one of the many progress bar modules.
|
||||
|
||||
Most progress bar modules include a rudimentary version of this, but my
|
||||
needs were more complex.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
```javascript
|
||||
var TrackerGroup = require("are-we-there-yet").TrackerGroup
|
||||
|
||||
var top = new TrackerGroup("program")
|
||||
|
||||
var single = top.newItem("one thing", 100)
|
||||
single.completeWork(20)
|
||||
|
||||
console.log(top.completed()) // 0.2
|
||||
|
||||
fs.stat("file", function(er, stat) {
|
||||
if (er) throw er
|
||||
var stream = top.newStream("file", stat.size)
|
||||
console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
|
||||
// and 50% * 20% == 10%
|
||||
fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
|
||||
// do stuff with chunk
|
||||
})
|
||||
top.on("change", function (name) {
|
||||
// called each time a chunk is read from "file"
|
||||
// top.completed() will start at 0.1 and fill up to 0.6 as the file is read
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
Shared Methods
|
||||
==============
|
||||
|
||||
* var completed = tracker.completed()
|
||||
|
||||
Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
|
||||
|
||||
Returns the ratio of completed work to work to be done. Range of 0 to 1.
|
||||
|
||||
* tracker.finish()
|
||||
|
||||
Implemented in: `Tracker`, `TrackerGroup`
|
||||
|
||||
Marks the tracker as completed. With a TrackerGroup this marks all of its
|
||||
components as completed.
|
||||
|
||||
Marks all of the components of this tracker as finished, which in turn means
|
||||
that `tracker.completed()` for this will now be 1.
|
||||
|
||||
This will result in one or more `change` events being emitted.
|
||||
|
||||
Events
|
||||
======
|
||||
|
||||
All tracker objects emit `change` events with the following arguments:
|
||||
|
||||
```
|
||||
function (name, completed, tracker)
|
||||
```
|
||||
|
||||
`name` is the name of the tracker that originally emitted the event,
|
||||
or if it didn't have one, the first containing tracker group that had one.
|
||||
|
||||
`completed` is the percent complete (as returned by `tracker.completed()` method).
|
||||
|
||||
`tracker` is the tracker object that you are listening for events on.
|
||||
|
||||
TrackerGroup
|
||||
============
|
||||
|
||||
* var tracker = new TrackerGroup(**name**)
|
||||
|
||||
* **name** *(optional)* - The name of this tracker group, used in change
|
||||
notifications if the component updating didn't have a name. Defaults to undefined.
|
||||
|
||||
Creates a new empty tracker aggregation group. These are trackers whose
|
||||
completion status is determined by the completion status of other trackers added to this aggregation group.
|
||||
|
||||
Ex.
|
||||
|
||||
```javascript
|
||||
var tracker = new TrackerGroup("parent")
|
||||
var foo = tracker.newItem("firstChild", 100)
|
||||
var bar = tracker.newItem("secondChild", 100)
|
||||
|
||||
foo.finish()
|
||||
console.log(tracker.completed()) // 0.5
|
||||
bar.finish()
|
||||
console.log(tracker.completed()) // 1
|
||||
```
|
||||
|
||||
* tracker.addUnit(**otherTracker**, **weight**)
|
||||
|
||||
* **otherTracker** - Any of the other are-we-there-yet tracker objects
|
||||
* **weight** *(optional)* - The weight to give the tracker, defaults to 1.
|
||||
|
||||
Adds the **otherTracker** to this aggregation group. The weight determines
|
||||
how long you expect this tracker to take to complete in proportion to other
|
||||
units. So for instance, if you add one tracker with a weight of 1 and
|
||||
another with a weight of 2, you're saying the second will take twice as long
|
||||
to complete as the first. As such, the first will account for 33% of the
|
||||
completion of this tracker and the second will account for the other 67%.
|
||||
|
||||
Returns **otherTracker**.
|
||||
|
||||
* var subGroup = tracker.newGroup(**name**, **weight**)
|
||||
|
||||
The above is exactly equivalent to:
|
||||
|
||||
```javascript
|
||||
var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
|
||||
```
|
||||
|
||||
* var subItem = tracker.newItem(**name**, **todo**, **weight**)
|
||||
|
||||
The above is exactly equivalent to:
|
||||
|
||||
```javascript
|
||||
var subItem = tracker.addUnit(new Tracker(name, todo), weight)
|
||||
```
|
||||
|
||||
* var subStream = tracker.newStream(**name**, **todo**, **weight**)
|
||||
|
||||
The above is exactly equivalent to:
|
||||
|
||||
```javascript
|
||||
var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
|
||||
```
|
||||
|
||||
* console.log( tracker.debug() )
|
||||
|
||||
Returns a tree showing the completion of this tracker group and all of its
|
||||
children, including recursively entering all of the children.
|
||||
|
||||
Tracker
|
||||
=======
|
||||
|
||||
* var tracker = new Tracker(**name**, **todo**)
|
||||
|
||||
* **name** *(optional)* The name of this counter to report in change
|
||||
events. Defaults to undefined.
|
||||
* **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
|
||||
|
||||
Ordinarily these are constructed as a part of a tracker group (via
|
||||
`newItem`).
|
||||
|
||||
* var completed = tracker.completed()
|
||||
|
||||
Returns the ratio of completed work to work to be done. Range of 0 to 1. If
|
||||
total work to be done is 0 then it will return 0.
|
||||
|
||||
* tracker.addWork(**todo**)
|
||||
|
||||
* **todo** A number to add to the amount of work to be done.
|
||||
|
||||
Increases the amount of work to be done, thus decreasing the completion
|
||||
percentage. Triggers a `change` event.
|
||||
|
||||
* tracker.completeWork(**completed**)
|
||||
|
||||
* **completed** A number to add to the work complete
|
||||
|
||||
Increase the amount of work complete, thus increasing the completion percentage.
|
||||
Will never increase the work completed past the amount of work todo. That is,
|
||||
percentages > 100% are not allowed. Triggers a `change` event.
|
||||
|
||||
* tracker.finish()
|
||||
|
||||
Marks this tracker as finished, tracker.completed() will now be 1. Triggers
|
||||
a `change` event.
|
||||
|
||||
TrackerStream
|
||||
=============
|
||||
|
||||
* var tracker = new TrackerStream(**name**, **size**, **options**)
|
||||
|
||||
* **name** *(optional)* The name of this counter to report in change
|
||||
events. Defaults to undefined.
|
||||
* **size** *(optional)* The number of bytes being sent through this stream.
|
||||
* **options** *(optional)* A hash of stream options
|
||||
|
||||
The tracker stream object is a pass through stream that updates an internal
|
||||
tracker object each time a block passes through. It's intended to track
|
||||
downloads, file extraction and other related activities. You use it by piping
|
||||
your data source into it and then using it as your data source.
|
||||
|
||||
If your data has a length attribute then that's used as the amount of work
|
||||
completed when the chunk is passed through. If it does not (eg, object
|
||||
streams) then each chunk counts as completing 1 unit of work, so your size
|
||||
should be the total number of objects being streamed.
|
||||
|
||||
* tracker.addWork(**todo**)
|
||||
|
||||
* **todo** Increase the expected overall size by **todo** bytes.
|
||||
|
||||
Increases the amount of work to be done, thus decreasing the completion
|
||||
percentage. Triggers a `change` event.
|
4
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/index.js
generated
vendored
Normal file
4
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
'use strict'
|
||||
exports.TrackerGroup = require('./tracker-group.js')
|
||||
exports.Tracker = require('./tracker.js')
|
||||
exports.TrackerStream = require('./tracker-stream.js')
|
11
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-base.js
generated
vendored
Normal file
11
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-base.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict'
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var util = require('util')
|
||||
|
||||
var trackerId = 0
|
||||
var TrackerBase = module.exports = function (name) {
|
||||
EventEmitter.call(this)
|
||||
this.id = ++trackerId
|
||||
this.name = name
|
||||
}
|
||||
util.inherits(TrackerBase, EventEmitter)
|
116
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-group.js
generated
vendored
Normal file
116
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-group.js
generated
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
'use strict'
|
||||
var util = require('util')
|
||||
var TrackerBase = require('./tracker-base.js')
|
||||
var Tracker = require('./tracker.js')
|
||||
var TrackerStream = require('./tracker-stream.js')
|
||||
|
||||
var TrackerGroup = module.exports = function (name) {
|
||||
TrackerBase.call(this, name)
|
||||
this.parentGroup = null
|
||||
this.trackers = []
|
||||
this.completion = {}
|
||||
this.weight = {}
|
||||
this.totalWeight = 0
|
||||
this.finished = false
|
||||
this.bubbleChange = bubbleChange(this)
|
||||
}
|
||||
util.inherits(TrackerGroup, TrackerBase)
|
||||
|
||||
function bubbleChange (trackerGroup) {
|
||||
return function (name, completed, tracker) {
|
||||
trackerGroup.completion[tracker.id] = completed
|
||||
if (trackerGroup.finished) {
|
||||
return
|
||||
}
|
||||
trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
|
||||
}
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.nameInTree = function () {
|
||||
var names = []
|
||||
var from = this
|
||||
while (from) {
|
||||
names.unshift(from.name)
|
||||
from = from.parentGroup
|
||||
}
|
||||
return names.join('/')
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.addUnit = function (unit, weight) {
|
||||
if (unit.addUnit) {
|
||||
var toTest = this
|
||||
while (toTest) {
|
||||
if (unit === toTest) {
|
||||
throw new Error(
|
||||
'Attempted to add tracker group ' +
|
||||
unit.name + ' to tree that already includes it ' +
|
||||
this.nameInTree(this))
|
||||
}
|
||||
toTest = toTest.parentGroup
|
||||
}
|
||||
unit.parentGroup = this
|
||||
}
|
||||
this.weight[unit.id] = weight || 1
|
||||
this.totalWeight += this.weight[unit.id]
|
||||
this.trackers.push(unit)
|
||||
this.completion[unit.id] = unit.completed()
|
||||
unit.on('change', this.bubbleChange)
|
||||
if (!this.finished) {
|
||||
this.emit('change', unit.name, this.completion[unit.id], unit)
|
||||
}
|
||||
return unit
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.completed = function () {
|
||||
if (this.trackers.length === 0) {
|
||||
return 0
|
||||
}
|
||||
var valPerWeight = 1 / this.totalWeight
|
||||
var completed = 0
|
||||
for (var ii = 0; ii < this.trackers.length; ii++) {
|
||||
var trackerId = this.trackers[ii].id
|
||||
completed +=
|
||||
valPerWeight * this.weight[trackerId] * this.completion[trackerId]
|
||||
}
|
||||
return completed
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.newGroup = function (name, weight) {
|
||||
return this.addUnit(new TrackerGroup(name), weight)
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.newItem = function (name, todo, weight) {
|
||||
return this.addUnit(new Tracker(name, todo), weight)
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.newStream = function (name, todo, weight) {
|
||||
return this.addUnit(new TrackerStream(name, todo), weight)
|
||||
}
|
||||
|
||||
TrackerGroup.prototype.finish = function () {
|
||||
this.finished = true
|
||||
if (!this.trackers.length) {
|
||||
this.addUnit(new Tracker(), 1, true)
|
||||
}
|
||||
for (var ii = 0; ii < this.trackers.length; ii++) {
|
||||
var tracker = this.trackers[ii]
|
||||
tracker.finish()
|
||||
tracker.removeListener('change', this.bubbleChange)
|
||||
}
|
||||
this.emit('change', this.name, 1, this)
|
||||
}
|
||||
|
||||
var buffer = ' '
|
||||
TrackerGroup.prototype.debug = function (depth) {
|
||||
depth = depth || 0
|
||||
var indent = depth ? buffer.substr(0, depth) : ''
|
||||
var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n'
|
||||
this.trackers.forEach(function (tracker) {
|
||||
if (tracker instanceof TrackerGroup) {
|
||||
output += tracker.debug(depth + 1)
|
||||
} else {
|
||||
output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n'
|
||||
}
|
||||
})
|
||||
return output
|
||||
}
|
36
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-stream.js
generated
vendored
Normal file
36
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker-stream.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict'
|
||||
var util = require('util')
|
||||
var stream = require('readable-stream')
|
||||
var delegate = require('delegates')
|
||||
var Tracker = require('./tracker.js')
|
||||
|
||||
var TrackerStream = module.exports = function (name, size, options) {
|
||||
stream.Transform.call(this, options)
|
||||
this.tracker = new Tracker(name, size)
|
||||
this.name = name
|
||||
this.id = this.tracker.id
|
||||
this.tracker.on('change', delegateChange(this))
|
||||
}
|
||||
util.inherits(TrackerStream, stream.Transform)
|
||||
|
||||
function delegateChange (trackerStream) {
|
||||
return function (name, completion, tracker) {
|
||||
trackerStream.emit('change', name, completion, trackerStream)
|
||||
}
|
||||
}
|
||||
|
||||
TrackerStream.prototype._transform = function (data, encoding, cb) {
|
||||
this.tracker.completeWork(data.length ? data.length : 1)
|
||||
this.push(data)
|
||||
cb()
|
||||
}
|
||||
|
||||
TrackerStream.prototype._flush = function (cb) {
|
||||
this.tracker.finish()
|
||||
cb()
|
||||
}
|
||||
|
||||
delegate(TrackerStream.prototype, 'tracker')
|
||||
.method('completed')
|
||||
.method('addWork')
|
||||
.method('finish')
|
32
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker.js
generated
vendored
Normal file
32
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/lib/tracker.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict'
|
||||
var util = require('util')
|
||||
var TrackerBase = require('./tracker-base.js')
|
||||
|
||||
var Tracker = module.exports = function (name, todo) {
|
||||
TrackerBase.call(this, name)
|
||||
this.workDone = 0
|
||||
this.workTodo = todo || 0
|
||||
}
|
||||
util.inherits(Tracker, TrackerBase)
|
||||
|
||||
Tracker.prototype.completed = function () {
|
||||
return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
|
||||
}
|
||||
|
||||
Tracker.prototype.addWork = function (work) {
|
||||
this.workTodo += work
|
||||
this.emit('change', this.name, this.completed(), this)
|
||||
}
|
||||
|
||||
Tracker.prototype.completeWork = function (work) {
|
||||
this.workDone += work
|
||||
if (this.workDone > this.workTodo) {
|
||||
this.workDone = this.workTodo
|
||||
}
|
||||
this.emit('change', this.name, this.completed(), this)
|
||||
}
|
||||
|
||||
Tracker.prototype.finish = function () {
|
||||
this.workTodo = this.workDone = 1
|
||||
this.emit('change', this.name, 1, this)
|
||||
}
|
53
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/package.json
generated
vendored
Normal file
53
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/are-we-there-yet/package.json
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "are-we-there-yet",
|
||||
"version": "2.0.0",
|
||||
"description": "Keep track of the overall completion of many disparate processes",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"npmclilint": "npmcli-lint",
|
||||
"lint": "eslint '**/*.js'",
|
||||
"lintfix": "npm run lint -- --fix",
|
||||
"posttest": "npm run lint",
|
||||
"postsnap": "npm run lintfix --",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"prepublishOnly": "git push origin --follow-tags",
|
||||
"snap": "tap"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/npm/are-we-there-yet.git"
|
||||
},
|
||||
"author": "GitHub Inc.",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/are-we-there-yet/issues"
|
||||
},
|
||||
"homepage": "https://github.com/npm/are-we-there-yet",
|
||||
"devDependencies": {
|
||||
"@npmcli/eslint-config": "^1.0.0",
|
||||
"@npmcli/template-oss": "^1.0.2",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"tap": "^15.0.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"delegates": "^1.0.0",
|
||||
"readable-stream": "^3.6.0"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"tap": {
|
||||
"branches": 68,
|
||||
"statements": 92,
|
||||
"functions": 86,
|
||||
"lines": 92
|
||||
},
|
||||
"templateVersion": "1.0.2"
|
||||
}
|
163
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/CHANGELOG.md
generated
vendored
Normal file
163
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,163 @@
|
|||
### v3.0.0
|
||||
* Drops support for Node v4, v6, v7 and v8
|
||||
|
||||
### v2.7.4
|
||||
|
||||
* Reset colors prior to ending a line, to eliminate flicker when a line
|
||||
is trucated between start and end color sequences.
|
||||
|
||||
### v2.7.3
|
||||
|
||||
* Only create our onExit handler when we're enabled and remove it when we're
|
||||
disabled. This stops us from creating multiple onExit handlers when
|
||||
multiple gauge objects are being used.
|
||||
* Fix bug where if a theme name were given instead of a theme object, it
|
||||
would crash.
|
||||
* Remove supports-color because it's not actually used. Uhm. Yes, I just
|
||||
updated it. >.>
|
||||
|
||||
### v2.7.2
|
||||
|
||||
* Use supports-color instead of has-color (as the module has been renamed)
|
||||
|
||||
### v2.7.1
|
||||
|
||||
* Bug fix: Calls to show/pulse while the progress bar is disabled should still
|
||||
update our internal representation of what would be shown should it be enabled.
|
||||
|
||||
### v2.7.0
|
||||
|
||||
* New feature: Add new `isEnabled` method to allow introspection of the gauge's
|
||||
"enabledness" as controlled by `.enable()` and `.disable()`.
|
||||
|
||||
### v2.6.0
|
||||
|
||||
* Bug fix: Don't run the code associated with `enable`/`disable` if the gauge
|
||||
is already enabled or disabled respectively. This prevents leaking event
|
||||
listeners, amongst other weirdness.
|
||||
* New feature: Template items can have default values that will be used if no
|
||||
value was otherwise passed in.
|
||||
|
||||
### v2.5.3
|
||||
|
||||
* Default to `enabled` only if we have a tty. Users can always override
|
||||
this by passing in the `enabled` option explicitly or by calling calling
|
||||
`gauge.enable()`.
|
||||
|
||||
### v2.5.2
|
||||
|
||||
* Externalized `./console-strings.js` into `console-control-strings`.
|
||||
|
||||
### v2.5.1
|
||||
|
||||
* Update to `signal-exit@3.0.0`, which fixes a compatibility bug with the
|
||||
node profiler.
|
||||
* [#39](https://github.com/iarna/gauge/pull/39) Fix tests on 0.10 and add
|
||||
a missing devDependency. ([@helloyou2012](https://github.com/helloyou2012))
|
||||
|
||||
### v2.5.0
|
||||
|
||||
* Add way to programmatically fetch a list of theme names in a themeset
|
||||
(`Themeset.getThemeNames`).
|
||||
|
||||
### v2.4.0
|
||||
|
||||
* Add support for setting themesets on existing gauge objects.
|
||||
* Add post-IO callback to `gauge.hide()` as it is somtetimes necessary when
|
||||
your terminal is interleaving output from multiple filehandles (ie, stdout
|
||||
& stderr).
|
||||
|
||||
### v2.3.1
|
||||
|
||||
* Fix a refactor bug in setTheme where it wasn't accepting the various types
|
||||
of args it should.
|
||||
|
||||
### v2.3.0
|
||||
|
||||
#### FEATURES
|
||||
|
||||
* Add setTemplate & setTheme back in.
|
||||
* Add support for named themes, you can now ask for things like 'colorASCII'
|
||||
and 'brailleSpinner'. Of course, you can still pass in theme objects.
|
||||
Additionally you can now pass in an object with `hasUnicode`, `hasColor` and
|
||||
`platform` keys in order to override our guesses as to those values when
|
||||
selecting a default theme from the themeset.
|
||||
* Make the output stream optional (it defaults to `process.stderr` now).
|
||||
* Add `setWriteTo(stream[, tty])` to change the output stream and,
|
||||
optionally, tty.
|
||||
|
||||
#### BUG FIXES & REFACTORING
|
||||
|
||||
* Abort the display phase early if we're supposed to be hidden and we are.
|
||||
* Stop printing a bunch of spaces at the end of lines, since we're already
|
||||
using an erase-to-end-of-line code anyway.
|
||||
* The unicode themes were missing the subsection separator.
|
||||
|
||||
### v2.2.1
|
||||
|
||||
* Fix image in readme
|
||||
|
||||
### v2.2.0
|
||||
|
||||
* All new themes API– reference themes by name and pass in custom themes and
|
||||
themesets (themesets get platform support autodetection done on them to
|
||||
select the best theme). Theme mixins let you add features to all existing
|
||||
themes.
|
||||
* Much, much improved test coverage.
|
||||
|
||||
### v2.1.0
|
||||
|
||||
* Got rid of ░ in the default platform, noUnicode, hasColor theme. Thanks
|
||||
to @yongtw123 for pointing out this had snuck in.
|
||||
* Fiddled with the demo output to make it easier to see the spinner spin. Also
|
||||
added prints before each platforms test output.
|
||||
* I forgot to include `signal-exit` in our deps. <.< Thank you @KenanY for
|
||||
finding this. Then I was lazy and made a new commit instead of using his
|
||||
PR. Again, thank you for your patience @KenenY.
|
||||
* Drastically speed up travis testing.
|
||||
* Add a small javascript demo (demo.js) for showing off the various themes
|
||||
(and testing them on diff platforms).
|
||||
* Change: The subsection separator from ⁄ and / (different chars) to >.
|
||||
* Fix crasher: A show or pulse without a label would cause the template renderer
|
||||
to complain about a missing value.
|
||||
* New feature: Add the ability to disable the clean-up-on-exit behavior.
|
||||
Not something I expect to be widely desirable, but important if you have
|
||||
multiple distinct gauge instances in your app.
|
||||
* Use our own color support detection.
|
||||
The `has-color` module proved too magic for my needs, making assumptions
|
||||
as to which stream we write to and reading command line arguments.
|
||||
|
||||
### v2.0.0
|
||||
|
||||
This is a major rewrite of the internals. Externally there are fewer
|
||||
changes:
|
||||
|
||||
* On node>0.8 gauge object now prints updates at a fixed rate. This means
|
||||
that when you call `show` it may wate up to `updateInterval` ms before it
|
||||
actually prints an update. You override this behavior with the
|
||||
`fixedFramerate` option.
|
||||
* The gauge object now keeps the cursor hidden as long as it's enabled and
|
||||
shown.
|
||||
* The constructor's arguments have changed, now it takes a mandatory output
|
||||
stream and an optional options object. The stream no longer needs to be
|
||||
an `ansi`ified stream, although it can be if you want (but we won't make
|
||||
use of its special features).
|
||||
* Previously the gauge was disabled by default if `process.stdout` wasn't a
|
||||
tty. Now it always defaults to enabled. If you want the previous
|
||||
behavior set the `enabled` option to `process.stdout.isTTY`.
|
||||
* The constructor's options have changed– see the docs for details.
|
||||
* Themes are entirely different. If you were using a custom theme, or
|
||||
referring to one directly (eg via `Gauge.unicode` or `Gauge.ascii`) then
|
||||
you'll need to change your code. You can get the equivalent of the latter
|
||||
with:
|
||||
```
|
||||
var themes = require('gauge/themes')
|
||||
var unicodeTheme = themes(true, true) // returns the color unicode theme for your platform
|
||||
```
|
||||
The default themes no longer use any ambiguous width characters, so even
|
||||
if you choose to display those as wide your progress bar should still
|
||||
display correctly.
|
||||
* Templates are entirely different and if you were using a custom one, you
|
||||
should consult the documentation to learn how to recreate it. If you were
|
||||
using the default, be aware that it has changed and the result looks quite
|
||||
a bit different.
|
13
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/LICENSE
generated
vendored
Normal file
13
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
Copyright (c) 2014, Rebecca Turner <me@re-becca.org>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
402
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/README.md
generated
vendored
Normal file
402
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/README.md
generated
vendored
Normal file
|
@ -0,0 +1,402 @@
|
|||
gauge
|
||||
=====
|
||||
|
||||
A nearly stateless terminal based horizontal gauge / progress bar.
|
||||
|
||||
```javascript
|
||||
var Gauge = require("gauge")
|
||||
|
||||
var gauge = new Gauge()
|
||||
|
||||
gauge.show("working…", 0)
|
||||
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.25) }, 500)
|
||||
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.50) }, 1000)
|
||||
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.75) }, 1500)
|
||||
setTimeout(() => { gauge.pulse(); gauge.show("working…", 0.99) }, 2000)
|
||||
setTimeout(() => gauge.hide(), 2300)
|
||||
```
|
||||
|
||||
See also the [demos](demo.js):
|
||||
|
||||

|
||||
|
||||
|
||||
### CHANGES FROM 1.x
|
||||
|
||||
Gauge 2.x is breaking release, please see the [changelog] for details on
|
||||
what's changed if you were previously a user of this module.
|
||||
|
||||
[changelog]: CHANGELOG.md
|
||||
|
||||
### THE GAUGE CLASS
|
||||
|
||||
This is the typical interface to the module– it provides a pretty
|
||||
fire-and-forget interface to displaying your status information.
|
||||
|
||||
```
|
||||
var Gauge = require("gauge")
|
||||
|
||||
var gauge = new Gauge([stream], [options])
|
||||
```
|
||||
|
||||
* **stream** – *(optional, default STDERR)* A stream that progress bar
|
||||
updates are to be written to. Gauge honors backpressure and will pause
|
||||
most writing if it is indicated.
|
||||
* **options** – *(optional)* An option object.
|
||||
|
||||
Constructs a new gauge. Gauges are drawn on a single line, and are not drawn
|
||||
if **stream** isn't a tty and a tty isn't explicitly provided.
|
||||
|
||||
If **stream** is a terminal or if you pass in **tty** to **options** then we
|
||||
will detect terminal resizes and redraw to fit. We do this by watching for
|
||||
`resize` events on the tty. (To work around a bug in versions of Node prior
|
||||
to 2.5.0, we watch for them on stdout if the tty is stderr.) Resizes to
|
||||
larger window sizes will be clean, but shrinking the window will always
|
||||
result in some cruft.
|
||||
|
||||
**IMPORTANT:** If you previously were passing in a non-tty stream but you still
|
||||
want output (for example, a stream wrapped by the `ansi` module) then you
|
||||
need to pass in the **tty** option below, as `gauge` needs access to
|
||||
the underlying tty in order to do things like terminal resizes and terminal
|
||||
width detection.
|
||||
|
||||
The **options** object can have the following properties, all of which are
|
||||
optional:
|
||||
|
||||
* **updateInterval**: How often gauge updates should be drawn, in milliseconds.
|
||||
* **fixedFramerate**: Defaults to false on node 0.8, true on everything
|
||||
else. When this is true a timer is created to trigger once every
|
||||
`updateInterval` ms, when false, updates are printed as soon as they come
|
||||
in but updates more often than `updateInterval` are ignored. The reason
|
||||
0.8 doesn't have this set to true is that it can't `unref` its timer and
|
||||
so it would stop your program from exiting– if you want to use this
|
||||
feature with 0.8 just make sure you call `gauge.disable()` before you
|
||||
expect your program to exit.
|
||||
* **themes**: A themeset to use when selecting the theme to use. Defaults
|
||||
to `gauge/themes`, see the [themes] documentation for details.
|
||||
* **theme**: Select a theme for use, it can be a:
|
||||
* Theme object, in which case the **themes** is not used.
|
||||
* The name of a theme, which will be looked up in the current *themes*
|
||||
object.
|
||||
* A configuration object with any of `hasUnicode`, `hasColor` or
|
||||
`platform` keys, which if will be used to override our guesses when making
|
||||
a default theme selection.
|
||||
|
||||
If no theme is selected then a default is picked using a combination of our
|
||||
best guesses at your OS, color support and unicode support.
|
||||
* **template**: Describes what you want your gauge to look like. The
|
||||
default is what npm uses. Detailed [documentation] is later in this
|
||||
document.
|
||||
* **hideCursor**: Defaults to true. If true, then the cursor will be hidden
|
||||
while the gauge is displayed.
|
||||
* **tty**: The tty that you're ultimately writing to. Defaults to the same
|
||||
as **stream**. This is used for detecting the width of the terminal and
|
||||
resizes. The width used is `tty.columns - 1`. If no tty is available then
|
||||
a width of `79` is assumed.
|
||||
* **enabled**: Defaults to true if `tty` is a TTY, false otherwise. If true
|
||||
the gauge starts enabled. If disabled then all update commands are
|
||||
ignored and no gauge will be printed until you call `.enable()`.
|
||||
* **Plumbing**: The class to use to actually generate the gauge for
|
||||
printing. This defaults to `require('gauge/plumbing')` and ordinarily you
|
||||
shouldn't need to override this.
|
||||
* **cleanupOnExit**: Defaults to true. Ordinarily we register an exit
|
||||
handler to make sure your cursor is turned back on and the progress bar
|
||||
erased when your process exits, even if you Ctrl-C out or otherwise exit
|
||||
unexpectedly. You can disable this and it won't register the exit handler.
|
||||
|
||||
[has-unicode]: https://www.npmjs.com/package/has-unicode
|
||||
[themes]: #themes
|
||||
[documentation]: #templates
|
||||
|
||||
#### `gauge.show(section | status, [completed])`
|
||||
|
||||
The first argument is either the section, the name of the current thing
|
||||
contributing to progress, or an object with keys like **section**,
|
||||
**subsection** & **completed** (or any others you have types for in a custom
|
||||
template). If you don't want to update or set any of these you can pass
|
||||
`null` and it will be ignored.
|
||||
|
||||
The second argument is the percent completed as a value between 0 and 1.
|
||||
Without it, completion is just not updated. You'll also note that completion
|
||||
can be passed in as part of a status object as the first argument. If both
|
||||
it and the completed argument are passed in, the completed argument wins.
|
||||
|
||||
#### `gauge.hide([cb])`
|
||||
|
||||
Removes the gauge from the terminal. Optionally, callback `cb` after IO has
|
||||
had an opportunity to happen (currently this just means after `setImmediate`
|
||||
has called back.)
|
||||
|
||||
It turns out this is important when you're pausing the progress bar on one
|
||||
filehandle and printing to another– otherwise (with a big enough print) node
|
||||
can end up printing the "end progress bar" bits to the progress bar filehandle
|
||||
while other stuff is printing to another filehandle. These getting interleaved
|
||||
can cause corruption in some terminals.
|
||||
|
||||
#### `gauge.pulse([subsection])`
|
||||
|
||||
* **subsection** – *(optional)* The specific thing that triggered this pulse
|
||||
|
||||
Spins the spinner in the gauge to show output. If **subsection** is
|
||||
included then it will be combined with the last name passed to `gauge.show`.
|
||||
|
||||
#### `gauge.disable()`
|
||||
|
||||
Hides the gauge and ignores further calls to `show` or `pulse`.
|
||||
|
||||
#### `gauge.enable()`
|
||||
|
||||
Shows the gauge and resumes updating when `show` or `pulse` is called.
|
||||
|
||||
#### `gauge.isEnabled()`
|
||||
|
||||
Returns true if the gauge is enabled.
|
||||
|
||||
#### `gauge.setThemeset(themes)`
|
||||
|
||||
Change the themeset to select a theme from. The same as the `themes` option
|
||||
used in the constructor. The theme will be reselected from this themeset.
|
||||
|
||||
#### `gauge.setTheme(theme)`
|
||||
|
||||
Change the active theme, will be displayed with the next show or pulse. This can be:
|
||||
|
||||
* Theme object, in which case the **themes** is not used.
|
||||
* The name of a theme, which will be looked up in the current *themes*
|
||||
object.
|
||||
* A configuration object with any of `hasUnicode`, `hasColor` or
|
||||
`platform` keys, which if will be used to override our guesses when making
|
||||
a default theme selection.
|
||||
|
||||
If no theme is selected then a default is picked using a combination of our
|
||||
best guesses at your OS, color support and unicode support.
|
||||
|
||||
#### `gauge.setTemplate(template)`
|
||||
|
||||
Change the active template, will be displayed with the next show or pulse
|
||||
|
||||
### Tracking Completion
|
||||
|
||||
If you have more than one thing going on that you want to track completion
|
||||
of, you may find the related [are-we-there-yet] helpful. It's `change`
|
||||
event can be wired up to the `show` method to get a more traditional
|
||||
progress bar interface.
|
||||
|
||||
[are-we-there-yet]: https://www.npmjs.com/package/are-we-there-yet
|
||||
|
||||
### THEMES
|
||||
|
||||
```
|
||||
var themes = require('gauge/themes')
|
||||
|
||||
// fetch the default color unicode theme for this platform
|
||||
var ourTheme = themes({hasUnicode: true, hasColor: true})
|
||||
|
||||
// fetch the default non-color unicode theme for osx
|
||||
var ourTheme = themes({hasUnicode: true, hasColor: false, platform: 'darwin'})
|
||||
|
||||
// create a new theme based on the color ascii theme for this platform
|
||||
// that brackets the progress bar with arrows
|
||||
var ourTheme = themes.newTheme(themes({hasUnicode: false, hasColor: true}), {
|
||||
preProgressbar: '→',
|
||||
postProgressbar: '←'
|
||||
})
|
||||
```
|
||||
|
||||
The object returned by `gauge/themes` is an instance of the `ThemeSet` class.
|
||||
|
||||
```
|
||||
var ThemeSet = require('gauge/theme-set')
|
||||
var themes = new ThemeSet()
|
||||
// or
|
||||
var themes = require('gauge/themes')
|
||||
var mythemes = themes.newThemeSet() // creates a new themeset based on the default themes
|
||||
```
|
||||
|
||||
#### themes(opts)
|
||||
#### themes.getDefault(opts)
|
||||
|
||||
Theme objects are a function that fetches the default theme based on
|
||||
platform, unicode and color support.
|
||||
|
||||
Options is an object with the following properties:
|
||||
|
||||
* **hasUnicode** - If true, fetch a unicode theme, if no unicode theme is
|
||||
available then a non-unicode theme will be used.
|
||||
* **hasColor** - If true, fetch a color theme, if no color theme is
|
||||
available a non-color theme will be used.
|
||||
* **platform** (optional) - Defaults to `process.platform`. If no
|
||||
platform match is available then `fallback` is used instead.
|
||||
|
||||
If no compatible theme can be found then an error will be thrown with a
|
||||
`code` of `EMISSINGTHEME`.
|
||||
|
||||
#### themes.addTheme(themeName, themeObj)
|
||||
#### themes.addTheme(themeName, [parentTheme], newTheme)
|
||||
|
||||
Adds a named theme to the themeset. You can pass in either a theme object,
|
||||
as returned by `themes.newTheme` or the arguments you'd pass to
|
||||
`themes.newTheme`.
|
||||
|
||||
#### themes.getThemeNames()
|
||||
|
||||
Return a list of all of the names of the themes in this themeset. Suitable
|
||||
for use in `themes.getTheme(…)`.
|
||||
|
||||
#### themes.getTheme(name)
|
||||
|
||||
Returns the theme object from this theme set named `name`.
|
||||
|
||||
If `name` does not exist in this themeset an error will be thrown with
|
||||
a `code` of `EMISSINGTHEME`.
|
||||
|
||||
#### themes.setDefault([opts], themeName)
|
||||
|
||||
`opts` is an object with the following properties.
|
||||
|
||||
* **platform** - Defaults to `'fallback'`. If your theme is platform
|
||||
specific, specify that here with the platform from `process.platform`, eg,
|
||||
`win32`, `darwin`, etc.
|
||||
* **hasUnicode** - Defaults to `false`. If your theme uses unicode you
|
||||
should set this to true.
|
||||
* **hasColor** - Defaults to `false`. If your theme uses color you should
|
||||
set this to true.
|
||||
|
||||
`themeName` is the name of the theme (as given to `addTheme`) to use for
|
||||
this set of `opts`.
|
||||
|
||||
#### themes.newTheme([parentTheme,] newTheme)
|
||||
|
||||
Create a new theme object based on `parentTheme`. If no `parentTheme` is
|
||||
provided then a minimal parentTheme that defines functions for rendering the
|
||||
activity indicator (spinner) and progress bar will be defined. (This
|
||||
fallback parent is defined in `gauge/base-theme`.)
|
||||
|
||||
newTheme should be a bare object– we'll start by discussing the properties
|
||||
defined by the default themes:
|
||||
|
||||
* **preProgressbar** - displayed prior to the progress bar, if the progress
|
||||
bar is displayed.
|
||||
* **postProgressbar** - displayed after the progress bar, if the progress bar
|
||||
is displayed.
|
||||
* **progressBarTheme** - The subtheme passed through to the progress bar
|
||||
renderer, it's an object with `complete` and `remaining` properties
|
||||
that are the strings you want repeated for those sections of the progress
|
||||
bar.
|
||||
* **activityIndicatorTheme** - The theme for the activity indicator (spinner),
|
||||
this can either be a string, in which each character is a different step, or
|
||||
an array of strings.
|
||||
* **preSubsection** - Displayed as a separator between the `section` and
|
||||
`subsection` when the latter is printed.
|
||||
|
||||
More generally, themes can have any value that would be a valid value when rendering
|
||||
templates. The properties in the theme are used when their name matches a type in
|
||||
the template. Their values can be:
|
||||
|
||||
* **strings & numbers** - They'll be included as is
|
||||
* **function (values, theme, width)** - Should return what you want in your output.
|
||||
*values* is an object with values provided via `gauge.show`,
|
||||
*theme* is the theme specific to this item (see below) or this theme object,
|
||||
and *width* is the number of characters wide your result should be.
|
||||
|
||||
There are a couple of special prefixes:
|
||||
|
||||
* **pre** - Is shown prior to the property, if its displayed.
|
||||
* **post** - Is shown after the property, if its displayed.
|
||||
|
||||
And one special suffix:
|
||||
|
||||
* **Theme** - Its value is passed to a function-type item as the theme.
|
||||
|
||||
#### themes.addToAllThemes(theme)
|
||||
|
||||
This *mixes-in* `theme` into all themes currently defined. It also adds it
|
||||
to the default parent theme for this themeset, so future themes added to
|
||||
this themeset will get the values from `theme` by default.
|
||||
|
||||
#### themes.newThemeSet()
|
||||
|
||||
Copy the current themeset into a new one. This allows you to easily inherit
|
||||
one themeset from another.
|
||||
|
||||
### TEMPLATES
|
||||
|
||||
A template is an array of objects and strings that, after being evaluated,
|
||||
will be turned into the gauge line. The default template is:
|
||||
|
||||
```javascript
|
||||
[
|
||||
{type: 'progressbar', length: 20},
|
||||
{type: 'activityIndicator', kerning: 1, length: 1},
|
||||
{type: 'section', kerning: 1, default: ''},
|
||||
{type: 'subsection', kerning: 1, default: ''}
|
||||
]
|
||||
```
|
||||
|
||||
The various template elements can either be **plain strings**, in which case they will
|
||||
be be included verbatum in the output, or objects with the following properties:
|
||||
|
||||
* *type* can be any of the following plus any keys you pass into `gauge.show` plus
|
||||
any keys you have on a custom theme.
|
||||
* `section` – What big thing you're working on now.
|
||||
* `subsection` – What component of that thing is currently working.
|
||||
* `activityIndicator` – Shows a spinner using the `activityIndicatorTheme`
|
||||
from your active theme.
|
||||
* `progressbar` – A progress bar representing your current `completed`
|
||||
using the `progressbarTheme` from your active theme.
|
||||
* *kerning* – Number of spaces that must be between this item and other
|
||||
items, if this item is displayed at all.
|
||||
* *maxLength* – The maximum length for this element. If its value is longer it
|
||||
will be truncated.
|
||||
* *minLength* – The minimum length for this element. If its value is shorter it
|
||||
will be padded according to the *align* value.
|
||||
* *align* – (Default: left) Possible values "left", "right" and "center". Works
|
||||
as you'd expect from word processors.
|
||||
* *length* – Provides a single value for both *minLength* and *maxLength*. If both
|
||||
*length* and *minLength or *maxLength* are specified then the latter take precedence.
|
||||
* *value* – A literal value to use for this template item.
|
||||
* *default* – A default value to use for this template item if a value
|
||||
wasn't otherwise passed in.
|
||||
|
||||
### PLUMBING
|
||||
|
||||
This is the super simple, assume nothing, do no magic internals used by gauge to
|
||||
implement its ordinary interface.
|
||||
|
||||
```
|
||||
var Plumbing = require('gauge/plumbing')
|
||||
var gauge = new Plumbing(theme, template, width)
|
||||
```
|
||||
|
||||
* **theme**: The theme to use.
|
||||
* **template**: The template to use.
|
||||
* **width**: How wide your gauge should be
|
||||
|
||||
#### `gauge.setTheme(theme)`
|
||||
|
||||
Change the active theme.
|
||||
|
||||
#### `gauge.setTemplate(template)`
|
||||
|
||||
Change the active template.
|
||||
|
||||
#### `gauge.setWidth(width)`
|
||||
|
||||
Change the width to render at.
|
||||
|
||||
#### `gauge.hide()`
|
||||
|
||||
Return the string necessary to hide the progress bar
|
||||
|
||||
#### `gauge.hideCursor()`
|
||||
|
||||
Return a string to hide the cursor.
|
||||
|
||||
#### `gauge.showCursor()`
|
||||
|
||||
Return a string to show the cursor.
|
||||
|
||||
#### `gauge.show(status)`
|
||||
|
||||
Using `status` for values, render the provided template with the theme and return
|
||||
a string that is suitable for printing to update the gauge.
|
14
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/base-theme.js
generated
vendored
Normal file
14
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/base-theme.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
'use strict'
|
||||
var spin = require('./spin.js')
|
||||
var progressBar = require('./progress-bar.js')
|
||||
|
||||
module.exports = {
|
||||
activityIndicator: function (values, theme, width) {
|
||||
if (values.spun == null) return
|
||||
return spin(theme, values.spun)
|
||||
},
|
||||
progressbar: function (values, theme, width) {
|
||||
if (values.completed == null) return
|
||||
return progressBar(theme, width, values.completed)
|
||||
}
|
||||
}
|
24
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/error.js
generated
vendored
Normal file
24
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/error.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict'
|
||||
var util = require('util')
|
||||
|
||||
var User = exports.User = function User (msg) {
|
||||
var err = new Error(msg)
|
||||
Error.captureStackTrace(err, User)
|
||||
err.code = 'EGAUGE'
|
||||
return err
|
||||
}
|
||||
|
||||
exports.MissingTemplateValue = function MissingTemplateValue (item, values) {
|
||||
var err = new User(util.format('Missing template value "%s"', item.type))
|
||||
Error.captureStackTrace(err, MissingTemplateValue)
|
||||
err.template = item
|
||||
err.values = values
|
||||
return err
|
||||
}
|
||||
|
||||
exports.Internal = function Internal (msg) {
|
||||
var err = new Error(msg)
|
||||
Error.captureStackTrace(err, Internal)
|
||||
err.code = 'EGAUGEINTERNAL'
|
||||
return err
|
||||
}
|
4
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/has-color.js
generated
vendored
Normal file
4
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/has-color.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
'use strict'
|
||||
var colorSupport = require('color-support')
|
||||
|
||||
module.exports = colorSupport().hasBasic
|
233
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/index.js
generated
vendored
Normal file
233
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/index.js
generated
vendored
Normal file
|
@ -0,0 +1,233 @@
|
|||
'use strict'
|
||||
var Plumbing = require('./plumbing.js')
|
||||
var hasUnicode = require('has-unicode')
|
||||
var hasColor = require('./has-color.js')
|
||||
var onExit = require('signal-exit')
|
||||
var defaultThemes = require('./themes')
|
||||
var setInterval = require('./set-interval.js')
|
||||
var process = require('./process.js')
|
||||
var setImmediate = require('./set-immediate')
|
||||
|
||||
module.exports = Gauge
|
||||
|
||||
function callWith (obj, method) {
|
||||
return function () {
|
||||
return method.call(obj)
|
||||
}
|
||||
}
|
||||
|
||||
function Gauge (arg1, arg2) {
|
||||
var options, writeTo
|
||||
if (arg1 && arg1.write) {
|
||||
writeTo = arg1
|
||||
options = arg2 || {}
|
||||
} else if (arg2 && arg2.write) {
|
||||
writeTo = arg2
|
||||
options = arg1 || {}
|
||||
} else {
|
||||
writeTo = process.stderr
|
||||
options = arg1 || arg2 || {}
|
||||
}
|
||||
|
||||
this._status = {
|
||||
spun: 0,
|
||||
section: '',
|
||||
subsection: ''
|
||||
}
|
||||
this._paused = false // are we paused for back pressure?
|
||||
this._disabled = true // are all progress bar updates disabled?
|
||||
this._showing = false // do we WANT the progress bar on screen
|
||||
this._onScreen = false // IS the progress bar on screen
|
||||
this._needsRedraw = false // should we print something at next tick?
|
||||
this._hideCursor = options.hideCursor == null ? true : options.hideCursor
|
||||
this._fixedFramerate = options.fixedFramerate == null
|
||||
? !(/^v0\.8\./.test(process.version))
|
||||
: options.fixedFramerate
|
||||
this._lastUpdateAt = null
|
||||
this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval
|
||||
|
||||
this._themes = options.themes || defaultThemes
|
||||
this._theme = options.theme
|
||||
var theme = this._computeTheme(options.theme)
|
||||
var template = options.template || [
|
||||
{type: 'progressbar', length: 20},
|
||||
{type: 'activityIndicator', kerning: 1, length: 1},
|
||||
{type: 'section', kerning: 1, default: ''},
|
||||
{type: 'subsection', kerning: 1, default: ''}
|
||||
]
|
||||
this.setWriteTo(writeTo, options.tty)
|
||||
var PlumbingClass = options.Plumbing || Plumbing
|
||||
this._gauge = new PlumbingClass(theme, template, this.getWidth())
|
||||
|
||||
this._$$doRedraw = callWith(this, this._doRedraw)
|
||||
this._$$handleSizeChange = callWith(this, this._handleSizeChange)
|
||||
|
||||
this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit
|
||||
this._removeOnExit = null
|
||||
|
||||
if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) {
|
||||
this.enable()
|
||||
} else {
|
||||
this.disable()
|
||||
}
|
||||
}
|
||||
Gauge.prototype = {}
|
||||
|
||||
Gauge.prototype.isEnabled = function () {
|
||||
return !this._disabled
|
||||
}
|
||||
|
||||
Gauge.prototype.setTemplate = function (template) {
|
||||
this._gauge.setTemplate(template)
|
||||
if (this._showing) this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._computeTheme = function (theme) {
|
||||
if (!theme) theme = {}
|
||||
if (typeof theme === 'string') {
|
||||
theme = this._themes.getTheme(theme)
|
||||
} else if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) {
|
||||
var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode
|
||||
var useColor = theme.hasColor == null ? hasColor : theme.hasColor
|
||||
theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform})
|
||||
}
|
||||
return theme
|
||||
}
|
||||
|
||||
Gauge.prototype.setThemeset = function (themes) {
|
||||
this._themes = themes
|
||||
this.setTheme(this._theme)
|
||||
}
|
||||
|
||||
Gauge.prototype.setTheme = function (theme) {
|
||||
this._gauge.setTheme(this._computeTheme(theme))
|
||||
if (this._showing) this._requestRedraw()
|
||||
this._theme = theme
|
||||
}
|
||||
|
||||
Gauge.prototype._requestRedraw = function () {
|
||||
this._needsRedraw = true
|
||||
if (!this._fixedFramerate) this._doRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype.getWidth = function () {
|
||||
return ((this._tty && this._tty.columns) || 80) - 1
|
||||
}
|
||||
|
||||
Gauge.prototype.setWriteTo = function (writeTo, tty) {
|
||||
var enabled = !this._disabled
|
||||
if (enabled) this.disable()
|
||||
this._writeTo = writeTo
|
||||
this._tty = tty ||
|
||||
(writeTo === process.stderr && process.stdout.isTTY && process.stdout) ||
|
||||
(writeTo.isTTY && writeTo) ||
|
||||
this._tty
|
||||
if (this._gauge) this._gauge.setWidth(this.getWidth())
|
||||
if (enabled) this.enable()
|
||||
}
|
||||
|
||||
Gauge.prototype.enable = function () {
|
||||
if (!this._disabled) return
|
||||
this._disabled = false
|
||||
if (this._tty) this._enableEvents()
|
||||
if (this._showing) this.show()
|
||||
}
|
||||
|
||||
Gauge.prototype.disable = function () {
|
||||
if (this._disabled) return
|
||||
if (this._showing) {
|
||||
this._lastUpdateAt = null
|
||||
this._showing = false
|
||||
this._doRedraw()
|
||||
this._showing = true
|
||||
}
|
||||
this._disabled = true
|
||||
if (this._tty) this._disableEvents()
|
||||
}
|
||||
|
||||
Gauge.prototype._enableEvents = function () {
|
||||
if (this._cleanupOnExit) {
|
||||
this._removeOnExit = onExit(callWith(this, this.disable))
|
||||
}
|
||||
this._tty.on('resize', this._$$handleSizeChange)
|
||||
if (this._fixedFramerate) {
|
||||
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
|
||||
if (this.redrawTracker.unref) this.redrawTracker.unref()
|
||||
}
|
||||
}
|
||||
|
||||
Gauge.prototype._disableEvents = function () {
|
||||
this._tty.removeListener('resize', this._$$handleSizeChange)
|
||||
if (this._fixedFramerate) clearInterval(this.redrawTracker)
|
||||
if (this._removeOnExit) this._removeOnExit()
|
||||
}
|
||||
|
||||
Gauge.prototype.hide = function (cb) {
|
||||
if (this._disabled) return cb && process.nextTick(cb)
|
||||
if (!this._showing) return cb && process.nextTick(cb)
|
||||
this._showing = false
|
||||
this._doRedraw()
|
||||
cb && setImmediate(cb)
|
||||
}
|
||||
|
||||
Gauge.prototype.show = function (section, completed) {
|
||||
this._showing = true
|
||||
if (typeof section === 'string') {
|
||||
this._status.section = section
|
||||
} else if (typeof section === 'object') {
|
||||
var sectionKeys = Object.keys(section)
|
||||
for (var ii = 0; ii < sectionKeys.length; ++ii) {
|
||||
var key = sectionKeys[ii]
|
||||
this._status[key] = section[key]
|
||||
}
|
||||
}
|
||||
if (completed != null) this._status.completed = completed
|
||||
if (this._disabled) return
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype.pulse = function (subsection) {
|
||||
this._status.subsection = subsection || ''
|
||||
this._status.spun++
|
||||
if (this._disabled) return
|
||||
if (!this._showing) return
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._handleSizeChange = function () {
|
||||
this._gauge.setWidth(this._tty.columns - 1)
|
||||
this._requestRedraw()
|
||||
}
|
||||
|
||||
Gauge.prototype._doRedraw = function () {
|
||||
if (this._disabled || this._paused) return
|
||||
if (!this._fixedFramerate) {
|
||||
var now = Date.now()
|
||||
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return
|
||||
this._lastUpdateAt = now
|
||||
}
|
||||
if (!this._showing && this._onScreen) {
|
||||
this._onScreen = false
|
||||
var result = this._gauge.hide()
|
||||
if (this._hideCursor) {
|
||||
result += this._gauge.showCursor()
|
||||
}
|
||||
return this._writeTo.write(result)
|
||||
}
|
||||
if (!this._showing && !this._onScreen) return
|
||||
if (this._showing && !this._onScreen) {
|
||||
this._onScreen = true
|
||||
this._needsRedraw = true
|
||||
if (this._hideCursor) {
|
||||
this._writeTo.write(this._gauge.hideCursor())
|
||||
}
|
||||
}
|
||||
if (!this._needsRedraw) return
|
||||
if (!this._writeTo.write(this._gauge.show(this._status))) {
|
||||
this._paused = true
|
||||
this._writeTo.on('drain', callWith(this, function () {
|
||||
this._paused = false
|
||||
this._doRedraw()
|
||||
}))
|
||||
}
|
||||
}
|
66
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/package.json
generated
vendored
Normal file
66
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/package.json
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"name": "gauge",
|
||||
"version": "3.0.2",
|
||||
"description": "A terminal based horizontal guage",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "standard && tap test/*.js --coverage"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/iarna/gauge"
|
||||
},
|
||||
"keywords": [
|
||||
"progressbar",
|
||||
"progress",
|
||||
"gauge"
|
||||
],
|
||||
"author": "Rebecca Turner <me@re-becca.org>",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/gauge/issues"
|
||||
},
|
||||
"homepage": "https://github.com/npm/gauge",
|
||||
"dependencies": {
|
||||
"aproba": "^1.0.3 || ^2.0.0",
|
||||
"color-support": "^1.1.2",
|
||||
"console-control-strings": "^1.0.0",
|
||||
"has-unicode": "^2.0.1",
|
||||
"object-assign": "^4.1.1",
|
||||
"signal-exit": "^3.0.0",
|
||||
"string-width": "^4.2.3",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"wide-align": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"readable-stream": "^2.0.6",
|
||||
"require-inject": "^1.4.0",
|
||||
"standard": "^11.0.1",
|
||||
"tap": "^12.0.1",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"files": [
|
||||
"base-theme.js",
|
||||
"CHANGELOG.md",
|
||||
"error.js",
|
||||
"has-color.js",
|
||||
"index.js",
|
||||
"LICENSE",
|
||||
"package.json",
|
||||
"plumbing.js",
|
||||
"process.js",
|
||||
"progress-bar.js",
|
||||
"README.md",
|
||||
"render-template.js",
|
||||
"set-immediate.js",
|
||||
"set-interval.js",
|
||||
"spin.js",
|
||||
"template-item.js",
|
||||
"theme-set.js",
|
||||
"themes.js",
|
||||
"wide-truncate.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
}
|
48
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/plumbing.js
generated
vendored
Normal file
48
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/plumbing.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
'use strict'
|
||||
var consoleControl = require('console-control-strings')
|
||||
var renderTemplate = require('./render-template.js')
|
||||
var validate = require('aproba')
|
||||
|
||||
var Plumbing = module.exports = function (theme, template, width) {
|
||||
if (!width) width = 80
|
||||
validate('OAN', [theme, template, width])
|
||||
this.showing = false
|
||||
this.theme = theme
|
||||
this.width = width
|
||||
this.template = template
|
||||
}
|
||||
Plumbing.prototype = {}
|
||||
|
||||
Plumbing.prototype.setTheme = function (theme) {
|
||||
validate('O', [theme])
|
||||
this.theme = theme
|
||||
}
|
||||
|
||||
Plumbing.prototype.setTemplate = function (template) {
|
||||
validate('A', [template])
|
||||
this.template = template
|
||||
}
|
||||
|
||||
Plumbing.prototype.setWidth = function (width) {
|
||||
validate('N', [width])
|
||||
this.width = width
|
||||
}
|
||||
|
||||
Plumbing.prototype.hide = function () {
|
||||
return consoleControl.gotoSOL() + consoleControl.eraseLine()
|
||||
}
|
||||
|
||||
Plumbing.prototype.hideCursor = consoleControl.hideCursor
|
||||
|
||||
Plumbing.prototype.showCursor = consoleControl.showCursor
|
||||
|
||||
Plumbing.prototype.show = function (status) {
|
||||
var values = Object.create(this.theme)
|
||||
for (var key in status) {
|
||||
values[key] = status[key]
|
||||
}
|
||||
|
||||
return renderTemplate(this.width, this.template, values).trim() +
|
||||
consoleControl.color('reset') +
|
||||
consoleControl.eraseLine() + consoleControl.gotoSOL()
|
||||
}
|
3
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/process.js
generated
vendored
Normal file
3
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/process.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict'
|
||||
// this exists so we can replace it during testing
|
||||
module.exports = process
|
35
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/progress-bar.js
generated
vendored
Normal file
35
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/progress-bar.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict'
|
||||
var validate = require('aproba')
|
||||
var renderTemplate = require('./render-template.js')
|
||||
var wideTruncate = require('./wide-truncate')
|
||||
var stringWidth = require('string-width')
|
||||
|
||||
module.exports = function (theme, width, completed) {
|
||||
validate('ONN', [theme, width, completed])
|
||||
if (completed < 0) completed = 0
|
||||
if (completed > 1) completed = 1
|
||||
if (width <= 0) return ''
|
||||
var sofar = Math.round(width * completed)
|
||||
var rest = width - sofar
|
||||
var template = [
|
||||
{type: 'complete', value: repeat(theme.complete, sofar), length: sofar},
|
||||
{type: 'remaining', value: repeat(theme.remaining, rest), length: rest}
|
||||
]
|
||||
return renderTemplate(width, template, theme)
|
||||
}
|
||||
|
||||
// lodash's way of repeating
|
||||
function repeat (string, width) {
|
||||
var result = ''
|
||||
var n = width
|
||||
do {
|
||||
if (n % 2) {
|
||||
result += string
|
||||
}
|
||||
n = Math.floor(n / 2)
|
||||
/* eslint no-self-assign: 0 */
|
||||
string += string
|
||||
} while (n && stringWidth(result) < width)
|
||||
|
||||
return wideTruncate(result, width)
|
||||
}
|
178
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/render-template.js
generated
vendored
Normal file
178
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/render-template.js
generated
vendored
Normal file
|
@ -0,0 +1,178 @@
|
|||
'use strict'
|
||||
var align = require('wide-align')
|
||||
var validate = require('aproba')
|
||||
var wideTruncate = require('./wide-truncate')
|
||||
var error = require('./error')
|
||||
var TemplateItem = require('./template-item')
|
||||
|
||||
function renderValueWithValues (values) {
|
||||
return function (item) {
|
||||
return renderValue(item, values)
|
||||
}
|
||||
}
|
||||
|
||||
var renderTemplate = module.exports = function (width, template, values) {
|
||||
var items = prepareItems(width, template, values)
|
||||
var rendered = items.map(renderValueWithValues(values)).join('')
|
||||
return align.left(wideTruncate(rendered, width), width)
|
||||
}
|
||||
|
||||
function preType (item) {
|
||||
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
||||
return 'pre' + cappedTypeName
|
||||
}
|
||||
|
||||
function postType (item) {
|
||||
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1)
|
||||
return 'post' + cappedTypeName
|
||||
}
|
||||
|
||||
function hasPreOrPost (item, values) {
|
||||
if (!item.type) return
|
||||
return values[preType(item)] || values[postType(item)]
|
||||
}
|
||||
|
||||
function generatePreAndPost (baseItem, parentValues) {
|
||||
var item = Object.assign({}, baseItem)
|
||||
var values = Object.create(parentValues)
|
||||
var template = []
|
||||
var pre = preType(item)
|
||||
var post = postType(item)
|
||||
if (values[pre]) {
|
||||
template.push({value: values[pre]})
|
||||
values[pre] = null
|
||||
}
|
||||
item.minLength = null
|
||||
item.length = null
|
||||
item.maxLength = null
|
||||
template.push(item)
|
||||
values[item.type] = values[item.type]
|
||||
if (values[post]) {
|
||||
template.push({value: values[post]})
|
||||
values[post] = null
|
||||
}
|
||||
return function ($1, $2, length) {
|
||||
return renderTemplate(length, template, values)
|
||||
}
|
||||
}
|
||||
|
||||
function prepareItems (width, template, values) {
|
||||
function cloneAndObjectify (item, index, arr) {
|
||||
var cloned = new TemplateItem(item, width)
|
||||
var type = cloned.type
|
||||
if (cloned.value == null) {
|
||||
if (!(type in values)) {
|
||||
if (cloned.default == null) {
|
||||
throw new error.MissingTemplateValue(cloned, values)
|
||||
} else {
|
||||
cloned.value = cloned.default
|
||||
}
|
||||
} else {
|
||||
cloned.value = values[type]
|
||||
}
|
||||
}
|
||||
if (cloned.value == null || cloned.value === '') return null
|
||||
cloned.index = index
|
||||
cloned.first = index === 0
|
||||
cloned.last = index === arr.length - 1
|
||||
if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values)
|
||||
return cloned
|
||||
}
|
||||
|
||||
var output = template.map(cloneAndObjectify).filter(function (item) { return item != null })
|
||||
|
||||
var remainingSpace = width
|
||||
var variableCount = output.length
|
||||
|
||||
function consumeSpace (length) {
|
||||
if (length > remainingSpace) length = remainingSpace
|
||||
remainingSpace -= length
|
||||
}
|
||||
|
||||
function finishSizing (item, length) {
|
||||
if (item.finished) throw new error.Internal('Tried to finish template item that was already finished')
|
||||
if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity')
|
||||
if (length != null) item.length = length
|
||||
item.minLength = null
|
||||
item.maxLength = null
|
||||
--variableCount
|
||||
item.finished = true
|
||||
if (item.length == null) item.length = item.getBaseLength()
|
||||
if (item.length == null) throw new error.Internal('Finished template items must have a length')
|
||||
consumeSpace(item.getLength())
|
||||
}
|
||||
|
||||
output.forEach(function (item) {
|
||||
if (!item.kerning) return
|
||||
var prevPadRight = item.first ? 0 : output[item.index - 1].padRight
|
||||
if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight
|
||||
if (!item.last) item.padRight = item.kerning
|
||||
})
|
||||
|
||||
// Finish any that have a fixed (literal or intuited) length
|
||||
output.forEach(function (item) {
|
||||
if (item.getBaseLength() == null) return
|
||||
finishSizing(item)
|
||||
})
|
||||
|
||||
var resized = 0
|
||||
var resizing
|
||||
var hunkSize
|
||||
do {
|
||||
resizing = false
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
if (!item.maxLength) return
|
||||
if (item.getMaxLength() < hunkSize) {
|
||||
finishSizing(item, item.maxLength)
|
||||
resizing = true
|
||||
}
|
||||
})
|
||||
} while (resizing && resized++ < output.length)
|
||||
if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength')
|
||||
|
||||
resized = 0
|
||||
do {
|
||||
resizing = false
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
if (!item.minLength) return
|
||||
if (item.getMinLength() >= hunkSize) {
|
||||
finishSizing(item, item.minLength)
|
||||
resizing = true
|
||||
}
|
||||
})
|
||||
} while (resizing && resized++ < output.length)
|
||||
if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength')
|
||||
|
||||
hunkSize = Math.round(remainingSpace / variableCount)
|
||||
output.forEach(function (item) {
|
||||
if (item.finished) return
|
||||
finishSizing(item, hunkSize)
|
||||
})
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
function renderFunction (item, values, length) {
|
||||
validate('OON', arguments)
|
||||
if (item.type) {
|
||||
return item.value(values, values[item.type + 'Theme'] || {}, length)
|
||||
} else {
|
||||
return item.value(values, {}, length)
|
||||
}
|
||||
}
|
||||
|
||||
function renderValue (item, values) {
|
||||
var length = item.getBaseLength()
|
||||
var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value
|
||||
if (value == null || value === '') return ''
|
||||
var alignWith = align[item.align] || align.left
|
||||
var leftPadding = item.padLeft ? align.left('', item.padLeft) : ''
|
||||
var rightPadding = item.padRight ? align.right('', item.padRight) : ''
|
||||
var truncated = wideTruncate(String(value), length)
|
||||
var aligned = alignWith(truncated, length)
|
||||
return leftPadding + aligned + rightPadding
|
||||
}
|
7
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/set-immediate.js
generated
vendored
Normal file
7
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/set-immediate.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict'
|
||||
var process = require('./process')
|
||||
try {
|
||||
module.exports = setImmediate
|
||||
} catch (ex) {
|
||||
module.exports = process.nextTick
|
||||
}
|
3
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/set-interval.js
generated
vendored
Normal file
3
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/set-interval.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
'use strict'
|
||||
// this exists so we can replace it during testing
|
||||
module.exports = setInterval
|
5
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/spin.js
generated
vendored
Normal file
5
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/spin.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = function spin (spinstr, spun) {
|
||||
return spinstr[spun % spinstr.length]
|
||||
}
|
72
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/template-item.js
generated
vendored
Normal file
72
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/template-item.js
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
'use strict'
|
||||
var stringWidth = require('string-width')
|
||||
|
||||
module.exports = TemplateItem
|
||||
|
||||
function isPercent (num) {
|
||||
if (typeof num !== 'string') return false
|
||||
return num.slice(-1) === '%'
|
||||
}
|
||||
|
||||
function percent (num) {
|
||||
return Number(num.slice(0, -1)) / 100
|
||||
}
|
||||
|
||||
function TemplateItem (values, outputLength) {
|
||||
this.overallOutputLength = outputLength
|
||||
this.finished = false
|
||||
this.type = null
|
||||
this.value = null
|
||||
this.length = null
|
||||
this.maxLength = null
|
||||
this.minLength = null
|
||||
this.kerning = null
|
||||
this.align = 'left'
|
||||
this.padLeft = 0
|
||||
this.padRight = 0
|
||||
this.index = null
|
||||
this.first = null
|
||||
this.last = null
|
||||
if (typeof values === 'string') {
|
||||
this.value = values
|
||||
} else {
|
||||
for (var prop in values) this[prop] = values[prop]
|
||||
}
|
||||
// Realize percents
|
||||
if (isPercent(this.length)) {
|
||||
this.length = Math.round(this.overallOutputLength * percent(this.length))
|
||||
}
|
||||
if (isPercent(this.minLength)) {
|
||||
this.minLength = Math.round(this.overallOutputLength * percent(this.minLength))
|
||||
}
|
||||
if (isPercent(this.maxLength)) {
|
||||
this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength))
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
TemplateItem.prototype = {}
|
||||
|
||||
TemplateItem.prototype.getBaseLength = function () {
|
||||
var length = this.length
|
||||
if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) {
|
||||
length = stringWidth(this.value)
|
||||
}
|
||||
return length
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getLength = function () {
|
||||
var length = this.getBaseLength()
|
||||
if (length == null) return null
|
||||
return length + this.padLeft + this.padRight
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getMaxLength = function () {
|
||||
if (this.maxLength == null) return null
|
||||
return this.maxLength + this.padLeft + this.padRight
|
||||
}
|
||||
|
||||
TemplateItem.prototype.getMinLength = function () {
|
||||
if (this.minLength == null) return null
|
||||
return this.minLength + this.padLeft + this.padRight
|
||||
}
|
114
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/theme-set.js
generated
vendored
Normal file
114
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/theme-set.js
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
'use strict'
|
||||
var objectAssign = require('object-assign')
|
||||
|
||||
module.exports = function () {
|
||||
return ThemeSetProto.newThemeSet()
|
||||
}
|
||||
|
||||
var ThemeSetProto = {}
|
||||
|
||||
ThemeSetProto.baseTheme = require('./base-theme.js')
|
||||
|
||||
ThemeSetProto.newTheme = function (parent, theme) {
|
||||
if (!theme) {
|
||||
theme = parent
|
||||
parent = this.baseTheme
|
||||
}
|
||||
return objectAssign({}, parent, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.getThemeNames = function () {
|
||||
return Object.keys(this.themes)
|
||||
}
|
||||
|
||||
ThemeSetProto.addTheme = function (name, parent, theme) {
|
||||
this.themes[name] = this.newTheme(parent, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.addToAllThemes = function (theme) {
|
||||
var themes = this.themes
|
||||
Object.keys(themes).forEach(function (name) {
|
||||
objectAssign(themes[name], theme)
|
||||
})
|
||||
objectAssign(this.baseTheme, theme)
|
||||
}
|
||||
|
||||
ThemeSetProto.getTheme = function (name) {
|
||||
if (!this.themes[name]) throw this.newMissingThemeError(name)
|
||||
return this.themes[name]
|
||||
}
|
||||
|
||||
ThemeSetProto.setDefault = function (opts, name) {
|
||||
if (name == null) {
|
||||
name = opts
|
||||
opts = {}
|
||||
}
|
||||
var platform = opts.platform == null ? 'fallback' : opts.platform
|
||||
var hasUnicode = !!opts.hasUnicode
|
||||
var hasColor = !!opts.hasColor
|
||||
if (!this.defaults[platform]) this.defaults[platform] = {true: {}, false: {}}
|
||||
this.defaults[platform][hasUnicode][hasColor] = name
|
||||
}
|
||||
|
||||
ThemeSetProto.getDefault = function (opts) {
|
||||
if (!opts) opts = {}
|
||||
var platformName = opts.platform || process.platform
|
||||
var platform = this.defaults[platformName] || this.defaults.fallback
|
||||
var hasUnicode = !!opts.hasUnicode
|
||||
var hasColor = !!opts.hasColor
|
||||
if (!platform) throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor)
|
||||
if (!platform[hasUnicode][hasColor]) {
|
||||
if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) {
|
||||
hasUnicode = false
|
||||
} else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) {
|
||||
hasColor = false
|
||||
} else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) {
|
||||
hasUnicode = false
|
||||
hasColor = false
|
||||
} else if (hasUnicode && !hasColor && platform[!hasUnicode][hasColor]) {
|
||||
hasUnicode = false
|
||||
} else if (!hasUnicode && hasColor && platform[hasUnicode][!hasColor]) {
|
||||
hasColor = false
|
||||
} else if (platform === this.defaults.fallback) {
|
||||
throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor)
|
||||
}
|
||||
}
|
||||
if (platform[hasUnicode][hasColor]) {
|
||||
return this.getTheme(platform[hasUnicode][hasColor])
|
||||
} else {
|
||||
return this.getDefault(objectAssign({}, opts, {platform: 'fallback'}))
|
||||
}
|
||||
}
|
||||
|
||||
ThemeSetProto.newMissingThemeError = function newMissingThemeError (name) {
|
||||
var err = new Error('Could not find a gauge theme named "' + name + '"')
|
||||
Error.captureStackTrace.call(err, newMissingThemeError)
|
||||
err.theme = name
|
||||
err.code = 'EMISSINGTHEME'
|
||||
return err
|
||||
}
|
||||
|
||||
ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError (platformName, hasUnicode, hasColor) {
|
||||
var err = new Error(
|
||||
'Could not find a gauge theme for your platform/unicode/color use combo:\n' +
|
||||
' platform = ' + platformName + '\n' +
|
||||
' hasUnicode = ' + hasUnicode + '\n' +
|
||||
' hasColor = ' + hasColor)
|
||||
Error.captureStackTrace.call(err, newMissingDefaultThemeError)
|
||||
err.platform = platformName
|
||||
err.hasUnicode = hasUnicode
|
||||
err.hasColor = hasColor
|
||||
err.code = 'EMISSINGTHEME'
|
||||
return err
|
||||
}
|
||||
|
||||
ThemeSetProto.newThemeSet = function () {
|
||||
var themeset = function (opts) {
|
||||
return themeset.getDefault(opts)
|
||||
}
|
||||
return objectAssign(themeset, ThemeSetProto, {
|
||||
themes: objectAssign({}, this.themes),
|
||||
baseTheme: objectAssign({}, this.baseTheme),
|
||||
defaults: JSON.parse(JSON.stringify(this.defaults || {}))
|
||||
})
|
||||
}
|
56
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/themes.js
generated
vendored
Normal file
56
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/themes.js
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
'use strict'
|
||||
var color = require('console-control-strings').color
|
||||
var ThemeSet = require('./theme-set.js')
|
||||
|
||||
var themes = module.exports = new ThemeSet()
|
||||
|
||||
themes.addTheme('ASCII', {
|
||||
preProgressbar: '[',
|
||||
postProgressbar: ']',
|
||||
progressbarTheme: {
|
||||
complete: '#',
|
||||
remaining: '.'
|
||||
},
|
||||
activityIndicatorTheme: '-\\|/',
|
||||
preSubsection: '>'
|
||||
})
|
||||
|
||||
themes.addTheme('colorASCII', themes.getTheme('ASCII'), {
|
||||
progressbarTheme: {
|
||||
preComplete: color('bgBrightWhite', 'brightWhite'),
|
||||
complete: '#',
|
||||
postComplete: color('reset'),
|
||||
preRemaining: color('bgBrightBlack', 'brightBlack'),
|
||||
remaining: '.',
|
||||
postRemaining: color('reset')
|
||||
}
|
||||
})
|
||||
|
||||
themes.addTheme('brailleSpinner', {
|
||||
preProgressbar: '⸨',
|
||||
postProgressbar: '⸩',
|
||||
progressbarTheme: {
|
||||
complete: '#',
|
||||
remaining: '⠂'
|
||||
},
|
||||
activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏',
|
||||
preSubsection: '>'
|
||||
})
|
||||
|
||||
themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), {
|
||||
progressbarTheme: {
|
||||
preComplete: color('bgBrightWhite', 'brightWhite'),
|
||||
complete: '#',
|
||||
postComplete: color('reset'),
|
||||
preRemaining: color('bgBrightBlack', 'brightBlack'),
|
||||
remaining: '⠂',
|
||||
postRemaining: color('reset')
|
||||
}
|
||||
})
|
||||
|
||||
themes.setDefault({}, 'ASCII')
|
||||
themes.setDefault({hasColor: true}, 'colorASCII')
|
||||
themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner')
|
||||
themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner')
|
||||
themes.setDefault({platform: 'linux', hasUnicode: true}, 'brailleSpinner')
|
||||
themes.setDefault({platform: 'linux', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner')
|
25
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/wide-truncate.js
generated
vendored
Normal file
25
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/gauge/wide-truncate.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict'
|
||||
var stringWidth = require('string-width')
|
||||
var stripAnsi = require('strip-ansi')
|
||||
|
||||
module.exports = wideTruncate
|
||||
|
||||
function wideTruncate (str, target) {
|
||||
if (stringWidth(str) === 0) return str
|
||||
if (target <= 0) return ''
|
||||
if (stringWidth(str) <= target) return str
|
||||
|
||||
// We compute the number of bytes of ansi sequences here and add
|
||||
// that to our initial truncation to ensure that we don't slice one
|
||||
// that we want to keep in half.
|
||||
var noAnsi = stripAnsi(str)
|
||||
var ansiSize = str.length + noAnsi.length
|
||||
var truncated = str.slice(0, target + ansiSize)
|
||||
|
||||
// we have to shrink the result to account for our ansi sequence buffer
|
||||
// (if an ansi sequence was truncated) and double width characters.
|
||||
while (stringWidth(truncated) > target) {
|
||||
truncated = truncated.slice(0, -1)
|
||||
}
|
||||
return truncated
|
||||
}
|
15
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/LICENSE
generated
vendored
Normal file
15
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
216
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/README.md
generated
vendored
Normal file
216
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/README.md
generated
vendored
Normal file
|
@ -0,0 +1,216 @@
|
|||
# npmlog
|
||||
|
||||
The logger util that npm uses.
|
||||
|
||||
This logger is very basic. It does the logging for npm. It supports
|
||||
custom levels and colored output.
|
||||
|
||||
By default, logs are written to stderr. If you want to send log messages
|
||||
to outputs other than streams, then you can change the `log.stream`
|
||||
member, or you can just listen to the events that it emits, and do
|
||||
whatever you want with them.
|
||||
|
||||
# Installation
|
||||
|
||||
```console
|
||||
npm install npmlog --save
|
||||
```
|
||||
|
||||
# Basic Usage
|
||||
|
||||
```javascript
|
||||
var log = require('npmlog')
|
||||
|
||||
// additional stuff ---------------------------+
|
||||
// message ----------+ |
|
||||
// prefix ----+ | |
|
||||
// level -+ | | |
|
||||
// v v v v
|
||||
log.info('fyi', 'I have a kitty cat: %j', myKittyCat)
|
||||
```
|
||||
|
||||
## log.level
|
||||
|
||||
* {String}
|
||||
|
||||
The level to display logs at. Any logs at or above this level will be
|
||||
displayed. The special level `silent` will prevent anything from being
|
||||
displayed ever.
|
||||
|
||||
## log.record
|
||||
|
||||
* {Array}
|
||||
|
||||
An array of all the log messages that have been entered.
|
||||
|
||||
## log.maxRecordSize
|
||||
|
||||
* {Number}
|
||||
|
||||
The maximum number of records to keep. If log.record gets bigger than
|
||||
10% over this value, then it is sliced down to 90% of this value.
|
||||
|
||||
The reason for the 10% window is so that it doesn't have to resize a
|
||||
large array on every log entry.
|
||||
|
||||
## log.prefixStyle
|
||||
|
||||
* {Object}
|
||||
|
||||
A style object that specifies how prefixes are styled. (See below)
|
||||
|
||||
## log.headingStyle
|
||||
|
||||
* {Object}
|
||||
|
||||
A style object that specifies how the heading is styled. (See below)
|
||||
|
||||
## log.heading
|
||||
|
||||
* {String} Default: ""
|
||||
|
||||
If set, a heading that is printed at the start of every line.
|
||||
|
||||
## log.stream
|
||||
|
||||
* {Stream} Default: `process.stderr`
|
||||
|
||||
The stream where output is written.
|
||||
|
||||
## log.enableColor()
|
||||
|
||||
Force colors to be used on all messages, regardless of the output
|
||||
stream.
|
||||
|
||||
## log.disableColor()
|
||||
|
||||
Disable colors on all messages.
|
||||
|
||||
## log.enableProgress()
|
||||
|
||||
Enable the display of log activity spinner and progress bar
|
||||
|
||||
## log.disableProgress()
|
||||
|
||||
Disable the display of a progress bar
|
||||
|
||||
## log.enableUnicode()
|
||||
|
||||
Force the unicode theme to be used for the progress bar.
|
||||
|
||||
## log.disableUnicode()
|
||||
|
||||
Disable the use of unicode in the progress bar.
|
||||
|
||||
## log.setGaugeTemplate(template)
|
||||
|
||||
Set a template for outputting the progress bar. See the [gauge documentation] for details.
|
||||
|
||||
[gauge documentation]: https://npmjs.com/package/gauge
|
||||
|
||||
## log.setGaugeThemeset(themes)
|
||||
|
||||
Select a themeset to pick themes from for the progress bar. See the [gauge documentation] for details.
|
||||
|
||||
## log.pause()
|
||||
|
||||
Stop emitting messages to the stream, but do not drop them.
|
||||
|
||||
## log.resume()
|
||||
|
||||
Emit all buffered messages that were written while paused.
|
||||
|
||||
## log.log(level, prefix, message, ...)
|
||||
|
||||
* `level` {String} The level to emit the message at
|
||||
* `prefix` {String} A string prefix. Set to "" to skip.
|
||||
* `message...` Arguments to `util.format`
|
||||
|
||||
Emit a log message at the specified level.
|
||||
|
||||
## log\[level](prefix, message, ...)
|
||||
|
||||
For example,
|
||||
|
||||
* log.silly(prefix, message, ...)
|
||||
* log.verbose(prefix, message, ...)
|
||||
* log.info(prefix, message, ...)
|
||||
* log.http(prefix, message, ...)
|
||||
* log.warn(prefix, message, ...)
|
||||
* log.error(prefix, message, ...)
|
||||
|
||||
Like `log.log(level, prefix, message, ...)`. In this way, each level is
|
||||
given a shorthand, so you can do `log.info(prefix, message)`.
|
||||
|
||||
## log.addLevel(level, n, style, disp)
|
||||
|
||||
* `level` {String} Level indicator
|
||||
* `n` {Number} The numeric level
|
||||
* `style` {Object} Object with fg, bg, inverse, etc.
|
||||
* `disp` {String} Optional replacement for `level` in the output.
|
||||
|
||||
Sets up a new level with a shorthand function and so forth.
|
||||
|
||||
Note that if the number is `Infinity`, then setting the level to that
|
||||
will cause all log messages to be suppressed. If the number is
|
||||
`-Infinity`, then the only way to show it is to enable all log messages.
|
||||
|
||||
## log.newItem(name, todo, weight)
|
||||
|
||||
* `name` {String} Optional; progress item name.
|
||||
* `todo` {Number} Optional; total amount of work to be done. Default 0.
|
||||
* `weight` {Number} Optional; the weight of this item relative to others. Default 1.
|
||||
|
||||
This adds a new `are-we-there-yet` item tracker to the progress tracker. The
|
||||
object returned has the `log[level]` methods but is otherwise an
|
||||
`are-we-there-yet` `Tracker` object.
|
||||
|
||||
## log.newStream(name, todo, weight)
|
||||
|
||||
This adds a new `are-we-there-yet` stream tracker to the progress tracker. The
|
||||
object returned has the `log[level]` methods but is otherwise an
|
||||
`are-we-there-yet` `TrackerStream` object.
|
||||
|
||||
## log.newGroup(name, weight)
|
||||
|
||||
This adds a new `are-we-there-yet` tracker group to the progress tracker. The
|
||||
object returned has the `log[level]` methods but is otherwise an
|
||||
`are-we-there-yet` `TrackerGroup` object.
|
||||
|
||||
# Events
|
||||
|
||||
Events are all emitted with the message object.
|
||||
|
||||
* `log` Emitted for all messages
|
||||
* `log.<level>` Emitted for all messages with the `<level>` level.
|
||||
* `<prefix>` Messages with prefixes also emit their prefix as an event.
|
||||
|
||||
# Style Objects
|
||||
|
||||
Style objects can have the following fields:
|
||||
|
||||
* `fg` {String} Color for the foreground text
|
||||
* `bg` {String} Color for the background
|
||||
* `bold`, `inverse`, `underline` {Boolean} Set the associated property
|
||||
* `bell` {Boolean} Make a noise (This is pretty annoying, probably.)
|
||||
|
||||
# Message Objects
|
||||
|
||||
Every log event is emitted with a message object, and the `log.record`
|
||||
list contains all of them that have been created. They have the
|
||||
following fields:
|
||||
|
||||
* `id` {Number}
|
||||
* `level` {String}
|
||||
* `prefix` {String}
|
||||
* `message` {String} Result of `util.format()`
|
||||
* `messageRaw` {Array} Arguments to `util.format()`
|
||||
|
||||
# Blocking TTYs
|
||||
|
||||
We use [`set-blocking`](https://npmjs.com/package/set-blocking) to set
|
||||
stderr and stdout blocking if they are tty's and have the setBlocking call.
|
||||
This is a work around for an issue in early versions of Node.js 6.x, which
|
||||
made stderr and stdout non-blocking on OSX. (They are always blocking
|
||||
Windows and were never blocking on Linux.) `npmlog` needs them to be blocking
|
||||
so that it can allow output to stdout and stderr to be interlaced.
|
403
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/log.js
generated
vendored
Normal file
403
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/log.js
generated
vendored
Normal file
|
@ -0,0 +1,403 @@
|
|||
'use strict'
|
||||
var Progress = require('are-we-there-yet')
|
||||
var Gauge = require('gauge')
|
||||
var EE = require('events').EventEmitter
|
||||
var log = exports = module.exports = new EE()
|
||||
var util = require('util')
|
||||
|
||||
var setBlocking = require('set-blocking')
|
||||
var consoleControl = require('console-control-strings')
|
||||
|
||||
setBlocking(true)
|
||||
var stream = process.stderr
|
||||
Object.defineProperty(log, 'stream', {
|
||||
set: function (newStream) {
|
||||
stream = newStream
|
||||
if (this.gauge) {
|
||||
this.gauge.setWriteTo(stream, stream)
|
||||
}
|
||||
},
|
||||
get: function () {
|
||||
return stream
|
||||
},
|
||||
})
|
||||
|
||||
// by default, decide based on tty-ness.
|
||||
var colorEnabled
|
||||
log.useColor = function () {
|
||||
return colorEnabled != null ? colorEnabled : stream.isTTY
|
||||
}
|
||||
|
||||
log.enableColor = function () {
|
||||
colorEnabled = true
|
||||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled})
|
||||
}
|
||||
log.disableColor = function () {
|
||||
colorEnabled = false
|
||||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled})
|
||||
}
|
||||
|
||||
// default level
|
||||
log.level = 'info'
|
||||
|
||||
log.gauge = new Gauge(stream, {
|
||||
enabled: false, // no progress bars unless asked
|
||||
theme: {hasColor: log.useColor()},
|
||||
template: [
|
||||
{type: 'progressbar', length: 20},
|
||||
{type: 'activityIndicator', kerning: 1, length: 1},
|
||||
{type: 'section', default: ''},
|
||||
':',
|
||||
{type: 'logline', kerning: 1, default: ''},
|
||||
],
|
||||
})
|
||||
|
||||
log.tracker = new Progress.TrackerGroup()
|
||||
|
||||
// we track this separately as we may need to temporarily disable the
|
||||
// display of the status bar for our own loggy purposes.
|
||||
log.progressEnabled = log.gauge.isEnabled()
|
||||
|
||||
var unicodeEnabled
|
||||
|
||||
log.enableUnicode = function () {
|
||||
unicodeEnabled = true
|
||||
this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled})
|
||||
}
|
||||
|
||||
log.disableUnicode = function () {
|
||||
unicodeEnabled = false
|
||||
this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled})
|
||||
}
|
||||
|
||||
log.setGaugeThemeset = function (themes) {
|
||||
this.gauge.setThemeset(themes)
|
||||
}
|
||||
|
||||
log.setGaugeTemplate = function (template) {
|
||||
this.gauge.setTemplate(template)
|
||||
}
|
||||
|
||||
log.enableProgress = function () {
|
||||
if (this.progressEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
this.progressEnabled = true
|
||||
this.tracker.on('change', this.showProgress)
|
||||
if (this._paused) {
|
||||
return
|
||||
}
|
||||
|
||||
this.gauge.enable()
|
||||
}
|
||||
|
||||
log.disableProgress = function () {
|
||||
if (!this.progressEnabled) {
|
||||
return
|
||||
}
|
||||
this.progressEnabled = false
|
||||
this.tracker.removeListener('change', this.showProgress)
|
||||
this.gauge.disable()
|
||||
}
|
||||
|
||||
var trackerConstructors = ['newGroup', 'newItem', 'newStream']
|
||||
|
||||
var mixinLog = function (tracker) {
|
||||
// mixin the public methods from log into the tracker
|
||||
// (except: conflicts and one's we handle specially)
|
||||
Object.keys(log).forEach(function (P) {
|
||||
if (P[0] === '_') {
|
||||
return
|
||||
}
|
||||
|
||||
if (trackerConstructors.filter(function (C) {
|
||||
return C === P
|
||||
}).length) {
|
||||
return
|
||||
}
|
||||
|
||||
if (tracker[P]) {
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof log[P] !== 'function') {
|
||||
return
|
||||
}
|
||||
|
||||
var func = log[P]
|
||||
tracker[P] = function () {
|
||||
return func.apply(log, arguments)
|
||||
}
|
||||
})
|
||||
// if the new tracker is a group, make sure any subtrackers get
|
||||
// mixed in too
|
||||
if (tracker instanceof Progress.TrackerGroup) {
|
||||
trackerConstructors.forEach(function (C) {
|
||||
var func = tracker[C]
|
||||
tracker[C] = function () {
|
||||
return mixinLog(func.apply(tracker, arguments))
|
||||
}
|
||||
})
|
||||
}
|
||||
return tracker
|
||||
}
|
||||
|
||||
// Add tracker constructors to the top level log object
|
||||
trackerConstructors.forEach(function (C) {
|
||||
log[C] = function () {
|
||||
return mixinLog(this.tracker[C].apply(this.tracker, arguments))
|
||||
}
|
||||
})
|
||||
|
||||
log.clearProgress = function (cb) {
|
||||
if (!this.progressEnabled) {
|
||||
return cb && process.nextTick(cb)
|
||||
}
|
||||
|
||||
this.gauge.hide(cb)
|
||||
}
|
||||
|
||||
log.showProgress = function (name, completed) {
|
||||
if (!this.progressEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
var values = {}
|
||||
if (name) {
|
||||
values.section = name
|
||||
}
|
||||
|
||||
var last = log.record[log.record.length - 1]
|
||||
if (last) {
|
||||
values.subsection = last.prefix
|
||||
var disp = log.disp[last.level] || last.level
|
||||
var logline = this._format(disp, log.style[last.level])
|
||||
if (last.prefix) {
|
||||
logline += ' ' + this._format(last.prefix, this.prefixStyle)
|
||||
}
|
||||
|
||||
logline += ' ' + last.message.split(/\r?\n/)[0]
|
||||
values.logline = logline
|
||||
}
|
||||
values.completed = completed || this.tracker.completed()
|
||||
this.gauge.show(values)
|
||||
}.bind(log) // bind for use in tracker's on-change listener
|
||||
|
||||
// temporarily stop emitting, but don't drop
|
||||
log.pause = function () {
|
||||
this._paused = true
|
||||
if (this.progressEnabled) {
|
||||
this.gauge.disable()
|
||||
}
|
||||
}
|
||||
|
||||
log.resume = function () {
|
||||
if (!this._paused) {
|
||||
return
|
||||
}
|
||||
|
||||
this._paused = false
|
||||
|
||||
var b = this._buffer
|
||||
this._buffer = []
|
||||
b.forEach(function (m) {
|
||||
this.emitLog(m)
|
||||
}, this)
|
||||
if (this.progressEnabled) {
|
||||
this.gauge.enable()
|
||||
}
|
||||
}
|
||||
|
||||
log._buffer = []
|
||||
|
||||
var id = 0
|
||||
log.record = []
|
||||
log.maxRecordSize = 10000
|
||||
log.log = function (lvl, prefix, message) {
|
||||
var l = this.levels[lvl]
|
||||
if (l === undefined) {
|
||||
return this.emit('error', new Error(util.format(
|
||||
'Undefined log level: %j', lvl)))
|
||||
}
|
||||
|
||||
var a = new Array(arguments.length - 2)
|
||||
var stack = null
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var arg = a[i - 2] = arguments[i]
|
||||
|
||||
// resolve stack traces to a plain string.
|
||||
if (typeof arg === 'object' && arg instanceof Error && arg.stack) {
|
||||
Object.defineProperty(arg, 'stack', {
|
||||
value: stack = arg.stack + '',
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
if (stack) {
|
||||
a.unshift(stack + '\n')
|
||||
}
|
||||
message = util.format.apply(util, a)
|
||||
|
||||
var m = {
|
||||
id: id++,
|
||||
level: lvl,
|
||||
prefix: String(prefix || ''),
|
||||
message: message,
|
||||
messageRaw: a,
|
||||
}
|
||||
|
||||
this.emit('log', m)
|
||||
this.emit('log.' + lvl, m)
|
||||
if (m.prefix) {
|
||||
this.emit(m.prefix, m)
|
||||
}
|
||||
|
||||
this.record.push(m)
|
||||
var mrs = this.maxRecordSize
|
||||
var n = this.record.length - mrs
|
||||
if (n > mrs / 10) {
|
||||
var newSize = Math.floor(mrs * 0.9)
|
||||
this.record = this.record.slice(-1 * newSize)
|
||||
}
|
||||
|
||||
this.emitLog(m)
|
||||
}.bind(log)
|
||||
|
||||
log.emitLog = function (m) {
|
||||
if (this._paused) {
|
||||
this._buffer.push(m)
|
||||
return
|
||||
}
|
||||
if (this.progressEnabled) {
|
||||
this.gauge.pulse(m.prefix)
|
||||
}
|
||||
|
||||
var l = this.levels[m.level]
|
||||
if (l === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (l < this.levels[this.level]) {
|
||||
return
|
||||
}
|
||||
|
||||
if (l > 0 && !isFinite(l)) {
|
||||
return
|
||||
}
|
||||
|
||||
// If 'disp' is null or undefined, use the lvl as a default
|
||||
// Allows: '', 0 as valid disp
|
||||
var disp = log.disp[m.level] != null ? log.disp[m.level] : m.level
|
||||
this.clearProgress()
|
||||
m.message.split(/\r?\n/).forEach(function (line) {
|
||||
if (this.heading) {
|
||||
this.write(this.heading, this.headingStyle)
|
||||
this.write(' ')
|
||||
}
|
||||
this.write(disp, log.style[m.level])
|
||||
var p = m.prefix || ''
|
||||
if (p) {
|
||||
this.write(' ')
|
||||
}
|
||||
|
||||
this.write(p, this.prefixStyle)
|
||||
this.write(' ' + line + '\n')
|
||||
}, this)
|
||||
this.showProgress()
|
||||
}
|
||||
|
||||
log._format = function (msg, style) {
|
||||
if (!stream) {
|
||||
return
|
||||
}
|
||||
|
||||
var output = ''
|
||||
if (this.useColor()) {
|
||||
style = style || {}
|
||||
var settings = []
|
||||
if (style.fg) {
|
||||
settings.push(style.fg)
|
||||
}
|
||||
|
||||
if (style.bg) {
|
||||
settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1))
|
||||
}
|
||||
|
||||
if (style.bold) {
|
||||
settings.push('bold')
|
||||
}
|
||||
|
||||
if (style.underline) {
|
||||
settings.push('underline')
|
||||
}
|
||||
|
||||
if (style.inverse) {
|
||||
settings.push('inverse')
|
||||
}
|
||||
|
||||
if (settings.length) {
|
||||
output += consoleControl.color(settings)
|
||||
}
|
||||
|
||||
if (style.beep) {
|
||||
output += consoleControl.beep()
|
||||
}
|
||||
}
|
||||
output += msg
|
||||
if (this.useColor()) {
|
||||
output += consoleControl.color('reset')
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
log.write = function (msg, style) {
|
||||
if (!stream) {
|
||||
return
|
||||
}
|
||||
|
||||
stream.write(this._format(msg, style))
|
||||
}
|
||||
|
||||
log.addLevel = function (lvl, n, style, disp) {
|
||||
// If 'disp' is null or undefined, use the lvl as a default
|
||||
if (disp == null) {
|
||||
disp = lvl
|
||||
}
|
||||
|
||||
this.levels[lvl] = n
|
||||
this.style[lvl] = style
|
||||
if (!this[lvl]) {
|
||||
this[lvl] = function () {
|
||||
var a = new Array(arguments.length + 1)
|
||||
a[0] = lvl
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
a[i + 1] = arguments[i]
|
||||
}
|
||||
|
||||
return this.log.apply(this, a)
|
||||
}.bind(this)
|
||||
}
|
||||
this.disp[lvl] = disp
|
||||
}
|
||||
|
||||
log.prefixStyle = { fg: 'magenta' }
|
||||
log.headingStyle = { fg: 'white', bg: 'black' }
|
||||
|
||||
log.style = {}
|
||||
log.levels = {}
|
||||
log.disp = {}
|
||||
log.addLevel('silly', -Infinity, { inverse: true }, 'sill')
|
||||
log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb')
|
||||
log.addLevel('info', 2000, { fg: 'green' })
|
||||
log.addLevel('timing', 2500, { fg: 'green', bg: 'black' })
|
||||
log.addLevel('http', 3000, { fg: 'green', bg: 'black' })
|
||||
log.addLevel('notice', 3500, { fg: 'blue', bg: 'black' })
|
||||
log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN')
|
||||
log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!')
|
||||
log.addLevel('silent', Infinity)
|
||||
|
||||
// allow 'error' prefix
|
||||
log.on('error', function () {})
|
33
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/package.json
generated
vendored
Normal file
33
lib/node/node_modules/@mapbox/node-pre-gyp/node_modules/npmlog/package.json
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"name": "npmlog",
|
||||
"description": "logger for npm",
|
||||
"version": "5.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/npm/npmlog.git"
|
||||
},
|
||||
"main": "log.js",
|
||||
"files": [
|
||||
"log.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --branches=95",
|
||||
"npmclilint": "npmcli-lint",
|
||||
"lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"",
|
||||
"lintfix": "npm run lint -- --fix",
|
||||
"posttest": "npm run lint --",
|
||||
"postsnap": "npm run lintfix --"
|
||||
},
|
||||
"dependencies": {
|
||||
"are-we-there-yet": "^2.0.0",
|
||||
"console-control-strings": "^1.1.0",
|
||||
"gauge": "^3.0.0",
|
||||
"set-blocking": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@npmcli/lint": "^1.0.1",
|
||||
"tap": "^15.0.9"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
62
lib/node/node_modules/@mapbox/node-pre-gyp/package.json
generated
vendored
Normal file
62
lib/node/node_modules/@mapbox/node-pre-gyp/package.json
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"name": "@mapbox/node-pre-gyp",
|
||||
"description": "Node.js native addon binary install tool",
|
||||
"version": "1.0.11",
|
||||
"keywords": [
|
||||
"native",
|
||||
"addon",
|
||||
"module",
|
||||
"c",
|
||||
"c++",
|
||||
"bindings",
|
||||
"binary"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"author": "Dane Springmeyer <dane@mapbox.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mapbox/node-pre-gyp.git"
|
||||
},
|
||||
"bin": "./bin/node-pre-gyp",
|
||||
"main": "./lib/node-pre-gyp.js",
|
||||
"dependencies": {
|
||||
"detect-libc": "^2.0.0",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"make-dir": "^3.1.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"nopt": "^5.0.0",
|
||||
"npmlog": "^5.0.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"semver": "^7.3.5",
|
||||
"tar": "^6.1.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mapbox/cloudfriend": "^5.1.0",
|
||||
"@mapbox/eslint-config-mapbox": "^3.0.0",
|
||||
"aws-sdk": "^2.1087.0",
|
||||
"codecov": "^3.8.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"mock-aws-s3": "^4.0.2",
|
||||
"nock": "^12.0.3",
|
||||
"node-addon-api": "^4.3.0",
|
||||
"nyc": "^15.1.0",
|
||||
"tape": "^5.5.2",
|
||||
"tar-fs": "^2.1.1"
|
||||
},
|
||||
"nyc": {
|
||||
"all": true,
|
||||
"skip-full": false,
|
||||
"exclude": [
|
||||
"test/**"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc --all --include index.js --include lib/ npm test",
|
||||
"upload-coverage": "nyc report --reporter json && codecov --clear --flags=unit --file=./coverage/coverage-final.json",
|
||||
"lint": "eslint bin/node-pre-gyp lib/*js lib/util/*js test/*js scripts/*js",
|
||||
"fix": "npm run lint -- --fix",
|
||||
"update-crosswalk": "node scripts/abi_crosswalk.js",
|
||||
"test": "tape test/*test.js"
|
||||
}
|
||||
}
|
20
lib/node/node_modules/@npmcli/fs/LICENSE.md
generated
vendored
Normal file
20
lib/node/node_modules/@npmcli/fs/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
|
||||
|
||||
ISC License
|
||||
|
||||
Copyright npm, Inc.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this
|
||||
software for any purpose with or without fee is hereby
|
||||
granted, provided that the above copyright notice and this
|
||||
permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
||||
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
USE OR PERFORMANCE OF THIS SOFTWARE.
|
60
lib/node/node_modules/@npmcli/fs/README.md
generated
vendored
Normal file
60
lib/node/node_modules/@npmcli/fs/README.md
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
# @npmcli/fs
|
||||
|
||||
polyfills, and extensions, of the core `fs` module.
|
||||
|
||||
## Features
|
||||
|
||||
- all exposed functions return promises
|
||||
- `fs.rm` polyfill for node versions < 14.14.0
|
||||
- `fs.mkdir` polyfill adding support for the `recursive` and `force` options in node versions < 10.12.0
|
||||
- `fs.copyFile` extended to accept an `owner` option
|
||||
- `fs.mkdir` extended to accept an `owner` option
|
||||
- `fs.mkdtemp` extended to accept an `owner` option
|
||||
- `fs.writeFile` extended to accept an `owner` option
|
||||
- `fs.withTempDir` added
|
||||
- `fs.cp` polyfill for node < 16.7.0
|
||||
|
||||
## The `owner` option
|
||||
|
||||
The `copyFile`, `mkdir`, `mkdtemp`, `writeFile`, and `withTempDir` functions
|
||||
all accept a new `owner` property in their options. It can be used in two ways:
|
||||
|
||||
- `{ owner: { uid: 100, gid: 100 } }` - set the `uid` and `gid` explicitly
|
||||
- `{ owner: 100 }` - use one value, will set both `uid` and `gid` the same
|
||||
|
||||
The special string `'inherit'` may be passed instead of a number, which will
|
||||
cause this module to automatically determine the correct `uid` and/or `gid`
|
||||
from the nearest existing parent directory of the target.
|
||||
|
||||
## `fs.withTempDir(root, fn, options) -> Promise`
|
||||
|
||||
### Parameters
|
||||
|
||||
- `root`: the directory in which to create the temporary directory
|
||||
- `fn`: a function that will be called with the path to the temporary directory
|
||||
- `options`
|
||||
- `tmpPrefix`: a prefix to be used in the generated directory name
|
||||
|
||||
### Usage
|
||||
|
||||
The `withTempDir` function creates a temporary directory, runs the provided
|
||||
function (`fn`), then removes the temporary directory and resolves or rejects
|
||||
based on the result of `fn`.
|
||||
|
||||
```js
|
||||
const fs = require('@npmcli/fs')
|
||||
const os = require('os')
|
||||
|
||||
// this function will be called with the full path to the temporary directory
|
||||
// it is called with `await` behind the scenes, so can be async if desired.
|
||||
const myFunction = async (tempPath) => {
|
||||
return 'done!'
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const result = await fs.withTempDir(os.tmpdir(), myFunction)
|
||||
// result === 'done!'
|
||||
}
|
||||
|
||||
main()
|
||||
```
|
17
lib/node/node_modules/@npmcli/fs/lib/common/file-url-to-path/index.js
generated
vendored
Normal file
17
lib/node/node_modules/@npmcli/fs/lib/common/file-url-to-path/index.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
const url = require('url')
|
||||
|
||||
const node = require('../node.js')
|
||||
const polyfill = require('./polyfill.js')
|
||||
|
||||
const useNative = node.satisfies('>=10.12.0')
|
||||
|
||||
const fileURLToPath = (path) => {
|
||||
// the polyfill is tested separately from this module, no need to hack
|
||||
// process.version to try to trigger it just for coverage
|
||||
// istanbul ignore next
|
||||
return useNative
|
||||
? url.fileURLToPath(path)
|
||||
: polyfill(path)
|
||||
}
|
||||
|
||||
module.exports = fileURLToPath
|
121
lib/node/node_modules/@npmcli/fs/lib/common/file-url-to-path/polyfill.js
generated
vendored
Normal file
121
lib/node/node_modules/@npmcli/fs/lib/common/file-url-to-path/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
const { URL, domainToUnicode } = require('url')
|
||||
|
||||
const CHAR_LOWERCASE_A = 97
|
||||
const CHAR_LOWERCASE_Z = 122
|
||||
|
||||
const isWindows = process.platform === 'win32'
|
||||
|
||||
class ERR_INVALID_FILE_URL_HOST extends TypeError {
|
||||
constructor (platform) {
|
||||
super(`File URL host must be "localhost" or empty on ${platform}`)
|
||||
this.code = 'ERR_INVALID_FILE_URL_HOST'
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_INVALID_FILE_URL_PATH extends TypeError {
|
||||
constructor (msg) {
|
||||
super(`File URL path ${msg}`)
|
||||
this.code = 'ERR_INVALID_FILE_URL_PATH'
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_INVALID_ARG_TYPE extends TypeError {
|
||||
constructor (name, actual) {
|
||||
super(`The "${name}" argument must be one of type string or an instance ` +
|
||||
`of URL. Received type ${typeof actual} ${actual}`)
|
||||
this.code = 'ERR_INVALID_ARG_TYPE'
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
class ERR_INVALID_URL_SCHEME extends TypeError {
|
||||
constructor (expected) {
|
||||
super(`The URL must be of scheme ${expected}`)
|
||||
this.code = 'ERR_INVALID_URL_SCHEME'
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
const isURLInstance = (input) => {
|
||||
return input != null && input.href && input.origin
|
||||
}
|
||||
|
||||
const getPathFromURLWin32 = (url) => {
|
||||
const hostname = url.hostname
|
||||
let pathname = url.pathname
|
||||
for (let n = 0; n < pathname.length; n++) {
|
||||
if (pathname[n] === '%') {
|
||||
const third = pathname.codePointAt(n + 2) | 0x20
|
||||
if ((pathname[n + 1] === '2' && third === 102) ||
|
||||
(pathname[n + 1] === '5' && third === 99)) {
|
||||
throw new ERR_INVALID_FILE_URL_PATH('must not include encoded \\ or / characters')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pathname = pathname.replace(/\//g, '\\')
|
||||
pathname = decodeURIComponent(pathname)
|
||||
if (hostname !== '') {
|
||||
return `\\\\${domainToUnicode(hostname)}${pathname}`
|
||||
}
|
||||
|
||||
const letter = pathname.codePointAt(1) | 0x20
|
||||
const sep = pathname[2]
|
||||
if (letter < CHAR_LOWERCASE_A || letter > CHAR_LOWERCASE_Z ||
|
||||
(sep !== ':')) {
|
||||
throw new ERR_INVALID_FILE_URL_PATH('must be absolute')
|
||||
}
|
||||
|
||||
return pathname.slice(1)
|
||||
}
|
||||
|
||||
const getPathFromURLPosix = (url) => {
|
||||
if (url.hostname !== '') {
|
||||
throw new ERR_INVALID_FILE_URL_HOST(process.platform)
|
||||
}
|
||||
|
||||
const pathname = url.pathname
|
||||
|
||||
for (let n = 0; n < pathname.length; n++) {
|
||||
if (pathname[n] === '%') {
|
||||
const third = pathname.codePointAt(n + 2) | 0x20
|
||||
if (pathname[n + 1] === '2' && third === 102) {
|
||||
throw new ERR_INVALID_FILE_URL_PATH('must not include encoded / characters')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return decodeURIComponent(pathname)
|
||||
}
|
||||
|
||||
const fileURLToPath = (path) => {
|
||||
if (typeof path === 'string') {
|
||||
path = new URL(path)
|
||||
} else if (!isURLInstance(path)) {
|
||||
throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path)
|
||||
}
|
||||
|
||||
if (path.protocol !== 'file:') {
|
||||
throw new ERR_INVALID_URL_SCHEME('file')
|
||||
}
|
||||
|
||||
return isWindows
|
||||
? getPathFromURLWin32(path)
|
||||
: getPathFromURLPosix(path)
|
||||
}
|
||||
|
||||
module.exports = fileURLToPath
|
20
lib/node/node_modules/@npmcli/fs/lib/common/get-options.js
generated
vendored
Normal file
20
lib/node/node_modules/@npmcli/fs/lib/common/get-options.js
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// given an input that may or may not be an object, return an object that has
|
||||
// a copy of every defined property listed in 'copy'. if the input is not an
|
||||
// object, assign it to the property named by 'wrap'
|
||||
const getOptions = (input, { copy, wrap }) => {
|
||||
const result = {}
|
||||
|
||||
if (input && typeof input === 'object') {
|
||||
for (const prop of copy) {
|
||||
if (input[prop] !== undefined) {
|
||||
result[prop] = input[prop]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result[wrap] = input
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = getOptions
|
9
lib/node/node_modules/@npmcli/fs/lib/common/node.js
generated
vendored
Normal file
9
lib/node/node_modules/@npmcli/fs/lib/common/node.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
const semver = require('semver')
|
||||
|
||||
const satisfies = (range) => {
|
||||
return semver.satisfies(process.version, range, { includePrerelease: true })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
satisfies,
|
||||
}
|
92
lib/node/node_modules/@npmcli/fs/lib/common/owner.js
generated
vendored
Normal file
92
lib/node/node_modules/@npmcli/fs/lib/common/owner.js
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
const { dirname, resolve } = require('path')
|
||||
|
||||
const fileURLToPath = require('./file-url-to-path/index.js')
|
||||
const fs = require('../fs.js')
|
||||
|
||||
// given a path, find the owner of the nearest parent
|
||||
const find = async (path) => {
|
||||
// if we have no getuid, permissions are irrelevant on this platform
|
||||
if (!process.getuid) {
|
||||
return {}
|
||||
}
|
||||
|
||||
// fs methods accept URL objects with a scheme of file: so we need to unwrap
|
||||
// those into an actual path string before we can resolve it
|
||||
const resolved = path != null && path.href && path.origin
|
||||
? resolve(fileURLToPath(path))
|
||||
: resolve(path)
|
||||
|
||||
let stat
|
||||
|
||||
try {
|
||||
stat = await fs.lstat(resolved)
|
||||
} finally {
|
||||
// if we got a stat, return its contents
|
||||
if (stat) {
|
||||
return { uid: stat.uid, gid: stat.gid }
|
||||
}
|
||||
|
||||
// try the parent directory
|
||||
if (resolved !== dirname(resolved)) {
|
||||
return find(dirname(resolved))
|
||||
}
|
||||
|
||||
// no more parents, never got a stat, just return an empty object
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
// given a path, uid, and gid update the ownership of the path if necessary
|
||||
const update = async (path, uid, gid) => {
|
||||
// nothing to update, just exit
|
||||
if (uid === undefined && gid === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// see if the permissions are already the same, if they are we don't
|
||||
// need to do anything, so return early
|
||||
const stat = await fs.stat(path)
|
||||
if (uid === stat.uid && gid === stat.gid) {
|
||||
return
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
try {
|
||||
await fs.chown(path, uid, gid)
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
// accepts a `path` and the `owner` property of an options object and normalizes
|
||||
// it into an object with numerical `uid` and `gid`
|
||||
const validate = async (path, input) => {
|
||||
let uid
|
||||
let gid
|
||||
|
||||
if (typeof input === 'string' || typeof input === 'number') {
|
||||
uid = input
|
||||
gid = input
|
||||
} else if (input && typeof input === 'object') {
|
||||
uid = input.uid
|
||||
gid = input.gid
|
||||
}
|
||||
|
||||
if (uid === 'inherit' || gid === 'inherit') {
|
||||
const owner = await find(path)
|
||||
if (uid === 'inherit') {
|
||||
uid = owner.uid
|
||||
}
|
||||
|
||||
if (gid === 'inherit') {
|
||||
gid = owner.gid
|
||||
}
|
||||
}
|
||||
|
||||
return { uid, gid }
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
find,
|
||||
update,
|
||||
validate,
|
||||
}
|
22
lib/node/node_modules/@npmcli/fs/lib/copy-file.js
generated
vendored
Normal file
22
lib/node/node_modules/@npmcli/fs/lib/copy-file.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
const fs = require('./fs.js')
|
||||
const getOptions = require('./common/get-options.js')
|
||||
const owner = require('./common/owner.js')
|
||||
|
||||
const copyFile = async (src, dest, opts) => {
|
||||
const options = getOptions(opts, {
|
||||
copy: ['mode', 'owner'],
|
||||
wrap: 'mode',
|
||||
})
|
||||
|
||||
const { uid, gid } = await owner.validate(dest, options.owner)
|
||||
|
||||
// the node core method as of 16.5.0 does not support the mode being in an
|
||||
// object, so we have to pass the mode value directly
|
||||
const result = await fs.copyFile(src, dest, options.mode)
|
||||
|
||||
await owner.update(dest, uid, gid)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = copyFile
|
15
lib/node/node_modules/@npmcli/fs/lib/cp/LICENSE
generated
vendored
Normal file
15
lib/node/node_modules/@npmcli/fs/lib/cp/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2017 JP Richardson
|
||||
|
||||
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.
|
22
lib/node/node_modules/@npmcli/fs/lib/cp/index.js
generated
vendored
Normal file
22
lib/node/node_modules/@npmcli/fs/lib/cp/index.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
const fs = require('../fs.js')
|
||||
const getOptions = require('../common/get-options.js')
|
||||
const node = require('../common/node.js')
|
||||
const polyfill = require('./polyfill.js')
|
||||
|
||||
// node 16.7.0 added fs.cp
|
||||
const useNative = node.satisfies('>=16.7.0')
|
||||
|
||||
const cp = async (src, dest, opts) => {
|
||||
const options = getOptions(opts, {
|
||||
copy: ['dereference', 'errorOnExist', 'filter', 'force', 'preserveTimestamps', 'recursive'],
|
||||
})
|
||||
|
||||
// the polyfill is tested separately from this module, no need to hack
|
||||
// process.version to try to trigger it just for coverage
|
||||
// istanbul ignore next
|
||||
return useNative
|
||||
? fs.cp(src, dest, options)
|
||||
: polyfill(src, dest, options)
|
||||
}
|
||||
|
||||
module.exports = cp
|
428
lib/node/node_modules/@npmcli/fs/lib/cp/polyfill.js
generated
vendored
Normal file
428
lib/node/node_modules/@npmcli/fs/lib/cp/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,428 @@
|
|||
// this file is a modified version of the code in node 17.2.0
|
||||
// which is, in turn, a modified version of the fs-extra module on npm
|
||||
// node core changes:
|
||||
// - Use of the assert module has been replaced with core's error system.
|
||||
// - All code related to the glob dependency has been removed.
|
||||
// - Bring your own custom fs module is not currently supported.
|
||||
// - Some basic code cleanup.
|
||||
// changes here:
|
||||
// - remove all callback related code
|
||||
// - drop sync support
|
||||
// - change assertions back to non-internal methods (see options.js)
|
||||
// - throws ENOTDIR when rmdir gets an ENOENT for a path that exists in Windows
|
||||
'use strict'
|
||||
|
||||
const {
|
||||
ERR_FS_CP_DIR_TO_NON_DIR,
|
||||
ERR_FS_CP_EEXIST,
|
||||
ERR_FS_CP_EINVAL,
|
||||
ERR_FS_CP_FIFO_PIPE,
|
||||
ERR_FS_CP_NON_DIR_TO_DIR,
|
||||
ERR_FS_CP_SOCKET,
|
||||
ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY,
|
||||
ERR_FS_CP_UNKNOWN,
|
||||
ERR_FS_EISDIR,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
} = require('../errors.js')
|
||||
const {
|
||||
constants: {
|
||||
errno: {
|
||||
EEXIST,
|
||||
EISDIR,
|
||||
EINVAL,
|
||||
ENOTDIR,
|
||||
},
|
||||
},
|
||||
} = require('os')
|
||||
const {
|
||||
chmod,
|
||||
copyFile,
|
||||
lstat,
|
||||
mkdir,
|
||||
readdir,
|
||||
readlink,
|
||||
stat,
|
||||
symlink,
|
||||
unlink,
|
||||
utimes,
|
||||
} = require('../fs.js')
|
||||
const {
|
||||
dirname,
|
||||
isAbsolute,
|
||||
join,
|
||||
parse,
|
||||
resolve,
|
||||
sep,
|
||||
toNamespacedPath,
|
||||
} = require('path')
|
||||
const { fileURLToPath } = require('url')
|
||||
|
||||
const defaultOptions = {
|
||||
dereference: false,
|
||||
errorOnExist: false,
|
||||
filter: undefined,
|
||||
force: true,
|
||||
preserveTimestamps: false,
|
||||
recursive: false,
|
||||
}
|
||||
|
||||
async function cp (src, dest, opts) {
|
||||
if (opts != null && typeof opts !== 'object') {
|
||||
throw new ERR_INVALID_ARG_TYPE('options', ['Object'], opts)
|
||||
}
|
||||
return cpFn(
|
||||
toNamespacedPath(getValidatedPath(src)),
|
||||
toNamespacedPath(getValidatedPath(dest)),
|
||||
{ ...defaultOptions, ...opts })
|
||||
}
|
||||
|
||||
function getValidatedPath (fileURLOrPath) {
|
||||
const path = fileURLOrPath != null && fileURLOrPath.href
|
||||
&& fileURLOrPath.origin
|
||||
? fileURLToPath(fileURLOrPath)
|
||||
: fileURLOrPath
|
||||
return path
|
||||
}
|
||||
|
||||
async function cpFn (src, dest, opts) {
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
// istanbul ignore next
|
||||
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
||||
const warning = 'Using the preserveTimestamps option in 32-bit ' +
|
||||
'node is not recommended'
|
||||
process.emitWarning(warning, 'TimestampPrecisionWarning')
|
||||
}
|
||||
const stats = await checkPaths(src, dest, opts)
|
||||
const { srcStat, destStat } = stats
|
||||
await checkParentPaths(src, srcStat, dest)
|
||||
if (opts.filter) {
|
||||
return handleFilter(checkParentDir, destStat, src, dest, opts)
|
||||
}
|
||||
return checkParentDir(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
async function checkPaths (src, dest, opts) {
|
||||
const { 0: srcStat, 1: destStat } = await getStats(src, dest, opts)
|
||||
if (destStat) {
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new ERR_FS_CP_EINVAL({
|
||||
message: 'src and dest cannot be the same',
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||||
throw new ERR_FS_CP_DIR_TO_NON_DIR({
|
||||
message: `cannot overwrite directory ${src} ` +
|
||||
`with non-directory ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EISDIR,
|
||||
})
|
||||
}
|
||||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||||
throw new ERR_FS_CP_NON_DIR_TO_DIR({
|
||||
message: `cannot overwrite non-directory ${src} ` +
|
||||
`with directory ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: ENOTDIR,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||||
throw new ERR_FS_CP_EINVAL({
|
||||
message: `cannot copy ${src} to a subdirectory of self ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
return { srcStat, destStat }
|
||||
}
|
||||
|
||||
function areIdentical (srcStat, destStat) {
|
||||
return destStat.ino && destStat.dev && destStat.ino === srcStat.ino &&
|
||||
destStat.dev === srcStat.dev
|
||||
}
|
||||
|
||||
function getStats (src, dest, opts) {
|
||||
const statFunc = opts.dereference ?
|
||||
(file) => stat(file, { bigint: true }) :
|
||||
(file) => lstat(file, { bigint: true })
|
||||
return Promise.all([
|
||||
statFunc(src),
|
||||
statFunc(dest).catch((err) => {
|
||||
// istanbul ignore next: unsure how to cover.
|
||||
if (err.code === 'ENOENT') {
|
||||
return null
|
||||
}
|
||||
// istanbul ignore next: unsure how to cover.
|
||||
throw err
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
async function checkParentDir (destStat, src, dest, opts) {
|
||||
const destParent = dirname(dest)
|
||||
const dirExists = await pathExists(destParent)
|
||||
if (dirExists) {
|
||||
return getStatsForCopy(destStat, src, dest, opts)
|
||||
}
|
||||
await mkdir(destParent, { recursive: true })
|
||||
return getStatsForCopy(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
function pathExists (dest) {
|
||||
return stat(dest).then(
|
||||
() => true,
|
||||
// istanbul ignore next: not sure when this would occur
|
||||
(err) => (err.code === 'ENOENT' ? false : Promise.reject(err)))
|
||||
}
|
||||
|
||||
// Recursively check if dest parent is a subdirectory of src.
|
||||
// It works for all file types including symlinks since it
|
||||
// checks the src and dest inodes. It starts from the deepest
|
||||
// parent and stops once it reaches the src parent or the root path.
|
||||
async function checkParentPaths (src, srcStat, dest) {
|
||||
const srcParent = resolve(dirname(src))
|
||||
const destParent = resolve(dirname(dest))
|
||||
if (destParent === srcParent || destParent === parse(destParent).root) {
|
||||
return
|
||||
}
|
||||
let destStat
|
||||
try {
|
||||
destStat = await stat(destParent, { bigint: true })
|
||||
} catch (err) {
|
||||
// istanbul ignore else: not sure when this would occur
|
||||
if (err.code === 'ENOENT') {
|
||||
return
|
||||
}
|
||||
// istanbul ignore next: not sure when this would occur
|
||||
throw err
|
||||
}
|
||||
if (areIdentical(srcStat, destStat)) {
|
||||
throw new ERR_FS_CP_EINVAL({
|
||||
message: `cannot copy ${src} to a subdirectory of self ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
return checkParentPaths(src, srcStat, destParent)
|
||||
}
|
||||
|
||||
const normalizePathToArray = (path) =>
|
||||
resolve(path).split(sep).filter(Boolean)
|
||||
|
||||
// Return true if dest is a subdir of src, otherwise false.
|
||||
// It only checks the path strings.
|
||||
function isSrcSubdir (src, dest) {
|
||||
const srcArr = normalizePathToArray(src)
|
||||
const destArr = normalizePathToArray(dest)
|
||||
return srcArr.every((cur, i) => destArr[i] === cur)
|
||||
}
|
||||
|
||||
async function handleFilter (onInclude, destStat, src, dest, opts, cb) {
|
||||
const include = await opts.filter(src, dest)
|
||||
if (include) {
|
||||
return onInclude(destStat, src, dest, opts, cb)
|
||||
}
|
||||
}
|
||||
|
||||
function startCopy (destStat, src, dest, opts) {
|
||||
if (opts.filter) {
|
||||
return handleFilter(getStatsForCopy, destStat, src, dest, opts)
|
||||
}
|
||||
return getStatsForCopy(destStat, src, dest, opts)
|
||||
}
|
||||
|
||||
async function getStatsForCopy (destStat, src, dest, opts) {
|
||||
const statFn = opts.dereference ? stat : lstat
|
||||
const srcStat = await statFn(src)
|
||||
// istanbul ignore else: can't portably test FIFO
|
||||
if (srcStat.isDirectory() && opts.recursive) {
|
||||
return onDir(srcStat, destStat, src, dest, opts)
|
||||
} else if (srcStat.isDirectory()) {
|
||||
throw new ERR_FS_EISDIR({
|
||||
message: `${src} is a directory (not copied)`,
|
||||
path: src,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
} else if (srcStat.isFile() ||
|
||||
srcStat.isCharacterDevice() ||
|
||||
srcStat.isBlockDevice()) {
|
||||
return onFile(srcStat, destStat, src, dest, opts)
|
||||
} else if (srcStat.isSymbolicLink()) {
|
||||
return onLink(destStat, src, dest)
|
||||
} else if (srcStat.isSocket()) {
|
||||
throw new ERR_FS_CP_SOCKET({
|
||||
message: `cannot copy a socket file: ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
} else if (srcStat.isFIFO()) {
|
||||
throw new ERR_FS_CP_FIFO_PIPE({
|
||||
message: `cannot copy a FIFO pipe: ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
// istanbul ignore next: should be unreachable
|
||||
throw new ERR_FS_CP_UNKNOWN({
|
||||
message: `cannot copy an unknown file type: ${dest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
|
||||
function onFile (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) {
|
||||
return _copyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
return mayCopyFile(srcStat, src, dest, opts)
|
||||
}
|
||||
|
||||
async function mayCopyFile (srcStat, src, dest, opts) {
|
||||
if (opts.force) {
|
||||
await unlink(dest)
|
||||
return _copyFile(srcStat, src, dest, opts)
|
||||
} else if (opts.errorOnExist) {
|
||||
throw new ERR_FS_CP_EEXIST({
|
||||
message: `${dest} already exists`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EEXIST,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function _copyFile (srcStat, src, dest, opts) {
|
||||
await copyFile(src, dest)
|
||||
if (opts.preserveTimestamps) {
|
||||
return handleTimestampsAndMode(srcStat.mode, src, dest)
|
||||
}
|
||||
return setDestMode(dest, srcStat.mode)
|
||||
}
|
||||
|
||||
async function handleTimestampsAndMode (srcMode, src, dest) {
|
||||
// Make sure the file is writable before setting the timestamp
|
||||
// otherwise open fails with EPERM when invoked with 'r+'
|
||||
// (through utimes call)
|
||||
if (fileIsNotWritable(srcMode)) {
|
||||
await makeFileWritable(dest, srcMode)
|
||||
return setDestTimestampsAndMode(srcMode, src, dest)
|
||||
}
|
||||
return setDestTimestampsAndMode(srcMode, src, dest)
|
||||
}
|
||||
|
||||
function fileIsNotWritable (srcMode) {
|
||||
return (srcMode & 0o200) === 0
|
||||
}
|
||||
|
||||
function makeFileWritable (dest, srcMode) {
|
||||
return setDestMode(dest, srcMode | 0o200)
|
||||
}
|
||||
|
||||
async function setDestTimestampsAndMode (srcMode, src, dest) {
|
||||
await setDestTimestamps(src, dest)
|
||||
return setDestMode(dest, srcMode)
|
||||
}
|
||||
|
||||
function setDestMode (dest, srcMode) {
|
||||
return chmod(dest, srcMode)
|
||||
}
|
||||
|
||||
async function setDestTimestamps (src, dest) {
|
||||
// The initial srcStat.atime cannot be trusted
|
||||
// because it is modified by the read(2) system call
|
||||
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
||||
const updatedSrcStat = await stat(src)
|
||||
return utimes(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
|
||||
}
|
||||
|
||||
function onDir (srcStat, destStat, src, dest, opts) {
|
||||
if (!destStat) {
|
||||
return mkDirAndCopy(srcStat.mode, src, dest, opts)
|
||||
}
|
||||
return copyDir(src, dest, opts)
|
||||
}
|
||||
|
||||
async function mkDirAndCopy (srcMode, src, dest, opts) {
|
||||
await mkdir(dest)
|
||||
await copyDir(src, dest, opts)
|
||||
return setDestMode(dest, srcMode)
|
||||
}
|
||||
|
||||
async function copyDir (src, dest, opts) {
|
||||
const dir = await readdir(src)
|
||||
for (let i = 0; i < dir.length; i++) {
|
||||
const item = dir[i]
|
||||
const srcItem = join(src, item)
|
||||
const destItem = join(dest, item)
|
||||
const { destStat } = await checkPaths(srcItem, destItem, opts)
|
||||
await startCopy(destStat, srcItem, destItem, opts)
|
||||
}
|
||||
}
|
||||
|
||||
async function onLink (destStat, src, dest) {
|
||||
let resolvedSrc = await readlink(src)
|
||||
if (!isAbsolute(resolvedSrc)) {
|
||||
resolvedSrc = resolve(dirname(src), resolvedSrc)
|
||||
}
|
||||
if (!destStat) {
|
||||
return symlink(resolvedSrc, dest)
|
||||
}
|
||||
let resolvedDest
|
||||
try {
|
||||
resolvedDest = await readlink(dest)
|
||||
} catch (err) {
|
||||
// Dest exists and is a regular file or directory,
|
||||
// Windows may throw UNKNOWN error. If dest already exists,
|
||||
// fs throws error anyway, so no need to guard against it here.
|
||||
// istanbul ignore next: can only test on windows
|
||||
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') {
|
||||
return symlink(resolvedSrc, dest)
|
||||
}
|
||||
// istanbul ignore next: should not be possible
|
||||
throw err
|
||||
}
|
||||
if (!isAbsolute(resolvedDest)) {
|
||||
resolvedDest = resolve(dirname(dest), resolvedDest)
|
||||
}
|
||||
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new ERR_FS_CP_EINVAL({
|
||||
message: `cannot copy ${resolvedSrc} to a subdirectory of self ` +
|
||||
`${resolvedDest}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
// Do not copy if src is a subdir of dest since unlinking
|
||||
// dest in this case would result in removing src contents
|
||||
// and therefore a broken symlink would be created.
|
||||
const srcStat = await stat(src)
|
||||
if (srcStat.isDirectory() && isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||||
throw new ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY({
|
||||
message: `cannot overwrite ${resolvedDest} with ${resolvedSrc}`,
|
||||
path: dest,
|
||||
syscall: 'cp',
|
||||
errno: EINVAL,
|
||||
})
|
||||
}
|
||||
return copyLink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
async function copyLink (resolvedSrc, dest) {
|
||||
await unlink(dest)
|
||||
return symlink(resolvedSrc, dest)
|
||||
}
|
||||
|
||||
module.exports = cp
|
129
lib/node/node_modules/@npmcli/fs/lib/errors.js
generated
vendored
Normal file
129
lib/node/node_modules/@npmcli/fs/lib/errors.js
generated
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
'use strict'
|
||||
const { inspect } = require('util')
|
||||
|
||||
// adapted from node's internal/errors
|
||||
// https://github.com/nodejs/node/blob/c8a04049/lib/internal/errors.js
|
||||
|
||||
// close copy of node's internal SystemError class.
|
||||
class SystemError {
|
||||
constructor (code, prefix, context) {
|
||||
// XXX context.code is undefined in all constructors used in cp/polyfill
|
||||
// that may be a bug copied from node, maybe the constructor should use
|
||||
// `code` not `errno`? nodejs/node#41104
|
||||
let message = `${prefix}: ${context.syscall} returned ` +
|
||||
`${context.code} (${context.message})`
|
||||
|
||||
if (context.path !== undefined) {
|
||||
message += ` ${context.path}`
|
||||
}
|
||||
if (context.dest !== undefined) {
|
||||
message += ` => ${context.dest}`
|
||||
}
|
||||
|
||||
this.code = code
|
||||
Object.defineProperties(this, {
|
||||
name: {
|
||||
value: 'SystemError',
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
},
|
||||
message: {
|
||||
value: message,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
},
|
||||
info: {
|
||||
value: context,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: false,
|
||||
},
|
||||
errno: {
|
||||
get () {
|
||||
return context.errno
|
||||
},
|
||||
set (value) {
|
||||
context.errno = value
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
syscall: {
|
||||
get () {
|
||||
return context.syscall
|
||||
},
|
||||
set (value) {
|
||||
context.syscall = value
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (context.path !== undefined) {
|
||||
Object.defineProperty(this, 'path', {
|
||||
get () {
|
||||
return context.path
|
||||
},
|
||||
set (value) {
|
||||
context.path = value
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
})
|
||||
}
|
||||
|
||||
if (context.dest !== undefined) {
|
||||
Object.defineProperty(this, 'dest', {
|
||||
get () {
|
||||
return context.dest
|
||||
},
|
||||
set (value) {
|
||||
context.dest = value
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
|
||||
[Symbol.for('nodejs.util.inspect.custom')] (_recurseTimes, ctx) {
|
||||
return inspect(this, {
|
||||
...ctx,
|
||||
getters: true,
|
||||
customInspect: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function E (code, message) {
|
||||
module.exports[code] = class NodeError extends SystemError {
|
||||
constructor (ctx) {
|
||||
super(code, message, ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
E('ERR_FS_CP_DIR_TO_NON_DIR', 'Cannot overwrite directory with non-directory')
|
||||
E('ERR_FS_CP_EEXIST', 'Target already exists')
|
||||
E('ERR_FS_CP_EINVAL', 'Invalid src or dest')
|
||||
E('ERR_FS_CP_FIFO_PIPE', 'Cannot copy a FIFO pipe')
|
||||
E('ERR_FS_CP_NON_DIR_TO_DIR', 'Cannot overwrite non-directory with directory')
|
||||
E('ERR_FS_CP_SOCKET', 'Cannot copy a socket file')
|
||||
E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY', 'Cannot overwrite symlink in subdirectory of self')
|
||||
E('ERR_FS_CP_UNKNOWN', 'Cannot copy an unknown file type')
|
||||
E('ERR_FS_EISDIR', 'Path is a directory')
|
||||
|
||||
module.exports.ERR_INVALID_ARG_TYPE = class ERR_INVALID_ARG_TYPE extends Error {
|
||||
constructor (name, expected, actual) {
|
||||
super()
|
||||
this.code = 'ERR_INVALID_ARG_TYPE'
|
||||
this.message = `The ${name} argument must be ${expected}. Received ${typeof actual}`
|
||||
}
|
||||
}
|
8
lib/node/node_modules/@npmcli/fs/lib/fs.js
generated
vendored
Normal file
8
lib/node/node_modules/@npmcli/fs/lib/fs.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
const fs = require('fs')
|
||||
const promisify = require('@gar/promisify')
|
||||
|
||||
// this module returns the core fs module wrapped in a proxy that promisifies
|
||||
// method calls within the getter. we keep it in a separate module so that the
|
||||
// overridden methods have a consistent way to get to promisified fs methods
|
||||
// without creating a circular dependency
|
||||
module.exports = promisify(fs)
|
10
lib/node/node_modules/@npmcli/fs/lib/index.js
generated
vendored
Normal file
10
lib/node/node_modules/@npmcli/fs/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
...require('./fs.js'),
|
||||
copyFile: require('./copy-file.js'),
|
||||
cp: require('./cp/index.js'),
|
||||
mkdir: require('./mkdir/index.js'),
|
||||
mkdtemp: require('./mkdtemp.js'),
|
||||
rm: require('./rm/index.js'),
|
||||
withTempDir: require('./with-temp-dir.js'),
|
||||
writeFile: require('./write-file.js'),
|
||||
}
|
32
lib/node/node_modules/@npmcli/fs/lib/mkdir/index.js
generated
vendored
Normal file
32
lib/node/node_modules/@npmcli/fs/lib/mkdir/index.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
const fs = require('../fs.js')
|
||||
const getOptions = require('../common/get-options.js')
|
||||
const node = require('../common/node.js')
|
||||
const owner = require('../common/owner.js')
|
||||
|
||||
const polyfill = require('./polyfill.js')
|
||||
|
||||
// node 10.12.0 added the options parameter, which allows recursive and mode
|
||||
// properties to be passed
|
||||
const useNative = node.satisfies('>=10.12.0')
|
||||
|
||||
// extends mkdir with the ability to specify an owner of the new dir
|
||||
const mkdir = async (path, opts) => {
|
||||
const options = getOptions(opts, {
|
||||
copy: ['mode', 'recursive', 'owner'],
|
||||
wrap: 'mode',
|
||||
})
|
||||
const { uid, gid } = await owner.validate(path, options.owner)
|
||||
|
||||
// the polyfill is tested separately from this module, no need to hack
|
||||
// process.version to try to trigger it just for coverage
|
||||
// istanbul ignore next
|
||||
const result = useNative
|
||||
? await fs.mkdir(path, options)
|
||||
: await polyfill(path, options)
|
||||
|
||||
await owner.update(path, uid, gid)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = mkdir
|
81
lib/node/node_modules/@npmcli/fs/lib/mkdir/polyfill.js
generated
vendored
Normal file
81
lib/node/node_modules/@npmcli/fs/lib/mkdir/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,81 @@
|
|||
const { dirname } = require('path')
|
||||
|
||||
const fileURLToPath = require('../common/file-url-to-path/index.js')
|
||||
const fs = require('../fs.js')
|
||||
|
||||
const defaultOptions = {
|
||||
mode: 0o777,
|
||||
recursive: false,
|
||||
}
|
||||
|
||||
const mkdir = async (path, opts) => {
|
||||
const options = { ...defaultOptions, ...opts }
|
||||
|
||||
// if we're not in recursive mode, just call the real mkdir with the path and
|
||||
// the mode option only
|
||||
if (!options.recursive) {
|
||||
return fs.mkdir(path, options.mode)
|
||||
}
|
||||
|
||||
const makeDirectory = async (dir, mode) => {
|
||||
// we can't use dirname directly since these functions support URL
|
||||
// objects with the file: protocol as the path input, so first we get a
|
||||
// string path, then we can call dirname on that
|
||||
const parent = dir != null && dir.href && dir.origin
|
||||
? dirname(fileURLToPath(dir))
|
||||
: dirname(dir)
|
||||
|
||||
// if the parent is the dir itself, try to create it. anything but EISDIR
|
||||
// should be rethrown
|
||||
if (parent === dir) {
|
||||
try {
|
||||
await fs.mkdir(dir, opts)
|
||||
} catch (err) {
|
||||
if (err.code !== 'EISDIR') {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.mkdir(dir, mode)
|
||||
return dir
|
||||
} catch (err) {
|
||||
// ENOENT means the parent wasn't there, so create that
|
||||
if (err.code === 'ENOENT') {
|
||||
const made = await makeDirectory(parent, mode)
|
||||
await makeDirectory(dir, mode)
|
||||
// return the shallowest path we created, i.e. the result of creating
|
||||
// the parent
|
||||
return made
|
||||
}
|
||||
|
||||
// an EEXIST means there's already something there
|
||||
// an EROFS means we have a read-only filesystem and can't create a dir
|
||||
// any other error is fatal and we should give up now
|
||||
if (err.code !== 'EEXIST' && err.code !== 'EROFS') {
|
||||
throw err
|
||||
}
|
||||
|
||||
// stat the directory, if the result is a directory, then we successfully
|
||||
// created this one so return its path. otherwise, we reject with the
|
||||
// original error by ignoring the error in the catch
|
||||
try {
|
||||
const stat = await fs.stat(dir)
|
||||
if (stat.isDirectory()) {
|
||||
// if it already existed, we didn't create anything so return
|
||||
// undefined
|
||||
return undefined
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
// if the thing that's there isn't a directory, then just re-throw
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
return makeDirectory(path, options.mode)
|
||||
}
|
||||
|
||||
module.exports = mkdir
|
28
lib/node/node_modules/@npmcli/fs/lib/mkdtemp.js
generated
vendored
Normal file
28
lib/node/node_modules/@npmcli/fs/lib/mkdtemp.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
const { dirname, sep } = require('path')
|
||||
|
||||
const fs = require('./fs.js')
|
||||
const getOptions = require('./common/get-options.js')
|
||||
const owner = require('./common/owner.js')
|
||||
|
||||
const mkdtemp = async (prefix, opts) => {
|
||||
const options = getOptions(opts, {
|
||||
copy: ['encoding', 'owner'],
|
||||
wrap: 'encoding',
|
||||
})
|
||||
|
||||
// mkdtemp relies on the trailing path separator to indicate if it should
|
||||
// create a directory inside of the prefix. if that's the case then the root
|
||||
// we infer ownership from is the prefix itself, otherwise it's the dirname
|
||||
// /tmp -> /tmpABCDEF, infers from /
|
||||
// /tmp/ -> /tmp/ABCDEF, infers from /tmp
|
||||
const root = prefix.endsWith(sep) ? prefix : dirname(prefix)
|
||||
const { uid, gid } = await owner.validate(root, options.owner)
|
||||
|
||||
const result = await fs.mkdtemp(prefix, options)
|
||||
|
||||
await owner.update(result, uid, gid)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = mkdtemp
|
22
lib/node/node_modules/@npmcli/fs/lib/rm/index.js
generated
vendored
Normal file
22
lib/node/node_modules/@npmcli/fs/lib/rm/index.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
const fs = require('../fs.js')
|
||||
const getOptions = require('../common/get-options.js')
|
||||
const node = require('../common/node.js')
|
||||
const polyfill = require('./polyfill.js')
|
||||
|
||||
// node 14.14.0 added fs.rm, which allows both the force and recursive options
|
||||
const useNative = node.satisfies('>=14.14.0')
|
||||
|
||||
const rm = async (path, opts) => {
|
||||
const options = getOptions(opts, {
|
||||
copy: ['retryDelay', 'maxRetries', 'recursive', 'force'],
|
||||
})
|
||||
|
||||
// the polyfill is tested separately from this module, no need to hack
|
||||
// process.version to try to trigger it just for coverage
|
||||
// istanbul ignore next
|
||||
return useNative
|
||||
? fs.rm(path, options)
|
||||
: polyfill(path, options)
|
||||
}
|
||||
|
||||
module.exports = rm
|
239
lib/node/node_modules/@npmcli/fs/lib/rm/polyfill.js
generated
vendored
Normal file
239
lib/node/node_modules/@npmcli/fs/lib/rm/polyfill.js
generated
vendored
Normal file
|
@ -0,0 +1,239 @@
|
|||
// this file is a modified version of the code in node core >=14.14.0
|
||||
// which is, in turn, a modified version of the rimraf module on npm
|
||||
// node core changes:
|
||||
// - Use of the assert module has been replaced with core's error system.
|
||||
// - All code related to the glob dependency has been removed.
|
||||
// - Bring your own custom fs module is not currently supported.
|
||||
// - Some basic code cleanup.
|
||||
// changes here:
|
||||
// - remove all callback related code
|
||||
// - drop sync support
|
||||
// - change assertions back to non-internal methods (see options.js)
|
||||
// - throws ENOTDIR when rmdir gets an ENOENT for a path that exists in Windows
|
||||
const errnos = require('os').constants.errno
|
||||
const { join } = require('path')
|
||||
const fs = require('../fs.js')
|
||||
|
||||
// error codes that mean we need to remove contents
|
||||
const notEmptyCodes = new Set([
|
||||
'ENOTEMPTY',
|
||||
'EEXIST',
|
||||
'EPERM',
|
||||
])
|
||||
|
||||
// error codes we can retry later
|
||||
const retryCodes = new Set([
|
||||
'EBUSY',
|
||||
'EMFILE',
|
||||
'ENFILE',
|
||||
'ENOTEMPTY',
|
||||
'EPERM',
|
||||
])
|
||||
|
||||
const isWindows = process.platform === 'win32'
|
||||
|
||||
const defaultOptions = {
|
||||
retryDelay: 100,
|
||||
maxRetries: 0,
|
||||
recursive: false,
|
||||
force: false,
|
||||
}
|
||||
|
||||
// this is drastically simplified, but should be roughly equivalent to what
|
||||
// node core throws
|
||||
class ERR_FS_EISDIR extends Error {
|
||||
constructor (path) {
|
||||
super()
|
||||
this.info = {
|
||||
code: 'EISDIR',
|
||||
message: 'is a directory',
|
||||
path,
|
||||
syscall: 'rm',
|
||||
errno: errnos.EISDIR,
|
||||
}
|
||||
this.name = 'SystemError'
|
||||
this.code = 'ERR_FS_EISDIR'
|
||||
this.errno = errnos.EISDIR
|
||||
this.syscall = 'rm'
|
||||
this.path = path
|
||||
this.message = `Path is a directory: ${this.syscall} returned ` +
|
||||
`${this.info.code} (is a directory) ${path}`
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name} [${this.code}]: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
class ENOTDIR extends Error {
|
||||
constructor (path) {
|
||||
super()
|
||||
this.name = 'Error'
|
||||
this.code = 'ENOTDIR'
|
||||
this.errno = errnos.ENOTDIR
|
||||
this.syscall = 'rmdir'
|
||||
this.path = path
|
||||
this.message = `not a directory, ${this.syscall} '${this.path}'`
|
||||
}
|
||||
|
||||
toString () {
|
||||
return `${this.name}: ${this.code}: ${this.message}`
|
||||
}
|
||||
}
|
||||
|
||||
// force is passed separately here because we respect it for the first entry
|
||||
// into rimraf only, any further calls that are spawned as a result (i.e. to
|
||||
// delete content within the target) will ignore ENOENT errors
|
||||
const rimraf = async (path, options, isTop = false) => {
|
||||
const force = isTop ? options.force : true
|
||||
const stat = await fs.lstat(path)
|
||||
.catch((err) => {
|
||||
// we only ignore ENOENT if we're forcing this call
|
||||
if (err.code === 'ENOENT' && force) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isWindows && err.code === 'EPERM') {
|
||||
return fixEPERM(path, options, err, isTop)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
|
||||
// no stat object here means either lstat threw an ENOENT, or lstat threw
|
||||
// an EPERM and the fixPERM function took care of things. either way, we're
|
||||
// already done, so return early
|
||||
if (!stat) {
|
||||
return
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
return rmdir(path, options, null, isTop)
|
||||
}
|
||||
|
||||
return fs.unlink(path)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT' && force) {
|
||||
return
|
||||
}
|
||||
|
||||
if (err.code === 'EISDIR') {
|
||||
return rmdir(path, options, err, isTop)
|
||||
}
|
||||
|
||||
if (err.code === 'EPERM') {
|
||||
// in windows, we handle this through fixEPERM which will also try to
|
||||
// delete things again. everywhere else since deleting the target as a
|
||||
// file didn't work we go ahead and try to delete it as a directory
|
||||
return isWindows
|
||||
? fixEPERM(path, options, err, isTop)
|
||||
: rmdir(path, options, err, isTop)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
const fixEPERM = async (path, options, originalErr, isTop) => {
|
||||
const force = isTop ? options.force : true
|
||||
const targetMissing = await fs.chmod(path, 0o666)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT' && force) {
|
||||
return true
|
||||
}
|
||||
|
||||
throw originalErr
|
||||
})
|
||||
|
||||
// got an ENOENT above, return now. no file = no problem
|
||||
if (targetMissing) {
|
||||
return
|
||||
}
|
||||
|
||||
// this function does its own lstat rather than calling rimraf again to avoid
|
||||
// infinite recursion for a repeating EPERM
|
||||
const stat = await fs.lstat(path)
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT' && force) {
|
||||
return
|
||||
}
|
||||
|
||||
throw originalErr
|
||||
})
|
||||
|
||||
if (!stat) {
|
||||
return
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
return rmdir(path, options, originalErr, isTop)
|
||||
}
|
||||
|
||||
return fs.unlink(path)
|
||||
}
|
||||
|
||||
const rmdir = async (path, options, originalErr, isTop) => {
|
||||
if (!options.recursive && isTop) {
|
||||
throw originalErr || new ERR_FS_EISDIR(path)
|
||||
}
|
||||
const force = isTop ? options.force : true
|
||||
|
||||
return fs.rmdir(path)
|
||||
.catch(async (err) => {
|
||||
// in Windows, calling rmdir on a file path will fail with ENOENT rather
|
||||
// than ENOTDIR. to determine if that's what happened, we have to do
|
||||
// another lstat on the path. if the path isn't actually gone, we throw
|
||||
// away the ENOENT and replace it with our own ENOTDIR
|
||||
if (isWindows && err.code === 'ENOENT') {
|
||||
const stillExists = await fs.lstat(path).then(() => true, () => false)
|
||||
if (stillExists) {
|
||||
err = new ENOTDIR(path)
|
||||
}
|
||||
}
|
||||
|
||||
// not there, not a problem
|
||||
if (err.code === 'ENOENT' && force) {
|
||||
return
|
||||
}
|
||||
|
||||
// we may not have originalErr if lstat tells us our target is a
|
||||
// directory but that changes before we actually remove it, so
|
||||
// only throw it here if it's set
|
||||
if (originalErr && err.code === 'ENOTDIR') {
|
||||
throw originalErr
|
||||
}
|
||||
|
||||
// the directory isn't empty, remove the contents and try again
|
||||
if (notEmptyCodes.has(err.code)) {
|
||||
const files = await fs.readdir(path)
|
||||
await Promise.all(files.map((file) => {
|
||||
const target = join(path, file)
|
||||
return rimraf(target, options)
|
||||
}))
|
||||
return fs.rmdir(path)
|
||||
}
|
||||
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
const rm = async (path, opts) => {
|
||||
const options = { ...defaultOptions, ...opts }
|
||||
let retries = 0
|
||||
|
||||
const errHandler = async (err) => {
|
||||
if (retryCodes.has(err.code) && ++retries < options.maxRetries) {
|
||||
const delay = retries * options.retryDelay
|
||||
await promiseTimeout(delay)
|
||||
return rimraf(path, options, true).catch(errHandler)
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
|
||||
return rimraf(path, options, true).catch(errHandler)
|
||||
}
|
||||
|
||||
const promiseTimeout = (ms) => new Promise((r) => setTimeout(r, ms))
|
||||
|
||||
module.exports = rm
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue