mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix condition to check if extension is enabled
This commit is contained in:
parent
e63fd8e122
commit
83cc9a4bcf
@ -47,13 +47,9 @@ exports.addINIValues = addINIValues;
|
|||||||
function enableExtensionWindows(extension) {
|
function enableExtensionWindows(extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return `try {
|
return `try {
|
||||||
$${extension}_found = 0
|
|
||||||
$ext_dir = Get-PhpIniKey extension_dir
|
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
$enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}"
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
if($enabled -eq 'no' -and $exist) {
|
|
||||||
Enable-PhpExtension ${extension} C:\\tools\\php
|
Enable-PhpExtension ${extension} C:\\tools\\php
|
||||||
$${extension}_found = 1
|
|
||||||
}
|
}
|
||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
echo $_
|
echo $_
|
||||||
@ -68,12 +64,9 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
|||||||
*/
|
*/
|
||||||
function enableExtensionUnix(extension) {
|
function enableExtensionUnix(extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return `${extension}_found=0
|
return `if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
|
||||||
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||||
echo "${extension} enabled"
|
echo "${extension} enabled"
|
||||||
${extension}_found=1
|
|
||||||
fi\n`;
|
fi\n`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -93,9 +86,9 @@ function addExtensionDarwin(extension_csv) {
|
|||||||
script += yield enableExtensionUnix(extension);
|
script += yield enableExtensionUnix(extension);
|
||||||
if (yield pecl.checkPECLExtension(extension)) {
|
if (yield pecl.checkPECLExtension(extension)) {
|
||||||
script +=
|
script +=
|
||||||
'if [ $' +
|
'if [ ! "$(php -m | grep ' +
|
||||||
extension +
|
extension +
|
||||||
'_found -eq 0 ]; then sudo pecl install ' +
|
')" ]; then sudo pecl install ' +
|
||||||
extension +
|
extension +
|
||||||
' || echo "Couldn\'t find extension: ' +
|
' || echo "Couldn\'t find extension: ' +
|
||||||
extension +
|
extension +
|
||||||
@ -127,9 +120,9 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
}
|
}
|
||||||
if (yield pecl.checkPECLExtension(extension)) {
|
if (yield pecl.checkPECLExtension(extension)) {
|
||||||
script +=
|
script +=
|
||||||
'if($' +
|
'if(!(php -m | findstr -i ' +
|
||||||
extension +
|
extension +
|
||||||
'_found -eq 0) { ' +
|
')) { ' +
|
||||||
'try { Install-PhpExtension ' +
|
'try { Install-PhpExtension ' +
|
||||||
extension +
|
extension +
|
||||||
' -MinimumStability ' +
|
' -MinimumStability ' +
|
||||||
@ -159,9 +152,9 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
// add script to enable extension is already installed along with php
|
// add script to enable extension is already installed along with php
|
||||||
script += yield enableExtensionUnix(extension);
|
script += yield enableExtensionUnix(extension);
|
||||||
script +=
|
script +=
|
||||||
'if [ $' +
|
'if [ ! "$(php -m | grep ' +
|
||||||
extension +
|
extension +
|
||||||
'_found -eq 0 ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
@ -207,8 +200,7 @@ function addINIValuesWindows(ini_values_csv) {
|
|||||||
yield utils.asyncForEach(ini_values, function (ini_value) {
|
yield utils.asyncForEach(ini_values, function (ini_value) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// add script to set ini value
|
// add script to set ini value
|
||||||
script +=
|
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
||||||
'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
|
15
node_modules/.bin/codecov
generated
vendored
15
node_modules/.bin/codecov
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../codecov/bin/codecov" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../codecov/bin/codecov" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
7
node_modules/.bin/codecov.cmd
generated
vendored
7
node_modules/.bin/codecov.cmd
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\codecov\bin\codecov" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\codecov\bin\codecov" %*
|
|
||||||
)
|
|
15
node_modules/.bin/esparse
generated
vendored
15
node_modules/.bin/esparse
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../esprima/bin/esparse.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../esprima/bin/esparse.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
7
node_modules/.bin/esparse.cmd
generated
vendored
7
node_modules/.bin/esparse.cmd
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esparse.js" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\esprima\bin\esparse.js" %*
|
|
||||||
)
|
|
15
node_modules/.bin/esvalidate
generated
vendored
15
node_modules/.bin/esvalidate
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../esprima/bin/esvalidate.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../esprima/bin/esvalidate.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
7
node_modules/.bin/esvalidate.cmd
generated
vendored
7
node_modules/.bin/esvalidate.cmd
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\esprima\bin\esvalidate.js" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\esprima\bin\esvalidate.js" %*
|
|
||||||
)
|
|
15
node_modules/.bin/js-yaml
generated
vendored
15
node_modules/.bin/js-yaml
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../js-yaml/bin/js-yaml.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../js-yaml/bin/js-yaml.js" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
7
node_modules/.bin/js-yaml.cmd
generated
vendored
7
node_modules/.bin/js-yaml.cmd
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\js-yaml\bin\js-yaml.js" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\js-yaml\bin\js-yaml.js" %*
|
|
||||||
)
|
|
24
node_modules/agent-base/.travis.yml
generated
vendored
24
node_modules/agent-base/.travis.yml
generated
vendored
@ -1,24 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
|
|
||||||
language: node_js
|
|
||||||
|
|
||||||
node_js:
|
|
||||||
- "4"
|
|
||||||
- "5"
|
|
||||||
- "6"
|
|
||||||
- "7"
|
|
||||||
- "8"
|
|
||||||
- "9"
|
|
||||||
- "10"
|
|
||||||
|
|
||||||
install:
|
|
||||||
- PATH="`npm bin`:`npm bin -g`:$PATH"
|
|
||||||
# Install dependencies and build
|
|
||||||
- npm install
|
|
||||||
|
|
||||||
script:
|
|
||||||
# Output useful info for debugging
|
|
||||||
- node --version
|
|
||||||
- npm --version
|
|
||||||
# Run tests
|
|
||||||
- npm test
|
|
113
node_modules/agent-base/History.md
generated
vendored
113
node_modules/agent-base/History.md
generated
vendored
@ -1,113 +0,0 @@
|
|||||||
|
|
||||||
4.2.0 / 2018-01-15
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Add support for returning an `http.Agent` instance
|
|
||||||
* Optimize promisifying logic
|
|
||||||
* Set `timeout` to null for proper cleanup
|
|
||||||
* Remove Node.js <= 0.11.3 special-casing from test case
|
|
||||||
|
|
||||||
4.1.2 / 2017-11-20
|
|
||||||
==================
|
|
||||||
|
|
||||||
* test Node 9 on Travis
|
|
||||||
* ensure that `https.get()` uses the patched `https.request()`
|
|
||||||
|
|
||||||
4.1.1 / 2017-07-20
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Correct `https.request()` with a String (#9)
|
|
||||||
|
|
||||||
4.1.0 / 2017-06-26
|
|
||||||
==================
|
|
||||||
|
|
||||||
* mix in Agent options into Request options
|
|
||||||
* throw when nothing is returned from agent-base callback
|
|
||||||
* do not modify the options object for https requests
|
|
||||||
|
|
||||||
4.0.1 / 2017-06-13
|
|
||||||
==================
|
|
||||||
|
|
||||||
* add `this` context tests and fixes
|
|
||||||
|
|
||||||
4.0.0 / 2017-06-06
|
|
||||||
==================
|
|
||||||
|
|
||||||
* drop support for Node.js < 4
|
|
||||||
* drop old versions of Node.js from Travis-CI
|
|
||||||
* specify Node.js >= 4.0.0 in `engines.node`
|
|
||||||
* remove more old code
|
|
||||||
* remove "extend" dependency
|
|
||||||
* remove "semver" dependency
|
|
||||||
* make the Promise logic a bit cleaner
|
|
||||||
* add async function pseudo-example to README
|
|
||||||
* use direct return in README example
|
|
||||||
|
|
||||||
3.0.0 / 2017-06-02
|
|
||||||
==================
|
|
||||||
|
|
||||||
* drop support for Node.js v0.8 and v0.10
|
|
||||||
* add support for async, Promises, and direct return
|
|
||||||
* add a couple `options` test cases
|
|
||||||
* implement a `"timeout"` option
|
|
||||||
* rename main file to `index.js`
|
|
||||||
* test Node 8 on Travis
|
|
||||||
|
|
||||||
2.1.1 / 2017-05-30
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Revert [`fe2162e`](https://github.com/TooTallNate/node-agent-base/commit/fe2162e0ba18123f5b301cba4de1e9dd74e437cd) and [`270bdc9`](https://github.com/TooTallNate/node-agent-base/commit/270bdc92eb8e3bd0444d1e5266e8e9390aeb3095) (fixes #7)
|
|
||||||
|
|
||||||
2.1.0 / 2017-05-26
|
|
||||||
==================
|
|
||||||
|
|
||||||
* unref is not supported for node < 0.9.1 (@pi0)
|
|
||||||
* add tests to dangling socket (@pi0)
|
|
||||||
* check unref() is supported (@pi0)
|
|
||||||
* fix dangling sockets problem (@pi0)
|
|
||||||
* add basic "ws" module tests
|
|
||||||
* make `Agent` be subclassable
|
|
||||||
* turn `addRequest()` into a named function
|
|
||||||
* test: Node.js v4 likes to call `cork` on the stream (#3, @tomhughes)
|
|
||||||
* travis: test node v4, v5, v6 and v7
|
|
||||||
|
|
||||||
2.0.1 / 2015-09-10
|
|
||||||
==================
|
|
||||||
|
|
||||||
* package: update "semver" to v5.0.1 for WebPack (#1, @vhpoet)
|
|
||||||
|
|
||||||
2.0.0 / 2015-07-10
|
|
||||||
==================
|
|
||||||
|
|
||||||
* refactor to patch Node.js core for more consistent `opts` values
|
|
||||||
* ensure that HTTP(s) default port numbers are always given
|
|
||||||
* test: use ssl-cert-snakeoil SSL certs
|
|
||||||
* test: add tests for arbitrary options
|
|
||||||
* README: add API section
|
|
||||||
* README: make the Agent HTTP/HTTPS generic in the example
|
|
||||||
* README: use SVG for Travis-CI badge
|
|
||||||
|
|
||||||
1.0.2 / 2015-06-27
|
|
||||||
==================
|
|
||||||
|
|
||||||
* agent: set `req._hadError` to true after emitting "error"
|
|
||||||
* package: update "mocha" to v2
|
|
||||||
* test: add artificial HTTP GET request test
|
|
||||||
* test: add artificial data events test
|
|
||||||
* test: fix artifical GET response test on node > v0.11.3
|
|
||||||
* test: use a real timeout for the async error test
|
|
||||||
|
|
||||||
1.0.1 / 2013-09-09
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Fix passing an "error" object to the callback function on the first tick
|
|
||||||
|
|
||||||
1.0.0 / 2013-09-09
|
|
||||||
==================
|
|
||||||
|
|
||||||
* New API: now you pass a callback function directly
|
|
||||||
|
|
||||||
0.0.1 / 2013-07-09
|
|
||||||
==================
|
|
||||||
|
|
||||||
* Initial release
|
|
145
node_modules/agent-base/README.md
generated
vendored
145
node_modules/agent-base/README.md
generated
vendored
@ -1,145 +0,0 @@
|
|||||||
agent-base
|
|
||||||
==========
|
|
||||||
### Turn a function into an [`http.Agent`][http.Agent] instance
|
|
||||||
[![Build Status](https://travis-ci.org/TooTallNate/node-agent-base.svg?branch=master)](https://travis-ci.org/TooTallNate/node-agent-base)
|
|
||||||
|
|
||||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
|
||||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
|
||||||
given callback function when sending outbound HTTP requests.
|
|
||||||
|
|
||||||
#### Some subclasses:
|
|
||||||
|
|
||||||
Here's some more interesting uses of `agent-base`.
|
|
||||||
Send a pull request to list yours!
|
|
||||||
|
|
||||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
|
||||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
|
||||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
|
||||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS (v4a) proxy `http.Agent` implementation for HTTP and HTTPS
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
Install with `npm`:
|
|
||||||
|
|
||||||
``` bash
|
|
||||||
$ npm install agent-base
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
|
||||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
|
||||||
|
|
||||||
```js
|
|
||||||
var net = require('net');
|
|
||||||
var tls = require('tls');
|
|
||||||
var url = require('url');
|
|
||||||
var http = require('http');
|
|
||||||
var agent = require('agent-base');
|
|
||||||
|
|
||||||
var endpoint = 'http://nodejs.org/api/';
|
|
||||||
var parsed = url.parse(endpoint);
|
|
||||||
|
|
||||||
// This is the important part!
|
|
||||||
parsed.agent = agent(function (req, opts) {
|
|
||||||
var socket;
|
|
||||||
// `secureEndpoint` is true when using the https module
|
|
||||||
if (opts.secureEndpoint) {
|
|
||||||
socket = tls.connect(opts);
|
|
||||||
} else {
|
|
||||||
socket = net.connect(opts);
|
|
||||||
}
|
|
||||||
return socket;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Everything else works just like normal...
|
|
||||||
http.get(parsed, function (res) {
|
|
||||||
console.log('"response" event!', res.headers);
|
|
||||||
res.pipe(process.stdout);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Returning a Promise or using an `async` function is also supported:
|
|
||||||
|
|
||||||
```js
|
|
||||||
agent(async function (req, opts) {
|
|
||||||
await sleep(1000);
|
|
||||||
// etc…
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Return another `http.Agent` instance to "pass through" the responsibility
|
|
||||||
for that HTTP request to that agent:
|
|
||||||
|
|
||||||
```js
|
|
||||||
agent(function (req, opts) {
|
|
||||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
API
|
|
||||||
---
|
|
||||||
|
|
||||||
## Agent(Function callback[, Object options]) → [http.Agent][]
|
|
||||||
|
|
||||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
|
||||||
for every HTTP request that it is used as the `agent` for. The callback function
|
|
||||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
|
||||||
used as the underlying socket in the HTTP request.
|
|
||||||
|
|
||||||
The `options` object accepts the following properties:
|
|
||||||
|
|
||||||
* `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
|
|
||||||
|
|
||||||
The callback function should have the following signature:
|
|
||||||
|
|
||||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
|
||||||
|
|
||||||
The ClientRequest `req` can be accessed to read request headers and
|
|
||||||
and the path, etc. The `options` object contains the options passed
|
|
||||||
to the `http.request()`/`https.request()` function call, and is formatted
|
|
||||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
|
||||||
else you want a Socket to be created. Pass the created socket to
|
|
||||||
the callback function `cb` once created, and the HTTP request will
|
|
||||||
continue to proceed.
|
|
||||||
|
|
||||||
If the `https` module is used to invoke the HTTP request, then the
|
|
||||||
`secureEndpoint` property on `options` _will be set to `true`_.
|
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
(The MIT License)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
|
||||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
|
||||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
|
||||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
|
||||||
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
|
43
node_modules/agent-base/index.d.ts
generated
vendored
43
node_modules/agent-base/index.d.ts
generated
vendored
@ -1,43 +0,0 @@
|
|||||||
// Type definitions for agent-base 4.2.1
|
|
||||||
// Project: https://github.com/TooTallNate/node-agent-base
|
|
||||||
// Definitions by: Christopher Quadflieg <https://github.com/Shinigami92>
|
|
||||||
|
|
||||||
/// <reference types="node" />
|
|
||||||
import { EventEmitter } from 'events';
|
|
||||||
|
|
||||||
declare namespace Agent {
|
|
||||||
export type AgentCallback = (
|
|
||||||
req?: any,
|
|
||||||
opts?: {
|
|
||||||
secureEndpoint: boolean;
|
|
||||||
}
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
export interface AgentOptions {
|
|
||||||
timeout?: number;
|
|
||||||
host?: string;
|
|
||||||
port?: number;
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Agent extends EventEmitter {
|
|
||||||
_promisifiedCallback: boolean;
|
|
||||||
timeout: number | null;
|
|
||||||
options?: AgentOptions;
|
|
||||||
callback: AgentCallback;
|
|
||||||
addRequest: (req?: any, opts?: any) => void;
|
|
||||||
freeSocket: (socket: any, opts: any) => void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base `http.Agent` implementation.
|
|
||||||
* No pooling/keep-alive is implemented by default.
|
|
||||||
*/
|
|
||||||
declare function Agent(opts?: Agent.AgentOptions): Agent.Agent;
|
|
||||||
declare function Agent(
|
|
||||||
callback: Agent.AgentCallback,
|
|
||||||
opts?: Agent.AgentOptions
|
|
||||||
): Agent.Agent;
|
|
||||||
|
|
||||||
export = Agent;
|
|
170
node_modules/agent-base/index.js
generated
vendored
170
node_modules/agent-base/index.js
generated
vendored
@ -1,170 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
require('./patch-core');
|
|
||||||
const inherits = require('util').inherits;
|
|
||||||
const promisify = require('es6-promisify');
|
|
||||||
const EventEmitter = require('events').EventEmitter;
|
|
||||||
|
|
||||||
module.exports = Agent;
|
|
||||||
|
|
||||||
function isAgent(v) {
|
|
||||||
return v && typeof v.addRequest === 'function';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base `http.Agent` implementation.
|
|
||||||
* No pooling/keep-alive is implemented by default.
|
|
||||||
*
|
|
||||||
* @param {Function} callback
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
function Agent(callback, _opts) {
|
|
||||||
if (!(this instanceof Agent)) {
|
|
||||||
return new Agent(callback, _opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
EventEmitter.call(this);
|
|
||||||
|
|
||||||
// The callback gets promisified if it has 3 parameters
|
|
||||||
// (i.e. it has a callback function) lazily
|
|
||||||
this._promisifiedCallback = false;
|
|
||||||
|
|
||||||
let opts = _opts;
|
|
||||||
if ('function' === typeof callback) {
|
|
||||||
this.callback = callback;
|
|
||||||
} else if (callback) {
|
|
||||||
opts = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// timeout for the socket to be returned from the callback
|
|
||||||
this.timeout = (opts && opts.timeout) || null;
|
|
||||||
|
|
||||||
this.options = opts;
|
|
||||||
}
|
|
||||||
inherits(Agent, EventEmitter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Override this function in your subclass!
|
|
||||||
*/
|
|
||||||
Agent.prototype.callback = function callback(req, opts) {
|
|
||||||
throw new Error(
|
|
||||||
'"agent-base" has no default implementation, you must subclass and override `callback()`'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by node-core's "_http_client.js" module when creating
|
|
||||||
* a new HTTP request with this Agent instance.
|
|
||||||
*
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
Agent.prototype.addRequest = function addRequest(req, _opts) {
|
|
||||||
const ownOpts = Object.assign({}, _opts);
|
|
||||||
|
|
||||||
// Set default `host` for HTTP to localhost
|
|
||||||
if (null == ownOpts.host) {
|
|
||||||
ownOpts.host = 'localhost';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set default `port` for HTTP if none was explicitly specified
|
|
||||||
if (null == ownOpts.port) {
|
|
||||||
ownOpts.port = ownOpts.secureEndpoint ? 443 : 80;
|
|
||||||
}
|
|
||||||
|
|
||||||
const opts = Object.assign({}, this.options, ownOpts);
|
|
||||||
|
|
||||||
if (opts.host && opts.path) {
|
|
||||||
// If both a `host` and `path` are specified then it's most likely the
|
|
||||||
// result of a `url.parse()` call... we need to remove the `path` portion so
|
|
||||||
// that `net.connect()` doesn't attempt to open that as a unix socket file.
|
|
||||||
delete opts.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete opts.agent;
|
|
||||||
delete opts.hostname;
|
|
||||||
delete opts._defaultAgent;
|
|
||||||
delete opts.defaultPort;
|
|
||||||
delete opts.createConnection;
|
|
||||||
|
|
||||||
// Hint to use "Connection: close"
|
|
||||||
// XXX: non-documented `http` module API :(
|
|
||||||
req._last = true;
|
|
||||||
req.shouldKeepAlive = false;
|
|
||||||
|
|
||||||
// Create the `stream.Duplex` instance
|
|
||||||
let timeout;
|
|
||||||
let timedOut = false;
|
|
||||||
const timeoutMs = this.timeout;
|
|
||||||
const freeSocket = this.freeSocket;
|
|
||||||
|
|
||||||
function onerror(err) {
|
|
||||||
if (req._hadError) return;
|
|
||||||
req.emit('error', err);
|
|
||||||
// For Safety. Some additional errors might fire later on
|
|
||||||
// and we need to make sure we don't double-fire the error event.
|
|
||||||
req._hadError = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ontimeout() {
|
|
||||||
timeout = null;
|
|
||||||
timedOut = true;
|
|
||||||
const err = new Error(
|
|
||||||
'A "socket" was not created for HTTP request before ' + timeoutMs + 'ms'
|
|
||||||
);
|
|
||||||
err.code = 'ETIMEOUT';
|
|
||||||
onerror(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callbackError(err) {
|
|
||||||
if (timedOut) return;
|
|
||||||
if (timeout != null) {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = null;
|
|
||||||
}
|
|
||||||
onerror(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onsocket(socket) {
|
|
||||||
if (timedOut) return;
|
|
||||||
if (timeout != null) {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
timeout = null;
|
|
||||||
}
|
|
||||||
if (isAgent(socket)) {
|
|
||||||
// `socket` is actually an http.Agent instance, so relinquish
|
|
||||||
// responsibility for this `req` to the Agent from here on
|
|
||||||
socket.addRequest(req, opts);
|
|
||||||
} else if (socket) {
|
|
||||||
function onfree() {
|
|
||||||
freeSocket(socket, opts);
|
|
||||||
}
|
|
||||||
socket.on('free', onfree);
|
|
||||||
req.onSocket(socket);
|
|
||||||
} else {
|
|
||||||
const err = new Error(
|
|
||||||
'no Duplex stream was returned to agent-base for `' + req.method + ' ' + req.path + '`'
|
|
||||||
);
|
|
||||||
onerror(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this._promisifiedCallback && this.callback.length >= 3) {
|
|
||||||
// Legacy callback function - convert to a Promise
|
|
||||||
this.callback = promisify(this.callback, this);
|
|
||||||
this._promisifiedCallback = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeoutMs > 0) {
|
|
||||||
timeout = setTimeout(ontimeout, timeoutMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Promise.resolve(this.callback(req, opts)).then(onsocket, callbackError);
|
|
||||||
} catch (err) {
|
|
||||||
Promise.reject(err).catch(callbackError);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Agent.prototype.freeSocket = function freeSocket(socket, opts) {
|
|
||||||
// TODO reuse sockets
|
|
||||||
socket.destroy();
|
|
||||||
};
|
|
70
node_modules/agent-base/package.json
generated
vendored
70
node_modules/agent-base/package.json
generated
vendored
@ -1,70 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"agent-base@4.3.0",
|
|
||||||
"E:\\python\\setup-php"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "agent-base@4.3.0",
|
|
||||||
"_id": "agent-base@4.3.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
|
|
||||||
"_location": "/agent-base",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "agent-base@4.3.0",
|
|
||||||
"name": "agent-base",
|
|
||||||
"escapedName": "agent-base",
|
|
||||||
"rawSpec": "4.3.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "4.3.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/https-proxy-agent"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
|
||||||
"_spec": "4.3.0",
|
|
||||||
"_where": "E:\\python\\setup-php",
|
|
||||||
"author": {
|
|
||||||
"name": "Nathan Rajlich",
|
|
||||||
"email": "nathan@tootallnate.net",
|
|
||||||
"url": "http://n8.io/"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/TooTallNate/node-agent-base/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"es6-promisify": "^5.0.0"
|
|
||||||
},
|
|
||||||
"description": "Turn a function into an `http.Agent` instance",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/es6-promisify": "^5.0.0",
|
|
||||||
"@types/node": "^10.5.3",
|
|
||||||
"mocha": "^3.4.2",
|
|
||||||
"ws": "^3.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 4.0.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/TooTallNate/node-agent-base#readme",
|
|
||||||
"keywords": [
|
|
||||||
"http",
|
|
||||||
"agent",
|
|
||||||
"base",
|
|
||||||
"barebones",
|
|
||||||
"https"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "./index.js",
|
|
||||||
"name": "agent-base",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/TooTallNate/node-agent-base.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "mocha --reporter spec"
|
|
||||||
},
|
|
||||||
"version": "4.3.0"
|
|
||||||
}
|
|
51
node_modules/agent-base/patch-core.js
generated
vendored
51
node_modules/agent-base/patch-core.js
generated
vendored
@ -1,51 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
const url = require('url');
|
|
||||||
const https = require('https');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This currently needs to be applied to all Node.js versions
|
|
||||||
* in order to determine if the `req` is an HTTP or HTTPS request.
|
|
||||||
*
|
|
||||||
* There is currently no PR attempting to move this property upstream.
|
|
||||||
*/
|
|
||||||
const patchMarker = "__agent_base_https_request_patched__";
|
|
||||||
if (!https.request[patchMarker]) {
|
|
||||||
https.request = (function(request) {
|
|
||||||
return function(_options, cb) {
|
|
||||||
let options;
|
|
||||||
if (typeof _options === 'string') {
|
|
||||||
options = url.parse(_options);
|
|
||||||
} else {
|
|
||||||
options = Object.assign({}, _options);
|
|
||||||
}
|
|
||||||
if (null == options.port) {
|
|
||||||
options.port = 443;
|
|
||||||
}
|
|
||||||
options.secureEndpoint = true;
|
|
||||||
return request.call(https, options, cb);
|
|
||||||
};
|
|
||||||
})(https.request);
|
|
||||||
https.request[patchMarker] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is needed for Node.js >= 9.0.0 to make sure `https.get()` uses the
|
|
||||||
* patched `https.request()`.
|
|
||||||
*
|
|
||||||
* Ref: https://github.com/nodejs/node/commit/5118f31
|
|
||||||
*/
|
|
||||||
https.get = function (_url, _options, cb) {
|
|
||||||
let options;
|
|
||||||
if (typeof _url === 'string' && _options && typeof _options !== 'function') {
|
|
||||||
options = Object.assign({}, url.parse(_url), _options);
|
|
||||||
} else if (!_options && !cb) {
|
|
||||||
options = _url;
|
|
||||||
} else if (!cb) {
|
|
||||||
options = _url;
|
|
||||||
cb = _options;
|
|
||||||
}
|
|
||||||
|
|
||||||
const req = https.request(options, cb);
|
|
||||||
req.end();
|
|
||||||
return req;
|
|
||||||
};
|
|
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIICWwIBAAKBgQCzURxIqzer0ACAbX/lHdsn4Gd9PLKrf7EeDYfIdV0HZKPD8WDr
|
|
||||||
bBx2/fBu0OW2sjnzv/SVZbJ0DAuPE/p0+eT0qb2qC10iz9iTD7ribd7gxhirVb8y
|
|
||||||
b3fBjXsxc8V8p4Ny1LcvNSqCjwUbJqdRogfoJeTiqPM58z5sNzuv5iq7iwIDAQAB
|
|
||||||
AoGAPMQy4olrP0UotlzlJ36bowLP70ffgHCwU+/f4NWs5fF78c3du0oSx1w820Dd
|
|
||||||
Z7E0JF8bgnlJJTxjumPZz0RUCugrEHBKJmzEz3cxF5E3+7NvteZcjKn9D67RrM5x
|
|
||||||
1/uSZ9cqKE9cYvY4fSuHx18diyZ4axR/wB1Pea2utjjDM+ECQQDb9ZbmmaWMiRpQ
|
|
||||||
5Up+loxP7BZNPsEVsm+DVJmEFbaFgGfncWBqSIqnPNjMwTwj0OigTwCAEGPkfRVW
|
|
||||||
T0pbYWCxAkEA0LK7SCTwzyDmhASUalk0x+3uCAA6ryFdwJf/wd8TRAvVOmkTEldX
|
|
||||||
uJ7ldLvfrONYO3v56uKTU/SoNdZYzKtO+wJAX2KM4ctXYy5BXztPpr2acz4qHa1N
|
|
||||||
Bh+vBAC34fOYhyQ76r3b1btHhWZ5jbFuZwm9F2erC94Ps5IaoqcX07DSwQJAPKGw
|
|
||||||
h2U0EPkd/3zVIZCJJQya+vgWFIs9EZcXVtvYXQyTBkVApTN66MhBIYjzkub5205J
|
|
||||||
bVQmOV37AKklY1DhwQJAA1wos0cYxro02edzatxd0DIR2r4qqOqLkw6BhYHhq6HJ
|
|
||||||
ZvIcQkHqdSXzdETFc01I1znDGGIrJHcnvKWgBPoEUg==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIB1TCCAT4CCQDV5mPlzm9+izANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyQ3
|
|
||||||
NTI3YmQ3Ny1hYjNlLTQ3NGItYWNlNy1lZWQ2MDUzOTMxZTcwHhcNMTUwNzA2MjI0
|
|
||||||
NTA3WhcNMjUwNzAzMjI0NTA3WjAvMS0wKwYDVQQDEyQ3NTI3YmQ3Ny1hYjNlLTQ3
|
|
||||||
NGItYWNlNy1lZWQ2MDUzOTMxZTcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
|
||||||
ALNRHEirN6vQAIBtf+Ud2yfgZ308sqt/sR4Nh8h1XQdko8PxYOtsHHb98G7Q5bay
|
|
||||||
OfO/9JVlsnQMC48T+nT55PSpvaoLXSLP2JMPuuJt3uDGGKtVvzJvd8GNezFzxXyn
|
|
||||||
g3LUty81KoKPBRsmp1GiB+gl5OKo8znzPmw3O6/mKruLAgMBAAEwDQYJKoZIhvcN
|
|
||||||
AQEFBQADgYEACzoHUF8UV2Z6541Q2wKEA0UFUzmUjf/E1XwBO+1P15ZZ64uw34B4
|
|
||||||
1RwMPtAo9RY/PmICTWtNxWGxkzwb2JtDWtnxVER/lF8k2XcXPE76fxTHJF/BKk9J
|
|
||||||
QU8OTD1dd9gHCBviQB9TqntRZ5X7axjtuWjb2umY+owBYzAHZkp1HKI=
|
|
||||||
-----END CERTIFICATE-----
|
|
728
node_modules/agent-base/test/test.js
generated
vendored
728
node_modules/agent-base/test/test.js
generated
vendored
@ -1,728 +0,0 @@
|
|||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var url = require('url');
|
|
||||||
var net = require('net');
|
|
||||||
var tls = require('tls');
|
|
||||||
var http = require('http');
|
|
||||||
var https = require('https');
|
|
||||||
var WebSocket = require('ws');
|
|
||||||
var assert = require('assert');
|
|
||||||
var events = require('events');
|
|
||||||
var inherits = require('util').inherits;
|
|
||||||
var Agent = require('../');
|
|
||||||
|
|
||||||
var PassthroughAgent = Agent(function(req, opts) {
|
|
||||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Agent', function() {
|
|
||||||
describe('subclass', function() {
|
|
||||||
it('should be subclassable', function(done) {
|
|
||||||
function MyAgent() {
|
|
||||||
Agent.call(this);
|
|
||||||
}
|
|
||||||
inherits(MyAgent, Agent);
|
|
||||||
|
|
||||||
MyAgent.prototype.callback = function(req, opts, fn) {
|
|
||||||
assert.equal(req.path, '/foo');
|
|
||||||
assert.equal(req.getHeader('host'), '127.0.0.1:1234');
|
|
||||||
assert.equal(opts.secureEndpoint, true);
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
|
|
||||||
var info = url.parse('https://127.0.0.1:1234/foo');
|
|
||||||
info.agent = new MyAgent();
|
|
||||||
https.get(info);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('options', function() {
|
|
||||||
it('should support an options Object as first argument', function() {
|
|
||||||
var agent = new Agent({ timeout: 1000 });
|
|
||||||
assert.equal(1000, agent.timeout);
|
|
||||||
});
|
|
||||||
it('should support an options Object as second argument', function() {
|
|
||||||
var agent = new Agent(function() {}, { timeout: 1000 });
|
|
||||||
assert.equal(1000, agent.timeout);
|
|
||||||
});
|
|
||||||
it('should be mixed in with HTTP request options', function(done) {
|
|
||||||
var agent = new Agent({
|
|
||||||
host: 'my-proxy.com',
|
|
||||||
port: 3128,
|
|
||||||
foo: 'bar'
|
|
||||||
});
|
|
||||||
agent.callback = function(req, opts, fn) {
|
|
||||||
assert.equal('bar', opts.foo);
|
|
||||||
assert.equal('a', opts.b);
|
|
||||||
|
|
||||||
// `host` and `port` are special-cases, and should always be
|
|
||||||
// overwritten in the request `opts` inside the agent-base callback
|
|
||||||
assert.equal('localhost', opts.host);
|
|
||||||
assert.equal(80, opts.port);
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
var opts = {
|
|
||||||
b: 'a',
|
|
||||||
agent: agent
|
|
||||||
};
|
|
||||||
http.get(opts);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('`this` context', function() {
|
|
||||||
it('should be the Agent instance', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent();
|
|
||||||
agent.callback = function() {
|
|
||||||
called = true;
|
|
||||||
assert.equal(this, agent);
|
|
||||||
};
|
|
||||||
var info = url.parse('http://127.0.0.1/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
var req = http.get(info);
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert(/no Duplex stream was returned/.test(err.message));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should be the Agent instance with callback signature', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent();
|
|
||||||
agent.callback = function(req, opts, fn) {
|
|
||||||
called = true;
|
|
||||||
assert.equal(this, agent);
|
|
||||||
fn();
|
|
||||||
};
|
|
||||||
var info = url.parse('http://127.0.0.1/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
var req = http.get(info);
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert(/no Duplex stream was returned/.test(err.message));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('"error" event', function() {
|
|
||||||
it('should be invoked on `http.ClientRequest` instance if `callback()` has not been defined', function(
|
|
||||||
done
|
|
||||||
) {
|
|
||||||
var agent = new Agent();
|
|
||||||
var info = url.parse('http://127.0.0.1/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
var req = http.get(info);
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert.equal(
|
|
||||||
'"agent-base" has no default implementation, you must subclass and override `callback()`',
|
|
||||||
err.message
|
|
||||||
);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should be invoked on `http.ClientRequest` instance if Error passed to callback function on the first tick', function(
|
|
||||||
done
|
|
||||||
) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
fn(new Error('is this caught?'));
|
|
||||||
});
|
|
||||||
var info = url.parse('http://127.0.0.1/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
var req = http.get(info);
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert.equal('is this caught?', err.message);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should be invoked on `http.ClientRequest` instance if Error passed to callback function after the first tick', function(
|
|
||||||
done
|
|
||||||
) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
setTimeout(function() {
|
|
||||||
fn(new Error('is this caught?'));
|
|
||||||
}, 10);
|
|
||||||
});
|
|
||||||
var info = url.parse('http://127.0.0.1/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
var req = http.get(info);
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert.equal('is this caught?', err.message);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('artificial "streams"', function() {
|
|
||||||
it('should send a GET request', function(done) {
|
|
||||||
var stream = new events.EventEmitter();
|
|
||||||
|
|
||||||
// needed for the `http` module to call .write() on the stream
|
|
||||||
stream.writable = true;
|
|
||||||
|
|
||||||
stream.write = function(str) {
|
|
||||||
assert(0 == str.indexOf('GET / HTTP/1.1'));
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
|
|
||||||
// needed for `http` module in Node.js 4
|
|
||||||
stream.cork = function() {};
|
|
||||||
|
|
||||||
var opts = {
|
|
||||||
method: 'GET',
|
|
||||||
host: '127.0.0.1',
|
|
||||||
path: '/',
|
|
||||||
port: 80,
|
|
||||||
agent: new Agent(function(req, opts, fn) {
|
|
||||||
fn(null, stream);
|
|
||||||
})
|
|
||||||
};
|
|
||||||
var req = http.request(opts);
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
it('should receive a GET response', function(done) {
|
|
||||||
var stream = new events.EventEmitter();
|
|
||||||
var opts = {
|
|
||||||
method: 'GET',
|
|
||||||
host: '127.0.0.1',
|
|
||||||
path: '/',
|
|
||||||
port: 80,
|
|
||||||
agent: new Agent(function(req, opts, fn) {
|
|
||||||
fn(null, stream);
|
|
||||||
})
|
|
||||||
};
|
|
||||||
var req = http.request(opts, function(res) {
|
|
||||||
assert.equal('1.0', res.httpVersion);
|
|
||||||
assert.equal(200, res.statusCode);
|
|
||||||
assert.equal('bar', res.headers.foo);
|
|
||||||
assert.deepEqual(['1', '2'], res.headers['set-cookie']);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
// have to wait for the "socket" event since `http.ClientRequest`
|
|
||||||
// doesn't *actually* attach the listeners to the "stream" until
|
|
||||||
// this happens
|
|
||||||
req.once('socket', function() {
|
|
||||||
var buf = Buffer.from(
|
|
||||||
'HTTP/1.0 200\r\n' +
|
|
||||||
'Foo: bar\r\n' +
|
|
||||||
'Set-Cookie: 1\r\n' +
|
|
||||||
'Set-Cookie: 2\r\n\r\n'
|
|
||||||
);
|
|
||||||
stream.emit('data', buf);
|
|
||||||
});
|
|
||||||
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('"http" module', function() {
|
|
||||||
var server;
|
|
||||||
var port;
|
|
||||||
|
|
||||||
// setup test HTTP server
|
|
||||||
before(function(done) {
|
|
||||||
server = http.createServer();
|
|
||||||
server.listen(0, function() {
|
|
||||||
port = server.address().port;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// shut down test HTTP server
|
|
||||||
after(function(done) {
|
|
||||||
server.once('close', function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for basic HTTP requests', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
called = true;
|
|
||||||
var socket = net.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
assert(called);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support direct return in `connect()`', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts) {
|
|
||||||
called = true;
|
|
||||||
return net.connect(opts);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
assert(called);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support returning a Promise in `connect()`', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts) {
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
called = true;
|
|
||||||
resolve(net.connect(opts));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
assert(called);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set the `Connection: close` response header', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
called = true;
|
|
||||||
var socket = net.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
assert.equal('close', req.headers.connection);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/bar');
|
|
||||||
info.agent = agent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
assert.equal('/bar', res.headers['x-url']);
|
|
||||||
assert.equal('close', res.headers.connection);
|
|
||||||
assert(gotReq);
|
|
||||||
assert(called);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pass through options from `http.request()`', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
assert.equal('google.com', opts.host);
|
|
||||||
assert.equal('bar', opts.foo);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
http.get({
|
|
||||||
host: 'google.com',
|
|
||||||
foo: 'bar',
|
|
||||||
agent: agent
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should default to port 80', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
assert.equal(80, opts.port);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
// (probably) not hitting a real HTTP server here,
|
|
||||||
// so no need to add a httpServer request listener
|
|
||||||
http.get({
|
|
||||||
host: '127.0.0.1',
|
|
||||||
path: '/foo',
|
|
||||||
agent: agent
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support the "timeout" option', function(done) {
|
|
||||||
// ensure we timeout after the "error" event had a chance to trigger
|
|
||||||
this.timeout(1000);
|
|
||||||
this.slow(800);
|
|
||||||
|
|
||||||
var agent = new Agent(
|
|
||||||
function(req, opts, fn) {
|
|
||||||
// this function will time out
|
|
||||||
},
|
|
||||||
{ timeout: 100 }
|
|
||||||
);
|
|
||||||
|
|
||||||
var opts = url.parse('http://nodejs.org');
|
|
||||||
opts.agent = agent;
|
|
||||||
|
|
||||||
var req = http.get(opts);
|
|
||||||
req.once('error', function(err) {
|
|
||||||
assert.equal('ETIMEOUT', err.code);
|
|
||||||
req.abort();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should free sockets after use', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
var socket = net.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
res.socket.emit('free');
|
|
||||||
assert.equal(true, res.socket.destroyed);
|
|
||||||
assert(gotReq);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('PassthroughAgent', function() {
|
|
||||||
it('should pass through to `http.globalAgent`', function(done) {
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = PassthroughAgent;
|
|
||||||
http.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('"https" module', function() {
|
|
||||||
var server;
|
|
||||||
var port;
|
|
||||||
|
|
||||||
// setup test HTTPS server
|
|
||||||
before(function(done) {
|
|
||||||
var options = {
|
|
||||||
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
|
|
||||||
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
|
|
||||||
};
|
|
||||||
server = https.createServer(options);
|
|
||||||
server.listen(0, function() {
|
|
||||||
port = server.address().port;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// shut down test HTTP server
|
|
||||||
after(function(done) {
|
|
||||||
server.once('close', function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not modify the passed in Options object', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
called = true;
|
|
||||||
assert.equal(true, opts.secureEndpoint);
|
|
||||||
assert.equal(443, opts.port);
|
|
||||||
assert.equal('localhost', opts.host);
|
|
||||||
});
|
|
||||||
var opts = { agent: agent };
|
|
||||||
var req = https.request(opts);
|
|
||||||
assert.equal(true, called);
|
|
||||||
assert.equal(false, 'secureEndpoint' in opts);
|
|
||||||
assert.equal(false, 'port' in opts);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work with a String URL', function(done) {
|
|
||||||
var endpoint = 'https://127.0.0.1:' + port;
|
|
||||||
var req = https.get(endpoint);
|
|
||||||
|
|
||||||
// it's gonna error out since `rejectUnauthorized` is not being passed in
|
|
||||||
req.on('error', function(err) {
|
|
||||||
assert.equal(err.code, 'DEPTH_ZERO_SELF_SIGNED_CERT');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for basic HTTPS requests', function(done) {
|
|
||||||
var called = false;
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
called = true;
|
|
||||||
assert(opts.secureEndpoint);
|
|
||||||
var socket = tls.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
// add HTTPS server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('https://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = agent;
|
|
||||||
info.rejectUnauthorized = false;
|
|
||||||
https.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
assert(called);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should pass through options from `https.request()`', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
assert.equal('google.com', opts.host);
|
|
||||||
assert.equal('bar', opts.foo);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
https.get({
|
|
||||||
host: 'google.com',
|
|
||||||
foo: 'bar',
|
|
||||||
agent: agent
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support the 3-argument `https.get()`', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
assert.equal('google.com', opts.host);
|
|
||||||
assert.equal('/q', opts.pathname || opts.path);
|
|
||||||
assert.equal('881', opts.port);
|
|
||||||
assert.equal('bar', opts.foo);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
https.get(
|
|
||||||
'https://google.com:881/q',
|
|
||||||
{
|
|
||||||
host: 'google.com',
|
|
||||||
foo: 'bar',
|
|
||||||
agent: agent
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should default to port 443', function(done) {
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
assert.equal(true, opts.secureEndpoint);
|
|
||||||
assert.equal(false, opts.rejectUnauthorized);
|
|
||||||
assert.equal(443, opts.port);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
// (probably) not hitting a real HTTPS server here,
|
|
||||||
// so no need to add a httpsServer request listener
|
|
||||||
https.get({
|
|
||||||
host: '127.0.0.1',
|
|
||||||
path: '/foo',
|
|
||||||
agent: agent,
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not re-patch https.request', () => {
|
|
||||||
var patchModulePath = "../patch-core";
|
|
||||||
var patchedRequest = https.request;
|
|
||||||
|
|
||||||
delete require.cache[require.resolve(patchModulePath)];
|
|
||||||
require(patchModulePath);
|
|
||||||
|
|
||||||
assert.equal(patchedRequest, https.request);
|
|
||||||
assert.equal(true, https.request.__agent_base_https_request_patched__);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('PassthroughAgent', function() {
|
|
||||||
it('should pass through to `https.globalAgent`', function(done) {
|
|
||||||
// add HTTP server "request" listener
|
|
||||||
var gotReq = false;
|
|
||||||
server.once('request', function(req, res) {
|
|
||||||
gotReq = true;
|
|
||||||
res.setHeader('X-Foo', 'bar');
|
|
||||||
res.setHeader('X-Url', req.url);
|
|
||||||
res.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
var info = url.parse('https://127.0.0.1:' + port + '/foo');
|
|
||||||
info.agent = PassthroughAgent;
|
|
||||||
info.rejectUnauthorized = false;
|
|
||||||
https.get(info, function(res) {
|
|
||||||
assert.equal('bar', res.headers['x-foo']);
|
|
||||||
assert.equal('/foo', res.headers['x-url']);
|
|
||||||
assert(gotReq);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('"ws" server', function() {
|
|
||||||
var wss;
|
|
||||||
var server;
|
|
||||||
var port;
|
|
||||||
|
|
||||||
// setup test HTTP server
|
|
||||||
before(function(done) {
|
|
||||||
server = http.createServer();
|
|
||||||
wss = new WebSocket.Server({ server: server });
|
|
||||||
server.listen(0, function() {
|
|
||||||
port = server.address().port;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// shut down test HTTP server
|
|
||||||
after(function(done) {
|
|
||||||
server.once('close', function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for basic WebSocket connections', function(done) {
|
|
||||||
function onconnection(ws) {
|
|
||||||
ws.on('message', function(data) {
|
|
||||||
assert.equal('ping', data);
|
|
||||||
ws.send('pong');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
wss.on('connection', onconnection);
|
|
||||||
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
var socket = net.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
var client = new WebSocket('ws://127.0.0.1:' + port + '/', {
|
|
||||||
agent: agent
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('open', function() {
|
|
||||||
client.send('ping');
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('message', function(data) {
|
|
||||||
assert.equal('pong', data);
|
|
||||||
client.close();
|
|
||||||
wss.removeListener('connection', onconnection);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('"wss" server', function() {
|
|
||||||
var wss;
|
|
||||||
var server;
|
|
||||||
var port;
|
|
||||||
|
|
||||||
// setup test HTTP server
|
|
||||||
before(function(done) {
|
|
||||||
var options = {
|
|
||||||
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
|
|
||||||
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
|
|
||||||
};
|
|
||||||
server = https.createServer(options);
|
|
||||||
wss = new WebSocket.Server({ server: server });
|
|
||||||
server.listen(0, function() {
|
|
||||||
port = server.address().port;
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// shut down test HTTP server
|
|
||||||
after(function(done) {
|
|
||||||
server.once('close', function() {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for secure WebSocket connections', function(done) {
|
|
||||||
function onconnection(ws) {
|
|
||||||
ws.on('message', function(data) {
|
|
||||||
assert.equal('ping', data);
|
|
||||||
ws.send('pong');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
wss.on('connection', onconnection);
|
|
||||||
|
|
||||||
var agent = new Agent(function(req, opts, fn) {
|
|
||||||
var socket = tls.connect(opts);
|
|
||||||
fn(null, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
var client = new WebSocket('wss://127.0.0.1:' + port + '/', {
|
|
||||||
agent: agent,
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('open', function() {
|
|
||||||
client.send('ping');
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('message', function(data) {
|
|
||||||
assert.equal('pong', data);
|
|
||||||
client.close();
|
|
||||||
wss.removeListener('connection', onconnection);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
185
node_modules/argparse/CHANGELOG.md
generated
vendored
185
node_modules/argparse/CHANGELOG.md
generated
vendored
@ -1,185 +0,0 @@
|
|||||||
1.0.10 / 2018-02-15
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Use .concat instead of + for arrays, #122.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.9 / 2016-09-29
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Rerelease after 1.0.8 - deps cleanup.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.8 / 2016-09-29
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Maintenance (deps bump, fix node 6.5+ tests, coverage report).
|
|
||||||
|
|
||||||
|
|
||||||
1.0.7 / 2016-03-17
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Teach `addArgument` to accept string arg names. #97, @tomxtobin.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.6 / 2016-02-06
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Maintenance: moved to eslint & updated CS.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.5 / 2016-02-05
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Removed lodash dependency to significantly reduce install size.
|
|
||||||
Thanks to @mourner.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.4 / 2016-01-17
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Maintenance: lodash update to 4.0.0.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.3 / 2015-10-27
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.2 / 2015-03-22
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Relaxed lodash version dependency.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.1 / 2015-02-20
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Changed dependencies to be compatible with ancient nodejs.
|
|
||||||
|
|
||||||
|
|
||||||
1.0.0 / 2015-02-19
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Maintenance release.
|
|
||||||
- Replaced `underscore` with `lodash`.
|
|
||||||
- Bumped version to 1.0.0 to better reflect semver meaning.
|
|
||||||
- HISTORY.md -> CHANGELOG.md
|
|
||||||
|
|
||||||
|
|
||||||
0.1.16 / 2013-12-01
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Maintenance release. Updated dependencies and docs.
|
|
||||||
|
|
||||||
|
|
||||||
0.1.15 / 2013-05-13
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Fixed #55, @trebor89
|
|
||||||
|
|
||||||
|
|
||||||
0.1.14 / 2013-05-12
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Fixed #62, @maxtaco
|
|
||||||
|
|
||||||
|
|
||||||
0.1.13 / 2013-04-08
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Added `.npmignore` to reduce package size
|
|
||||||
|
|
||||||
|
|
||||||
0.1.12 / 2013-02-10
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Fixed conflictHandler (#46), @hpaulj
|
|
||||||
|
|
||||||
|
|
||||||
0.1.11 / 2013-02-07
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Multiple bugfixes, @hpaulj
|
|
||||||
- Added 70+ tests (ported from python), @hpaulj
|
|
||||||
- Added conflictHandler, @applepicke
|
|
||||||
- Added fromfilePrefixChar, @hpaulj
|
|
||||||
|
|
||||||
|
|
||||||
0.1.10 / 2012-12-30
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion)
|
|
||||||
support, thanks to @hpaulj
|
|
||||||
- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj
|
|
||||||
|
|
||||||
|
|
||||||
0.1.9 / 2012-12-27
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj
|
|
||||||
- Fixed default value behavior with `*` positionals, thanks to @hpaulj
|
|
||||||
- Improve `getDefault()` behavior, thanks to @hpaulj
|
|
||||||
- Imrove negative argument parsing, thanks to @hpaulj
|
|
||||||
|
|
||||||
|
|
||||||
0.1.8 / 2012-12-01
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed parser parents (issue #19), thanks to @hpaulj
|
|
||||||
- Fixed negative argument parse (issue #20), thanks to @hpaulj
|
|
||||||
|
|
||||||
|
|
||||||
0.1.7 / 2012-10-14
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed 'choices' argument parse (issue #16)
|
|
||||||
- Fixed stderr output (issue #15)
|
|
||||||
|
|
||||||
|
|
||||||
0.1.6 / 2012-09-09
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed check for conflict of options (thanks to @tomxtobin)
|
|
||||||
|
|
||||||
|
|
||||||
0.1.5 / 2012-09-03
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fix parser #setDefaults method (thanks to @tomxtobin)
|
|
||||||
|
|
||||||
|
|
||||||
0.1.4 / 2012-07-30
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed pseudo-argument support (thanks to @CGamesPlay)
|
|
||||||
- Fixed addHelp default (should be true), if not set (thanks to @benblank)
|
|
||||||
|
|
||||||
|
|
||||||
0.1.3 / 2012-06-27
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed formatter api name: Formatter -> HelpFormatter
|
|
||||||
|
|
||||||
|
|
||||||
0.1.2 / 2012-05-29
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Added basic tests
|
|
||||||
- Removed excess whitespace in help
|
|
||||||
- Fixed error reporting, when parcer with subcommands
|
|
||||||
called with empty arguments
|
|
||||||
|
|
||||||
|
|
||||||
0.1.1 / 2012-05-23
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- Fixed line wrapping in help formatter
|
|
||||||
- Added better error reporting on invalid arguments
|
|
||||||
|
|
||||||
|
|
||||||
0.1.0 / 2012-05-16
|
|
||||||
------------------
|
|
||||||
|
|
||||||
- First release.
|
|
21
node_modules/argparse/LICENSE
generated
vendored
21
node_modules/argparse/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
(The MIT License)
|
|
||||||
|
|
||||||
Copyright (C) 2012 by Vitaly Puzrin
|
|
||||||
|
|
||||||
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.
|
|
257
node_modules/argparse/README.md
generated
vendored
257
node_modules/argparse/README.md
generated
vendored
@ -1,257 +0,0 @@
|
|||||||
argparse
|
|
||||||
========
|
|
||||||
|
|
||||||
[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse)
|
|
||||||
[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse)
|
|
||||||
|
|
||||||
CLI arguments parser for node.js. Javascript port of python's
|
|
||||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
|
||||||
(original version 3.2). That's a full port, except some very rare options,
|
|
||||||
recorded in issue tracker.
|
|
||||||
|
|
||||||
**NB. Difference with original.**
|
|
||||||
|
|
||||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
|
||||||
- Use `defaultValue` instead of `default`.
|
|
||||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
|
||||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
|
||||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
|
||||||
`SUPPRESS`.
|
|
||||||
|
|
||||||
|
|
||||||
Example
|
|
||||||
=======
|
|
||||||
|
|
||||||
test.js file:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
#!/usr/bin/env node
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
|
||||||
var parser = new ArgumentParser({
|
|
||||||
version: '0.0.1',
|
|
||||||
addHelp:true,
|
|
||||||
description: 'Argparse example'
|
|
||||||
});
|
|
||||||
parser.addArgument(
|
|
||||||
[ '-f', '--foo' ],
|
|
||||||
{
|
|
||||||
help: 'foo bar'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
parser.addArgument(
|
|
||||||
[ '-b', '--bar' ],
|
|
||||||
{
|
|
||||||
help: 'bar foo'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
parser.addArgument(
|
|
||||||
'--baz',
|
|
||||||
{
|
|
||||||
help: 'baz bar'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var args = parser.parseArgs();
|
|
||||||
console.dir(args);
|
|
||||||
```
|
|
||||||
|
|
||||||
Display help:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ./test.js -h
|
|
||||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
|
||||||
|
|
||||||
Argparse example
|
|
||||||
|
|
||||||
Optional arguments:
|
|
||||||
-h, --help Show this help message and exit.
|
|
||||||
-v, --version Show program's version number and exit.
|
|
||||||
-f FOO, --foo FOO foo bar
|
|
||||||
-b BAR, --bar BAR bar foo
|
|
||||||
--baz BAZ baz bar
|
|
||||||
```
|
|
||||||
|
|
||||||
Parse arguments:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ./test.js -f=3 --bar=4 --baz 5
|
|
||||||
{ foo: '3', bar: '4', baz: '5' }
|
|
||||||
```
|
|
||||||
|
|
||||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
|
||||||
|
|
||||||
|
|
||||||
ArgumentParser objects
|
|
||||||
======================
|
|
||||||
|
|
||||||
```
|
|
||||||
new ArgumentParser({parameters hash});
|
|
||||||
```
|
|
||||||
|
|
||||||
Creates a new ArgumentParser object.
|
|
||||||
|
|
||||||
**Supported params:**
|
|
||||||
|
|
||||||
- ```description``` - Text to display before the argument help.
|
|
||||||
- ```epilog``` - Text to display after the argument help.
|
|
||||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
|
||||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
|
||||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
|
||||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
|
||||||
- ```formatterClass``` - A class for customizing the help output.
|
|
||||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
|
||||||
- ```usage``` - The string describing the program usage (default: generated)
|
|
||||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
|
||||||
|
|
||||||
**Not supported yet**
|
|
||||||
|
|
||||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
|
||||||
|
|
||||||
|
|
||||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
|
||||||
|
|
||||||
|
|
||||||
addArgument() method
|
|
||||||
====================
|
|
||||||
|
|
||||||
```
|
|
||||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
|
||||||
```
|
|
||||||
|
|
||||||
Defines how a single command-line argument should be parsed.
|
|
||||||
|
|
||||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
|
||||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
|
||||||
of a single positional name (e.g., `['foo']`), or an array of options
|
|
||||||
(e.g., `['-f', '--foo']`).
|
|
||||||
|
|
||||||
Options:
|
|
||||||
|
|
||||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
|
||||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
|
||||||
- ```constant``` - A constant value required by some action and nargs selections.
|
|
||||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
|
||||||
- ```type``` - The type to which the command-line argument should be converted.
|
|
||||||
- ```choices``` - A container of the allowable values for the argument.
|
|
||||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
|
||||||
- ```help``` - A brief description of what the argument does.
|
|
||||||
- ```metavar``` - A name for the argument in usage messages.
|
|
||||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
|
||||||
|
|
||||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
|
||||||
|
|
||||||
|
|
||||||
Action (some details)
|
|
||||||
================
|
|
||||||
|
|
||||||
ArgumentParser objects associate command-line arguments with actions.
|
|
||||||
These actions can do just about anything with the command-line arguments associated
|
|
||||||
with them, though most actions simply add an attribute to the object returned by
|
|
||||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
|
||||||
should be handled. The supported actions are:
|
|
||||||
|
|
||||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
|
||||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
|
||||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
|
||||||
The 'storeConst' action is most commonly used with optional arguments, that
|
|
||||||
specify some sort of flag.
|
|
||||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
|
||||||
respectively. These are special cases of 'storeConst'.
|
|
||||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
|
||||||
This is useful to allow an option to be specified multiple times.
|
|
||||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
|
||||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
|
||||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
|
||||||
to store constants to the same list.
|
|
||||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
|
||||||
used for increasing verbosity levels.
|
|
||||||
- ```help``` - Prints a complete help message for all the options in the current
|
|
||||||
parser and then exits. By default a help action is automatically added to the parser.
|
|
||||||
See ArgumentParser for details of how the output is created.
|
|
||||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
|
||||||
keyword argument in the addArgument() call.
|
|
||||||
|
|
||||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
|
||||||
|
|
||||||
|
|
||||||
Sub-commands
|
|
||||||
============
|
|
||||||
|
|
||||||
ArgumentParser.addSubparsers()
|
|
||||||
|
|
||||||
Many programs split their functionality into a number of sub-commands, for
|
|
||||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
|
||||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
|
||||||
idea when a program performs several different functions which require different
|
|
||||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
|
||||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
|
||||||
normally called with no arguments and returns an special action object.
|
|
||||||
This object has a single method `addParser()`, which takes a command name and
|
|
||||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
|
||||||
that can be modified as usual.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
sub_commands.js
|
|
||||||
```javascript
|
|
||||||
#!/usr/bin/env node
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
|
||||||
var parser = new ArgumentParser({
|
|
||||||
version: '0.0.1',
|
|
||||||
addHelp:true,
|
|
||||||
description: 'Argparse examples: sub-commands',
|
|
||||||
});
|
|
||||||
|
|
||||||
var subparsers = parser.addSubparsers({
|
|
||||||
title:'subcommands',
|
|
||||||
dest:"subcommand_name"
|
|
||||||
});
|
|
||||||
|
|
||||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
|
||||||
bar.addArgument(
|
|
||||||
[ '-f', '--foo' ],
|
|
||||||
{
|
|
||||||
action: 'store',
|
|
||||||
help: 'foo3 bar3'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var bar = subparsers.addParser(
|
|
||||||
'c2',
|
|
||||||
{aliases:['co'], addHelp:true}
|
|
||||||
);
|
|
||||||
bar.addArgument(
|
|
||||||
[ '-b', '--bar' ],
|
|
||||||
{
|
|
||||||
action: 'store',
|
|
||||||
type: 'int',
|
|
||||||
help: 'foo3 bar3'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var args = parser.parseArgs();
|
|
||||||
console.dir(args);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
|
||||||
|
|
||||||
|
|
||||||
Contributors
|
|
||||||
============
|
|
||||||
|
|
||||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
|
||||||
- [Paul Jacobson](https://github.com/hpaulj)
|
|
||||||
|
|
||||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
|
||||||
Released under the MIT license. See
|
|
||||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
|
||||||
|
|
||||||
|
|
3
node_modules/argparse/index.js
generated
vendored
3
node_modules/argparse/index.js
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = require('./lib/argparse');
|
|
146
node_modules/argparse/lib/action.js
generated
vendored
146
node_modules/argparse/lib/action.js
generated
vendored
@ -1,146 +0,0 @@
|
|||||||
/**
|
|
||||||
* class Action
|
|
||||||
*
|
|
||||||
* Base class for all actions
|
|
||||||
* Do not call in your code, use this class only for inherits your own action
|
|
||||||
*
|
|
||||||
* Information about how to convert command line strings to Javascript objects.
|
|
||||||
* Action objects are used by an ArgumentParser to represent the information
|
|
||||||
* needed to parse a single argument from one or more strings from the command
|
|
||||||
* line. The keyword arguments to the Action constructor are also all attributes
|
|
||||||
* of Action instances.
|
|
||||||
*
|
|
||||||
* ##### Allowed keywords:
|
|
||||||
*
|
|
||||||
* - `store`
|
|
||||||
* - `storeConstant`
|
|
||||||
* - `storeTrue`
|
|
||||||
* - `storeFalse`
|
|
||||||
* - `append`
|
|
||||||
* - `appendConstant`
|
|
||||||
* - `count`
|
|
||||||
* - `help`
|
|
||||||
* - `version`
|
|
||||||
*
|
|
||||||
* Information about action options see [[Action.new]]
|
|
||||||
*
|
|
||||||
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('./const');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new Action(options)
|
|
||||||
*
|
|
||||||
* Base class for all actions. Used only for inherits
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ##### Options:
|
|
||||||
*
|
|
||||||
* - `optionStrings` A list of command-line option strings for the action.
|
|
||||||
* - `dest` Attribute to hold the created object(s)
|
|
||||||
* - `nargs` The number of command-line arguments that should be consumed.
|
|
||||||
* By default, one argument will be consumed and a single value will be
|
|
||||||
* produced.
|
|
||||||
* - `constant` Default value for an action with no value.
|
|
||||||
* - `defaultValue` The value to be produced if the option is not specified.
|
|
||||||
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
|
||||||
* None, 'string'.
|
|
||||||
* - `choices` The choices available.
|
|
||||||
* - `required` True if the action must always be specified at the command
|
|
||||||
* line.
|
|
||||||
* - `help` The help describing the argument.
|
|
||||||
* - `metavar` The name to be used for the option's argument with the help
|
|
||||||
* string. If None, the 'dest' value will be used as the name.
|
|
||||||
*
|
|
||||||
* ##### nargs supported values:
|
|
||||||
*
|
|
||||||
* - `N` (an integer) consumes N arguments (and produces a list)
|
|
||||||
* - `?` consumes zero or one arguments
|
|
||||||
* - `*` consumes zero or more arguments (and produces a list)
|
|
||||||
* - `+` consumes one or more arguments (and produces a list)
|
|
||||||
*
|
|
||||||
* Note: that the difference between the default and nargs=1 is that with the
|
|
||||||
* default, a single value will be produced, while with nargs=1, a list
|
|
||||||
* containing a single value will be produced.
|
|
||||||
**/
|
|
||||||
var Action = module.exports = function Action(options) {
|
|
||||||
options = options || {};
|
|
||||||
this.optionStrings = options.optionStrings || [];
|
|
||||||
this.dest = options.dest;
|
|
||||||
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
|
||||||
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
|
||||||
this.defaultValue = options.defaultValue;
|
|
||||||
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
|
||||||
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
|
||||||
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
|
||||||
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
|
||||||
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
|
||||||
|
|
||||||
if (!(this.optionStrings instanceof Array)) {
|
|
||||||
throw new Error('optionStrings should be an array');
|
|
||||||
}
|
|
||||||
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
|
||||||
throw new Error('required should be a boolean');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action#getName -> String
|
|
||||||
*
|
|
||||||
* Tells action name
|
|
||||||
**/
|
|
||||||
Action.prototype.getName = function () {
|
|
||||||
if (this.optionStrings.length > 0) {
|
|
||||||
return this.optionStrings.join('/');
|
|
||||||
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
|
||||||
return this.metavar;
|
|
||||||
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
|
||||||
return this.dest;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action#isOptional -> Boolean
|
|
||||||
*
|
|
||||||
* Return true if optional
|
|
||||||
**/
|
|
||||||
Action.prototype.isOptional = function () {
|
|
||||||
return !this.isPositional();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action#isPositional -> Boolean
|
|
||||||
*
|
|
||||||
* Return true if positional
|
|
||||||
**/
|
|
||||||
Action.prototype.isPositional = function () {
|
|
||||||
return (this.optionStrings.length === 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Should be implemented in inherited classes
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
|
||||||
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
|
||||||
* };
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
Action.prototype.call = function () {
|
|
||||||
throw new Error('.call() not defined');// Not Implemented error
|
|
||||||
};
|
|
53
node_modules/argparse/lib/action/append.js
generated
vendored
53
node_modules/argparse/lib/action/append.js
generated
vendored
@ -1,53 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionAppend
|
|
||||||
*
|
|
||||||
* This action stores a list, and appends each argument value to the list.
|
|
||||||
* This is useful to allow an option to be specified multiple times.
|
|
||||||
* This class inherided from [[Action]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionAppend(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
* Note: options.nargs should be optional for constants
|
|
||||||
* and more then zero for other
|
|
||||||
**/
|
|
||||||
var ActionAppend = module.exports = function ActionAppend(options) {
|
|
||||||
options = options || {};
|
|
||||||
if (this.nargs <= 0) {
|
|
||||||
throw new Error('nargs for append actions must be > 0; if arg ' +
|
|
||||||
'strings are not supplying the value to append, ' +
|
|
||||||
'the append const action may be more appropriate');
|
|
||||||
}
|
|
||||||
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
|
||||||
throw new Error('nargs must be OPTIONAL to supply const');
|
|
||||||
}
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionAppend, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Save result in namespace object
|
|
||||||
**/
|
|
||||||
ActionAppend.prototype.call = function (parser, namespace, values) {
|
|
||||||
var items = (namespace[this.dest] || []).slice();
|
|
||||||
items.push(values);
|
|
||||||
namespace.set(this.dest, items);
|
|
||||||
};
|
|
47
node_modules/argparse/lib/action/append/constant.js
generated
vendored
47
node_modules/argparse/lib/action/append/constant.js
generated
vendored
@ -1,47 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionAppendConstant
|
|
||||||
*
|
|
||||||
* This stores a list, and appends the value specified by
|
|
||||||
* the const keyword argument to the list.
|
|
||||||
* (Note that the const keyword argument defaults to null.)
|
|
||||||
* The 'appendConst' action is typically useful when multiple
|
|
||||||
* arguments need to store constants to the same list.
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../../action');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionAppendConstant(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.nargs = 0;
|
|
||||||
if (typeof options.constant === 'undefined') {
|
|
||||||
throw new Error('constant option is required for appendAction');
|
|
||||||
}
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionAppendConstant, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Save result in namespace object
|
|
||||||
**/
|
|
||||||
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
|
||||||
var items = [].concat(namespace[this.dest] || []);
|
|
||||||
items.push(this.constant);
|
|
||||||
namespace.set(this.dest, items);
|
|
||||||
};
|
|
40
node_modules/argparse/lib/action/count.js
generated
vendored
40
node_modules/argparse/lib/action/count.js
generated
vendored
@ -1,40 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionCount
|
|
||||||
*
|
|
||||||
* This counts the number of times a keyword argument occurs.
|
|
||||||
* For example, this is useful for increasing verbosity levels
|
|
||||||
*
|
|
||||||
* This class inherided from [[Action]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionCount(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionCount = module.exports = function ActionCount(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.nargs = 0;
|
|
||||||
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionCount, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Save result in namespace object
|
|
||||||
**/
|
|
||||||
ActionCount.prototype.call = function (parser, namespace) {
|
|
||||||
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
|
||||||
};
|
|
47
node_modules/argparse/lib/action/help.js
generated
vendored
47
node_modules/argparse/lib/action/help.js
generated
vendored
@ -1,47 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionHelp
|
|
||||||
*
|
|
||||||
* Support action for printing help
|
|
||||||
* This class inherided from [[Action]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionHelp(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionHelp = module.exports = function ActionHelp(options) {
|
|
||||||
options = options || {};
|
|
||||||
if (options.defaultValue !== null) {
|
|
||||||
options.defaultValue = options.defaultValue;
|
|
||||||
} else {
|
|
||||||
options.defaultValue = c.SUPPRESS;
|
|
||||||
}
|
|
||||||
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
|
||||||
options.nargs = 0;
|
|
||||||
Action.call(this, options);
|
|
||||||
|
|
||||||
};
|
|
||||||
util.inherits(ActionHelp, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionHelp#call(parser, namespace, values, optionString)
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Print help and exit
|
|
||||||
**/
|
|
||||||
ActionHelp.prototype.call = function (parser) {
|
|
||||||
parser.printHelp();
|
|
||||||
parser.exit();
|
|
||||||
};
|
|
50
node_modules/argparse/lib/action/store.js
generated
vendored
50
node_modules/argparse/lib/action/store.js
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionStore
|
|
||||||
*
|
|
||||||
* This action just stores the argument’s value. This is the default action.
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionStore(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionStore = module.exports = function ActionStore(options) {
|
|
||||||
options = options || {};
|
|
||||||
if (this.nargs <= 0) {
|
|
||||||
throw new Error('nargs for store actions must be > 0; if you ' +
|
|
||||||
'have nothing to store, actions such as store ' +
|
|
||||||
'true or store const may be more appropriate');
|
|
||||||
|
|
||||||
}
|
|
||||||
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
|
||||||
throw new Error('nargs must be OPTIONAL to supply const');
|
|
||||||
}
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionStore, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Save result in namespace object
|
|
||||||
**/
|
|
||||||
ActionStore.prototype.call = function (parser, namespace, values) {
|
|
||||||
namespace.set(this.dest, values);
|
|
||||||
};
|
|
43
node_modules/argparse/lib/action/store/constant.js
generated
vendored
43
node_modules/argparse/lib/action/store/constant.js
generated
vendored
@ -1,43 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionStoreConstant
|
|
||||||
*
|
|
||||||
* This action stores the value specified by the const keyword argument.
|
|
||||||
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
|
||||||
* The 'store_const' action is most commonly used with optional
|
|
||||||
* arguments that specify some sort of flag.
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../../action');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionStoreConstant(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.nargs = 0;
|
|
||||||
if (typeof options.constant === 'undefined') {
|
|
||||||
throw new Error('constant option is required for storeAction');
|
|
||||||
}
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionStoreConstant, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Save result in namespace object
|
|
||||||
**/
|
|
||||||
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
|
||||||
namespace.set(this.dest, this.constant);
|
|
||||||
};
|
|
27
node_modules/argparse/lib/action/store/false.js
generated
vendored
27
node_modules/argparse/lib/action/store/false.js
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionStoreFalse
|
|
||||||
*
|
|
||||||
* This action store the values False respectively.
|
|
||||||
* This is special cases of 'storeConst'
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var ActionStoreConstant = require('./constant');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionStoreFalse(options)
|
|
||||||
* - options (object): hash of options see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.constant = false;
|
|
||||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
|
||||||
ActionStoreConstant.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
|
26
node_modules/argparse/lib/action/store/true.js
generated
vendored
26
node_modules/argparse/lib/action/store/true.js
generated
vendored
@ -1,26 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionStoreTrue
|
|
||||||
*
|
|
||||||
* This action store the values True respectively.
|
|
||||||
* This isspecial cases of 'storeConst'
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var ActionStoreConstant = require('./constant');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionStoreTrue(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.constant = true;
|
|
||||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
|
||||||
ActionStoreConstant.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
|
149
node_modules/argparse/lib/action/subparsers.js
generated
vendored
149
node_modules/argparse/lib/action/subparsers.js
generated
vendored
@ -1,149 +0,0 @@
|
|||||||
/** internal
|
|
||||||
* class ActionSubparsers
|
|
||||||
*
|
|
||||||
* Support the creation of such sub-commands with the addSubparsers()
|
|
||||||
*
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
var format = require('util').format;
|
|
||||||
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
// Errors
|
|
||||||
var argumentErrorHelper = require('../argument/error');
|
|
||||||
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ChoicesPseudoAction(name, help)
|
|
||||||
*
|
|
||||||
* Create pseudo action for correct help text
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
function ChoicesPseudoAction(name, help) {
|
|
||||||
var options = {
|
|
||||||
optionStrings: [],
|
|
||||||
dest: name,
|
|
||||||
help: help
|
|
||||||
};
|
|
||||||
|
|
||||||
Action.call(this, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(ChoicesPseudoAction, Action);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new ActionSubparsers(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
function ActionSubparsers(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.dest = options.dest || c.SUPPRESS;
|
|
||||||
options.nargs = c.PARSER;
|
|
||||||
|
|
||||||
this.debug = (options.debug === true);
|
|
||||||
|
|
||||||
this._progPrefix = options.prog;
|
|
||||||
this._parserClass = options.parserClass;
|
|
||||||
this._nameParserMap = {};
|
|
||||||
this._choicesActions = [];
|
|
||||||
|
|
||||||
options.choices = this._nameParserMap;
|
|
||||||
Action.call(this, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(ActionSubparsers, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
|
||||||
* - name (string): sub-command name
|
|
||||||
* - options (object): see [[ArgumentParser.new]]
|
|
||||||
*
|
|
||||||
* Note:
|
|
||||||
* addParser supports an additional aliases option,
|
|
||||||
* which allows multiple strings to refer to the same subparser.
|
|
||||||
* This example, like svn, aliases co as a shorthand for checkout
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
ActionSubparsers.prototype.addParser = function (name, options) {
|
|
||||||
var parser;
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
options.debug = (this.debug === true);
|
|
||||||
|
|
||||||
// set program from the existing prefix
|
|
||||||
if (!options.prog) {
|
|
||||||
options.prog = this._progPrefix + ' ' + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
var aliases = options.aliases || [];
|
|
||||||
|
|
||||||
// create a pseudo-action to hold the choice help
|
|
||||||
if (!!options.help || typeof options.help === 'string') {
|
|
||||||
var help = options.help;
|
|
||||||
delete options.help;
|
|
||||||
|
|
||||||
var choiceAction = new ChoicesPseudoAction(name, help);
|
|
||||||
this._choicesActions.push(choiceAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the parser and add it to the map
|
|
||||||
parser = new this._parserClass(options);
|
|
||||||
this._nameParserMap[name] = parser;
|
|
||||||
|
|
||||||
// make parser available under aliases also
|
|
||||||
aliases.forEach(function (alias) {
|
|
||||||
self._nameParserMap[alias] = parser;
|
|
||||||
});
|
|
||||||
|
|
||||||
return parser;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionSubparsers.prototype._getSubactions = function () {
|
|
||||||
return this._choicesActions;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Call the action. Parse input aguments
|
|
||||||
**/
|
|
||||||
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
|
||||||
var parserName = values[0];
|
|
||||||
var argStrings = values.slice(1);
|
|
||||||
|
|
||||||
// set the parser name if requested
|
|
||||||
if (this.dest !== c.SUPPRESS) {
|
|
||||||
namespace[this.dest] = parserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// select the parser
|
|
||||||
if (this._nameParserMap[parserName]) {
|
|
||||||
parser = this._nameParserMap[parserName];
|
|
||||||
} else {
|
|
||||||
throw argumentErrorHelper(format(
|
|
||||||
'Unknown parser "%s" (choices: [%s]).',
|
|
||||||
parserName,
|
|
||||||
Object.keys(this._nameParserMap).join(', ')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse all the remaining options into the namespace
|
|
||||||
parser.parseArgs(argStrings, namespace);
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = ActionSubparsers;
|
|
47
node_modules/argparse/lib/action/version.js
generated
vendored
47
node_modules/argparse/lib/action/version.js
generated
vendored
@ -1,47 +0,0 @@
|
|||||||
/*:nodoc:*
|
|
||||||
* class ActionVersion
|
|
||||||
*
|
|
||||||
* Support action for printing program version
|
|
||||||
* This class inherited from [[Action]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var Action = require('../action');
|
|
||||||
|
|
||||||
//
|
|
||||||
// Constants
|
|
||||||
//
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* new ActionVersion(options)
|
|
||||||
* - options (object): options hash see [[Action.new]]
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ActionVersion = module.exports = function ActionVersion(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
|
||||||
options.dest = (options.dest || c.SUPPRESS);
|
|
||||||
options.nargs = 0;
|
|
||||||
this.version = options.version;
|
|
||||||
Action.call(this, options);
|
|
||||||
};
|
|
||||||
util.inherits(ActionVersion, Action);
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
|
||||||
* - parser (ArgumentParser): current parser
|
|
||||||
* - namespace (Namespace): namespace for output data
|
|
||||||
* - values (Array): parsed values
|
|
||||||
* - optionString (Array): input option string(not parsed)
|
|
||||||
*
|
|
||||||
* Print version and exit
|
|
||||||
**/
|
|
||||||
ActionVersion.prototype.call = function (parser) {
|
|
||||||
var version = this.version || parser.version;
|
|
||||||
var formatter = parser._getFormatter();
|
|
||||||
formatter.addText(version);
|
|
||||||
parser.exit(0, formatter.formatHelp());
|
|
||||||
};
|
|
482
node_modules/argparse/lib/action_container.js
generated
vendored
482
node_modules/argparse/lib/action_container.js
generated
vendored
@ -1,482 +0,0 @@
|
|||||||
/** internal
|
|
||||||
* class ActionContainer
|
|
||||||
*
|
|
||||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
|
||||||
**/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var format = require('util').format;
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('./const');
|
|
||||||
|
|
||||||
var $$ = require('./utils');
|
|
||||||
|
|
||||||
//Actions
|
|
||||||
var ActionHelp = require('./action/help');
|
|
||||||
var ActionAppend = require('./action/append');
|
|
||||||
var ActionAppendConstant = require('./action/append/constant');
|
|
||||||
var ActionCount = require('./action/count');
|
|
||||||
var ActionStore = require('./action/store');
|
|
||||||
var ActionStoreConstant = require('./action/store/constant');
|
|
||||||
var ActionStoreTrue = require('./action/store/true');
|
|
||||||
var ActionStoreFalse = require('./action/store/false');
|
|
||||||
var ActionVersion = require('./action/version');
|
|
||||||
var ActionSubparsers = require('./action/subparsers');
|
|
||||||
|
|
||||||
// Errors
|
|
||||||
var argumentErrorHelper = require('./argument/error');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new ActionContainer(options)
|
|
||||||
*
|
|
||||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
|
||||||
*
|
|
||||||
* ##### Options:
|
|
||||||
*
|
|
||||||
* - `description` -- A description of what the program does
|
|
||||||
* - `prefixChars` -- Characters that prefix optional arguments
|
|
||||||
* - `argumentDefault` -- The default value for all arguments
|
|
||||||
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
|
||||||
**/
|
|
||||||
var ActionContainer = module.exports = function ActionContainer(options) {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
this.description = options.description;
|
|
||||||
this.argumentDefault = options.argumentDefault;
|
|
||||||
this.prefixChars = options.prefixChars || '';
|
|
||||||
this.conflictHandler = options.conflictHandler;
|
|
||||||
|
|
||||||
// set up registries
|
|
||||||
this._registries = {};
|
|
||||||
|
|
||||||
// register actions
|
|
||||||
this.register('action', null, ActionStore);
|
|
||||||
this.register('action', 'store', ActionStore);
|
|
||||||
this.register('action', 'storeConst', ActionStoreConstant);
|
|
||||||
this.register('action', 'storeTrue', ActionStoreTrue);
|
|
||||||
this.register('action', 'storeFalse', ActionStoreFalse);
|
|
||||||
this.register('action', 'append', ActionAppend);
|
|
||||||
this.register('action', 'appendConst', ActionAppendConstant);
|
|
||||||
this.register('action', 'count', ActionCount);
|
|
||||||
this.register('action', 'help', ActionHelp);
|
|
||||||
this.register('action', 'version', ActionVersion);
|
|
||||||
this.register('action', 'parsers', ActionSubparsers);
|
|
||||||
|
|
||||||
// raise an exception if the conflict handler is invalid
|
|
||||||
this._getHandler();
|
|
||||||
|
|
||||||
// action storage
|
|
||||||
this._actions = [];
|
|
||||||
this._optionStringActions = {};
|
|
||||||
|
|
||||||
// groups
|
|
||||||
this._actionGroups = [];
|
|
||||||
this._mutuallyExclusiveGroups = [];
|
|
||||||
|
|
||||||
// defaults storage
|
|
||||||
this._defaults = {};
|
|
||||||
|
|
||||||
// determines whether an "option" looks like a negative number
|
|
||||||
// -1, -1.5 -5e+4
|
|
||||||
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
|
||||||
|
|
||||||
// whether or not there are any optionals that look like negative
|
|
||||||
// numbers -- uses a list so it can be shared and edited
|
|
||||||
this._hasNegativeNumberOptionals = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
// Groups must be required, then ActionContainer already defined
|
|
||||||
var ArgumentGroup = require('./argument/group');
|
|
||||||
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
|
||||||
|
|
||||||
//
|
|
||||||
// Registration methods
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#register(registryName, value, object) -> Void
|
|
||||||
* - registryName (String) : object type action|type
|
|
||||||
* - value (string) : keyword
|
|
||||||
* - object (Object|Function) : handler
|
|
||||||
*
|
|
||||||
* Register handlers
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.register = function (registryName, value, object) {
|
|
||||||
this._registries[registryName] = this._registries[registryName] || {};
|
|
||||||
this._registries[registryName][value] = object;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
|
||||||
if (arguments.length < 3) {
|
|
||||||
defaultValue = null;
|
|
||||||
}
|
|
||||||
return this._registries[registryName][value] || defaultValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Namespace default accessor methods
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#setDefaults(options) -> Void
|
|
||||||
* - options (object):hash of options see [[Action.new]]
|
|
||||||
*
|
|
||||||
* Set defaults
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.setDefaults = function (options) {
|
|
||||||
options = options || {};
|
|
||||||
for (var property in options) {
|
|
||||||
if ($$.has(options, property)) {
|
|
||||||
this._defaults[property] = options[property];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if these defaults match any existing arguments, replace the previous
|
|
||||||
// default on the object with the new one
|
|
||||||
this._actions.forEach(function (action) {
|
|
||||||
if ($$.has(options, action.dest)) {
|
|
||||||
action.defaultValue = options[action.dest];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#getDefault(dest) -> Mixed
|
|
||||||
* - dest (string): action destination
|
|
||||||
*
|
|
||||||
* Return action default value
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.getDefault = function (dest) {
|
|
||||||
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
|
||||||
|
|
||||||
this._actions.forEach(function (action) {
|
|
||||||
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
|
||||||
result = action.defaultValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// Adding argument actions
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#addArgument(args, options) -> Object
|
|
||||||
* - args (String|Array): argument key, or array of argument keys
|
|
||||||
* - options (Object): action objects see [[Action.new]]
|
|
||||||
*
|
|
||||||
* #### Examples
|
|
||||||
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
|
||||||
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
|
||||||
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.addArgument = function (args, options) {
|
|
||||||
args = args;
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
if (typeof args === 'string') {
|
|
||||||
args = [ args ];
|
|
||||||
}
|
|
||||||
if (!Array.isArray(args)) {
|
|
||||||
throw new TypeError('addArgument first argument should be a string or an array');
|
|
||||||
}
|
|
||||||
if (typeof options !== 'object' || Array.isArray(options)) {
|
|
||||||
throw new TypeError('addArgument second argument should be a hash');
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no positional args are supplied or only one is supplied and
|
|
||||||
// it doesn't look like an option string, parse a positional argument
|
|
||||||
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
|
||||||
if (args && !!options.dest) {
|
|
||||||
throw new Error('dest supplied twice for positional argument');
|
|
||||||
}
|
|
||||||
options = this._getPositional(args, options);
|
|
||||||
|
|
||||||
// otherwise, we're adding an optional argument
|
|
||||||
} else {
|
|
||||||
options = this._getOptional(args, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no default was supplied, use the parser-level default
|
|
||||||
if (typeof options.defaultValue === 'undefined') {
|
|
||||||
var dest = options.dest;
|
|
||||||
if ($$.has(this._defaults, dest)) {
|
|
||||||
options.defaultValue = this._defaults[dest];
|
|
||||||
} else if (typeof this.argumentDefault !== 'undefined') {
|
|
||||||
options.defaultValue = this.argumentDefault;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the action object, and add it to the parser
|
|
||||||
var ActionClass = this._popActionClass(options);
|
|
||||||
if (typeof ActionClass !== 'function') {
|
|
||||||
throw new Error(format('Unknown action "%s".', ActionClass));
|
|
||||||
}
|
|
||||||
var action = new ActionClass(options);
|
|
||||||
|
|
||||||
// throw an error if the action type is not callable
|
|
||||||
var typeFunction = this._registryGet('type', action.type, action.type);
|
|
||||||
if (typeof typeFunction !== 'function') {
|
|
||||||
throw new Error(format('"%s" is not callable', typeFunction));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._addAction(action);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
|
||||||
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
|
||||||
*
|
|
||||||
* Create new arguments groups
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.addArgumentGroup = function (options) {
|
|
||||||
var group = new ArgumentGroup(this, options);
|
|
||||||
this._actionGroups.push(group);
|
|
||||||
return group;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
|
||||||
* - options (Object): {required: false}
|
|
||||||
*
|
|
||||||
* Create new mutual exclusive groups
|
|
||||||
**/
|
|
||||||
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
|
||||||
var group = new MutuallyExclusiveGroup(this, options);
|
|
||||||
this._mutuallyExclusiveGroups.push(group);
|
|
||||||
return group;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._addAction = function (action) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// resolve any conflicts
|
|
||||||
this._checkConflict(action);
|
|
||||||
|
|
||||||
// add to actions list
|
|
||||||
this._actions.push(action);
|
|
||||||
action.container = this;
|
|
||||||
|
|
||||||
// index the action by any option strings it has
|
|
||||||
action.optionStrings.forEach(function (optionString) {
|
|
||||||
self._optionStringActions[optionString] = action;
|
|
||||||
});
|
|
||||||
|
|
||||||
// set the flag if any option strings look like negative numbers
|
|
||||||
action.optionStrings.forEach(function (optionString) {
|
|
||||||
if (optionString.match(self._regexpNegativeNumber)) {
|
|
||||||
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
|
||||||
self._hasNegativeNumberOptionals.push(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// return the created action
|
|
||||||
return action;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._removeAction = function (action) {
|
|
||||||
var actionIndex = this._actions.indexOf(action);
|
|
||||||
if (actionIndex >= 0) {
|
|
||||||
this._actions.splice(actionIndex, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._addContainerActions = function (container) {
|
|
||||||
// collect groups by titles
|
|
||||||
var titleGroupMap = {};
|
|
||||||
this._actionGroups.forEach(function (group) {
|
|
||||||
if (titleGroupMap[group.title]) {
|
|
||||||
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
|
||||||
}
|
|
||||||
titleGroupMap[group.title] = group;
|
|
||||||
});
|
|
||||||
|
|
||||||
// map each action to its group
|
|
||||||
var groupMap = {};
|
|
||||||
function actionHash(action) {
|
|
||||||
// unique (hopefully?) string suitable as dictionary key
|
|
||||||
return action.getName();
|
|
||||||
}
|
|
||||||
container._actionGroups.forEach(function (group) {
|
|
||||||
// if a group with the title exists, use that, otherwise
|
|
||||||
// create a new group matching the container's group
|
|
||||||
if (!titleGroupMap[group.title]) {
|
|
||||||
titleGroupMap[group.title] = this.addArgumentGroup({
|
|
||||||
title: group.title,
|
|
||||||
description: group.description
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// map the actions to their new group
|
|
||||||
group._groupActions.forEach(function (action) {
|
|
||||||
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// add container's mutually exclusive groups
|
|
||||||
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
|
||||||
// description= then this code will need to be expanded as above
|
|
||||||
var mutexGroup;
|
|
||||||
container._mutuallyExclusiveGroups.forEach(function (group) {
|
|
||||||
mutexGroup = this.addMutuallyExclusiveGroup({
|
|
||||||
required: group.required
|
|
||||||
});
|
|
||||||
// map the actions to their new mutex group
|
|
||||||
group._groupActions.forEach(function (action) {
|
|
||||||
groupMap[actionHash(action)] = mutexGroup;
|
|
||||||
});
|
|
||||||
}, this); // forEach takes a 'this' argument
|
|
||||||
|
|
||||||
// add all actions to this container or their group
|
|
||||||
container._actions.forEach(function (action) {
|
|
||||||
var key = actionHash(action);
|
|
||||||
if (groupMap[key]) {
|
|
||||||
groupMap[key]._addAction(action);
|
|
||||||
} else {
|
|
||||||
this._addAction(action);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._getPositional = function (dest, options) {
|
|
||||||
if (Array.isArray(dest)) {
|
|
||||||
dest = dest[0];
|
|
||||||
}
|
|
||||||
// make sure required is not specified
|
|
||||||
if (options.required) {
|
|
||||||
throw new Error('"required" is an invalid argument for positionals.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// mark positional arguments as required if at least one is
|
|
||||||
// always required
|
|
||||||
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
|
||||||
options.required = true;
|
|
||||||
}
|
|
||||||
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
|
||||||
options.required = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the keyword arguments with no option strings
|
|
||||||
options.dest = dest;
|
|
||||||
options.optionStrings = [];
|
|
||||||
return options;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._getOptional = function (args, options) {
|
|
||||||
var prefixChars = this.prefixChars;
|
|
||||||
var optionStrings = [];
|
|
||||||
var optionStringsLong = [];
|
|
||||||
|
|
||||||
// determine short and long option strings
|
|
||||||
args.forEach(function (optionString) {
|
|
||||||
// error on strings that don't start with an appropriate prefix
|
|
||||||
if (prefixChars.indexOf(optionString[0]) < 0) {
|
|
||||||
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
|
||||||
optionString,
|
|
||||||
prefixChars
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// strings starting with two prefix characters are long options
|
|
||||||
optionStrings.push(optionString);
|
|
||||||
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
|
||||||
optionStringsLong.push(optionString);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
|
||||||
var dest = options.dest || null;
|
|
||||||
delete options.dest;
|
|
||||||
|
|
||||||
if (!dest) {
|
|
||||||
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
|
||||||
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
|
||||||
|
|
||||||
if (dest.length === 0) {
|
|
||||||
throw new Error(
|
|
||||||
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
dest = dest.replace(/-/g, '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the updated keyword arguments
|
|
||||||
options.dest = dest;
|
|
||||||
options.optionStrings = optionStrings;
|
|
||||||
|
|
||||||
return options;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
|
||||||
defaultValue = defaultValue || null;
|
|
||||||
|
|
||||||
var action = (options.action || defaultValue);
|
|
||||||
delete options.action;
|
|
||||||
|
|
||||||
var actionClass = this._registryGet('action', action, action);
|
|
||||||
return actionClass;
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._getHandler = function () {
|
|
||||||
var handlerString = this.conflictHandler;
|
|
||||||
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
|
||||||
var func = this[handlerFuncName];
|
|
||||||
if (typeof func === 'undefined') {
|
|
||||||
var msg = 'invalid conflict resolution value: ' + handlerString;
|
|
||||||
throw new Error(msg);
|
|
||||||
} else {
|
|
||||||
return func;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._checkConflict = function (action) {
|
|
||||||
var optionStringActions = this._optionStringActions;
|
|
||||||
var conflictOptionals = [];
|
|
||||||
|
|
||||||
// find all options that conflict with this option
|
|
||||||
// collect pairs, the string, and an existing action that it conflicts with
|
|
||||||
action.optionStrings.forEach(function (optionString) {
|
|
||||||
var conflOptional = optionStringActions[optionString];
|
|
||||||
if (typeof conflOptional !== 'undefined') {
|
|
||||||
conflictOptionals.push([ optionString, conflOptional ]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (conflictOptionals.length > 0) {
|
|
||||||
var conflictHandler = this._getHandler();
|
|
||||||
conflictHandler.call(this, action, conflictOptionals);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
|
||||||
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
|
||||||
conflicts = conflicts.join(', ');
|
|
||||||
throw argumentErrorHelper(
|
|
||||||
action,
|
|
||||||
format('Conflicting option string(s): %s', conflicts)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
|
||||||
// remove all conflicting options
|
|
||||||
var self = this;
|
|
||||||
conflOptionals.forEach(function (pair) {
|
|
||||||
var optionString = pair[0];
|
|
||||||
var conflictingAction = pair[1];
|
|
||||||
// remove the conflicting option string
|
|
||||||
var i = conflictingAction.optionStrings.indexOf(optionString);
|
|
||||||
if (i >= 0) {
|
|
||||||
conflictingAction.optionStrings.splice(i, 1);
|
|
||||||
}
|
|
||||||
delete self._optionStringActions[optionString];
|
|
||||||
// if the option now has no option string, remove it from the
|
|
||||||
// container holding it
|
|
||||||
if (conflictingAction.optionStrings.length === 0) {
|
|
||||||
conflictingAction.container._removeAction(conflictingAction);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
14
node_modules/argparse/lib/argparse.js
generated
vendored
14
node_modules/argparse/lib/argparse.js
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports.ArgumentParser = require('./argument_parser.js');
|
|
||||||
module.exports.Namespace = require('./namespace');
|
|
||||||
module.exports.Action = require('./action');
|
|
||||||
module.exports.HelpFormatter = require('./help/formatter.js');
|
|
||||||
module.exports.Const = require('./const.js');
|
|
||||||
|
|
||||||
module.exports.ArgumentDefaultsHelpFormatter =
|
|
||||||
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
|
|
||||||
module.exports.RawDescriptionHelpFormatter =
|
|
||||||
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
|
|
||||||
module.exports.RawTextHelpFormatter =
|
|
||||||
require('./help/added_formatters.js').RawTextHelpFormatter;
|
|
50
node_modules/argparse/lib/argument/error.js
generated
vendored
50
node_modules/argparse/lib/argument/error.js
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
var format = require('util').format;
|
|
||||||
|
|
||||||
|
|
||||||
var ERR_CODE = 'ARGError';
|
|
||||||
|
|
||||||
/*:nodoc:*
|
|
||||||
* argumentError(argument, message) -> TypeError
|
|
||||||
* - argument (Object): action with broken argument
|
|
||||||
* - message (String): error message
|
|
||||||
*
|
|
||||||
* Error format helper. An error from creating or using an argument
|
|
||||||
* (optional or positional). The string value of this exception
|
|
||||||
* is the message, augmented with information
|
|
||||||
* about the argument that caused it.
|
|
||||||
*
|
|
||||||
* #####Example
|
|
||||||
*
|
|
||||||
* var argumentErrorHelper = require('./argument/error');
|
|
||||||
* if (conflictOptionals.length > 0) {
|
|
||||||
* throw argumentErrorHelper(
|
|
||||||
* action,
|
|
||||||
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
|
|
||||||
* );
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
module.exports = function (argument, message) {
|
|
||||||
var argumentName = null;
|
|
||||||
var errMessage;
|
|
||||||
var err;
|
|
||||||
|
|
||||||
if (argument.getName) {
|
|
||||||
argumentName = argument.getName();
|
|
||||||
} else {
|
|
||||||
argumentName = '' + argument;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!argumentName) {
|
|
||||||
errMessage = message;
|
|
||||||
} else {
|
|
||||||
errMessage = format('argument "%s": %s', argumentName, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
err = new TypeError(errMessage);
|
|
||||||
err.code = ERR_CODE;
|
|
||||||
return err;
|
|
||||||
};
|
|
54
node_modules/argparse/lib/argument/exclusive.js
generated
vendored
54
node_modules/argparse/lib/argument/exclusive.js
generated
vendored
@ -1,54 +0,0 @@
|
|||||||
/** internal
|
|
||||||
* class MutuallyExclusiveGroup
|
|
||||||
*
|
|
||||||
* Group arguments.
|
|
||||||
* By default, ArgumentParser groups command-line arguments
|
|
||||||
* into “positional arguments” and “optional arguments”
|
|
||||||
* when displaying help messages. When there is a better
|
|
||||||
* conceptual grouping of arguments than this default one,
|
|
||||||
* appropriate groups can be created using the addArgumentGroup() method
|
|
||||||
*
|
|
||||||
* This class inherited from [[ArgumentContainer]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var ArgumentGroup = require('./group');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new MutuallyExclusiveGroup(container, options)
|
|
||||||
* - container (object): main container
|
|
||||||
* - options (object): options.required -> true/false
|
|
||||||
*
|
|
||||||
* `required` could be an argument itself, but making it a property of
|
|
||||||
* the options argument is more consistent with the JS adaptation of the Python)
|
|
||||||
**/
|
|
||||||
var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
|
|
||||||
var required;
|
|
||||||
options = options || {};
|
|
||||||
required = options.required || false;
|
|
||||||
ArgumentGroup.call(this, container);
|
|
||||||
this.required = required;
|
|
||||||
|
|
||||||
};
|
|
||||||
util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
|
|
||||||
|
|
||||||
|
|
||||||
MutuallyExclusiveGroup.prototype._addAction = function (action) {
|
|
||||||
var msg;
|
|
||||||
if (action.required) {
|
|
||||||
msg = 'mutually exclusive arguments must be optional';
|
|
||||||
throw new Error(msg);
|
|
||||||
}
|
|
||||||
action = this._container._addAction(action);
|
|
||||||
this._groupActions.push(action);
|
|
||||||
return action;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
MutuallyExclusiveGroup.prototype._removeAction = function (action) {
|
|
||||||
this._container._removeAction(action);
|
|
||||||
this._groupActions.remove(action);
|
|
||||||
};
|
|
||||||
|
|
75
node_modules/argparse/lib/argument/group.js
generated
vendored
75
node_modules/argparse/lib/argument/group.js
generated
vendored
@ -1,75 +0,0 @@
|
|||||||
/** internal
|
|
||||||
* class ArgumentGroup
|
|
||||||
*
|
|
||||||
* Group arguments.
|
|
||||||
* By default, ArgumentParser groups command-line arguments
|
|
||||||
* into “positional arguments” and “optional arguments”
|
|
||||||
* when displaying help messages. When there is a better
|
|
||||||
* conceptual grouping of arguments than this default one,
|
|
||||||
* appropriate groups can be created using the addArgumentGroup() method
|
|
||||||
*
|
|
||||||
* This class inherited from [[ArgumentContainer]]
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
var ActionContainer = require('../action_container');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new ArgumentGroup(container, options)
|
|
||||||
* - container (object): main container
|
|
||||||
* - options (object): hash of group options
|
|
||||||
*
|
|
||||||
* #### options
|
|
||||||
* - **prefixChars** group name prefix
|
|
||||||
* - **argumentDefault** default argument value
|
|
||||||
* - **title** group title
|
|
||||||
* - **description** group description
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
|
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
// add any missing keyword arguments by checking the container
|
|
||||||
options.conflictHandler = (options.conflictHandler || container.conflictHandler);
|
|
||||||
options.prefixChars = (options.prefixChars || container.prefixChars);
|
|
||||||
options.argumentDefault = (options.argumentDefault || container.argumentDefault);
|
|
||||||
|
|
||||||
ActionContainer.call(this, options);
|
|
||||||
|
|
||||||
// group attributes
|
|
||||||
this.title = options.title;
|
|
||||||
this._groupActions = [];
|
|
||||||
|
|
||||||
// share most attributes with the container
|
|
||||||
this._container = container;
|
|
||||||
this._registries = container._registries;
|
|
||||||
this._actions = container._actions;
|
|
||||||
this._optionStringActions = container._optionStringActions;
|
|
||||||
this._defaults = container._defaults;
|
|
||||||
this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
|
|
||||||
this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
|
|
||||||
};
|
|
||||||
util.inherits(ArgumentGroup, ActionContainer);
|
|
||||||
|
|
||||||
|
|
||||||
ArgumentGroup.prototype._addAction = function (action) {
|
|
||||||
// Parent add action
|
|
||||||
action = ActionContainer.prototype._addAction.call(this, action);
|
|
||||||
this._groupActions.push(action);
|
|
||||||
return action;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ArgumentGroup.prototype._removeAction = function (action) {
|
|
||||||
// Parent remove action
|
|
||||||
ActionContainer.prototype._removeAction.call(this, action);
|
|
||||||
var actionIndex = this._groupActions.indexOf(action);
|
|
||||||
if (actionIndex >= 0) {
|
|
||||||
this._groupActions.splice(actionIndex, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
1161
node_modules/argparse/lib/argument_parser.js
generated
vendored
1161
node_modules/argparse/lib/argument_parser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
21
node_modules/argparse/lib/const.js
generated
vendored
21
node_modules/argparse/lib/const.js
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
//
|
|
||||||
// Constants
|
|
||||||
//
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports.EOL = '\n';
|
|
||||||
|
|
||||||
module.exports.SUPPRESS = '==SUPPRESS==';
|
|
||||||
|
|
||||||
module.exports.OPTIONAL = '?';
|
|
||||||
|
|
||||||
module.exports.ZERO_OR_MORE = '*';
|
|
||||||
|
|
||||||
module.exports.ONE_OR_MORE = '+';
|
|
||||||
|
|
||||||
module.exports.PARSER = 'A...';
|
|
||||||
|
|
||||||
module.exports.REMAINDER = '...';
|
|
||||||
|
|
||||||
module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
|
|
87
node_modules/argparse/lib/help/added_formatters.js
generated
vendored
87
node_modules/argparse/lib/help/added_formatters.js
generated
vendored
@ -1,87 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
var $$ = require('../utils');
|
|
||||||
var HelpFormatter = require('./formatter.js');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new RawDescriptionHelpFormatter(options)
|
|
||||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
|
||||||
*
|
|
||||||
* Help message formatter which adds default values to argument help.
|
|
||||||
*
|
|
||||||
* Only the name of this class is considered a public API. All the methods
|
|
||||||
* provided by the class are considered an implementation detail.
|
|
||||||
**/
|
|
||||||
|
|
||||||
function ArgumentDefaultsHelpFormatter(options) {
|
|
||||||
HelpFormatter.call(this, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
|
|
||||||
|
|
||||||
ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
|
|
||||||
var help = action.help;
|
|
||||||
if (action.help.indexOf('%(defaultValue)s') === -1) {
|
|
||||||
if (action.defaultValue !== c.SUPPRESS) {
|
|
||||||
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
|
|
||||||
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
|
|
||||||
help += ' (default: %(defaultValue)s)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return help;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new RawDescriptionHelpFormatter(options)
|
|
||||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
|
||||||
*
|
|
||||||
* Help message formatter which retains any formatting in descriptions.
|
|
||||||
*
|
|
||||||
* Only the name of this class is considered a public API. All the methods
|
|
||||||
* provided by the class are considered an implementation detail.
|
|
||||||
**/
|
|
||||||
|
|
||||||
function RawDescriptionHelpFormatter(options) {
|
|
||||||
HelpFormatter.call(this, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
|
|
||||||
|
|
||||||
RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
|
|
||||||
var lines = text.split('\n');
|
|
||||||
lines = lines.map(function (line) {
|
|
||||||
return $$.trimEnd(indent + line);
|
|
||||||
});
|
|
||||||
return lines.join('\n');
|
|
||||||
};
|
|
||||||
module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new RawTextHelpFormatter(options)
|
|
||||||
* new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
|
|
||||||
*
|
|
||||||
* Help message formatter which retains formatting of all help text.
|
|
||||||
*
|
|
||||||
* Only the name of this class is considered a public API. All the methods
|
|
||||||
* provided by the class are considered an implementation detail.
|
|
||||||
**/
|
|
||||||
|
|
||||||
function RawTextHelpFormatter(options) {
|
|
||||||
RawDescriptionHelpFormatter.call(this, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
|
|
||||||
|
|
||||||
RawTextHelpFormatter.prototype._splitLines = function (text) {
|
|
||||||
return text.split('\n');
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
|
|
795
node_modules/argparse/lib/help/formatter.js
generated
vendored
795
node_modules/argparse/lib/help/formatter.js
generated
vendored
@ -1,795 +0,0 @@
|
|||||||
/**
|
|
||||||
* class HelpFormatter
|
|
||||||
*
|
|
||||||
* Formatter for generating usage messages and argument help strings. Only the
|
|
||||||
* name of this class is considered a public API. All the methods provided by
|
|
||||||
* the class are considered an implementation detail.
|
|
||||||
*
|
|
||||||
* Do not call in your code, use this class only for inherits your own forvatter
|
|
||||||
*
|
|
||||||
* ToDo add [additonal formatters][1]
|
|
||||||
*
|
|
||||||
* [1]:http://docs.python.org/dev/library/argparse.html#formatter-class
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var sprintf = require('sprintf-js').sprintf;
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
var c = require('../const');
|
|
||||||
|
|
||||||
var $$ = require('../utils');
|
|
||||||
|
|
||||||
|
|
||||||
/*:nodoc:* internal
|
|
||||||
* new Support(parent, heding)
|
|
||||||
* - parent (object): parent section
|
|
||||||
* - heading (string): header string
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
function Section(parent, heading) {
|
|
||||||
this._parent = parent;
|
|
||||||
this._heading = heading;
|
|
||||||
this._items = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*:nodoc:* internal
|
|
||||||
* Section#addItem(callback) -> Void
|
|
||||||
* - callback (array): tuple with function and args
|
|
||||||
*
|
|
||||||
* Add function for single element
|
|
||||||
**/
|
|
||||||
Section.prototype.addItem = function (callback) {
|
|
||||||
this._items.push(callback);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*:nodoc:* internal
|
|
||||||
* Section#formatHelp(formatter) -> string
|
|
||||||
* - formatter (HelpFormatter): current formatter
|
|
||||||
*
|
|
||||||
* Form help section string
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
Section.prototype.formatHelp = function (formatter) {
|
|
||||||
var itemHelp, heading;
|
|
||||||
|
|
||||||
// format the indented section
|
|
||||||
if (this._parent) {
|
|
||||||
formatter._indent();
|
|
||||||
}
|
|
||||||
|
|
||||||
itemHelp = this._items.map(function (item) {
|
|
||||||
var obj, func, args;
|
|
||||||
|
|
||||||
obj = formatter;
|
|
||||||
func = item[0];
|
|
||||||
args = item[1];
|
|
||||||
return func.apply(obj, args);
|
|
||||||
});
|
|
||||||
itemHelp = formatter._joinParts(itemHelp);
|
|
||||||
|
|
||||||
if (this._parent) {
|
|
||||||
formatter._dedent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// return nothing if the section was empty
|
|
||||||
if (!itemHelp) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the heading if the section was non-empty
|
|
||||||
heading = '';
|
|
||||||
if (this._heading && this._heading !== c.SUPPRESS) {
|
|
||||||
var currentIndent = formatter.currentIndent;
|
|
||||||
heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// join the section-initialize newline, the heading and the help
|
|
||||||
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new HelpFormatter(options)
|
|
||||||
*
|
|
||||||
* #### Options:
|
|
||||||
* - `prog`: program name
|
|
||||||
* - `indentIncriment`: indent step, default value 2
|
|
||||||
* - `maxHelpPosition`: max help position, default value = 24
|
|
||||||
* - `width`: line width
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var HelpFormatter = module.exports = function HelpFormatter(options) {
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
this._prog = options.prog;
|
|
||||||
|
|
||||||
this._maxHelpPosition = options.maxHelpPosition || 24;
|
|
||||||
this._width = (options.width || ((process.env.COLUMNS || 80) - 2));
|
|
||||||
|
|
||||||
this._currentIndent = 0;
|
|
||||||
this._indentIncriment = options.indentIncriment || 2;
|
|
||||||
this._level = 0;
|
|
||||||
this._actionMaxLength = 0;
|
|
||||||
|
|
||||||
this._rootSection = new Section(null);
|
|
||||||
this._currentSection = this._rootSection;
|
|
||||||
|
|
||||||
this._whitespaceMatcher = new RegExp('\\s+', 'g');
|
|
||||||
this._longBreakMatcher = new RegExp(c.EOL + c.EOL + c.EOL + '+', 'g');
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._indent = function () {
|
|
||||||
this._currentIndent += this._indentIncriment;
|
|
||||||
this._level += 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._dedent = function () {
|
|
||||||
this._currentIndent -= this._indentIncriment;
|
|
||||||
this._level -= 1;
|
|
||||||
if (this._currentIndent < 0) {
|
|
||||||
throw new Error('Indent decreased below 0.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._addItem = function (func, args) {
|
|
||||||
this._currentSection.addItem([ func, args ]);
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Message building methods
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#startSection(heading) -> Void
|
|
||||||
* - heading (string): header string
|
|
||||||
*
|
|
||||||
* Start new help section
|
|
||||||
*
|
|
||||||
* See alse [code example][1]
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.startSection(actionGroup.title);
|
|
||||||
* formatter.addText(actionGroup.description);
|
|
||||||
* formatter.addArguments(actionGroup._groupActions);
|
|
||||||
* formatter.endSection();
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.startSection = function (heading) {
|
|
||||||
this._indent();
|
|
||||||
var section = new Section(this._currentSection, heading);
|
|
||||||
var func = section.formatHelp.bind(section);
|
|
||||||
this._addItem(func, [ this ]);
|
|
||||||
this._currentSection = section;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#endSection -> Void
|
|
||||||
*
|
|
||||||
* End help section
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.startSection(actionGroup.title);
|
|
||||||
* formatter.addText(actionGroup.description);
|
|
||||||
* formatter.addArguments(actionGroup._groupActions);
|
|
||||||
* formatter.endSection();
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.endSection = function () {
|
|
||||||
this._currentSection = this._currentSection._parent;
|
|
||||||
this._dedent();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#addText(text) -> Void
|
|
||||||
* - text (string): plain text
|
|
||||||
*
|
|
||||||
* Add plain text into current section
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.startSection(actionGroup.title);
|
|
||||||
* formatter.addText(actionGroup.description);
|
|
||||||
* formatter.addArguments(actionGroup._groupActions);
|
|
||||||
* formatter.endSection();
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.addText = function (text) {
|
|
||||||
if (text && text !== c.SUPPRESS) {
|
|
||||||
this._addItem(this._formatText, [ text ]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#addUsage(usage, actions, groups, prefix) -> Void
|
|
||||||
* - usage (string): usage text
|
|
||||||
* - actions (array): actions list
|
|
||||||
* - groups (array): groups list
|
|
||||||
* - prefix (string): usage prefix
|
|
||||||
*
|
|
||||||
* Add usage data into current section
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.addUsage(this.usage, this._actions, []);
|
|
||||||
* return formatter.formatHelp();
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {
|
|
||||||
if (usage !== c.SUPPRESS) {
|
|
||||||
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#addArgument(action) -> Void
|
|
||||||
* - action (object): action
|
|
||||||
*
|
|
||||||
* Add argument into current section
|
|
||||||
*
|
|
||||||
* Single variant of [[HelpFormatter#addArguments]]
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.addArgument = function (action) {
|
|
||||||
if (action.help !== c.SUPPRESS) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// find all invocations
|
|
||||||
var invocations = [ this._formatActionInvocation(action) ];
|
|
||||||
var invocationLength = invocations[0].length;
|
|
||||||
|
|
||||||
var actionLength;
|
|
||||||
|
|
||||||
if (action._getSubactions) {
|
|
||||||
this._indent();
|
|
||||||
action._getSubactions().forEach(function (subaction) {
|
|
||||||
|
|
||||||
var invocationNew = self._formatActionInvocation(subaction);
|
|
||||||
invocations.push(invocationNew);
|
|
||||||
invocationLength = Math.max(invocationLength, invocationNew.length);
|
|
||||||
|
|
||||||
});
|
|
||||||
this._dedent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the maximum item length
|
|
||||||
actionLength = invocationLength + this._currentIndent;
|
|
||||||
this._actionMaxLength = Math.max(this._actionMaxLength, actionLength);
|
|
||||||
|
|
||||||
// add the item to the list
|
|
||||||
this._addItem(this._formatAction, [ action ]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#addArguments(actions) -> Void
|
|
||||||
* - actions (array): actions list
|
|
||||||
*
|
|
||||||
* Mass add arguments into current section
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.startSection(actionGroup.title);
|
|
||||||
* formatter.addText(actionGroup.description);
|
|
||||||
* formatter.addArguments(actionGroup._groupActions);
|
|
||||||
* formatter.endSection();
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.addArguments = function (actions) {
|
|
||||||
var self = this;
|
|
||||||
actions.forEach(function (action) {
|
|
||||||
self.addArgument(action);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Help-formatting methods
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HelpFormatter#formatHelp -> string
|
|
||||||
*
|
|
||||||
* Format help
|
|
||||||
*
|
|
||||||
* ##### Example
|
|
||||||
*
|
|
||||||
* formatter.addText(this.epilog);
|
|
||||||
* return formatter.formatHelp();
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
HelpFormatter.prototype.formatHelp = function () {
|
|
||||||
var help = this._rootSection.formatHelp(this);
|
|
||||||
if (help) {
|
|
||||||
help = help.replace(this._longBreakMatcher, c.EOL + c.EOL);
|
|
||||||
help = $$.trimChars(help, c.EOL) + c.EOL;
|
|
||||||
}
|
|
||||||
return help;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._joinParts = function (partStrings) {
|
|
||||||
return partStrings.filter(function (part) {
|
|
||||||
return (part && part !== c.SUPPRESS);
|
|
||||||
}).join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatUsage = function (usage, actions, groups, prefix) {
|
|
||||||
if (!prefix && typeof prefix !== 'string') {
|
|
||||||
prefix = 'usage: ';
|
|
||||||
}
|
|
||||||
|
|
||||||
actions = actions || [];
|
|
||||||
groups = groups || [];
|
|
||||||
|
|
||||||
|
|
||||||
// if usage is specified, use that
|
|
||||||
if (usage) {
|
|
||||||
usage = sprintf(usage, { prog: this._prog });
|
|
||||||
|
|
||||||
// if no optionals or positionals are available, usage is just prog
|
|
||||||
} else if (!usage && actions.length === 0) {
|
|
||||||
usage = this._prog;
|
|
||||||
|
|
||||||
// if optionals and positionals are available, calculate usage
|
|
||||||
} else if (!usage) {
|
|
||||||
var prog = this._prog;
|
|
||||||
var optionals = [];
|
|
||||||
var positionals = [];
|
|
||||||
var actionUsage;
|
|
||||||
var textWidth;
|
|
||||||
|
|
||||||
// split optionals from positionals
|
|
||||||
actions.forEach(function (action) {
|
|
||||||
if (action.isOptional()) {
|
|
||||||
optionals.push(action);
|
|
||||||
} else {
|
|
||||||
positionals.push(action);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// build full usage string
|
|
||||||
actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
|
|
||||||
usage = [ prog, actionUsage ].join(' ');
|
|
||||||
|
|
||||||
// wrap the usage parts if it's too long
|
|
||||||
textWidth = this._width - this._currentIndent;
|
|
||||||
if ((prefix.length + usage.length) > textWidth) {
|
|
||||||
|
|
||||||
// break usage into wrappable parts
|
|
||||||
var regexpPart = new RegExp('\\(.*?\\)+|\\[.*?\\]+|\\S+', 'g');
|
|
||||||
var optionalUsage = this._formatActionsUsage(optionals, groups);
|
|
||||||
var positionalUsage = this._formatActionsUsage(positionals, groups);
|
|
||||||
|
|
||||||
|
|
||||||
var optionalParts = optionalUsage.match(regexpPart);
|
|
||||||
var positionalParts = positionalUsage.match(regexpPart) || [];
|
|
||||||
|
|
||||||
if (optionalParts.join(' ') !== optionalUsage) {
|
|
||||||
throw new Error('assert "optionalParts.join(\' \') === optionalUsage"');
|
|
||||||
}
|
|
||||||
if (positionalParts.join(' ') !== positionalUsage) {
|
|
||||||
throw new Error('assert "positionalParts.join(\' \') === positionalUsage"');
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper for wrapping lines
|
|
||||||
/*eslint-disable func-style*/ // node 0.10 compat
|
|
||||||
var _getLines = function (parts, indent, prefix) {
|
|
||||||
var lines = [];
|
|
||||||
var line = [];
|
|
||||||
|
|
||||||
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;
|
|
||||||
|
|
||||||
parts.forEach(function (part) {
|
|
||||||
if (lineLength + 1 + part.length > textWidth) {
|
|
||||||
lines.push(indent + line.join(' '));
|
|
||||||
line = [];
|
|
||||||
lineLength = indent.length - 1;
|
|
||||||
}
|
|
||||||
line.push(part);
|
|
||||||
lineLength += part.length + 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (line) {
|
|
||||||
lines.push(indent + line.join(' '));
|
|
||||||
}
|
|
||||||
if (prefix) {
|
|
||||||
lines[0] = lines[0].substr(indent.length);
|
|
||||||
}
|
|
||||||
return lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
var lines, indent, parts;
|
|
||||||
// if prog is short, follow it with optionals or positionals
|
|
||||||
if (prefix.length + prog.length <= 0.75 * textWidth) {
|
|
||||||
indent = $$.repeat(' ', (prefix.length + prog.length + 1));
|
|
||||||
if (optionalParts) {
|
|
||||||
lines = [].concat(
|
|
||||||
_getLines([ prog ].concat(optionalParts), indent, prefix),
|
|
||||||
_getLines(positionalParts, indent)
|
|
||||||
);
|
|
||||||
} else if (positionalParts) {
|
|
||||||
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
|
|
||||||
} else {
|
|
||||||
lines = [ prog ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// if prog is long, put it on its own line
|
|
||||||
} else {
|
|
||||||
indent = $$.repeat(' ', prefix.length);
|
|
||||||
parts = optionalParts.concat(positionalParts);
|
|
||||||
lines = _getLines(parts, indent);
|
|
||||||
if (lines.length > 1) {
|
|
||||||
lines = [].concat(
|
|
||||||
_getLines(optionalParts, indent),
|
|
||||||
_getLines(positionalParts, indent)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
lines = [ prog ].concat(lines);
|
|
||||||
}
|
|
||||||
// join lines into usage
|
|
||||||
usage = lines.join(c.EOL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// prefix with 'usage:'
|
|
||||||
return prefix + usage + c.EOL + c.EOL;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatActionsUsage = function (actions, groups) {
|
|
||||||
// find group indices and identify actions in groups
|
|
||||||
var groupActions = [];
|
|
||||||
var inserts = [];
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
groups.forEach(function (group) {
|
|
||||||
var end;
|
|
||||||
var i;
|
|
||||||
|
|
||||||
var start = actions.indexOf(group._groupActions[0]);
|
|
||||||
if (start >= 0) {
|
|
||||||
end = start + group._groupActions.length;
|
|
||||||
|
|
||||||
//if (actions.slice(start, end) === group._groupActions) {
|
|
||||||
if ($$.arrayEqual(actions.slice(start, end), group._groupActions)) {
|
|
||||||
group._groupActions.forEach(function (action) {
|
|
||||||
groupActions.push(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!group.required) {
|
|
||||||
if (inserts[start]) {
|
|
||||||
inserts[start] += ' [';
|
|
||||||
} else {
|
|
||||||
inserts[start] = '[';
|
|
||||||
}
|
|
||||||
inserts[end] = ']';
|
|
||||||
} else {
|
|
||||||
if (inserts[start]) {
|
|
||||||
inserts[start] += ' (';
|
|
||||||
} else {
|
|
||||||
inserts[start] = '(';
|
|
||||||
}
|
|
||||||
inserts[end] = ')';
|
|
||||||
}
|
|
||||||
for (i = start + 1; i < end; i += 1) {
|
|
||||||
inserts[i] = '|';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// collect all actions format strings
|
|
||||||
var parts = [];
|
|
||||||
|
|
||||||
actions.forEach(function (action, actionIndex) {
|
|
||||||
var part;
|
|
||||||
var optionString;
|
|
||||||
var argsDefault;
|
|
||||||
var argsString;
|
|
||||||
|
|
||||||
// suppressed arguments are marked with None
|
|
||||||
// remove | separators for suppressed arguments
|
|
||||||
if (action.help === c.SUPPRESS) {
|
|
||||||
parts.push(null);
|
|
||||||
if (inserts[actionIndex] === '|') {
|
|
||||||
inserts.splice(actionIndex, actionIndex);
|
|
||||||
} else if (inserts[actionIndex + 1] === '|') {
|
|
||||||
inserts.splice(actionIndex + 1, actionIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// produce all arg strings
|
|
||||||
} else if (!action.isOptional()) {
|
|
||||||
part = self._formatArgs(action, action.dest);
|
|
||||||
|
|
||||||
// if it's in a group, strip the outer []
|
|
||||||
if (groupActions.indexOf(action) >= 0) {
|
|
||||||
if (part[0] === '[' && part[part.length - 1] === ']') {
|
|
||||||
part = part.slice(1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add the action string to the list
|
|
||||||
parts.push(part);
|
|
||||||
|
|
||||||
// produce the first way to invoke the option in brackets
|
|
||||||
} else {
|
|
||||||
optionString = action.optionStrings[0];
|
|
||||||
|
|
||||||
// if the Optional doesn't take a value, format is: -s or --long
|
|
||||||
if (action.nargs === 0) {
|
|
||||||
part = '' + optionString;
|
|
||||||
|
|
||||||
// if the Optional takes a value, format is: -s ARGS or --long ARGS
|
|
||||||
} else {
|
|
||||||
argsDefault = action.dest.toUpperCase();
|
|
||||||
argsString = self._formatArgs(action, argsDefault);
|
|
||||||
part = optionString + ' ' + argsString;
|
|
||||||
}
|
|
||||||
// make it look optional if it's not required or in a group
|
|
||||||
if (!action.required && groupActions.indexOf(action) < 0) {
|
|
||||||
part = '[' + part + ']';
|
|
||||||
}
|
|
||||||
// add the action string to the list
|
|
||||||
parts.push(part);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// insert things at the necessary indices
|
|
||||||
for (var i = inserts.length - 1; i >= 0; --i) {
|
|
||||||
if (inserts[i] !== null) {
|
|
||||||
parts.splice(i, 0, inserts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// join all the action items with spaces
|
|
||||||
var text = parts.filter(function (part) {
|
|
||||||
return !!part;
|
|
||||||
}).join(' ');
|
|
||||||
|
|
||||||
// clean up separators for mutually exclusive groups
|
|
||||||
text = text.replace(/([\[(]) /g, '$1'); // remove spaces
|
|
||||||
text = text.replace(/ ([\])])/g, '$1');
|
|
||||||
text = text.replace(/\[ *\]/g, ''); // remove empty groups
|
|
||||||
text = text.replace(/\( *\)/g, '');
|
|
||||||
text = text.replace(/\(([^|]*)\)/g, '$1'); // remove () from single action groups
|
|
||||||
|
|
||||||
text = text.trim();
|
|
||||||
|
|
||||||
// return the text
|
|
||||||
return text;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatText = function (text) {
|
|
||||||
text = sprintf(text, { prog: this._prog });
|
|
||||||
var textWidth = this._width - this._currentIndent;
|
|
||||||
var indentIncriment = $$.repeat(' ', this._currentIndent);
|
|
||||||
return this._fillText(text, textWidth, indentIncriment) + c.EOL + c.EOL;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatAction = function (action) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var helpText;
|
|
||||||
var helpLines;
|
|
||||||
var parts;
|
|
||||||
var indentFirst;
|
|
||||||
|
|
||||||
// determine the required width and the entry label
|
|
||||||
var helpPosition = Math.min(this._actionMaxLength + 2, this._maxHelpPosition);
|
|
||||||
var helpWidth = this._width - helpPosition;
|
|
||||||
var actionWidth = helpPosition - this._currentIndent - 2;
|
|
||||||
var actionHeader = this._formatActionInvocation(action);
|
|
||||||
|
|
||||||
// no help; start on same line and add a final newline
|
|
||||||
if (!action.help) {
|
|
||||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
|
||||||
|
|
||||||
// short action name; start on the same line and pad two spaces
|
|
||||||
} else if (actionHeader.length <= actionWidth) {
|
|
||||||
actionHeader = $$.repeat(' ', this._currentIndent) +
|
|
||||||
actionHeader +
|
|
||||||
' ' +
|
|
||||||
$$.repeat(' ', actionWidth - actionHeader.length);
|
|
||||||
indentFirst = 0;
|
|
||||||
|
|
||||||
// long action name; start on the next line
|
|
||||||
} else {
|
|
||||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
|
||||||
indentFirst = helpPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// collect the pieces of the action help
|
|
||||||
parts = [ actionHeader ];
|
|
||||||
|
|
||||||
// if there was help for the action, add lines of help text
|
|
||||||
if (action.help) {
|
|
||||||
helpText = this._expandHelp(action);
|
|
||||||
helpLines = this._splitLines(helpText, helpWidth);
|
|
||||||
parts.push($$.repeat(' ', indentFirst) + helpLines[0] + c.EOL);
|
|
||||||
helpLines.slice(1).forEach(function (line) {
|
|
||||||
parts.push($$.repeat(' ', helpPosition) + line + c.EOL);
|
|
||||||
});
|
|
||||||
|
|
||||||
// or add a newline if the description doesn't end with one
|
|
||||||
} else if (actionHeader.charAt(actionHeader.length - 1) !== c.EOL) {
|
|
||||||
parts.push(c.EOL);
|
|
||||||
}
|
|
||||||
// if there are any sub-actions, add their help as well
|
|
||||||
if (action._getSubactions) {
|
|
||||||
this._indent();
|
|
||||||
action._getSubactions().forEach(function (subaction) {
|
|
||||||
parts.push(self._formatAction(subaction));
|
|
||||||
});
|
|
||||||
this._dedent();
|
|
||||||
}
|
|
||||||
// return a single string
|
|
||||||
return this._joinParts(parts);
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatActionInvocation = function (action) {
|
|
||||||
if (!action.isOptional()) {
|
|
||||||
var format_func = this._metavarFormatter(action, action.dest);
|
|
||||||
var metavars = format_func(1);
|
|
||||||
return metavars[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
var parts = [];
|
|
||||||
var argsDefault;
|
|
||||||
var argsString;
|
|
||||||
|
|
||||||
// if the Optional doesn't take a value, format is: -s, --long
|
|
||||||
if (action.nargs === 0) {
|
|
||||||
parts = parts.concat(action.optionStrings);
|
|
||||||
|
|
||||||
// if the Optional takes a value, format is: -s ARGS, --long ARGS
|
|
||||||
} else {
|
|
||||||
argsDefault = action.dest.toUpperCase();
|
|
||||||
argsString = this._formatArgs(action, argsDefault);
|
|
||||||
action.optionStrings.forEach(function (optionString) {
|
|
||||||
parts.push(optionString + ' ' + argsString);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return parts.join(', ');
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._metavarFormatter = function (action, metavarDefault) {
|
|
||||||
var result;
|
|
||||||
|
|
||||||
if (action.metavar || action.metavar === '') {
|
|
||||||
result = action.metavar;
|
|
||||||
} else if (action.choices) {
|
|
||||||
var choices = action.choices;
|
|
||||||
|
|
||||||
if (typeof choices === 'string') {
|
|
||||||
choices = choices.split('').join(', ');
|
|
||||||
} else if (Array.isArray(choices)) {
|
|
||||||
choices = choices.join(',');
|
|
||||||
} else {
|
|
||||||
choices = Object.keys(choices).join(',');
|
|
||||||
}
|
|
||||||
result = '{' + choices + '}';
|
|
||||||
} else {
|
|
||||||
result = metavarDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (size) {
|
|
||||||
if (Array.isArray(result)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
var metavars = [];
|
|
||||||
for (var i = 0; i < size; i += 1) {
|
|
||||||
metavars.push(result);
|
|
||||||
}
|
|
||||||
return metavars;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._formatArgs = function (action, metavarDefault) {
|
|
||||||
var result;
|
|
||||||
var metavars;
|
|
||||||
|
|
||||||
var buildMetavar = this._metavarFormatter(action, metavarDefault);
|
|
||||||
|
|
||||||
switch (action.nargs) {
|
|
||||||
/*eslint-disable no-undefined*/
|
|
||||||
case undefined:
|
|
||||||
case null:
|
|
||||||
metavars = buildMetavar(1);
|
|
||||||
result = '' + metavars[0];
|
|
||||||
break;
|
|
||||||
case c.OPTIONAL:
|
|
||||||
metavars = buildMetavar(1);
|
|
||||||
result = '[' + metavars[0] + ']';
|
|
||||||
break;
|
|
||||||
case c.ZERO_OR_MORE:
|
|
||||||
metavars = buildMetavar(2);
|
|
||||||
result = '[' + metavars[0] + ' [' + metavars[1] + ' ...]]';
|
|
||||||
break;
|
|
||||||
case c.ONE_OR_MORE:
|
|
||||||
metavars = buildMetavar(2);
|
|
||||||
result = '' + metavars[0] + ' [' + metavars[1] + ' ...]';
|
|
||||||
break;
|
|
||||||
case c.REMAINDER:
|
|
||||||
result = '...';
|
|
||||||
break;
|
|
||||||
case c.PARSER:
|
|
||||||
metavars = buildMetavar(1);
|
|
||||||
result = metavars[0] + ' ...';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
metavars = buildMetavar(action.nargs);
|
|
||||||
result = metavars.join(' ');
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._expandHelp = function (action) {
|
|
||||||
var params = { prog: this._prog };
|
|
||||||
|
|
||||||
Object.keys(action).forEach(function (actionProperty) {
|
|
||||||
var actionValue = action[actionProperty];
|
|
||||||
|
|
||||||
if (actionValue !== c.SUPPRESS) {
|
|
||||||
params[actionProperty] = actionValue;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (params.choices) {
|
|
||||||
if (typeof params.choices === 'string') {
|
|
||||||
params.choices = params.choices.split('').join(', ');
|
|
||||||
} else if (Array.isArray(params.choices)) {
|
|
||||||
params.choices = params.choices.join(', ');
|
|
||||||
} else {
|
|
||||||
params.choices = Object.keys(params.choices).join(', ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(this._getHelpString(action), params);
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._splitLines = function (text, width) {
|
|
||||||
var lines = [];
|
|
||||||
var delimiters = [ ' ', '.', ',', '!', '?' ];
|
|
||||||
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
|
|
||||||
|
|
||||||
text = text.replace(/[\n\|\t]/g, ' ');
|
|
||||||
|
|
||||||
text = text.trim();
|
|
||||||
text = text.replace(this._whitespaceMatcher, ' ');
|
|
||||||
|
|
||||||
// Wraps the single paragraph in text (a string) so every line
|
|
||||||
// is at most width characters long.
|
|
||||||
text.split(c.EOL).forEach(function (line) {
|
|
||||||
if (width >= line.length) {
|
|
||||||
lines.push(line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var wrapStart = 0;
|
|
||||||
var wrapEnd = width;
|
|
||||||
var delimiterIndex = 0;
|
|
||||||
while (wrapEnd <= line.length) {
|
|
||||||
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
|
|
||||||
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
|
|
||||||
wrapEnd = wrapStart + delimiterIndex + 1;
|
|
||||||
}
|
|
||||||
lines.push(line.substring(wrapStart, wrapEnd));
|
|
||||||
wrapStart = wrapEnd;
|
|
||||||
wrapEnd += width;
|
|
||||||
}
|
|
||||||
if (wrapStart < line.length) {
|
|
||||||
lines.push(line.substring(wrapStart, wrapEnd));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return lines;
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._fillText = function (text, width, indent) {
|
|
||||||
var lines = this._splitLines(text, width);
|
|
||||||
lines = lines.map(function (line) {
|
|
||||||
return indent + line;
|
|
||||||
});
|
|
||||||
return lines.join(c.EOL);
|
|
||||||
};
|
|
||||||
|
|
||||||
HelpFormatter.prototype._getHelpString = function (action) {
|
|
||||||
return action.help;
|
|
||||||
};
|
|
76
node_modules/argparse/lib/namespace.js
generated
vendored
76
node_modules/argparse/lib/namespace.js
generated
vendored
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* class Namespace
|
|
||||||
*
|
|
||||||
* Simple object for storing attributes. Implements equality by attribute names
|
|
||||||
* and values, and provides a simple string representation.
|
|
||||||
*
|
|
||||||
* See also [original guide][1]
|
|
||||||
*
|
|
||||||
* [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
|
|
||||||
**/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var $$ = require('./utils');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* new Namespace(options)
|
|
||||||
* - options(object): predefined propertis for result object
|
|
||||||
*
|
|
||||||
**/
|
|
||||||
var Namespace = module.exports = function Namespace(options) {
|
|
||||||
$$.extend(this, options);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace#isset(key) -> Boolean
|
|
||||||
* - key (string|number): property name
|
|
||||||
*
|
|
||||||
* Tells whenever `namespace` contains given `key` or not.
|
|
||||||
**/
|
|
||||||
Namespace.prototype.isset = function (key) {
|
|
||||||
return $$.has(this, key);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace#set(key, value) -> self
|
|
||||||
* -key (string|number|object): propery name
|
|
||||||
* -value (mixed): new property value
|
|
||||||
*
|
|
||||||
* Set the property named key with value.
|
|
||||||
* If key object then set all key properties to namespace object
|
|
||||||
**/
|
|
||||||
Namespace.prototype.set = function (key, value) {
|
|
||||||
if (typeof (key) === 'object') {
|
|
||||||
$$.extend(this, key);
|
|
||||||
} else {
|
|
||||||
this[key] = value;
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace#get(key, defaultValue) -> mixed
|
|
||||||
* - key (string|number): property name
|
|
||||||
* - defaultValue (mixed): default value
|
|
||||||
*
|
|
||||||
* Return the property key or defaulValue if not set
|
|
||||||
**/
|
|
||||||
Namespace.prototype.get = function (key, defaultValue) {
|
|
||||||
return !this[key] ? defaultValue : this[key];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace#unset(key, defaultValue) -> mixed
|
|
||||||
* - key (string|number): property name
|
|
||||||
* - defaultValue (mixed): default value
|
|
||||||
*
|
|
||||||
* Return data[key](and delete it) or defaultValue
|
|
||||||
**/
|
|
||||||
Namespace.prototype.unset = function (key, defaultValue) {
|
|
||||||
var value = this[key];
|
|
||||||
if (value !== null) {
|
|
||||||
delete this[key];
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
};
|
|
57
node_modules/argparse/lib/utils.js
generated
vendored
57
node_modules/argparse/lib/utils.js
generated
vendored
@ -1,57 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
exports.repeat = function (str, num) {
|
|
||||||
var result = '';
|
|
||||||
for (var i = 0; i < num; i++) { result += str; }
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.arrayEqual = function (a, b) {
|
|
||||||
if (a.length !== b.length) { return false; }
|
|
||||||
for (var i = 0; i < a.length; i++) {
|
|
||||||
if (a[i] !== b[i]) { return false; }
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.trimChars = function (str, chars) {
|
|
||||||
var start = 0;
|
|
||||||
var end = str.length - 1;
|
|
||||||
while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
|
|
||||||
while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
|
|
||||||
return str.slice(start, end + 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.capitalize = function (str) {
|
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.arrayUnion = function () {
|
|
||||||
var result = [];
|
|
||||||
for (var i = 0, values = {}; i < arguments.length; i++) {
|
|
||||||
var arr = arguments[i];
|
|
||||||
for (var j = 0; j < arr.length; j++) {
|
|
||||||
if (!values[arr[j]]) {
|
|
||||||
values[arr[j]] = true;
|
|
||||||
result.push(arr[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
function has(obj, key) {
|
|
||||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.has = has;
|
|
||||||
|
|
||||||
exports.extend = function (dest, src) {
|
|
||||||
for (var i in src) {
|
|
||||||
if (has(src, i)) { dest[i] = src[i]; }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.trimEnd = function (str) {
|
|
||||||
return str.replace(/\s+$/g, '');
|
|
||||||
};
|
|
73
node_modules/argparse/package.json
generated
vendored
73
node_modules/argparse/package.json
generated
vendored
@ -1,73 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"argparse@1.0.10",
|
|
||||||
"E:\\python\\setup-php"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "argparse@1.0.10",
|
|
||||||
"_id": "argparse@1.0.10",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
|
||||||
"_location": "/argparse",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "argparse@1.0.10",
|
|
||||||
"name": "argparse",
|
|
||||||
"escapedName": "argparse",
|
|
||||||
"rawSpec": "1.0.10",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.10"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/js-yaml"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
|
||||||
"_spec": "1.0.10",
|
|
||||||
"_where": "E:\\python\\setup-php",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/nodeca/argparse/issues"
|
|
||||||
},
|
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "Eugene Shkuropat"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Paul Jacobson"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"sprintf-js": "~1.0.2"
|
|
||||||
},
|
|
||||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^2.13.1",
|
|
||||||
"istanbul": "^0.4.5",
|
|
||||||
"mocha": "^3.1.0",
|
|
||||||
"ndoc": "^5.0.1"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"lib/"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/nodeca/argparse#readme",
|
|
||||||
"keywords": [
|
|
||||||
"cli",
|
|
||||||
"parser",
|
|
||||||
"argparse",
|
|
||||||
"option",
|
|
||||||
"args"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"name": "argparse",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/nodeca/argparse.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "make test"
|
|
||||||
},
|
|
||||||
"version": "1.0.10"
|
|
||||||
}
|
|
10
node_modules/argv/.nodelint.json
generated
vendored
10
node_modules/argv/.nodelint.json
generated
vendored
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"ignore": [
|
|
||||||
"node_modules/"
|
|
||||||
],
|
|
||||||
"linters": {
|
|
||||||
"jshint": {
|
|
||||||
"boss": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2
node_modules/argv/.npmignore
generated
vendored
2
node_modules/argv/.npmignore
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
build/results/
|
|
3
node_modules/argv/.travis.yml
generated
vendored
3
node_modules/argv/.travis.yml
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- "0.8"
|
|
8
node_modules/argv/CHANGELOG.md
generated
vendored
8
node_modules/argv/CHANGELOG.md
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
## v0.0.2
|
|
||||||
|
|
||||||
* Transfering help and version option after calling clear
|
|
||||||
|
|
||||||
|
|
||||||
## v0.0.1
|
|
||||||
|
|
||||||
Initial Release
|
|
21
node_modules/argv/LICENSE
generated
vendored
21
node_modules/argv/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2012-2013 Corey Hart
|
|
||||||
|
|
||||||
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.
|
|
16
node_modules/argv/Makefile
generated
vendored
16
node_modules/argv/Makefile
generated
vendored
@ -1,16 +0,0 @@
|
|||||||
all: test
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -rf build/results/
|
|
||||||
|
|
||||||
lint:
|
|
||||||
@node build/lint.js
|
|
||||||
|
|
||||||
test: clean lint
|
|
||||||
@node build/test.js
|
|
||||||
|
|
||||||
test-all:
|
|
||||||
@NODE_TEST_NO_SKIP=1 make test
|
|
||||||
|
|
||||||
test-full:
|
|
||||||
@./build/full.sh
|
|
189
node_modules/argv/README.md
generated
vendored
189
node_modules/argv/README.md
generated
vendored
@ -1,189 +0,0 @@
|
|||||||
# argv
|
|
||||||
|
|
||||||
argv is a nodejs module that does command line argument parsing.
|
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/codenothing/argv.png?branch=master)](https://travis-ci.org/codenothing/argv)
|
|
||||||
|
|
||||||
### Installation
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm install argv
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
var argv = require( 'argv' );
|
|
||||||
var args = argv.option( options ).run();
|
|
||||||
-> { targets: [], options: {} }
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Run
|
|
||||||
|
|
||||||
Runs the argument parser on the global arguments. Custom arguments array can be used by passing into this method
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Parses default arguments 'process.argv.slice( 2 )'
|
|
||||||
argv.run();
|
|
||||||
|
|
||||||
// Parses array instead
|
|
||||||
argv.run([ '--option=123', '-o', '123' ]);
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
argv is a strict argument parser, which means all options must be defined before parsing starts.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.option({
|
|
||||||
name: 'option',
|
|
||||||
short: 'o',
|
|
||||||
type: 'string',
|
|
||||||
description: 'Defines an option for your script',
|
|
||||||
example: "'script --opiton=value' or 'script -o value'"
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Modules
|
|
||||||
|
|
||||||
Modules are nested commands for more complicated scripts. Each module has it's own set of options that
|
|
||||||
have to be defined independently of the root options.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.mod({
|
|
||||||
mod: 'module',
|
|
||||||
description: 'Description of what the module is used for',
|
|
||||||
options: [ list of options ]
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Types
|
|
||||||
|
|
||||||
Types convert option values to useful js objects. They are defined along with each option.
|
|
||||||
|
|
||||||
* **string**: Ensure values are strings
|
|
||||||
* **path**: Converts value into a fully resolved path.
|
|
||||||
* **int**: Converts value into an integer
|
|
||||||
* **float**: Converts value into a float number
|
|
||||||
* **boolean**: Converts value into a boolean object. 'true' and '1' are converted to true, everything else is false.
|
|
||||||
* **csv**: Converts value into an array by splitting on comma's.
|
|
||||||
* **list**: Allows for option to be defined multiple times, and each value added to an array
|
|
||||||
* **[list|csv],[type]**: Combo type that allows you to create a list or csv and convert each individual value into a type.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.option([
|
|
||||||
{
|
|
||||||
name: 'option',
|
|
||||||
type: 'csv,int'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'path',
|
|
||||||
short: 'p',
|
|
||||||
type: 'list,path'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
// csv and int combo
|
|
||||||
$ script --option=123,456.001,789.01
|
|
||||||
-> option: [ 123, 456, 789 ]
|
|
||||||
|
|
||||||
// list and path combo
|
|
||||||
$ script -p /path/to/file1 -p /path/to/file2
|
|
||||||
-> option: [ '/path/to/file1', '/path/to/file2' ]
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also create your own custom type for special conversions.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.type( 'squared', function( value ) {
|
|
||||||
value = parseFloat( value );
|
|
||||||
return value * value;
|
|
||||||
});
|
|
||||||
|
|
||||||
argv.option({
|
|
||||||
name: 'square',
|
|
||||||
short: 's',
|
|
||||||
type: 'squared'
|
|
||||||
});
|
|
||||||
|
|
||||||
$ script -s 2
|
|
||||||
-> 4
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Version
|
|
||||||
|
|
||||||
Defining the scripts version number will add the version option and print it out when asked.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.version( 'v1.0' );
|
|
||||||
|
|
||||||
$ script --version
|
|
||||||
v1.0
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Info
|
|
||||||
|
|
||||||
Custom information can be displayed at the top of the help printout using this method
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.info( 'Special script info' );
|
|
||||||
|
|
||||||
$ script --help
|
|
||||||
|
|
||||||
Special script info
|
|
||||||
|
|
||||||
... Rest of Help Doc ...
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Clear
|
|
||||||
|
|
||||||
If you have competing scripts accessing the argv object, you can clear out any previous options that may have been set.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.clear().option( [new options] );
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Help
|
|
||||||
|
|
||||||
argv injects a default help option initially and on clears. The help() method triggers the help printout.
|
|
||||||
|
|
||||||
```js
|
|
||||||
argv.help();
|
|
||||||
```
|
|
||||||
|
|
||||||
----
|
|
||||||
### License
|
|
||||||
|
|
||||||
```
|
|
||||||
The MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2012-2013 Corey Hart
|
|
||||||
|
|
||||||
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.
|
|
||||||
```
|
|
29
node_modules/argv/build/full.sh
generated
vendored
29
node_modules/argv/build/full.sh
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd `dirname $0`
|
|
||||||
cd ../
|
|
||||||
SRCROOT=${PWD}
|
|
||||||
|
|
||||||
# Clean out and rebuild before running through each enviorment
|
|
||||||
make clean
|
|
||||||
|
|
||||||
echo "===== NVM DIR::: $NVM_DIR ===="
|
|
||||||
|
|
||||||
# Find each availiable node version and test with that version
|
|
||||||
for i in $( ls $NVM_DIR )
|
|
||||||
do
|
|
||||||
if [[ $i =~ ^v ]]; then
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo "=== Node $i ==="
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Run test suite
|
|
||||||
"$NVM_DIR/$i/bin/node" "$SRCROOT/build/test.js"
|
|
||||||
|
|
||||||
# Any non successful exit should be treated as full error
|
|
||||||
RESULT=$?
|
|
||||||
if [[ $RESULT != 0 ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
1
node_modules/argv/build/lint.js
generated
vendored
1
node_modules/argv/build/lint.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
require( 'nlint' ).render( __dirname + '/../' );
|
|
13
node_modules/argv/build/test.js
generated
vendored
13
node_modules/argv/build/test.js
generated
vendored
@ -1,13 +0,0 @@
|
|||||||
global.munit = require( 'munit' );
|
|
||||||
global.argv = require( '../' );
|
|
||||||
|
|
||||||
// Only stop test suite when running make test
|
|
||||||
if ( ! process.env.NODE_TEST_NO_SKIP ) {
|
|
||||||
munit.defaults.settings.stopOnFail = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render all tests
|
|
||||||
munit.render( __dirname + '/../test/', {
|
|
||||||
junit: __dirname + '/results/',
|
|
||||||
junitPrefix: process.version.replace( /\./g, '_' )
|
|
||||||
});
|
|
1
node_modules/argv/index.js
generated
vendored
1
node_modules/argv/index.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require( './lib/argv.js' );
|
|
465
node_modules/argv/lib/argv.js
generated
vendored
465
node_modules/argv/lib/argv.js
generated
vendored
@ -1,465 +0,0 @@
|
|||||||
var PATH = require( 'path' ),
|
|
||||||
toString = Object.prototype.toString,
|
|
||||||
rhome = /^\~\//,
|
|
||||||
rroot = /^\//,
|
|
||||||
rlistcsv = /^(list|csv)\,[a-z]+$/,
|
|
||||||
rdash = /^\-/,
|
|
||||||
rddash = /^\-\-/,
|
|
||||||
ristarget = /^[^\-]/,
|
|
||||||
SCRIPT_NAME = ( process.argv[ 1 ] || '' ).split( '/' ).pop(),
|
|
||||||
helpOption = {
|
|
||||||
name: 'help',
|
|
||||||
short: 'h',
|
|
||||||
type: function(){ return true; },
|
|
||||||
description: 'Displays help information about this script',
|
|
||||||
example: "'" + SCRIPT_NAME + " -h' or '" + SCRIPT_NAME + " --help'",
|
|
||||||
onset: function( args ) {
|
|
||||||
self.help( args.mod );
|
|
||||||
process.exit( 0 );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
boolTest = function( value ) {
|
|
||||||
return value == 'true' || value == 'false' || value == '1' || value == '0';
|
|
||||||
},
|
|
||||||
self;
|
|
||||||
|
|
||||||
// argv module
|
|
||||||
module.exports = self = {
|
|
||||||
|
|
||||||
// Default script name
|
|
||||||
name: SCRIPT_NAME,
|
|
||||||
|
|
||||||
// Default description to the triggered script 'node script'
|
|
||||||
description: 'Usage: ' + SCRIPT_NAME + ' [options]',
|
|
||||||
|
|
||||||
// Modules
|
|
||||||
mods: {},
|
|
||||||
|
|
||||||
// Shorthand options
|
|
||||||
short: { h: helpOption },
|
|
||||||
|
|
||||||
// Options
|
|
||||||
options: { help: helpOption },
|
|
||||||
|
|
||||||
// List of common types
|
|
||||||
types: {
|
|
||||||
|
|
||||||
string: function( value ) {
|
|
||||||
return value.toString();
|
|
||||||
},
|
|
||||||
|
|
||||||
path: function( value ) {
|
|
||||||
var end = value[ value.length - 1 ] == '/';
|
|
||||||
|
|
||||||
if ( rhome.exec( value ) ) {
|
|
||||||
value = PATH.normalize( process.env.HOME + '/' + value.replace( rhome, '' ) );
|
|
||||||
}
|
|
||||||
else if ( ! rroot.exec( value ) ) {
|
|
||||||
value = PATH.normalize( process.cwd() + '/' + value );
|
|
||||||
}
|
|
||||||
|
|
||||||
return value + ( end && value[ value.length - 1 ] != '/' ? '/' : '' );
|
|
||||||
},
|
|
||||||
|
|
||||||
'int': function( value ) {
|
|
||||||
return parseInt( value, 10 );
|
|
||||||
},
|
|
||||||
|
|
||||||
'float': function( value ) {
|
|
||||||
return parseFloat( value, 10 );
|
|
||||||
},
|
|
||||||
|
|
||||||
'boolean': function( value ) {
|
|
||||||
return ( value == 'true' || value === '1' );
|
|
||||||
},
|
|
||||||
|
|
||||||
list: function( value, name, options ) {
|
|
||||||
if ( ! options[ name ] ) {
|
|
||||||
options[ name ] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
options[ name ].push( value );
|
|
||||||
return options[ name ];
|
|
||||||
},
|
|
||||||
|
|
||||||
csv: function( value ) {
|
|
||||||
return value.split( ',' );
|
|
||||||
},
|
|
||||||
|
|
||||||
'listcsv-combo': function( type ) {
|
|
||||||
var parts = type.split( ',' ),
|
|
||||||
primary = parts.shift(),
|
|
||||||
secondary = parts.shift();
|
|
||||||
|
|
||||||
return function( value, name, options, args ) {
|
|
||||||
// Entry is going to be an array
|
|
||||||
if ( ! options[ name ] ) {
|
|
||||||
options[ name ] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Channel to csv or list
|
|
||||||
if ( primary == 'csv' ) {
|
|
||||||
value.split( ',' ).forEach(function( val ) {
|
|
||||||
options[ name ].push( self.types[ secondary ]( val, name, options, args ) );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
options[ name ].push( self.types[ secondary ]( value, name, options, args ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return options[ name ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
// Creates custom type function
|
|
||||||
type: function( name, callback ) {
|
|
||||||
if ( self.isObject( name ) ) {
|
|
||||||
for ( var i in name ) {
|
|
||||||
if ( self.isFunction( name[ i ] ) ) {
|
|
||||||
self.types[ i ] = name[ i ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( callback === undefined ) {
|
|
||||||
return self.types[ name ];
|
|
||||||
}
|
|
||||||
else if ( self.isFunction( callback ) ) {
|
|
||||||
self.types[ name ] = callback;
|
|
||||||
}
|
|
||||||
else if ( callback === null && self.types.hasOwnProperty( name ) ) {
|
|
||||||
delete self.types[ name ];
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Setting version number, and auto setting version option
|
|
||||||
version: function( v ) {
|
|
||||||
self.option({
|
|
||||||
_version: v,
|
|
||||||
name: 'version',
|
|
||||||
type: function(){ return true; },
|
|
||||||
description: 'Displays version info',
|
|
||||||
example: self.name + " --version",
|
|
||||||
onset: function( args ) {
|
|
||||||
console.log( v + "\n" );
|
|
||||||
process.exit( 0 );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Adding options to definitions list
|
|
||||||
option: function( mod, object ) {
|
|
||||||
if ( object === undefined ) {
|
|
||||||
object = mod;
|
|
||||||
mod = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over array for multi entry
|
|
||||||
if ( self.isArray( object ) ) {
|
|
||||||
object.forEach(function( entry ) {
|
|
||||||
self.option( mod, entry );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Handle edge case
|
|
||||||
else if ( ! self.isObject( object ) ) {
|
|
||||||
throw new Error( 'No option definition provided' + ( mod ? ' for module ' + mod : '' ) );
|
|
||||||
}
|
|
||||||
// Handle module definition
|
|
||||||
else if ( object.mod ) {
|
|
||||||
self.mod( object );
|
|
||||||
}
|
|
||||||
// Correct the object
|
|
||||||
else {
|
|
||||||
if ( ! object.name ) {
|
|
||||||
throw new Error( 'No name provided for option' );
|
|
||||||
}
|
|
||||||
else if ( ! object.type ) {
|
|
||||||
throw new Error( 'No type proveded for option' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach tester for value on booleans
|
|
||||||
// to avoid false targets
|
|
||||||
object.test = object.test || ( object.type == 'boolean' ? boolTest : null );
|
|
||||||
object.description = object.description || '';
|
|
||||||
object.type = self.isFunction( object.type ) ? object.type :
|
|
||||||
self.isString( object.type ) && rlistcsv.exec( object.type ) ? self.types[ 'listcsv-combo' ]( object.type ) :
|
|
||||||
self.isString( object.type ) && self.types[ object.type ] ? self.types[ object.type ] :
|
|
||||||
self.types.string;
|
|
||||||
|
|
||||||
// Apply to module
|
|
||||||
if ( mod ) {
|
|
||||||
if ( ! self.mods[ mod ] ) {
|
|
||||||
self.mods[ mod ] = { mod: mod, options: {}, short: {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach option to submodule
|
|
||||||
mod = self.mods[ mod ];
|
|
||||||
mod.options[ object.name ] = object;
|
|
||||||
|
|
||||||
// Attach shorthand
|
|
||||||
if ( object.short ) {
|
|
||||||
mod.short[ object.short ] = object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Apply to root options
|
|
||||||
else {
|
|
||||||
self.options[ object.name ] = object;
|
|
||||||
|
|
||||||
// Attach shorthand option
|
|
||||||
if ( object.short ) {
|
|
||||||
self.short[ object.short ] = object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Creating module
|
|
||||||
mod: function( object ) {
|
|
||||||
var mod;
|
|
||||||
|
|
||||||
// Allow multi mod setup
|
|
||||||
if ( self.isArray( object ) ) {
|
|
||||||
object.forEach(function( value ) {
|
|
||||||
self.mod( value );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Handle edge case
|
|
||||||
else if ( ! self.isObject( object ) ) {
|
|
||||||
throw new Error( 'No mod definition provided' );
|
|
||||||
}
|
|
||||||
// Force mod name
|
|
||||||
else if ( ! object.mod ) {
|
|
||||||
throw new Error( "Expecting 'mod' entry for module" );
|
|
||||||
}
|
|
||||||
// Create object if not already done so
|
|
||||||
else if ( ! self.mods[ object.mod ] ) {
|
|
||||||
self.mods[ object.mod ] = { mod: object.mod, options: {}, short: {} };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup
|
|
||||||
mod = self.mods[ object.mod ];
|
|
||||||
mod.description = object.description || mod.description;
|
|
||||||
|
|
||||||
// Attach each option
|
|
||||||
self.option( mod.mod, object.options );
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Cleans out current options
|
|
||||||
clear: function(){
|
|
||||||
var version = self.options.version;
|
|
||||||
|
|
||||||
// Clean out modes and reapply help option
|
|
||||||
self.short = {};
|
|
||||||
self.options = {};
|
|
||||||
self.mods = {};
|
|
||||||
self.option( helpOption );
|
|
||||||
|
|
||||||
// Re-apply version if set
|
|
||||||
if ( version ) {
|
|
||||||
self.option( version );
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Description setup
|
|
||||||
info: function( mod, description ) {
|
|
||||||
if ( description === undefined ) {
|
|
||||||
self.description = mod;
|
|
||||||
}
|
|
||||||
else if ( self.mods[ mod ] ) {
|
|
||||||
self.mods[ mod ] = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Prints out the help doc
|
|
||||||
help: function( mod ) {
|
|
||||||
var output = [], name, option;
|
|
||||||
|
|
||||||
// Printing out just a module's definitions
|
|
||||||
if ( mod && ( mod = self.mods[ mod ] ) ) {
|
|
||||||
output = [ '', mod.description, '' ];
|
|
||||||
|
|
||||||
for ( name in mod.options ) {
|
|
||||||
option = mod.options[ name ];
|
|
||||||
|
|
||||||
output.push( "\t--" +option.name + ( option.short ? ', -' + option.short : '' ) );
|
|
||||||
output.push( "\t\t" + option.description );
|
|
||||||
if ( option.example ) {
|
|
||||||
output.push( "\t\t" + option.example );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spacing
|
|
||||||
output.push( "" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Printing out just the root options
|
|
||||||
else {
|
|
||||||
output = [ '', self.description, '' ];
|
|
||||||
|
|
||||||
for ( name in self.options ) {
|
|
||||||
option = self.options[ name ];
|
|
||||||
|
|
||||||
output.push( "\t--" +option.name + ( option.short ? ', -' + option.short : '' ) );
|
|
||||||
output.push( "\t\t" + option.description );
|
|
||||||
if ( option.example ) {
|
|
||||||
output.push( "\t\t" + option.example );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spacing
|
|
||||||
output.push( "" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print out the output
|
|
||||||
console.log( output.join( "\n" ) + "\n\n" );
|
|
||||||
return self;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Runs the arguments parser
|
|
||||||
_run: function( argv ) {
|
|
||||||
var args = { targets: [], options: {} },
|
|
||||||
opts = self.options,
|
|
||||||
shortOpts = self.short,
|
|
||||||
skip = false;
|
|
||||||
|
|
||||||
// Allow for passing of arguments list
|
|
||||||
argv = self.isArray( argv ) ? argv : process.argv.slice( 2 );
|
|
||||||
|
|
||||||
// Switch to module's options when used
|
|
||||||
if ( argv.length && ristarget.exec( argv[ 0 ] ) && self.mods[ argv[ 0 ] ] ) {
|
|
||||||
args.mod = argv.shift();
|
|
||||||
opts = self.mods[ args.mod ].options;
|
|
||||||
shortOpts = self.mods[ args.mod ].short;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over arguments
|
|
||||||
argv.forEach(function( arg, i ) {
|
|
||||||
var peek = argv[ i + 1 ], option, index, value;
|
|
||||||
|
|
||||||
// Allow skipping of arguments
|
|
||||||
if ( skip ) {
|
|
||||||
return ( skip = false );
|
|
||||||
}
|
|
||||||
// Full option '--option'
|
|
||||||
else if ( rddash.exec( arg ) ) {
|
|
||||||
arg = arg.replace( rddash, '' );
|
|
||||||
|
|
||||||
// Default no value to true
|
|
||||||
if ( ( index = arg.indexOf( '=' ) ) !== -1 ) {
|
|
||||||
value = arg.substr( index + 1 );
|
|
||||||
arg = arg.substr( 0, index );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
value = 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Be strict, if option doesn't exist, throw and error
|
|
||||||
if ( ! ( option = opts[ arg ] ) ) {
|
|
||||||
throw "Option '--" + arg + "' not supported";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send through type converter
|
|
||||||
args.options[ arg ] = option.type( value, arg, args.options, args );
|
|
||||||
|
|
||||||
// Trigger onset callback when option is set
|
|
||||||
if ( self.isFunction( option.onset ) ) {
|
|
||||||
option.onset( args );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Shorthand option '-o'
|
|
||||||
else if ( rdash.exec( arg ) ) {
|
|
||||||
arg = arg.replace( rdash, '' );
|
|
||||||
|
|
||||||
if ( arg.length > 1 ) {
|
|
||||||
arg.split( '' ).forEach(function( character ) {
|
|
||||||
if ( ! ( option = shortOpts[ character ] ) ) {
|
|
||||||
throw "Option '-" + character + "' not supported";
|
|
||||||
}
|
|
||||||
|
|
||||||
args.options[ option.name ] = option.type( 'true', option.name, args.options, args );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Ensure that an option exists
|
|
||||||
if ( ! ( option = shortOpts[ arg ] ) ) {
|
|
||||||
throw "Option '-" + arg + "' not supported";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check next option for target association
|
|
||||||
if ( peek && option.test && option.test( peek, option.name, args.options, args ) ) {
|
|
||||||
value = peek;
|
|
||||||
skip = true;
|
|
||||||
}
|
|
||||||
else if ( peek && ! option.test && ristarget.exec( peek ) ) {
|
|
||||||
value = peek;
|
|
||||||
skip = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
value = 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert it
|
|
||||||
args.options[ option.name ] = option.type( value, option.name, args.options, args );
|
|
||||||
|
|
||||||
// Trigger onset callback when option is set
|
|
||||||
if ( self.isFunction( option.onset ) ) {
|
|
||||||
option.onset( args );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Targets
|
|
||||||
else {
|
|
||||||
args.targets.push( arg );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return args;
|
|
||||||
},
|
|
||||||
|
|
||||||
run: function( argv ) {
|
|
||||||
try {
|
|
||||||
return self._run( argv );
|
|
||||||
}
|
|
||||||
catch ( e ) {
|
|
||||||
if ( ! self.isString( e ) ) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log( "\n" + e + ". Trigger '" + self.name + " -h' for more details.\n\n" );
|
|
||||||
process.exit( 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Type tests
|
|
||||||
"Boolean Number String Function Array Date RegExp Object Error".split(' ').forEach(function( method ) {
|
|
||||||
if ( method == 'Array' ) {
|
|
||||||
return ( self.isArray = Array.isArray );
|
|
||||||
}
|
|
||||||
else if ( method == 'Error' ) {
|
|
||||||
self.isError = function( object ) {
|
|
||||||
return object && ( object instanceof Error );
|
|
||||||
};
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var match = '[object ' + method + ']';
|
|
||||||
self[ 'is' + method ] = function( object ) {
|
|
||||||
return object !== undefined && object !== null && toString.call( object ) == match;
|
|
||||||
};
|
|
||||||
});
|
|
55
node_modules/argv/package.json
generated
vendored
55
node_modules/argv/package.json
generated
vendored
@ -1,55 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"argv@0.0.2",
|
|
||||||
"E:\\python\\setup-php"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "argv@0.0.2",
|
|
||||||
"_id": "argv@0.0.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-7L0W+JSbFXGDcRsb2jNPN4QBhas=",
|
|
||||||
"_location": "/argv",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "argv@0.0.2",
|
|
||||||
"name": "argv",
|
|
||||||
"escapedName": "argv",
|
|
||||||
"rawSpec": "0.0.2",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "0.0.2"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/codecov"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/argv/-/argv-0.0.2.tgz",
|
|
||||||
"_spec": "0.0.2",
|
|
||||||
"_where": "E:\\python\\setup-php",
|
|
||||||
"author": {
|
|
||||||
"name": "Corey Hart",
|
|
||||||
"email": "corey@codenothing.com"
|
|
||||||
},
|
|
||||||
"dependencies": {},
|
|
||||||
"description": "CLI Argument Parser",
|
|
||||||
"devDependencies": {
|
|
||||||
"munit": "0.0.5",
|
|
||||||
"nlint": "0.0.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6.10"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"cli",
|
|
||||||
"argv",
|
|
||||||
"options"
|
|
||||||
],
|
|
||||||
"main": "./index.js",
|
|
||||||
"name": "argv",
|
|
||||||
"scripts": {
|
|
||||||
"test": "make test"
|
|
||||||
},
|
|
||||||
"url": "http://codenothing.github.com/argv/",
|
|
||||||
"version": "0.0.2"
|
|
||||||
}
|
|
168
node_modules/argv/test/test-core.js
generated
vendored
168
node_modules/argv/test/test-core.js
generated
vendored
@ -1,168 +0,0 @@
|
|||||||
munit( 'Root.Options', function( assert ) {
|
|
||||||
argv.clear().option([
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool',
|
|
||||||
short: 'b',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'path',
|
|
||||||
short: 'p',
|
|
||||||
type: 'path'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'int',
|
|
||||||
short: 'i',
|
|
||||||
type: 'int'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'float',
|
|
||||||
short: 'f',
|
|
||||||
type: 'float'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'csv',
|
|
||||||
short: 'c',
|
|
||||||
type: 'csv'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'list',
|
|
||||||
short: 'l',
|
|
||||||
type: 'list'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'listpath',
|
|
||||||
short: 't',
|
|
||||||
type: 'list,path'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'csvcombo',
|
|
||||||
type: 'csv,int'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool2',
|
|
||||||
short: 'x',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool3',
|
|
||||||
short: 'y',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool4',
|
|
||||||
short: 'z',
|
|
||||||
type: 'boolean'
|
|
||||||
}
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Tests
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'basic',
|
|
||||||
args: '-b false --path=/a/b/c -i 123.456 --float=123.456 -c a,b,c -l a -l b -l c',
|
|
||||||
options: {
|
|
||||||
bool: false,
|
|
||||||
path: '/a/b/c',
|
|
||||||
'int': 123,
|
|
||||||
'float': 123.456,
|
|
||||||
csv: [ 'a', 'b', 'c' ],
|
|
||||||
list: [ 'a', 'b', 'c' ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'path-relative',
|
|
||||||
args: '-p a/b/c',
|
|
||||||
options: {
|
|
||||||
path: process.cwd() + '/a/b/c'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'path-home',
|
|
||||||
args: '-p ~/a/b/c',
|
|
||||||
options: {
|
|
||||||
path: process.env.HOME + '/a/b/c'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'listpath',
|
|
||||||
args: '-t ~/a/b/c -t /a/b/c -t a/b/c',
|
|
||||||
options: {
|
|
||||||
listpath: [
|
|
||||||
process.env.HOME + '/a/b/c',
|
|
||||||
'/a/b/c',
|
|
||||||
process.cwd() + '/a/b/c'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'csvcombo',
|
|
||||||
args: '--csvcombo=123,456.99,0.00001',
|
|
||||||
options: {
|
|
||||||
csvcombo: [ 123, 456, 0 ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'targets',
|
|
||||||
args: 'targ1 -p /a/b/c targ2 targ3 --bool targ4',
|
|
||||||
targets: [ 'targ1', 'targ2', 'targ3', 'targ4' ],
|
|
||||||
options: {
|
|
||||||
path: '/a/b/c',
|
|
||||||
bool: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool-target-test',
|
|
||||||
args: 'targ1 -b targ2',
|
|
||||||
targets: [ 'targ1', 'targ2' ],
|
|
||||||
options: {
|
|
||||||
bool: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool-multi-option',
|
|
||||||
args: 'targ1 -bxy targ2 -z targ3',
|
|
||||||
targets: [ 'targ1', 'targ2', 'targ3' ],
|
|
||||||
options: {
|
|
||||||
bool: true,
|
|
||||||
bool2: true,
|
|
||||||
bool3: true,
|
|
||||||
bool4: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
].forEach(function( object ) {
|
|
||||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
|
||||||
|
|
||||||
// Option parsing
|
|
||||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
|
||||||
|
|
||||||
// Target comparison
|
|
||||||
if ( object.targets ) {
|
|
||||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
65
node_modules/argv/test/test-custom.js
generated
vendored
65
node_modules/argv/test/test-custom.js
generated
vendored
@ -1,65 +0,0 @@
|
|||||||
munit( 'Custom', function( assert ) {
|
|
||||||
// Add custom types
|
|
||||||
argv.type({
|
|
||||||
|
|
||||||
'special-int': function(){
|
|
||||||
return 777;
|
|
||||||
},
|
|
||||||
|
|
||||||
'special-float': function(){
|
|
||||||
return 777.777;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Setup options
|
|
||||||
argv.clear().option([
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'foo',
|
|
||||||
type: 'special-int'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bar',
|
|
||||||
type: 'special-float'
|
|
||||||
}
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Tests
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'types',
|
|
||||||
args: '--foo=123 --bar=456',
|
|
||||||
options: {
|
|
||||||
foo: 777,
|
|
||||||
bar: 777.777
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
].forEach(function( object ) {
|
|
||||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
|
||||||
|
|
||||||
// Option parsing
|
|
||||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
|
||||||
|
|
||||||
// Target comparison
|
|
||||||
if ( object.targets ) {
|
|
||||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Deletion checks
|
|
||||||
assert.ok( 'Int Exists', argv.types[ 'special-int' ] );
|
|
||||||
assert.ok( 'Float Exists', argv.types[ 'special-float' ] );
|
|
||||||
argv.type( 'special-int', null );
|
|
||||||
argv.type( 'special-float', null );
|
|
||||||
assert.ok( 'Delete Int', ! argv.types[ 'special-int' ] );
|
|
||||||
assert.ok( 'Delete Float', ! argv.types[ 'special-float' ] );
|
|
||||||
});
|
|
118
node_modules/argv/test/test-mods.js
generated
vendored
118
node_modules/argv/test/test-mods.js
generated
vendored
@ -1,118 +0,0 @@
|
|||||||
munit( 'Modules', function( assert ) {
|
|
||||||
argv.clear().option([
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool',
|
|
||||||
short: 'a',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool2',
|
|
||||||
short: 'b',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool3',
|
|
||||||
short: 'c',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'path',
|
|
||||||
short: 'p',
|
|
||||||
type: 'path'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
mod: 'mod',
|
|
||||||
options: [
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool',
|
|
||||||
short: 'a',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool2',
|
|
||||||
short: 'b',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'bool3',
|
|
||||||
short: 'c',
|
|
||||||
type: 'boolean'
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'path',
|
|
||||||
short: 'p',
|
|
||||||
type: 'path'
|
|
||||||
}
|
|
||||||
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
[
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'root',
|
|
||||||
args: 'targ1 -p /a/b/c targ2 -abc targ3',
|
|
||||||
targets: [ 'targ1', 'targ2', 'targ3' ],
|
|
||||||
options: {
|
|
||||||
path: '/a/b/c',
|
|
||||||
bool: true,
|
|
||||||
bool2: true,
|
|
||||||
bool3: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'mod',
|
|
||||||
args: 'mod targ1 -ab',
|
|
||||||
mod: 'mod',
|
|
||||||
targets: [ 'targ1' ],
|
|
||||||
options: {
|
|
||||||
bool: true,
|
|
||||||
bool2: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
name: 'mod-path',
|
|
||||||
args: 'mod targ1 -p /a/b/c',
|
|
||||||
mod: 'mod',
|
|
||||||
targets: [ 'targ1' ],
|
|
||||||
options: {
|
|
||||||
path: '/a/b/c'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
].forEach(function( object ) {
|
|
||||||
var args = argv.run( argv.isArray( object.args ) ? object.args : object.args.split( ' ' ) );
|
|
||||||
|
|
||||||
// Option parsing
|
|
||||||
assert.deepEqual( object.name + '::options', args.options, object.options );
|
|
||||||
|
|
||||||
// Mod comparison
|
|
||||||
if ( object.mod ) {
|
|
||||||
assert.equal( object.name + '::mod', args.mod, object.mod );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.ok( object.name + '::mod', ! args.mod );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target comparison
|
|
||||||
if ( object.targets ) {
|
|
||||||
assert.deepEqual( object.name + '::targets', args.targets, object.targets );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
assert.ok( object.name + '::targets', ! args.targets.length );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
12
node_modules/argv/test/test-version.js
generated
vendored
12
node_modules/argv/test/test-version.js
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
munit( 'Root.version', { priority: munit.PRIORITY_LOW }, function( assert ) {
|
|
||||||
argv.clear();
|
|
||||||
if ( argv.options.version ) {
|
|
||||||
delete argv.options.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.empty( 'Version Start', argv.options.version );
|
|
||||||
argv.version( "1.2.4" );
|
|
||||||
assert.exists( 'Version Option', argv.options.version );
|
|
||||||
argv.clear();
|
|
||||||
assert.exists( 'Version Option after Clear', argv.options.version );
|
|
||||||
});
|
|
5
node_modules/balanced-match/.npmignore
generated
vendored
5
node_modules/balanced-match/.npmignore
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
test
|
|
||||||
.gitignore
|
|
||||||
.travis.yml
|
|
||||||
Makefile
|
|
||||||
example.js
|
|
21
node_modules/balanced-match/LICENSE.md
generated
vendored
21
node_modules/balanced-match/LICENSE.md
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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.
|
|
91
node_modules/balanced-match/README.md
generated
vendored
91
node_modules/balanced-match/README.md
generated
vendored
@ -1,91 +0,0 @@
|
|||||||
# balanced-match
|
|
||||||
|
|
||||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
|
||||||
|
|
||||||
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
|
|
||||||
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
|
|
||||||
|
|
||||||
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Get the first matching pair of braces:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var balanced = require('balanced-match');
|
|
||||||
|
|
||||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
|
||||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
|
||||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
|
||||||
```
|
|
||||||
|
|
||||||
The matches are:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ node example.js
|
|
||||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
|
||||||
{ start: 3,
|
|
||||||
end: 9,
|
|
||||||
pre: 'pre',
|
|
||||||
body: 'first',
|
|
||||||
post: 'between{second}post' }
|
|
||||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### var m = balanced(a, b, str)
|
|
||||||
|
|
||||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
|
||||||
object with those keys:
|
|
||||||
|
|
||||||
* **start** the index of the first match of `a`
|
|
||||||
* **end** the index of the matching `b`
|
|
||||||
* **pre** the preamble, `a` and `b` not included
|
|
||||||
* **body** the match, `a` and `b` not included
|
|
||||||
* **post** the postscript, `a` and `b` not included
|
|
||||||
|
|
||||||
If there's no match, `undefined` will be returned.
|
|
||||||
|
|
||||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
|
||||||
|
|
||||||
### var r = balanced.range(a, b, str)
|
|
||||||
|
|
||||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
|
||||||
array with indexes: `[ <a index>, <b index> ]`.
|
|
||||||
|
|
||||||
If there's no match, `undefined` will be returned.
|
|
||||||
|
|
||||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install balanced-match
|
|
||||||
```
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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.
|
|
59
node_modules/balanced-match/index.js
generated
vendored
59
node_modules/balanced-match/index.js
generated
vendored
@ -1,59 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
module.exports = balanced;
|
|
||||||
function balanced(a, b, str) {
|
|
||||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
||||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
||||||
|
|
||||||
var r = range(a, b, str);
|
|
||||||
|
|
||||||
return r && {
|
|
||||||
start: r[0],
|
|
||||||
end: r[1],
|
|
||||||
pre: str.slice(0, r[0]),
|
|
||||||
body: str.slice(r[0] + a.length, r[1]),
|
|
||||||
post: str.slice(r[1] + b.length)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeMatch(reg, str) {
|
|
||||||
var m = str.match(reg);
|
|
||||||
return m ? m[0] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
balanced.range = range;
|
|
||||||
function range(a, b, str) {
|
|
||||||
var begs, beg, left, right, result;
|
|
||||||
var ai = str.indexOf(a);
|
|
||||||
var bi = str.indexOf(b, ai + 1);
|
|
||||||
var i = ai;
|
|
||||||
|
|
||||||
if (ai >= 0 && bi > 0) {
|
|
||||||
begs = [];
|
|
||||||
left = str.length;
|
|
||||||
|
|
||||||
while (i >= 0 && !result) {
|
|
||||||
if (i == ai) {
|
|
||||||
begs.push(i);
|
|
||||||
ai = str.indexOf(a, i + 1);
|
|
||||||
} else if (begs.length == 1) {
|
|
||||||
result = [ begs.pop(), bi ];
|
|
||||||
} else {
|
|
||||||
beg = begs.pop();
|
|
||||||
if (beg < left) {
|
|
||||||
left = beg;
|
|
||||||
right = bi;
|
|
||||||
}
|
|
||||||
|
|
||||||
bi = str.indexOf(b, i + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = ai < bi && ai >= 0 ? ai : bi;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (begs.length) {
|
|
||||||
result = [ left, right ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
80
node_modules/balanced-match/package.json
generated
vendored
80
node_modules/balanced-match/package.json
generated
vendored
@ -1,80 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"balanced-match@1.0.0",
|
|
||||||
"E:\\python\\setup-php"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "balanced-match@1.0.0",
|
|
||||||
"_id": "balanced-match@1.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
|
||||||
"_location": "/balanced-match",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "balanced-match@1.0.0",
|
|
||||||
"name": "balanced-match",
|
|
||||||
"escapedName": "balanced-match",
|
|
||||||
"rawSpec": "1.0.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/brace-expansion"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
|
||||||
"_spec": "1.0.0",
|
|
||||||
"_where": "E:\\python\\setup-php",
|
|
||||||
"author": {
|
|
||||||
"name": "Julian Gruber",
|
|
||||||
"email": "mail@juliangruber.com",
|
|
||||||
"url": "http://juliangruber.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/juliangruber/balanced-match/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {},
|
|
||||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
|
||||||
"devDependencies": {
|
|
||||||
"matcha": "^0.7.0",
|
|
||||||
"tape": "^4.6.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
|
||||||
"keywords": [
|
|
||||||
"match",
|
|
||||||
"regexp",
|
|
||||||
"test",
|
|
||||||
"balanced",
|
|
||||||
"parse"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "balanced-match",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"bench": "make bench",
|
|
||||||
"test": "make test"
|
|
||||||
},
|
|
||||||
"testling": {
|
|
||||||
"files": "test/*.js",
|
|
||||||
"browsers": [
|
|
||||||
"ie/8..latest",
|
|
||||||
"firefox/20..latest",
|
|
||||||
"firefox/nightly",
|
|
||||||
"chrome/25..latest",
|
|
||||||
"chrome/canary",
|
|
||||||
"opera/12..latest",
|
|
||||||
"opera/next",
|
|
||||||
"safari/5.1..latest",
|
|
||||||
"ipad/6.0..latest",
|
|
||||||
"iphone/6.0..latest",
|
|
||||||
"android-browser/4.2..latest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version": "1.0.0"
|
|
||||||
}
|
|
21
node_modules/brace-expansion/LICENSE
generated
vendored
21
node_modules/brace-expansion/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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.
|
|
129
node_modules/brace-expansion/README.md
generated
vendored
129
node_modules/brace-expansion/README.md
generated
vendored
@ -1,129 +0,0 @@
|
|||||||
# brace-expansion
|
|
||||||
|
|
||||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
|
||||||
as known from sh/bash, in JavaScript.
|
|
||||||
|
|
||||||
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
|
|
||||||
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
|
|
||||||
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
|
|
||||||
|
|
||||||
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
|
|
||||||
expand('file-{a,b,c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('-v{,,}')
|
|
||||||
// => ['-v', '-v', '-v']
|
|
||||||
|
|
||||||
expand('file{0..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..c}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
|
||||||
|
|
||||||
expand('file{2..0}.jpg')
|
|
||||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
|
||||||
|
|
||||||
expand('file{0..4..2}.jpg')
|
|
||||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
|
||||||
|
|
||||||
expand('file-{a..e..2}.jpg')
|
|
||||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
|
||||||
|
|
||||||
expand('file{00..10..5}.jpg')
|
|
||||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
|
||||||
|
|
||||||
expand('{{A..C},{a..c}}')
|
|
||||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
|
||||||
|
|
||||||
expand('ppp{,config,oe{,conf}}')
|
|
||||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
```js
|
|
||||||
var expand = require('brace-expansion');
|
|
||||||
```
|
|
||||||
|
|
||||||
### var expanded = expand(str)
|
|
||||||
|
|
||||||
Return an array of all possible and valid expansions of `str`. If none are
|
|
||||||
found, `[str]` is returned.
|
|
||||||
|
|
||||||
Valid expansions are:
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^(.*,)+(.+)?$/
|
|
||||||
// {a,b,...}
|
|
||||||
```
|
|
||||||
|
|
||||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
|
||||||
to have equal length. Negative numbers and backwards iteration work too.
|
|
||||||
|
|
||||||
```js
|
|
||||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
|
||||||
// {x..y[..incr]}
|
|
||||||
```
|
|
||||||
|
|
||||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
|
||||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
|
||||||
number.
|
|
||||||
|
|
||||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With [npm](https://npmjs.org) do:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install brace-expansion
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- [Julian Gruber](https://github.com/juliangruber)
|
|
||||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
|
||||||
|
|
||||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
(MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
|
||||||
|
|
||||||
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.
|
|
201
node_modules/brace-expansion/index.js
generated
vendored
201
node_modules/brace-expansion/index.js
generated
vendored
@ -1,201 +0,0 @@
|
|||||||
var concatMap = require('concat-map');
|
|
||||||
var balanced = require('balanced-match');
|
|
||||||
|
|
||||||
module.exports = expandTop;
|
|
||||||
|
|
||||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
||||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
||||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
||||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
||||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
||||||
|
|
||||||
function numeric(str) {
|
|
||||||
return parseInt(str, 10) == str
|
|
||||||
? parseInt(str, 10)
|
|
||||||
: str.charCodeAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeBraces(str) {
|
|
||||||
return str.split('\\\\').join(escSlash)
|
|
||||||
.split('\\{').join(escOpen)
|
|
||||||
.split('\\}').join(escClose)
|
|
||||||
.split('\\,').join(escComma)
|
|
||||||
.split('\\.').join(escPeriod);
|
|
||||||
}
|
|
||||||
|
|
||||||
function unescapeBraces(str) {
|
|
||||||
return str.split(escSlash).join('\\')
|
|
||||||
.split(escOpen).join('{')
|
|
||||||
.split(escClose).join('}')
|
|
||||||
.split(escComma).join(',')
|
|
||||||
.split(escPeriod).join('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Basically just str.split(","), but handling cases
|
|
||||||
// where we have nested braced sections, which should be
|
|
||||||
// treated as individual members, like {a,{b,c},d}
|
|
||||||
function parseCommaParts(str) {
|
|
||||||
if (!str)
|
|
||||||
return [''];
|
|
||||||
|
|
||||||
var parts = [];
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
|
|
||||||
if (!m)
|
|
||||||
return str.split(',');
|
|
||||||
|
|
||||||
var pre = m.pre;
|
|
||||||
var body = m.body;
|
|
||||||
var post = m.post;
|
|
||||||
var p = pre.split(',');
|
|
||||||
|
|
||||||
p[p.length-1] += '{' + body + '}';
|
|
||||||
var postParts = parseCommaParts(post);
|
|
||||||
if (post.length) {
|
|
||||||
p[p.length-1] += postParts.shift();
|
|
||||||
p.push.apply(p, postParts);
|
|
||||||
}
|
|
||||||
|
|
||||||
parts.push.apply(parts, p);
|
|
||||||
|
|
||||||
return parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expandTop(str) {
|
|
||||||
if (!str)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
||||||
// but a{},b}c will be expanded to [a}c,abc].
|
|
||||||
// One could argue that this is a bug in Bash, but since the goal of
|
|
||||||
// this module is to match Bash's rules, we escape a leading {}
|
|
||||||
if (str.substr(0, 2) === '{}') {
|
|
||||||
str = '\\{\\}' + str.substr(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
||||||
}
|
|
||||||
|
|
||||||
function identity(e) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
function embrace(str) {
|
|
||||||
return '{' + str + '}';
|
|
||||||
}
|
|
||||||
function isPadded(el) {
|
|
||||||
return /^-?0\d/.test(el);
|
|
||||||
}
|
|
||||||
|
|
||||||
function lte(i, y) {
|
|
||||||
return i <= y;
|
|
||||||
}
|
|
||||||
function gte(i, y) {
|
|
||||||
return i >= y;
|
|
||||||
}
|
|
||||||
|
|
||||||
function expand(str, isTop) {
|
|
||||||
var expansions = [];
|
|
||||||
|
|
||||||
var m = balanced('{', '}', str);
|
|
||||||
if (!m || /\$$/.test(m.pre)) return [str];
|
|
||||||
|
|
||||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
||||||
var isSequence = isNumericSequence || isAlphaSequence;
|
|
||||||
var isOptions = m.body.indexOf(',') >= 0;
|
|
||||||
if (!isSequence && !isOptions) {
|
|
||||||
// {a},b}
|
|
||||||
if (m.post.match(/,.*\}/)) {
|
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
|
||||||
return expand(str);
|
|
||||||
}
|
|
||||||
return [str];
|
|
||||||
}
|
|
||||||
|
|
||||||
var n;
|
|
||||||
if (isSequence) {
|
|
||||||
n = m.body.split(/\.\./);
|
|
||||||
} else {
|
|
||||||
n = parseCommaParts(m.body);
|
|
||||||
if (n.length === 1) {
|
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
|
||||||
n = expand(n[0], false).map(embrace);
|
|
||||||
if (n.length === 1) {
|
|
||||||
var post = m.post.length
|
|
||||||
? expand(m.post, false)
|
|
||||||
: [''];
|
|
||||||
return post.map(function(p) {
|
|
||||||
return m.pre + n[0] + p;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point, n is the parts, and we know it's not a comma set
|
|
||||||
// with a single entry.
|
|
||||||
|
|
||||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
||||||
var pre = m.pre;
|
|
||||||
var post = m.post.length
|
|
||||||
? expand(m.post, false)
|
|
||||||
: [''];
|
|
||||||
|
|
||||||
var N;
|
|
||||||
|
|
||||||
if (isSequence) {
|
|
||||||
var x = numeric(n[0]);
|
|
||||||
var y = numeric(n[1]);
|
|
||||||
var width = Math.max(n[0].length, n[1].length)
|
|
||||||
var incr = n.length == 3
|
|
||||||
? Math.abs(numeric(n[2]))
|
|
||||||
: 1;
|
|
||||||
var test = lte;
|
|
||||||
var reverse = y < x;
|
|
||||||
if (reverse) {
|
|
||||||
incr *= -1;
|
|
||||||
test = gte;
|
|
||||||
}
|
|
||||||
var pad = n.some(isPadded);
|
|
||||||
|
|
||||||
N = [];
|
|
||||||
|
|
||||||
for (var i = x; test(i, y); i += incr) {
|
|
||||||
var c;
|
|
||||||
if (isAlphaSequence) {
|
|
||||||
c = String.fromCharCode(i);
|
|
||||||
if (c === '\\')
|
|
||||||
c = '';
|
|
||||||
} else {
|
|
||||||
c = String(i);
|
|
||||||
if (pad) {
|
|
||||||
var need = width - c.length;
|
|
||||||
if (need > 0) {
|
|
||||||
var z = new Array(need + 1).join('0');
|
|
||||||
if (i < 0)
|
|
||||||
c = '-' + z + c.slice(1);
|
|
||||||
else
|
|
||||||
c = z + c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
N.push(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
N = concatMap(n, function(el) { return expand(el, false) });
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var j = 0; j < N.length; j++) {
|
|
||||||
for (var k = 0; k < post.length; k++) {
|
|
||||||
var expansion = pre + N[j] + post[k];
|
|
||||||
if (!isTop || isSequence || expansion)
|
|
||||||
expansions.push(expansion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return expansions;
|
|
||||||
}
|
|
||||||
|
|
78
node_modules/brace-expansion/package.json
generated
vendored
78
node_modules/brace-expansion/package.json
generated
vendored
@ -1,78 +0,0 @@
|
|||||||
{
|
|
||||||
"_args": [
|
|
||||||
[
|
|
||||||
"brace-expansion@1.1.11",
|
|
||||||
"E:\\python\\setup-php"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "brace-expansion@1.1.11",
|
|
||||||
"_id": "brace-expansion@1.1.11",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
|
||||||
"_location": "/brace-expansion",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "brace-expansion@1.1.11",
|
|
||||||
"name": "brace-expansion",
|
|
||||||
"escapedName": "brace-expansion",
|
|
||||||
"rawSpec": "1.1.11",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.1.11"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/minimatch"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
|
||||||
"_spec": "1.1.11",
|
|
||||||
"_where": "E:\\python\\setup-php",
|
|
||||||
"author": {
|
|
||||||
"name": "Julian Gruber",
|
|
||||||
"email": "mail@juliangruber.com",
|
|
||||||
"url": "http://juliangruber.com"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/juliangruber/brace-expansion/issues"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"balanced-match": "^1.0.0",
|
|
||||||
"concat-map": "0.0.1"
|
|
||||||
},
|
|
||||||
"description": "Brace expansion as known from sh/bash",
|
|
||||||
"devDependencies": {
|
|
||||||
"matcha": "^0.7.0",
|
|
||||||
"tape": "^4.6.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
|
||||||
"keywords": [],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"name": "brace-expansion",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"bench": "matcha test/perf/bench.js",
|
|
||||||
"gentest": "bash test/generate.sh",
|
|
||||||
"test": "tape test/*.js"
|
|
||||||
},
|
|
||||||
"testling": {
|
|
||||||
"files": "test/*.js",
|
|
||||||
"browsers": [
|
|
||||||
"ie/8..latest",
|
|
||||||
"firefox/20..latest",
|
|
||||||
"firefox/nightly",
|
|
||||||
"chrome/25..latest",
|
|
||||||
"chrome/canary",
|
|
||||||
"opera/12..latest",
|
|
||||||
"opera/next",
|
|
||||||
"safari/5.1..latest",
|
|
||||||
"ipad/6.0..latest",
|
|
||||||
"iphone/6.0..latest",
|
|
||||||
"android-browser/4.2..latest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"version": "1.1.11"
|
|
||||||
}
|
|
14
node_modules/codecov/.eslintrc.json
generated
vendored
14
node_modules/codecov/.eslintrc.json
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["eslint:recommended", "prettier"],
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"jest": true
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"expect": true
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"no-console": "off",
|
|
||||||
"no-empty": ["error", { "allowEmptyCatch": true }]
|
|
||||||
}
|
|
||||||
}
|
|
3
node_modules/codecov/.prettierignore
generated
vendored
3
node_modules/codecov/.prettierignore
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
.git/
|
|
||||||
coverage/
|
|
6
node_modules/codecov/.prettierrc
generated
vendored
6
node_modules/codecov/.prettierrc
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"semi": false,
|
|
||||||
"trailingComma": "es5",
|
|
||||||
"singleQuote": true,
|
|
||||||
"useTabs": false
|
|
||||||
}
|
|
14
node_modules/codecov/.travis.yml
generated
vendored
14
node_modules/codecov/.travis.yml
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
node_js:
|
|
||||||
- '11'
|
|
||||||
- '10'
|
|
||||||
- '9'
|
|
||||||
- '8'
|
|
||||||
- '7'
|
|
||||||
- '6'
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- ./bin/codecov -e TRAVIS_NODE_VERSION -f coverage/*.json
|
|
76
node_modules/codecov/CODE_OF_CONDUCT.md
generated
vendored
76
node_modules/codecov/CODE_OF_CONDUCT.md
generated
vendored
@ -1,76 +0,0 @@
|
|||||||
# Contributor Covenant Code of Conduct
|
|
||||||
|
|
||||||
## Our Pledge
|
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
|
||||||
contributors and maintainers pledge to making participation in our project and
|
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
|
||||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
||||||
level of experience, education, socio-economic status, nationality, personal
|
|
||||||
appearance, race, religion, or sexual identity and orientation.
|
|
||||||
|
|
||||||
## Our Standards
|
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
|
||||||
include:
|
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
|
||||||
* Being respectful of differing viewpoints and experiences
|
|
||||||
* Gracefully accepting constructive criticism
|
|
||||||
* Focusing on what is best for the community
|
|
||||||
* Showing empathy towards other community members
|
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
||||||
advances
|
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
||||||
* Public or private harassment
|
|
||||||
* Publishing others' private information, such as a physical or electronic
|
|
||||||
address, without explicit permission
|
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
|
||||||
professional setting
|
|
||||||
|
|
||||||
## Our Responsibilities
|
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
|
||||||
response to any instances of unacceptable behavior.
|
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
|
||||||
when an individual is representing the project or its community. Examples of
|
|
||||||
representing a project or community include using an official project e-mail
|
|
||||||
address, posting via an official social media account, or acting as an appointed
|
|
||||||
representative at an online or offline event. Representation of a project may be
|
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
||||||
reported by contacting the project team at hello@codecov.io. All
|
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
|
||||||
members of the project's leadership.
|
|
||||||
|
|
||||||
## Attribution
|
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
||||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
|
||||||
|
|
||||||
For answers to common questions about this code of conduct, see
|
|
||||||
https://www.contributor-covenant.org/faq
|
|
21
node_modules/codecov/LICENSE
generated
vendored
21
node_modules/codecov/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2014 Gregg Caines
|
|
||||||
|
|
||||||
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.
|
|
108
node_modules/codecov/README.md
generated
vendored
108
node_modules/codecov/README.md
generated
vendored
@ -1,108 +0,0 @@
|
|||||||
# Codecov NodeJS Uploader
|
|
||||||
|
|
||||||
[![NPM version][npm-image]][npm-url]
|
|
||||||
[![Build Status][travis-image]][travis-url]
|
|
||||||
[![Build Status][appveyor-image]][appveyor-url]
|
|
||||||
[![codecov.io](https://codecov.io/github/codecov/codecov-node/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-node?branch=master)
|
|
||||||
[![Dependency Status][depstat-image]][depstat-url]
|
|
||||||
[![Dev Dependency Status][devdepstat-image]][devdepstat-url]
|
|
||||||
|
|
||||||
[Codecov.io](https://codecov.io/) support for node.js.
|
|
||||||
|
|
||||||
## Installation:
|
|
||||||
|
|
||||||
Add the latest version of `codecov` to your package.json:
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install codecov --save-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
```
|
|
||||||
yarn add codecov --dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage:
|
|
||||||
|
|
||||||
This script ( `bin/codecov` ) detect your CI provider and all coverage reports and uploads them to Codecov.
|
|
||||||
|
|
||||||
Once your app is instrumented for coverage, and building, simply call `./node_modules/.bin/codecov`.
|
|
||||||
|
|
||||||
This library currently supports the following CI companies: [Travis CI](https://travis-ci.org/), [Travis](https://travis-ci.com/), [Appveyor](https://appveyor.com/), [CircleCI](https://circleci.com/), [Cirrus CI](https://cirrus-ci.org/), [Codeship](https://codeship.io/), [Drone](https://drone.io/), [Jenkins](http://jenkins-ci.org/), [Shippable](https://shippable.com/), [Semaphore](https://semaphoreapp.com/), [Wercker](https://wercker.com/), [Snap CI](https://snap-ci.com/), [Buildkite](https://buildkite.com/).
|
|
||||||
|
|
||||||
#### Upload repo tokens
|
|
||||||
|
|
||||||
> Repo tokens are **not** required for public repos tested on Travis-Org, CircleCI or AppVeyor.
|
|
||||||
|
|
||||||
Repo tokens are necessary to distinguish your repository from others. You can find your repo token on your repository page at Codecov. Set this unique uuid to `CODECOV_TOKEN` in your environment variables.
|
|
||||||
|
|
||||||
```
|
|
||||||
export CODECOV_TOKEN=":uuid-repo-token"
|
|
||||||
# or
|
|
||||||
./node_modules/.bin/codecov --token=:token
|
|
||||||
# or
|
|
||||||
./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/codecov --pipe
|
|
||||||
```
|
|
||||||
|
|
||||||
#### [Istanbul](https://github.com/gotwarlost/istanbul)
|
|
||||||
|
|
||||||
**With Mocha:**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec
|
|
||||||
./node_modules/.bin/codecov
|
|
||||||
```
|
|
||||||
|
|
||||||
**With Jasmine:**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
istanbul cover jasmine-node --captureExceptions spec/
|
|
||||||
./node_modules/.bin/codecov
|
|
||||||
```
|
|
||||||
|
|
||||||
**With Tape:**
|
|
||||||
|
|
||||||
```sh
|
|
||||||
istanbul cover test.js
|
|
||||||
./node_modules/.bin/codecov
|
|
||||||
```
|
|
||||||
|
|
||||||
[travis-image]: https://travis-ci.org/codecov/codecov-node.svg?branch=master
|
|
||||||
[travis-url]: https://travis-ci.org/codecov/codecov-node
|
|
||||||
[appveyor-image]: https://ci.appveyor.com/api/projects/status/ea1suiv0tprnq61l?svg=true
|
|
||||||
[appveyor-url]: https://ci.appveyor.com/project/eddiemoore/codecov-node/branch/master
|
|
||||||
[npm-url]: https://npmjs.org/package/codecov
|
|
||||||
[npm-image]: https://img.shields.io/npm/v/codecov.svg
|
|
||||||
[depstat-url]: https://david-dm.org/codecov/codecov-node
|
|
||||||
[depstat-image]: https://img.shields.io/david/codecov/codecov-node/master.svg
|
|
||||||
[devdepstat-url]: https://david-dm.org/codecov/codecov-node#info=devDependencies
|
|
||||||
[devdepstat-image]: https://img.shields.io/david/dev/codecov/codecov-node/master.svg
|
|
||||||
|
|
||||||
**With NYC**
|
|
||||||
|
|
||||||
```
|
|
||||||
nyc npm test
|
|
||||||
nyc report --reporter=text-lcov > coverage.lcov
|
|
||||||
./node_modules/.bin/codecov
|
|
||||||
```
|
|
||||||
|
|
||||||
## Change Log
|
|
||||||
|
|
||||||
- v2.0.0 No longer supports node v0.10 because of the execSync.
|
|
||||||
- v2.0.1 Publish as latest instead of next.
|
|
||||||
- v2.0.2 Display correct version number in console.
|
|
||||||
- v2.1.0 Flags supported http://docs.codecov.io/docs/flags
|
|
||||||
- v2.2.0 Support for Jenkins Blue Ocean. Clean reports after upload. Fix for Gitlab.
|
|
||||||
- v2.3.0 Added support for Windows. Updated dependencies.
|
|
||||||
- v3.0.0 No longer supports node v0.12 because of new version of request
|
|
||||||
- v3.0.1 Security fixes
|
|
||||||
- v3.0.2 Security fixes
|
|
||||||
- v3.0.3 Support non-git/hg root dirs
|
|
||||||
- v3.0.4 Security fixes
|
|
||||||
- v3.1.0 Custom yaml file. Allow codecov token from yml file.
|
|
||||||
- v3.2.0 Added azure pipelines
|
|
||||||
- v3.3.0 Added pipe with `--pipe`, `-l`
|
|
||||||
- v3.4.0 Added Heroku CI support
|
|
||||||
- v3.5.0 Added TeamCity support
|
|
||||||
- v3.6.0 Added AWS CodeBuild and Semaphore2
|
|
30
node_modules/codecov/appveyor.yml
generated
vendored
30
node_modules/codecov/appveyor.yml
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
environment:
|
|
||||||
matrix:
|
|
||||||
- nodejs_version: '11'
|
|
||||||
- nodejs_version: '10'
|
|
||||||
- nodejs_version: '9'
|
|
||||||
- nodejs_version: '8'
|
|
||||||
- nodejs_version: '7'
|
|
||||||
- nodejs_version: '6'
|
|
||||||
|
|
||||||
max_jobs: 4
|
|
||||||
|
|
||||||
clone_depth: 50
|
|
||||||
|
|
||||||
init:
|
|
||||||
- git config --global core.autocrlf true
|
|
||||||
|
|
||||||
install:
|
|
||||||
- ps: Install-Product node $env:nodejs_version
|
|
||||||
- npm install
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- cmd: SET PATH=C:\MinGW\bin;%PATH%
|
|
||||||
- npm run test
|
|
||||||
|
|
||||||
after_test:
|
|
||||||
- node .\bin\codecov -f coverage\*.json
|
|
||||||
|
|
||||||
build: off
|
|
||||||
|
|
||||||
deploy: off
|
|
41
node_modules/codecov/bin/codecov
generated
vendored
41
node_modules/codecov/bin/codecov
generated
vendored
@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
var argv = require('argv');
|
|
||||||
var codecov = require('../lib/codecov');
|
|
||||||
|
|
||||||
|
|
||||||
var args = argv.option([
|
|
||||||
{name: 'token', short: 't', type: 'string', description: "Private repository token. Not required for public repos on Travis, CircleCI and AppVeyor"},
|
|
||||||
{name: 'file', short: 'f', type: 'path', description: "Target a specific file for uploading and disabling automatic detection of coverage files."},
|
|
||||||
{name: 'env', short: 'e', type: 'string', description: "Store environment variables to help distinguish CI builds. Example: http://bit.ly/1ElohCu", example: "--env=VAR1,VAR2,VAR3"},
|
|
||||||
{name: 'root', short: 'p', type: 'path', description: "Project root, if not current directory"},
|
|
||||||
{name: 'gcov-root', type: 'path', description: "Project root directory when preparing gcov"},
|
|
||||||
{name: 'gcov-glob', type: 'string', description: "Paths to ignore during gcov gathering"},
|
|
||||||
{name: 'gcov-exec', type: 'string', description: "gcov executable to run. Defaults to 'gcov'"},
|
|
||||||
{name: 'gcov-args', type: 'string', description: "extra arguments to pass to gcov"},
|
|
||||||
{name: 'disable', short: 'X', type: 'string', description: "Disable features. Accepting `search` to disable crawling through directories, `detect` to disable detecting CI provider, `gcov` disable gcov commands"},
|
|
||||||
{name: 'commit', short: 'c', type: 'string', description: "Commit sha, set automatically"},
|
|
||||||
{name: 'clear', short: 'C', type: 'boolean', description: "Remove all discovered reports after uploading"},
|
|
||||||
{name: 'branch', short: 'b', type: 'string', description: "Branch name"},
|
|
||||||
{name: 'build', short: 'B', type: 'string', description: "Specify a custom build number to distinguish ci jobs, provided automatically for supported ci companies"},
|
|
||||||
{name: 'slug', short: 'r', type: 'string', description: "Specify repository slug for Enterprise ex. owner/repo"},
|
|
||||||
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
|
|
||||||
{name: 'flags', short: 'F', type: 'string', description: "Codecov Flags"},
|
|
||||||
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"},
|
|
||||||
{name: 'pipe', short: 'l', type: 'boolean', description: "Listen to stdin for coverage data"},
|
|
||||||
{name: 'yml', short: 'y', type: 'string', description: "Configuration file Used to specify the location of the .codecov.yml config file. Defaults to codecov.yml and .codecov.yml"},
|
|
||||||
]).run();
|
|
||||||
|
|
||||||
if (args.options.pipe) {
|
|
||||||
process.stdin.setEncoding('utf8');
|
|
||||||
args.options.pipe = [];
|
|
||||||
|
|
||||||
process.stdin.on('data', function(report) {
|
|
||||||
args.options.pipe.push(report);
|
|
||||||
});
|
|
||||||
|
|
||||||
process.stdin.on('end', function() {
|
|
||||||
codecov.upload(args);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
codecov.upload(args);
|
|
||||||
}
|
|
7
node_modules/codecov/circle.yml
generated
vendored
7
node_modules/codecov/circle.yml
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
machine:
|
|
||||||
node:
|
|
||||||
version: 4
|
|
||||||
|
|
||||||
test:
|
|
||||||
post:
|
|
||||||
- ./bin/codecov -f coverage/*.json
|
|
4
node_modules/codecov/codecov.yml
generated
vendored
4
node_modules/codecov/codecov.yml
generated
vendored
@ -1,4 +0,0 @@
|
|||||||
coverage:
|
|
||||||
parsers:
|
|
||||||
javascript:
|
|
||||||
enable_partials: no
|
|
3
node_modules/codecov/index.js
generated
vendored
3
node_modules/codecov/index.js
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
var handleInput = require('./lib/codecov')
|
|
||||||
|
|
||||||
exports.handleInput = handleInput
|
|
563
node_modules/codecov/lib/codecov.js
generated
vendored
563
node_modules/codecov/lib/codecov.js
generated
vendored
@ -1,563 +0,0 @@
|
|||||||
var fs = require('fs')
|
|
||||||
var path = require('path')
|
|
||||||
var request = require('teeny-request').teenyRequest
|
|
||||||
var urlgrey = require('urlgrey')
|
|
||||||
var jsYaml = require('js-yaml')
|
|
||||||
var walk = require('ignore-walk')
|
|
||||||
var execSync = require('child_process').execSync
|
|
||||||
|
|
||||||
var detectProvider = require('./detect')
|
|
||||||
|
|
||||||
var version = 'v' + require('../package.json').version
|
|
||||||
|
|
||||||
var patterns,
|
|
||||||
more_patterns = ''
|
|
||||||
|
|
||||||
var isWindows =
|
|
||||||
process.platform.match(/win32/) || process.platform.match(/win64/)
|
|
||||||
|
|
||||||
if (!isWindows) {
|
|
||||||
patterns =
|
|
||||||
"-type f \\( -name '*coverage.*' " +
|
|
||||||
"-or -name 'nosetests.xml' " +
|
|
||||||
"-or -name 'jacoco*.xml' " +
|
|
||||||
"-or -name 'clover.xml' " +
|
|
||||||
"-or -name 'report.xml' " +
|
|
||||||
"-or -name 'cobertura.xml' " +
|
|
||||||
"-or -name 'luacov.report.out' " +
|
|
||||||
"-or -name 'lcov.info' " +
|
|
||||||
"-or -name '*.lcov' " +
|
|
||||||
"-or -name 'gcov.info' " +
|
|
||||||
"-or -name '*.gcov' " +
|
|
||||||
"-or -name '*.lst' \\) " +
|
|
||||||
"-not -name '*.sh' " +
|
|
||||||
"-not -name '*.data' " +
|
|
||||||
"-not -name '*.py' " +
|
|
||||||
"-not -name '*.class' " +
|
|
||||||
"-not -name '*.xcconfig' " +
|
|
||||||
"-not -name 'Coverage.profdata' " +
|
|
||||||
"-not -name 'phpunit-code-coverage.xml' " +
|
|
||||||
"-not -name 'coverage.serialized' " +
|
|
||||||
"-not -name '*.pyc' " +
|
|
||||||
"-not -name '*.cfg' " +
|
|
||||||
"-not -name '*.egg' " +
|
|
||||||
"-not -name '*.whl' " +
|
|
||||||
"-not -name '*.html' " +
|
|
||||||
"-not -name '*.js' " +
|
|
||||||
"-not -name '*.cpp' " +
|
|
||||||
"-not -name 'coverage.jade' " +
|
|
||||||
"-not -name 'include.lst' " +
|
|
||||||
"-not -name 'inputFiles.lst' " +
|
|
||||||
"-not -name 'createdFiles.lst' " +
|
|
||||||
"-not -name 'coverage.html' " +
|
|
||||||
"-not -name 'scoverage.measurements.*' " +
|
|
||||||
"-not -name 'test_*_coverage.txt' " +
|
|
||||||
"-not -path '*/vendor/*' " +
|
|
||||||
"-not -path '*/htmlcov/*' " +
|
|
||||||
"-not -path '*/home/cainus/*' " +
|
|
||||||
"-not -path '*/virtualenv/*' " +
|
|
||||||
"-not -path '*/js/generated/coverage/*' " +
|
|
||||||
"-not -path '*/.virtualenv/*' " +
|
|
||||||
"-not -path '*/virtualenvs/*' " +
|
|
||||||
"-not -path '*/.virtualenvs/*' " +
|
|
||||||
"-not -path '*/.env/*' " +
|
|
||||||
"-not -path '*/.envs/*' " +
|
|
||||||
"-not -path '*/env/*' " +
|
|
||||||
"-not -path '*/envs/*' " +
|
|
||||||
"-not -path '*/.venv/*' " +
|
|
||||||
"-not -path '*/.venvs/*' " +
|
|
||||||
"-not -path '*/venv/*' " +
|
|
||||||
"-not -path '*/venvs/*' " +
|
|
||||||
"-not -path '*/.git/*' " +
|
|
||||||
"-not -path '*/.hg/*' " +
|
|
||||||
"-not -path '*/.tox/*' " +
|
|
||||||
"-not -path '*/__pycache__/*' " +
|
|
||||||
"-not -path '*/.egg-info*' " +
|
|
||||||
"-not -path '*/$bower_components/*' " +
|
|
||||||
"-not -path '*/node_modules/*' " +
|
|
||||||
"-not -path '*/conftest_*.c.gcov'"
|
|
||||||
} else {
|
|
||||||
patterns =
|
|
||||||
'/a-d /b /s *coverage.* ' +
|
|
||||||
'/s nosetests.xml ' +
|
|
||||||
'/s jacoco*.xml ' +
|
|
||||||
'/s clover.xml ' +
|
|
||||||
'/s report.xml ' +
|
|
||||||
'/s cobertura.xml ' +
|
|
||||||
'/s luacov.report.out ' +
|
|
||||||
'/s lcov.info ' +
|
|
||||||
'/s *.lcov ' +
|
|
||||||
'/s gcov.info ' +
|
|
||||||
'/s *.gcov ' +
|
|
||||||
'/s *.lst' +
|
|
||||||
'| findstr /i /v \\.sh$ ' +
|
|
||||||
'| findstr /i /v \\.data$ ' +
|
|
||||||
'| findstr /i /v \\.py$ ' +
|
|
||||||
'| findstr /i /v \\.class$ ' +
|
|
||||||
'| findstr /i /v \\.xcconfig$ ' +
|
|
||||||
'| findstr /i /v Coverage\\.profdata$ ' +
|
|
||||||
'| findstr /i /v phpunit-code-coverage\\.xml$ ' +
|
|
||||||
'| findstr /i /v coverage\\.serialized$ ' +
|
|
||||||
'| findstr /i /v \\.pyc$ ' +
|
|
||||||
'| findstr /i /v \\.cfg$ ' +
|
|
||||||
'| findstr /i /v \\.egg$ ' +
|
|
||||||
'| findstr /i /v \\.whl$ ' +
|
|
||||||
'| findstr /i /v \\.html$ ' +
|
|
||||||
'| findstr /i /v \\.js$ ' +
|
|
||||||
'| findstr /i /v \\.cpp$ ' +
|
|
||||||
'| findstr /i /v coverage\\.jade$ ' +
|
|
||||||
'| findstr /i /v include\\.lst$ ' +
|
|
||||||
'| findstr /i /v inputFiles\\.lst$ ' +
|
|
||||||
'| findstr /i /v createdFiles\\.lst$ ' +
|
|
||||||
'| findstr /i /v coverage\\.html$ ' +
|
|
||||||
'| findstr /i /v scoverage\\.measurements\\..* ' +
|
|
||||||
'| findstr /i /v test_.*_coverage\\.txt ' +
|
|
||||||
'| findstr /i /v \\vendor\\ ' +
|
|
||||||
'| findstr /i /v \\htmlcov\\ ' +
|
|
||||||
'| findstr /i /v \\home\\cainus\\ ' +
|
|
||||||
'| findstr /i /v \\js\\generated\\coverage\\ ' +
|
|
||||||
'| findstr /i /v \\virtualenv\\ ' +
|
|
||||||
'| findstr /i /v \\virtualenvs\\ ' +
|
|
||||||
'| findstr /i /v \\\\.virtualenv\\ ' +
|
|
||||||
'| findstr /i /v \\\\.virtualenvs\\ ' +
|
|
||||||
'| findstr /i /v \\\\.env\\ ' +
|
|
||||||
'| findstr /i /v \\\\.envs\\ ' +
|
|
||||||
'| findstr /i /v \\env\\ ' +
|
|
||||||
'| findstr /i /v \\envs\\ ' +
|
|
||||||
'| findstr /i /v \\\\.venv\\ ' +
|
|
||||||
'| findstr /i /v \\\\.venvs\\ ' +
|
|
||||||
'| findstr /i /v \\venv\\ ' +
|
|
||||||
'| findstr /i /v \\venvs\\ ' +
|
|
||||||
'| findstr /i /v \\\\.git\\ ' +
|
|
||||||
'| findstr /i /v \\\\.hg\\ ' +
|
|
||||||
'| findstr /i /v \\\\.tox\\ ' +
|
|
||||||
'| findstr /i /v \\__pycache__\\ ' +
|
|
||||||
'| findstr /i /v \\\\.egg-info* ' +
|
|
||||||
'| findstr /i /v \\\\$bower_components\\ ' +
|
|
||||||
'| findstr /i /v \\node_modules\\ ' +
|
|
||||||
'| findstr /i /v \\conftest_.*\\.c\\.gcov '
|
|
||||||
}
|
|
||||||
|
|
||||||
var sendToCodecovV2 = function(
|
|
||||||
codecov_endpoint,
|
|
||||||
query,
|
|
||||||
upload_body,
|
|
||||||
on_success,
|
|
||||||
on_failure
|
|
||||||
) {
|
|
||||||
// Direct to Codecov
|
|
||||||
request(
|
|
||||||
{
|
|
||||||
uri: urlgrey(codecov_endpoint + '/upload/v2')
|
|
||||||
.query(query)
|
|
||||||
.toString(),
|
|
||||||
method: 'POST',
|
|
||||||
body: upload_body,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'text/plain',
|
|
||||||
Accept: 'text/plain',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
function(err, response) {
|
|
||||||
if (err || response.statusCode !== 200) {
|
|
||||||
console.log(' ' + (err || response.body))
|
|
||||||
return response
|
|
||||||
? on_failure(response.statusCode, response.body)
|
|
||||||
: on_failure(err.code, err.message)
|
|
||||||
} else {
|
|
||||||
console.log(' Success!')
|
|
||||||
console.log(' View report at: ' + response.body)
|
|
||||||
return on_success(response.body)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
var sendToCodecovV3 = function(
|
|
||||||
codecov_endpoint,
|
|
||||||
query,
|
|
||||||
upload_body,
|
|
||||||
on_success,
|
|
||||||
on_failure
|
|
||||||
) {
|
|
||||||
// Direct to S3
|
|
||||||
request(
|
|
||||||
{
|
|
||||||
uri: urlgrey(codecov_endpoint + '/upload/v4')
|
|
||||||
.query(query)
|
|
||||||
.toString(),
|
|
||||||
method: 'POST',
|
|
||||||
body: '',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'text/plain',
|
|
||||||
Accept: 'text/plain',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
function(err, response, result) {
|
|
||||||
if (err) {
|
|
||||||
sendToCodecovV2(
|
|
||||||
codecov_endpoint,
|
|
||||||
query,
|
|
||||||
upload_body,
|
|
||||||
on_success,
|
|
||||||
on_failure
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
var codecov_report_url = result.split('\n')[0]
|
|
||||||
request(
|
|
||||||
{
|
|
||||||
uri: result.split('\n')[1],
|
|
||||||
method: 'PUT',
|
|
||||||
body: upload_body,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'text/plain',
|
|
||||||
'x-amz-acl': 'public-read',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
function(err) {
|
|
||||||
if (err) {
|
|
||||||
sendToCodecovV2(
|
|
||||||
codecov_endpoint,
|
|
||||||
query,
|
|
||||||
upload_body,
|
|
||||||
on_success,
|
|
||||||
on_failure
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
console.log(' Success!')
|
|
||||||
console.log(' View report at: ' + codecov_report_url)
|
|
||||||
on_success(codecov_report_url)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
var upload = function(args, on_success, on_failure) {
|
|
||||||
// Build query
|
|
||||||
var codecov_endpoint =
|
|
||||||
args.options.url ||
|
|
||||||
process.env.codecov_url ||
|
|
||||||
process.env.CODECOV_URL ||
|
|
||||||
'https://codecov.io'
|
|
||||||
var query = {}
|
|
||||||
var debug = []
|
|
||||||
var yamlFile =
|
|
||||||
args.options.yml ||
|
|
||||||
process.env.codecov_yml ||
|
|
||||||
process.env.CODECOV_YML ||
|
|
||||||
'codecov.yml'
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
'' +
|
|
||||||
' _____ _ \n' +
|
|
||||||
' / ____| | | \n' +
|
|
||||||
'| | ___ __| | ___ ___ _____ __ \n' +
|
|
||||||
'| | / _ \\ / _` |/ _ \\/ __/ _ \\ \\ / / \n' +
|
|
||||||
'| |___| (_) | (_| | __/ (_| (_) \\ V / \n' +
|
|
||||||
' \\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/ \n' +
|
|
||||||
' ' +
|
|
||||||
version
|
|
||||||
)
|
|
||||||
|
|
||||||
if ((args.options.disable || '').split(',').indexOf('detect') === -1) {
|
|
||||||
console.log('==> Detecting CI Provider')
|
|
||||||
query = detectProvider()
|
|
||||||
} else {
|
|
||||||
debug.push('disabled detect')
|
|
||||||
}
|
|
||||||
|
|
||||||
query.yaml = [yamlFile, '.codecov.yml'].reduce(function(result, file) {
|
|
||||||
return (
|
|
||||||
result ||
|
|
||||||
(fs.existsSync(path.resolve(process.cwd(), file))
|
|
||||||
? path.resolve(process.cwd(), file)
|
|
||||||
: undefined)
|
|
||||||
)
|
|
||||||
}, undefined)
|
|
||||||
|
|
||||||
if (args.options.build) {
|
|
||||||
query.build = args.options.build
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.options.commit) {
|
|
||||||
query.commit = args.options.commit
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.options.branch) {
|
|
||||||
query.branch = args.options.branch
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.options.slug) {
|
|
||||||
query.slug = args.options.slug
|
|
||||||
}
|
|
||||||
|
|
||||||
var flags =
|
|
||||||
args.options.flags || process.env.codecov_flags || process.env.CODECOV_FLAGS
|
|
||||||
if (flags) {
|
|
||||||
query.flags = flags
|
|
||||||
}
|
|
||||||
|
|
||||||
var yamlToken
|
|
||||||
try {
|
|
||||||
var loadedYamlFile = jsYaml.safeLoad(fs.readFileSync(query.yaml, 'utf8'))
|
|
||||||
yamlToken =
|
|
||||||
loadedYamlFile && loadedYamlFile.codecov && loadedYamlFile.codecov.token
|
|
||||||
} catch (e) {
|
|
||||||
// silently fail
|
|
||||||
}
|
|
||||||
var token =
|
|
||||||
args.options.token ||
|
|
||||||
yamlToken ||
|
|
||||||
process.env.codecov_token ||
|
|
||||||
process.env.CODECOV_TOKEN
|
|
||||||
if (token) {
|
|
||||||
query.token = token
|
|
||||||
}
|
|
||||||
|
|
||||||
query.package = 'node-' + version
|
|
||||||
|
|
||||||
console.log('==> Configuration: ')
|
|
||||||
console.log(' Endpoint: ' + codecov_endpoint)
|
|
||||||
// Don't output `query` directly as it contains the upload token
|
|
||||||
console.log({
|
|
||||||
commit: query.commit,
|
|
||||||
branch: query.branch,
|
|
||||||
package: query.package,
|
|
||||||
})
|
|
||||||
|
|
||||||
var upload = ''
|
|
||||||
|
|
||||||
// Add specified env vars
|
|
||||||
var env_found = false
|
|
||||||
if (args.options.env || process.env.CODECOV_ENV || process.env.codecov_env) {
|
|
||||||
var env = (
|
|
||||||
args.options.env +
|
|
||||||
',' +
|
|
||||||
(process.env.CODECOV_ENV || '') +
|
|
||||||
',' +
|
|
||||||
(process.env.codecov_env || '')
|
|
||||||
).split(',')
|
|
||||||
for (var i = env.length - 1; i >= 0; i--) {
|
|
||||||
if (env[i]) {
|
|
||||||
upload += env[i] + '=' + (process.env[env[i]] || '').toString() + '\n'
|
|
||||||
env_found = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (env_found) {
|
|
||||||
upload += '<<<<<< ENV\n'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List git files
|
|
||||||
var root = path.resolve(args.options.root || query.root || '.')
|
|
||||||
console.log('==> Building file structure')
|
|
||||||
try {
|
|
||||||
upload +=
|
|
||||||
execSync('git ls-files || hg locate', { cwd: root })
|
|
||||||
.toString()
|
|
||||||
.trim() + '\n<<<<<< network\n'
|
|
||||||
} catch (err) {
|
|
||||||
// not a git/hg dir, emulating git/hg ignore behavior
|
|
||||||
upload +=
|
|
||||||
walk
|
|
||||||
.sync({ path: root, ignoreFiles: ['.gitignore', '.hgignore'] })
|
|
||||||
.join('\n')
|
|
||||||
.trim() + '\n<<<<<< network\n'
|
|
||||||
}
|
|
||||||
// Make gcov reports
|
|
||||||
if ((args.options.disable || '').split(',').indexOf('gcov') === -1) {
|
|
||||||
try {
|
|
||||||
console.log('==> Generating gcov reports (skip via --disable=gcov)')
|
|
||||||
var gcg = args.options['gcov-glob'] || ''
|
|
||||||
if (gcg) {
|
|
||||||
if (!isWindows) {
|
|
||||||
gcg = gcg
|
|
||||||
.split(' ')
|
|
||||||
.map(function(p) {
|
|
||||||
return "-not -path '" + p + "'"
|
|
||||||
})
|
|
||||||
.join(' ')
|
|
||||||
} else {
|
|
||||||
gcg = gcg
|
|
||||||
.split(' ')
|
|
||||||
.map(function(p) {
|
|
||||||
return '^| findstr /i /v ' + p
|
|
||||||
})
|
|
||||||
.join(' ')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var gcov
|
|
||||||
if (!isWindows) {
|
|
||||||
gcov =
|
|
||||||
'find ' +
|
|
||||||
(args.options['gcov-root'] || root) +
|
|
||||||
" -type f -name '*.gcno' " +
|
|
||||||
gcg +
|
|
||||||
' -exec ' +
|
|
||||||
(args.options['gcov-exec'] || 'gcov') +
|
|
||||||
' ' +
|
|
||||||
(args.options['gcov-args'] || '') +
|
|
||||||
' {} +'
|
|
||||||
} else {
|
|
||||||
// @TODO support for root
|
|
||||||
// not straight forward due to nature of windows command dir
|
|
||||||
gcov =
|
|
||||||
'for /f "delims=" %g in (\'dir /a-d /b /s *.gcno ' +
|
|
||||||
gcg +
|
|
||||||
"') do " +
|
|
||||||
(args.options['gcov-exec'] || 'gcov') +
|
|
||||||
' ' +
|
|
||||||
(args.options['gcov-args'] || '') +
|
|
||||||
' %g'
|
|
||||||
}
|
|
||||||
debug.push(gcov)
|
|
||||||
console.log(' $ ' + gcov)
|
|
||||||
execSync(gcov)
|
|
||||||
} catch (e) {
|
|
||||||
console.log(' Failed to run gcov command.')
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug.push('disabled gcov')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect .bowerrc
|
|
||||||
var bowerrc
|
|
||||||
if (!isWindows) {
|
|
||||||
bowerrc = execSync('test -f .bowerrc && cat .bowerrc || echo ""', {
|
|
||||||
cwd: root,
|
|
||||||
})
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
} else {
|
|
||||||
bowerrc = execSync('if exist .bowerrc type .bowerrc', { cwd: root })
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
}
|
|
||||||
if (bowerrc) {
|
|
||||||
bowerrc = JSON.parse(bowerrc).directory
|
|
||||||
if (bowerrc) {
|
|
||||||
if (!isWindows) {
|
|
||||||
more_patterns =
|
|
||||||
" -not -path '*/" + bowerrc.toString().replace(/\/$/, '') + "/*'"
|
|
||||||
} else {
|
|
||||||
more_patterns =
|
|
||||||
'| findstr /i /v \\' + bowerrc.toString().replace(/\/$/, '') + '\\'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var files = [],
|
|
||||||
file = null
|
|
||||||
if (args.options.pipe) {
|
|
||||||
// Append piped reports
|
|
||||||
upload += '# path=piped\n' + args.options.pipe.join('') + '\n<<<<<< EOF\n'
|
|
||||||
console.log('==> Reading report from stdin')
|
|
||||||
} else if (args.options.file) {
|
|
||||||
// Append manually entered reports
|
|
||||||
file = args.options.file
|
|
||||||
console.log('==> Targeting specific file')
|
|
||||||
try {
|
|
||||||
upload +=
|
|
||||||
'# path=' +
|
|
||||||
file +
|
|
||||||
'\n' +
|
|
||||||
fs.readFileSync(file, 'utf8').toString() +
|
|
||||||
'\n<<<<<< EOF\n'
|
|
||||||
console.log(' + ' + file)
|
|
||||||
files.push(file)
|
|
||||||
} catch (e) {
|
|
||||||
debug.push('failed: ' + file.split('/').pop())
|
|
||||||
console.log(' X Failed to read file at ' + file)
|
|
||||||
}
|
|
||||||
} else if ((args.options.disable || '').split(',').indexOf('search') === -1) {
|
|
||||||
console.log('==> Scanning for reports')
|
|
||||||
var _files
|
|
||||||
if (!isWindows) {
|
|
||||||
_files = execSync('find ' + root + ' ' + patterns + more_patterns)
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.split('\n')
|
|
||||||
} else {
|
|
||||||
// @TODO support for a root directory
|
|
||||||
// It's not straightforward due to the nature of the dir command
|
|
||||||
_files = execSync('dir ' + patterns + more_patterns)
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
.split('\r\n')
|
|
||||||
}
|
|
||||||
if (_files) {
|
|
||||||
for (var i2 = _files.length - 1; i2 >= 0; i2--) {
|
|
||||||
file = _files[i2]
|
|
||||||
try {
|
|
||||||
upload +=
|
|
||||||
'# path=' +
|
|
||||||
file +
|
|
||||||
'\n' +
|
|
||||||
fs.readFileSync(file, 'utf8').toString() +
|
|
||||||
'\n<<<<<< EOF\n'
|
|
||||||
console.log(' + ' + file)
|
|
||||||
files.push(file)
|
|
||||||
} catch (e) {
|
|
||||||
debug.push('failed: ' + file.split('/').pop())
|
|
||||||
console.log(' X Failed to read file at ' + file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug.push('disabled search')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (files) {
|
|
||||||
// Upload to Codecov
|
|
||||||
if (args.options.dump) {
|
|
||||||
console.log('-------- DEBUG START --------')
|
|
||||||
console.log(upload)
|
|
||||||
console.log('-------- DEBUG END --------')
|
|
||||||
} else {
|
|
||||||
console.log('==> Uploading reports')
|
|
||||||
var _upload
|
|
||||||
if ((args.options.disable || '').split(',').indexOf('s3') === -1) {
|
|
||||||
_upload = sendToCodecovV3
|
|
||||||
} else {
|
|
||||||
_upload = sendToCodecovV2
|
|
||||||
}
|
|
||||||
_upload(
|
|
||||||
codecov_endpoint,
|
|
||||||
query,
|
|
||||||
upload,
|
|
||||||
function() {
|
|
||||||
// remove files after Uploading
|
|
||||||
if (args.options.clear) {
|
|
||||||
for (var i = files.length - 1; i >= 0; i--) {
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(files[i])
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (on_success) {
|
|
||||||
on_success.apply(this, arguments)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
on_failure || function() {}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
body: upload,
|
|
||||||
files: files,
|
|
||||||
query: query,
|
|
||||||
debug: debug,
|
|
||||||
url: codecov_endpoint,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
upload: upload,
|
|
||||||
version: version,
|
|
||||||
sendToCodecovV2: sendToCodecovV2,
|
|
||||||
sendToCodecovV3: sendToCodecovV3,
|
|
||||||
}
|
|
39
node_modules/codecov/lib/detect.js
generated
vendored
39
node_modules/codecov/lib/detect.js
generated
vendored
@ -1,39 +0,0 @@
|
|||||||
var services = {
|
|
||||||
travis: require('./services/travis'),
|
|
||||||
circle: require('./services/circle'),
|
|
||||||
cirrus: require('./services/cirrus'),
|
|
||||||
buildkite: require('./services/buildkite'),
|
|
||||||
azurePipelines: require('./services/azurePipelines'),
|
|
||||||
codeship: require('./services/codeship'),
|
|
||||||
drone: require('./services/drone'),
|
|
||||||
appveyor: require('./services/appveyor'),
|
|
||||||
wercker: require('./services/wercker'),
|
|
||||||
jenkins: require('./services/jenkins'),
|
|
||||||
semaphore: require('./services/semaphore'),
|
|
||||||
semaphore2x: require('./services/semaphore2x'),
|
|
||||||
snap: require('./services/snap'),
|
|
||||||
gitlab: require('./services/gitlab'),
|
|
||||||
heroku: require('./services/heroku'),
|
|
||||||
teamcity: require('./services/teamcity'),
|
|
||||||
codebuild: require('./services/codebuild'),
|
|
||||||
}
|
|
||||||
|
|
||||||
var detectProvider = function() {
|
|
||||||
var config
|
|
||||||
for (var name in services) {
|
|
||||||
if (services[name].detect()) {
|
|
||||||
config = services[name].configuration()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!config) {
|
|
||||||
var local = require('./services/localGit')
|
|
||||||
config = local.configuration()
|
|
||||||
if (!config) {
|
|
||||||
throw new Error('Unknown CI service provider. Unable to upload coverage.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = detectProvider
|
|
15
node_modules/codecov/lib/git.js
generated
vendored
15
node_modules/codecov/lib/git.js
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
var execSync = require('child_process').execSync
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
branch: function() {
|
|
||||||
return execSync('git rev-parse --abbrev-ref HEAD || hg branch')
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
},
|
|
||||||
|
|
||||||
head: function() {
|
|
||||||
return execSync("git log -1 --pretty=%H || hg id -i --debug | tr -d '+'")
|
|
||||||
.toString()
|
|
||||||
.trim()
|
|
||||||
},
|
|
||||||
}
|
|
14
node_modules/codecov/lib/offline.js
generated
vendored
14
node_modules/codecov/lib/offline.js
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
// see: http://man7.org/linux/man-pages/man2/accept.2.html#ERRORS
|
|
||||||
var offlineErrorCodes = [
|
|
||||||
'EAI_AGAIN',
|
|
||||||
'ENETDOWN',
|
|
||||||
'EPROTO',
|
|
||||||
'ENOPROTOOPT',
|
|
||||||
'EHOSTDOWN',
|
|
||||||
'ENONET',
|
|
||||||
'EHOSTUNREACH',
|
|
||||||
'EOPNOTSUPP',
|
|
||||||
'ENETUNREACH',
|
|
||||||
]
|
|
||||||
|
|
||||||
module.exports = offlineErrorCodes
|
|
23
node_modules/codecov/lib/services/appveyor.js
generated
vendored
23
node_modules/codecov/lib/services/appveyor.js
generated
vendored
@ -1,23 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.APPVEYOR
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' AppVeyor CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'appveyor',
|
|
||||||
commit: process.env.APPVEYOR_REPO_COMMIT,
|
|
||||||
branch: process.env.APPVEYOR_REPO_BRANCH,
|
|
||||||
pr: process.env.APPVEYOR_PULL_REQUEST_NUMBER,
|
|
||||||
job:
|
|
||||||
process.env.APPVEYOR_ACCOUNT_NAME +
|
|
||||||
'/' +
|
|
||||||
process.env.APPVEYOR_PROJECT_SLUG +
|
|
||||||
'/' +
|
|
||||||
process.env.APPVEYOR_BUILD_VERSION,
|
|
||||||
build: process.env.APPVEYOR_JOB_ID,
|
|
||||||
slug: process.env.APPVEYOR_REPO_NAME,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
23
node_modules/codecov/lib/services/azurePipelines.js
generated
vendored
23
node_modules/codecov/lib/services/azurePipelines.js
generated
vendored
@ -1,23 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.TF_BUILD
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Azure Pipelines CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'azure_pipelines',
|
|
||||||
commit: process.env.BUILD_SOURCEVERSION,
|
|
||||||
branch: process.env.BUILD_SOURCEBRANCH,
|
|
||||||
pr: process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER,
|
|
||||||
job: process.env.SYSTEM_JOBID,
|
|
||||||
build: process.env.BUILD_BUILDID,
|
|
||||||
build_url:
|
|
||||||
process.env.SYSTEM_TEAMFOUNDATIONSERVERURI +
|
|
||||||
process.env.SYSTEM_TEAMPROJECT +
|
|
||||||
'/_build/results?buildId=' +
|
|
||||||
process.env.BUILD_BUILDID,
|
|
||||||
slug: process.env.BUILD_REPOSITORY_ID,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
18
node_modules/codecov/lib/services/buildkite.js
generated
vendored
18
node_modules/codecov/lib/services/buildkite.js
generated
vendored
@ -1,18 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.BUILDKITE
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
// https://buildkite.com/docs/guides/environment-variables
|
|
||||||
console.log(' Buildkite CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'buildkite',
|
|
||||||
build: process.env.BUILDKITE_BUILD_NUMBER,
|
|
||||||
build_url: process.env.BUILDKITE_BUILD_URL,
|
|
||||||
commit: process.env.BUILDKITE_COMMIT,
|
|
||||||
branch: process.env.BUILDKITE_BRANCH,
|
|
||||||
slug: process.env.BUILDKITE_PROJECT_SLUG,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
40
node_modules/codecov/lib/services/circle.js
generated
vendored
40
node_modules/codecov/lib/services/circle.js
generated
vendored
@ -1,40 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.CIRCLECI
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Circle CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'circleci',
|
|
||||||
build: process.env.CIRCLE_BUILD_NUM + '.' + process.env.CIRCLE_NODE_INDEX,
|
|
||||||
job: process.env.CIRCLE_BUILD_NUM + '.' + process.env.CIRCLE_NODE_INDEX,
|
|
||||||
commit: process.env.CIRCLE_SHA1,
|
|
||||||
branch: process.env.CIRCLE_BRANCH,
|
|
||||||
pr: process.env.CIRCLE_PR_NUMBER,
|
|
||||||
slug: detectRepoSlug(),
|
|
||||||
}
|
|
||||||
function detectRepoSlug() {
|
|
||||||
if (process.env.CIRCLE_PROJECT_REPONAME) {
|
|
||||||
// CircleCI 1.0
|
|
||||||
// CIRCLE_PROJECT_REPONAME=codecov
|
|
||||||
// CIRCLE_PROJECT_USERNAME=codecov-node
|
|
||||||
// CIRCLE_REPOSITORY_URL=https://github.com/codecov/codecov-node (note: GitHub Web URL)
|
|
||||||
return (
|
|
||||||
process.env.CIRCLE_PROJECT_USERNAME +
|
|
||||||
'/' +
|
|
||||||
process.env.CIRCLE_PROJECT_REPONAME
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (process.env.CIRCLE_REPOSITORY_URL) {
|
|
||||||
// CircleCI 2.0
|
|
||||||
// CIRCLE_REPOSITORY_URL=git@github.com:codecov/codecov-node.git (note: Git/SSH URL)
|
|
||||||
return process.env.CIRCLE_REPOSITORY_URL.replace(/^.*:/, '').replace(
|
|
||||||
/\.git$/,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
}
|
|
||||||
throw new Error('Cannot detect repository slug.')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
17
node_modules/codecov/lib/services/cirrus.js
generated
vendored
17
node_modules/codecov/lib/services/cirrus.js
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.CIRRUS_CI
|
|
||||||
},
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Cirrus CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'cirrusci',
|
|
||||||
build: process.env.CIRRUS_BUILD_ID,
|
|
||||||
job: process.env.CIRRUS_TASK_ID,
|
|
||||||
commit: process.env.CIRRUS_CHANGE_IN_REPO,
|
|
||||||
branch: process.env.CIRRUS_BRANCH,
|
|
||||||
pr: process.env.CIRRUS_PR,
|
|
||||||
slug: process.env.CIRRUS_REPO_FULL_NAME,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
42
node_modules/codecov/lib/services/codebuild.js
generated
vendored
42
node_modules/codecov/lib/services/codebuild.js
generated
vendored
@ -1,42 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.CODEBUILD_CI
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' AWS CodeBuild Detected')
|
|
||||||
return {
|
|
||||||
service: 'codebuild',
|
|
||||||
build: process.env.CODEBUILD_BUILD_ID,
|
|
||||||
job: process.env.CODEBUILD_BUILD_ID,
|
|
||||||
commit: process.env.CODEBUILD_RESOLVED_SOURCE_VERSION,
|
|
||||||
branch: detectBranchName(),
|
|
||||||
pr: detectPRNumber(),
|
|
||||||
slug: detectRepoSlug(),
|
|
||||||
}
|
|
||||||
function detectBranchName() {
|
|
||||||
if (process.env.CODEBUILD_WEBHOOK_HEAD_REF) {
|
|
||||||
return process.env.CODEBUILD_WEBHOOK_HEAD_REF.replace(
|
|
||||||
/^refs\/heads\//,
|
|
||||||
''
|
|
||||||
)
|
|
||||||
}
|
|
||||||
throw new Error('Cannot detect branch name.')
|
|
||||||
}
|
|
||||||
function detectPRNumber() {
|
|
||||||
if (process.env.CODEBUILD_SOURCE_VERSION) {
|
|
||||||
return process.env.CODEBUILD_SOURCE_VERSION.replace(/^pr\//, '')
|
|
||||||
}
|
|
||||||
throw new Error('Cannot detect PR number.')
|
|
||||||
}
|
|
||||||
function detectRepoSlug() {
|
|
||||||
if (process.env.CODEBUILD_SOURCE_REPO_URL) {
|
|
||||||
return process.env.CODEBUILD_SOURCE_REPO_URL.replace(
|
|
||||||
/^.*github.com\//,
|
|
||||||
''
|
|
||||||
).replace(/\.git$/, '')
|
|
||||||
}
|
|
||||||
throw new Error('Cannot detect repository slug.')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
16
node_modules/codecov/lib/services/codeship.js
generated
vendored
16
node_modules/codecov/lib/services/codeship.js
generated
vendored
@ -1,16 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return process.env.CI_NAME && process.env.CI_NAME === 'codeship'
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Codeship CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'codeship',
|
|
||||||
build: process.env.CI_BUILD_NUMBER,
|
|
||||||
build_url: process.env.CI_BUILD_URL,
|
|
||||||
commit: process.env.CI_COMMIT_ID,
|
|
||||||
branch: process.env.CI_BRANCH,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
19
node_modules/codecov/lib/services/drone.js
generated
vendored
19
node_modules/codecov/lib/services/drone.js
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
var git = require('../git')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.DRONE
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Drone.io CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'drone.io',
|
|
||||||
build: process.env.DRONE_BUILD_NUMBER,
|
|
||||||
commit: git.head(),
|
|
||||||
build_url: process.env.DRONE_BUILD_URL,
|
|
||||||
branch: process.env.DRONE_BRANCH,
|
|
||||||
root: process.env.DRONE_BUILD_DIR,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
25
node_modules/codecov/lib/services/gitlab.js
generated
vendored
25
node_modules/codecov/lib/services/gitlab.js
generated
vendored
@ -1,25 +0,0 @@
|
|||||||
// https://docs.gitlab.com/ce/ci/variables/README.html
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.GITLAB_CI
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Gitlab CI Detected')
|
|
||||||
var remote =
|
|
||||||
process.env.CI_BUILD_REPO || process.env.CI_REPOSITORY_URL || ''
|
|
||||||
return {
|
|
||||||
service: 'gitlab',
|
|
||||||
build: process.env.CI_BUILD_ID,
|
|
||||||
commit: process.env.CI_BUILD_REF,
|
|
||||||
branch: process.env.CI_BUILD_REF_NAME,
|
|
||||||
root: process.env.CI_PROJECT_DIR,
|
|
||||||
slug: remote
|
|
||||||
.split('/')
|
|
||||||
.slice(3, 5)
|
|
||||||
.join('/')
|
|
||||||
.replace('.git', ''),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
17
node_modules/codecov/lib/services/heroku.js
generated
vendored
17
node_modules/codecov/lib/services/heroku.js
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
// https://devcenter.heroku.com/articles/heroku-ci
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.HEROKU_TEST_RUN_ID
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' heroku CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'heroku',
|
|
||||||
build: process.env.HEROKU_TEST_RUN_ID,
|
|
||||||
commit: process.env.HEROKU_TEST_RUN_COMMIT_VERSION,
|
|
||||||
branch: process.env.HEROKU_TEST_RUN_BRANCH,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
24
node_modules/codecov/lib/services/jenkins.js
generated
vendored
24
node_modules/codecov/lib/services/jenkins.js
generated
vendored
@ -1,24 +0,0 @@
|
|||||||
var git = require('../git')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
detect: function() {
|
|
||||||
return !!process.env.JENKINS_URL
|
|
||||||
},
|
|
||||||
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' Jenkins CI Detected')
|
|
||||||
return {
|
|
||||||
service: 'jenkins',
|
|
||||||
commit:
|
|
||||||
process.env.ghprbActualCommit || process.env.GIT_COMMIT || git.head(),
|
|
||||||
branch:
|
|
||||||
process.env.ghprbSourceBranch ||
|
|
||||||
process.env.GIT_BRANCH ||
|
|
||||||
process.env.BRANCH_NAME,
|
|
||||||
build: process.env.BUILD_NUMBER,
|
|
||||||
build_url: process.env.BUILD_URL,
|
|
||||||
root: process.env.WORKSPACE,
|
|
||||||
pr: process.env.ghprbPullId || process.env.CHANGE_ID,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
16
node_modules/codecov/lib/services/localGit.js
generated
vendored
16
node_modules/codecov/lib/services/localGit.js
generated
vendored
@ -1,16 +0,0 @@
|
|||||||
var git = require('../git')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
configuration: function() {
|
|
||||||
console.log(' No CI Detected. Using git/mercurial')
|
|
||||||
var branch = git.branch()
|
|
||||||
if (branch === 'HEAD') {
|
|
||||||
branch = 'master'
|
|
||||||
}
|
|
||||||
var head = git.head()
|
|
||||||
return {
|
|
||||||
commit: head,
|
|
||||||
branch: branch,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user