Deployed the page to Github Pages.
This commit is contained in:
parent
1d79754e93
commit
2c89899458
62797 changed files with 6551425 additions and 15279 deletions
21
node_modules/arg/LICENSE.md
generated
vendored
Normal file
21
node_modules/arg/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017-2019 Zeit, Inc.
|
||||
|
||||
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.
|
280
node_modules/arg/README.md
generated
vendored
Normal file
280
node_modules/arg/README.md
generated
vendored
Normal file
|
@ -0,0 +1,280 @@
|
|||
# Arg [](https://circleci.com/gh/zeit/arg)
|
||||
|
||||
`arg` is yet another command line option parser.
|
||||
|
||||
## Installation
|
||||
|
||||
Use Yarn or NPM to install.
|
||||
|
||||
```console
|
||||
$ yarn add arg
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```console
|
||||
$ npm install arg
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
`arg()` takes either 1 or 2 arguments:
|
||||
|
||||
1. Command line specification object (see below)
|
||||
2. Parse options (_Optional_, defaults to `{permissive: false, argv: process.argv.slice(2), stopAtPositional: false}`)
|
||||
|
||||
It returns an object with any values present on the command-line (missing options are thus
|
||||
missing from the resulting object). Arg performs no validation/requirement checking - we
|
||||
leave that up to the application.
|
||||
|
||||
All parameters that aren't consumed by options (commonly referred to as "extra" parameters)
|
||||
are added to `result._`, which is _always_ an array (even if no extra parameters are passed,
|
||||
in which case an empty array is returned).
|
||||
|
||||
```javascript
|
||||
const arg = require('arg');
|
||||
|
||||
// `options` is an optional parameter
|
||||
const args = arg(spec, options = {permissive: false, argv: process.argv.slice(2)});
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```console
|
||||
$ node ./hello.js --verbose -vvv --port=1234 -n 'My name' foo bar --tag qux --tag=qix -- --foobar
|
||||
```
|
||||
|
||||
```javascript
|
||||
// hello.js
|
||||
const arg = require('arg');
|
||||
|
||||
const args = arg({
|
||||
// Types
|
||||
'--help': Boolean,
|
||||
'--version': Boolean,
|
||||
'--verbose': arg.COUNT, // Counts the number of times --verbose is passed
|
||||
'--port': Number, // --port <number> or --port=<number>
|
||||
'--name': String, // --name <string> or --name=<string>
|
||||
'--tag': [String], // --tag <string> or --tag=<string>
|
||||
|
||||
// Aliases
|
||||
'-v': '--verbose',
|
||||
'-n': '--name', // -n <string>; result is stored in --name
|
||||
'--label': '--name' // --label <string> or --label=<string>;
|
||||
// result is stored in --name
|
||||
});
|
||||
|
||||
console.log(args);
|
||||
/*
|
||||
{
|
||||
_: ["foo", "bar", "--foobar"],
|
||||
'--port': 1234,
|
||||
'--verbose': 4,
|
||||
'--name': "My name",
|
||||
'--tag': ["qux", "qix"]
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
The values for each key=>value pair is either a type (function or [function]) or a string (indicating an alias).
|
||||
|
||||
- In the case of a function, the string value of the argument's value is passed to it,
|
||||
and the return value is used as the ultimate value.
|
||||
|
||||
- In the case of an array, the only element _must_ be a type function. Array types indicate
|
||||
that the argument may be passed multiple times, and as such the resulting value in the returned
|
||||
object is an array with all of the values that were passed using the specified flag.
|
||||
|
||||
- In the case of a string, an alias is established. If a flag is passed that matches the _key_,
|
||||
then the _value_ is substituted in its place.
|
||||
|
||||
Type functions are passed three arguments:
|
||||
|
||||
1. The parameter value (always a string)
|
||||
2. The parameter name (e.g. `--label`)
|
||||
3. The previous value for the destination (useful for reduce-like operations or for supporting `-v` multiple times, etc.)
|
||||
|
||||
This means the built-in `String`, `Number`, and `Boolean` type constructors "just work" as type functions.
|
||||
|
||||
Note that `Boolean` and `[Boolean]` have special treatment - an option argument is _not_ consumed or passed, but instead `true` is
|
||||
returned. These options are called "flags".
|
||||
|
||||
For custom handlers that wish to behave as flags, you may pass the function through `arg.flag()`:
|
||||
|
||||
```javascript
|
||||
const arg = require('arg');
|
||||
|
||||
const argv = ['--foo', 'bar', '-ff', 'baz', '--foo', '--foo', 'qux', '-fff', 'qix'];
|
||||
|
||||
function myHandler(value, argName, previousValue) {
|
||||
/* `value` is always `true` */
|
||||
return 'na ' + (previousValue || 'batman!');
|
||||
}
|
||||
|
||||
const args = arg({
|
||||
'--foo': arg.flag(myHandler),
|
||||
'-f': '--foo'
|
||||
}, {
|
||||
argv
|
||||
});
|
||||
|
||||
console.log(args);
|
||||
/*
|
||||
{
|
||||
_: ['bar', 'baz', 'qux', 'qix'],
|
||||
'--foo': 'na na na na na na na na batman!'
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
As well, `arg` supplies a helper argument handler called `arg.COUNT`, which equivalent to a `[Boolean]` argument's `.length`
|
||||
property - effectively counting the number of times the boolean flag, denoted by the key, is passed on the command line..
|
||||
For example, this is how you could implement `ssh`'s multiple levels of verbosity (`-vvvv` being the most verbose).
|
||||
|
||||
```javascript
|
||||
const arg = require('arg');
|
||||
|
||||
const argv = ['-AAAA', '-BBBB'];
|
||||
|
||||
const args = arg({
|
||||
'-A': arg.COUNT,
|
||||
'-B': [Boolean]
|
||||
}, {
|
||||
argv
|
||||
});
|
||||
|
||||
console.log(args);
|
||||
/*
|
||||
{
|
||||
_: [],
|
||||
'-A': 4,
|
||||
'-B': [true, true, true, true]
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
If a second parameter is specified and is an object, it specifies parsing options to modify the behavior of `arg()`.
|
||||
|
||||
#### `argv`
|
||||
|
||||
If you have already sliced or generated a number of raw arguments to be parsed (as opposed to letting `arg`
|
||||
slice them from `process.argv`) you may specify them in the `argv` option.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
const args = arg(
|
||||
{
|
||||
'--foo': String
|
||||
}, {
|
||||
argv: ['hello', '--foo', 'world']
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
results in:
|
||||
|
||||
```javascript
|
||||
const args = {
|
||||
_: ['hello'],
|
||||
'--foo': 'world'
|
||||
};
|
||||
```
|
||||
|
||||
#### `permissive`
|
||||
|
||||
When `permissive` set to `true`, `arg` will push any unknown arguments
|
||||
onto the "extra" argument array (`result._`) instead of throwing an error about
|
||||
an unknown flag.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
const arg = require('arg');
|
||||
|
||||
const argv = ['--foo', 'hello', '--qux', 'qix', '--bar', '12345', 'hello again'];
|
||||
|
||||
const args = arg(
|
||||
{
|
||||
'--foo': String,
|
||||
'--bar': Number
|
||||
}, {
|
||||
argv,
|
||||
permissive: true
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
results in:
|
||||
|
||||
```javascript
|
||||
const args = {
|
||||
_: ['--qux', 'qix', 'hello again'],
|
||||
'--foo': 'hello',
|
||||
'--bar': 12345
|
||||
}
|
||||
```
|
||||
|
||||
#### `stopAtPositional`
|
||||
|
||||
When `stopAtPositional` is set to `true`, `arg` will halt parsing at the first
|
||||
positional argument.
|
||||
|
||||
For example:
|
||||
|
||||
```javascript
|
||||
const arg = require('arg');
|
||||
|
||||
const argv = ['--foo', 'hello', '--bar'];
|
||||
|
||||
const args = arg(
|
||||
{
|
||||
'--foo': Boolean,
|
||||
'--bar': Boolean
|
||||
}, {
|
||||
argv,
|
||||
stopAtPositional: true
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
results in:
|
||||
|
||||
```javascript
|
||||
const args = {
|
||||
_: ['hello', '--bar'],
|
||||
'--foo': true
|
||||
};
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
Some errors that `arg` throws provide a `.code` property in order to aid in recovering from user error, or to
|
||||
differentiate between user error and developer error (bug).
|
||||
|
||||
##### ARG_UNKNOWN_OPTION
|
||||
|
||||
If an unknown option (not defined in the spec object) is passed, an error with code `ARG_UNKNOWN_OPTION` will be thrown:
|
||||
```js
|
||||
// cli.js
|
||||
try {
|
||||
require('arg')({ '--hi': String });
|
||||
} catch (err) {
|
||||
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
||||
console.log(err.message);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```shell
|
||||
node cli.js --extraneous true
|
||||
Unknown or unexpected option: --extraneous
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
Copyright © 2017-2019 by ZEIT, Inc. Released under the [MIT License](LICENSE.md).
|
31
node_modules/arg/index.d.ts
generated
vendored
Normal file
31
node_modules/arg/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
declare const flagSymbol: unique symbol;
|
||||
|
||||
declare function arg<T extends arg.Spec>(spec: T, options?: arg.Options): arg.Result<T>;
|
||||
|
||||
declare namespace arg {
|
||||
export function flag<T>(fn: T): T & { [flagSymbol]: true };
|
||||
|
||||
export const COUNT: Handler<number> & { [flagSymbol]: true };
|
||||
|
||||
export type Handler <T = any> = (value: string, name: string, previousValue?: T) => T;
|
||||
|
||||
export interface Spec {
|
||||
[key: string]: string | Handler | [Handler];
|
||||
}
|
||||
|
||||
export type Result<T extends Spec> = { _: string[] } & {
|
||||
[K in keyof T]?: T[K] extends Handler
|
||||
? ReturnType<T[K]>
|
||||
: T[K] extends [Handler]
|
||||
? Array<ReturnType<T[K][0]>>
|
||||
: never
|
||||
};
|
||||
|
||||
export interface Options {
|
||||
argv?: string[];
|
||||
permissive?: boolean;
|
||||
stopAtPositional?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = arg;
|
144
node_modules/arg/index.js
generated
vendored
Normal file
144
node_modules/arg/index.js
generated
vendored
Normal file
|
@ -0,0 +1,144 @@
|
|||
const flagSymbol = Symbol('arg flag');
|
||||
|
||||
function arg(opts, {argv = process.argv.slice(2), permissive = false, stopAtPositional = false} = {}) {
|
||||
if (!opts) {
|
||||
throw new Error('Argument specification object is required');
|
||||
}
|
||||
|
||||
const result = {_: []};
|
||||
|
||||
const aliases = {};
|
||||
const handlers = {};
|
||||
|
||||
for (const key of Object.keys(opts)) {
|
||||
if (!key) {
|
||||
throw new TypeError('Argument key cannot be an empty string');
|
||||
}
|
||||
|
||||
if (key[0] !== '-') {
|
||||
throw new TypeError(`Argument key must start with '-' but found: '${key}'`);
|
||||
}
|
||||
|
||||
if (key.length === 1) {
|
||||
throw new TypeError(`Argument key must have a name; singular '-' keys are not allowed: ${key}`);
|
||||
}
|
||||
|
||||
if (typeof opts[key] === 'string') {
|
||||
aliases[key] = opts[key];
|
||||
continue;
|
||||
}
|
||||
|
||||
let type = opts[key];
|
||||
let isFlag = false;
|
||||
|
||||
if (Array.isArray(type) && type.length === 1 && typeof type[0] === 'function') {
|
||||
const [fn] = type;
|
||||
type = (value, name, prev = []) => {
|
||||
prev.push(fn(value, name, prev[prev.length - 1]));
|
||||
return prev;
|
||||
};
|
||||
isFlag = fn === Boolean || fn[flagSymbol] === true;
|
||||
} else if (typeof type === 'function') {
|
||||
isFlag = type === Boolean || type[flagSymbol] === true;
|
||||
} else {
|
||||
throw new TypeError(`Type missing or not a function or valid array type: ${key}`);
|
||||
}
|
||||
|
||||
if (key[1] !== '-' && key.length > 2) {
|
||||
throw new TypeError(`Short argument keys (with a single hyphen) must have only one character: ${key}`);
|
||||
}
|
||||
|
||||
handlers[key] = [type, isFlag];
|
||||
}
|
||||
|
||||
for (let i = 0, len = argv.length; i < len; i++) {
|
||||
const wholeArg = argv[i];
|
||||
|
||||
if (stopAtPositional && result._.length > 0) {
|
||||
result._ = result._.concat(argv.slice(i));
|
||||
break;
|
||||
}
|
||||
|
||||
if (wholeArg === '--') {
|
||||
result._ = result._.concat(argv.slice(i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
if (wholeArg.length > 1 && wholeArg[0] === '-') {
|
||||
/* eslint-disable operator-linebreak */
|
||||
const separatedArguments = (wholeArg[1] === '-' || wholeArg.length === 2)
|
||||
? [wholeArg]
|
||||
: wholeArg.slice(1).split('').map(a => `-${a}`);
|
||||
/* eslint-enable operator-linebreak */
|
||||
|
||||
for (let j = 0; j < separatedArguments.length; j++) {
|
||||
const arg = separatedArguments[j];
|
||||
const [originalArgName, argStr] = arg[1] === '-' ? arg.split(/=(.*)/, 2) : [arg, undefined];
|
||||
|
||||
let argName = originalArgName;
|
||||
while (argName in aliases) {
|
||||
argName = aliases[argName];
|
||||
}
|
||||
|
||||
if (!(argName in handlers)) {
|
||||
if (permissive) {
|
||||
result._.push(arg);
|
||||
continue;
|
||||
} else {
|
||||
const err = new Error(`Unknown or unexpected option: ${originalArgName}`);
|
||||
err.code = 'ARG_UNKNOWN_OPTION';
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const [type, isFlag] = handlers[argName];
|
||||
|
||||
if (!isFlag && ((j + 1) < separatedArguments.length)) {
|
||||
throw new TypeError(`Option requires argument (but was followed by another short argument): ${originalArgName}`);
|
||||
}
|
||||
|
||||
if (isFlag) {
|
||||
result[argName] = type(true, argName, result[argName]);
|
||||
} else if (argStr === undefined) {
|
||||
if (
|
||||
argv.length < i + 2 ||
|
||||
(
|
||||
argv[i + 1].length > 1 &&
|
||||
(argv[i + 1][0] === '-') &&
|
||||
!(
|
||||
argv[i + 1].match(/^-?\d*(\.(?=\d))?\d*$/) &&
|
||||
(
|
||||
type === Number ||
|
||||
// eslint-disable-next-line no-undef
|
||||
(typeof BigInt !== 'undefined' && type === BigInt)
|
||||
)
|
||||
)
|
||||
)
|
||||
) {
|
||||
const extended = originalArgName === argName ? '' : ` (alias for ${argName})`;
|
||||
throw new Error(`Option requires argument: ${originalArgName}${extended}`);
|
||||
}
|
||||
|
||||
result[argName] = type(argv[i + 1], argName, result[argName]);
|
||||
++i;
|
||||
} else {
|
||||
result[argName] = type(argStr, argName, result[argName]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result._.push(wholeArg);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
arg.flag = fn => {
|
||||
fn[flagSymbol] = true;
|
||||
return fn;
|
||||
};
|
||||
|
||||
// Utility types
|
||||
arg.COUNT = arg.flag((v, name, existingCount) => (existingCount || 0) + 1);
|
||||
|
||||
module.exports = arg;
|
30
node_modules/arg/package.json
generated
vendored
Normal file
30
node_modules/arg/package.json
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "arg",
|
||||
"version": "4.1.3",
|
||||
"description": "Another simple argument parser",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": "zeit/arg",
|
||||
"author": "Josh Junon <junon@zeit.co>",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"pretest": "xo",
|
||||
"test": "WARN_EXIT=1 jest --coverage -w 2"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"complexity": 0,
|
||||
"max-depth": 0,
|
||||
"no-div-regex": 0
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.1",
|
||||
"jest": "^20.0.4",
|
||||
"xo": "^0.18.2"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue