feat: docker compose maybe
This commit is contained in:
21
node_modules/mri/index.d.ts
generated
vendored
Normal file
21
node_modules/mri/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
type Dict<T> = Record<string, T>;
|
||||
type Arrayable<T> = T | T[];
|
||||
type Default = Dict<any>;
|
||||
|
||||
declare function mri<T=Default>(args?: string[], options?: mri.Options): mri.Argv<T>;
|
||||
|
||||
declare namespace mri {
|
||||
export interface Options {
|
||||
boolean?: Arrayable<string>;
|
||||
string?: Arrayable<string>;
|
||||
alias?: Dict<Arrayable<string>>;
|
||||
default?: Dict<any>;
|
||||
unknown?(flag: string): void;
|
||||
}
|
||||
|
||||
export type Argv<T=Default> = T & {
|
||||
_: string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = mri;
|
119
node_modules/mri/lib/index.js
generated
vendored
Normal file
119
node_modules/mri/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
function toArr(any) {
|
||||
return any == null ? [] : Array.isArray(any) ? any : [any];
|
||||
}
|
||||
|
||||
function toVal(out, key, val, opts) {
|
||||
var x, old=out[key], nxt=(
|
||||
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
||||
: typeof val === 'boolean' ? val
|
||||
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
||||
: (x = +val,x * 0 === 0) ? x : val
|
||||
);
|
||||
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
||||
}
|
||||
|
||||
module.exports = function (args, opts) {
|
||||
args = args || [];
|
||||
opts = opts || {};
|
||||
|
||||
var k, arr, arg, name, val, out={ _:[] };
|
||||
var i=0, j=0, idx=0, len=args.length;
|
||||
|
||||
const alibi = opts.alias !== void 0;
|
||||
const strict = opts.unknown !== void 0;
|
||||
const defaults = opts.default !== void 0;
|
||||
|
||||
opts.alias = opts.alias || {};
|
||||
opts.string = toArr(opts.string);
|
||||
opts.boolean = toArr(opts.boolean);
|
||||
|
||||
if (alibi) {
|
||||
for (k in opts.alias) {
|
||||
arr = opts.alias[k] = toArr(opts.alias[k]);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=opts.boolean.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.boolean[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
||||
}
|
||||
|
||||
for (i=opts.string.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.string[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
name = typeof opts.default[k];
|
||||
arr = opts.alias[k] = opts.alias[k] || [];
|
||||
if (opts[name] !== void 0) {
|
||||
opts[name].push(k);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
opts[name].push(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const keys = strict ? Object.keys(opts.alias) : [];
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
out._ = out._.concat(args.slice(++i));
|
||||
break;
|
||||
}
|
||||
|
||||
for (j=0; j < arg.length; j++) {
|
||||
if (arg.charCodeAt(j) !== 45) break; // "-"
|
||||
}
|
||||
|
||||
if (j === 0) {
|
||||
out._.push(arg);
|
||||
} else if (arg.substring(j, j + 3) === 'no-') {
|
||||
name = arg.substring(j + 3);
|
||||
if (strict && !~keys.indexOf(name)) {
|
||||
return opts.unknown(arg);
|
||||
}
|
||||
out[name] = false;
|
||||
} else {
|
||||
for (idx=j+1; idx < arg.length; idx++) {
|
||||
if (arg.charCodeAt(idx) === 61) break; // "="
|
||||
}
|
||||
|
||||
name = arg.substring(j, idx);
|
||||
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
||||
arr = (j === 2 ? [name] : name);
|
||||
|
||||
for (idx=0; idx < arr.length; idx++) {
|
||||
name = arr[idx];
|
||||
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
||||
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
if (out[k] === void 0) {
|
||||
out[k] = opts.default[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alibi) {
|
||||
for (k in out) {
|
||||
arr = opts.alias[k] || [];
|
||||
while (arr.length > 0) {
|
||||
out[arr.shift()] = out[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
119
node_modules/mri/lib/index.mjs
generated
vendored
Normal file
119
node_modules/mri/lib/index.mjs
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
function toArr(any) {
|
||||
return any == null ? [] : Array.isArray(any) ? any : [any];
|
||||
}
|
||||
|
||||
function toVal(out, key, val, opts) {
|
||||
var x, old=out[key], nxt=(
|
||||
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
||||
: typeof val === 'boolean' ? val
|
||||
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
||||
: (x = +val,x * 0 === 0) ? x : val
|
||||
);
|
||||
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
||||
}
|
||||
|
||||
export default function (args, opts) {
|
||||
args = args || [];
|
||||
opts = opts || {};
|
||||
|
||||
var k, arr, arg, name, val, out={ _:[] };
|
||||
var i=0, j=0, idx=0, len=args.length;
|
||||
|
||||
const alibi = opts.alias !== void 0;
|
||||
const strict = opts.unknown !== void 0;
|
||||
const defaults = opts.default !== void 0;
|
||||
|
||||
opts.alias = opts.alias || {};
|
||||
opts.string = toArr(opts.string);
|
||||
opts.boolean = toArr(opts.boolean);
|
||||
|
||||
if (alibi) {
|
||||
for (k in opts.alias) {
|
||||
arr = opts.alias[k] = toArr(opts.alias[k]);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=opts.boolean.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.boolean[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
||||
}
|
||||
|
||||
for (i=opts.string.length; i-- > 0;) {
|
||||
arr = opts.alias[opts.string[i]] || [];
|
||||
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
name = typeof opts.default[k];
|
||||
arr = opts.alias[k] = opts.alias[k] || [];
|
||||
if (opts[name] !== void 0) {
|
||||
opts[name].push(k);
|
||||
for (i=0; i < arr.length; i++) {
|
||||
opts[name].push(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const keys = strict ? Object.keys(opts.alias) : [];
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
arg = args[i];
|
||||
|
||||
if (arg === '--') {
|
||||
out._ = out._.concat(args.slice(++i));
|
||||
break;
|
||||
}
|
||||
|
||||
for (j=0; j < arg.length; j++) {
|
||||
if (arg.charCodeAt(j) !== 45) break; // "-"
|
||||
}
|
||||
|
||||
if (j === 0) {
|
||||
out._.push(arg);
|
||||
} else if (arg.substring(j, j + 3) === 'no-') {
|
||||
name = arg.substring(j + 3);
|
||||
if (strict && !~keys.indexOf(name)) {
|
||||
return opts.unknown(arg);
|
||||
}
|
||||
out[name] = false;
|
||||
} else {
|
||||
for (idx=j+1; idx < arg.length; idx++) {
|
||||
if (arg.charCodeAt(idx) === 61) break; // "="
|
||||
}
|
||||
|
||||
name = arg.substring(j, idx);
|
||||
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
||||
arr = (j === 2 ? [name] : name);
|
||||
|
||||
for (idx=0; idx < arr.length; idx++) {
|
||||
name = arr[idx];
|
||||
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
||||
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaults) {
|
||||
for (k in opts.default) {
|
||||
if (out[k] === void 0) {
|
||||
out[k] = opts.default[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alibi) {
|
||||
for (k in out) {
|
||||
arr = opts.alias[k] || [];
|
||||
while (arr.length > 0) {
|
||||
out[arr.shift()] = out[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
21
node_modules/mri/license.md
generated
vendored
Normal file
21
node_modules/mri/license.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.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.
|
43
node_modules/mri/package.json
generated
vendored
Normal file
43
node_modules/mri/package.json
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "mri",
|
||||
"version": "1.2.0",
|
||||
"description": "Quickly scan for CLI flags and arguments",
|
||||
"repository": "lukeed/mri",
|
||||
"module": "lib/index.mjs",
|
||||
"main": "lib/index.js",
|
||||
"types": "index.d.ts",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"lib"
|
||||
],
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"bench": "node bench",
|
||||
"pretest": "npm run build",
|
||||
"test": "tape test/*.js | tap-spec"
|
||||
},
|
||||
"keywords": [
|
||||
"argv",
|
||||
"arguments",
|
||||
"cli",
|
||||
"minimist",
|
||||
"options",
|
||||
"optimist",
|
||||
"parser",
|
||||
"args"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bundt": "1.0.2",
|
||||
"tap-spec": "4.1.2",
|
||||
"tape": "4.13.3"
|
||||
}
|
||||
}
|
166
node_modules/mri/readme.md
generated
vendored
Normal file
166
node_modules/mri/readme.md
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
# mri [](https://github.com/lukeed/mri/actions)
|
||||
|
||||
> Quickly scan for CLI flags and arguments
|
||||
|
||||
This is a [fast](#benchmarks) and lightweight alternative to [`minimist`](https://github.com/substack/minimist) and [`yargs-parser`](https://github.com/yargs/yargs-parser).
|
||||
|
||||
It only exists because I find that I usually don't need most of what `minimist` and `yargs-parser` have to offer. However, `mri` is similar _enough_ that it might function as a "drop-in replacement" for you, too!
|
||||
|
||||
See [Comparisons](#comparisons) for more info.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save mri
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
$ demo-cli --foo --bar=baz -mtv -- hello world
|
||||
```
|
||||
|
||||
```js
|
||||
const mri = require('mri');
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
|
||||
mri(argv);
|
||||
//=> { _: ['hello', 'world'], foo:true, bar:'baz', m:true, t:true, v:true }
|
||||
|
||||
mri(argv, { boolean:['bar'] });
|
||||
//=> { _: ['baz', 'hello', 'world'], foo:true, bar:true, m:true, t:true, v:true }
|
||||
|
||||
mri(argv, {
|
||||
alias: {
|
||||
b: 'bar',
|
||||
foo: ['f', 'fuz']
|
||||
}
|
||||
});
|
||||
//=> { _: ['hello', 'world'], foo:true, f:true, fuz:true, b:'baz', bar:'baz', m:true, t:true, v:true }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### mri(args, options)
|
||||
Return: `Object`
|
||||
|
||||
#### args
|
||||
Type: `Array`<br>
|
||||
Default: `[]`
|
||||
|
||||
An array of arguments to parse. For CLI usage, send `process.argv.slice(2)`. See [`process.argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) for info.
|
||||
|
||||
#### options.alias
|
||||
Type: `Object`<br>
|
||||
Default: `{}`
|
||||
|
||||
An object of keys whose values are `String`s or `Array<String>` of aliases. These will be added to the parsed output with matching values.
|
||||
|
||||
#### options.boolean
|
||||
Type: `Array|String`<br>
|
||||
Default: `[]`
|
||||
|
||||
A single key (or array of keys) that should be parsed as `Boolean`s.
|
||||
|
||||
#### options.default
|
||||
Type: `Object`<br>
|
||||
Default: `{}`
|
||||
|
||||
An `key:value` object of defaults. If a default is provided for a key, its type (`typeof`) will be used to cast parsed arguments.
|
||||
|
||||
```js
|
||||
mri(['--foo', 'bar']);
|
||||
//=> { _:[], foo:'bar' }
|
||||
|
||||
mri(['--foo', 'bar'], {
|
||||
default: { foo:true, baz:'hello', bat:42 }
|
||||
});
|
||||
//=> { _:['bar'], foo:true, baz:'hello', bat:42 }
|
||||
```
|
||||
|
||||
> **Note:** Because `--foo` has a default of `true`, its output is cast to a Boolean. This means that `foo=true`, making `'bar'` an extra argument (`_` key).
|
||||
|
||||
#### options.string
|
||||
Type: `Array|String`<br>
|
||||
Default: `[]`
|
||||
|
||||
A single key (or array of keys) that should be parsed as `String`s.
|
||||
|
||||
#### options.unknown
|
||||
Type: `Function`<br>
|
||||
Default: `undefined`
|
||||
|
||||
Callback that is run when a parsed flag has not been defined as a known key or alias. Its only parameter is the unknown flag itself; eg `--foobar` or `-f`.
|
||||
|
||||
Once an unknown flag is encountered, parsing will terminate, regardless of your return value.
|
||||
|
||||
> **Note:** `mri` _only_ checks for unknown flags if `options.unknown` **and** `options.alias` are populated. Otherwise, everything will be accepted.
|
||||
|
||||
|
||||
## Comparisons
|
||||
|
||||
#### minimist
|
||||
|
||||
- `mri` is 5x faster (see [benchmarks](#benchmarks))
|
||||
- Numerical values are cast as `Number`s when possible
|
||||
- A key (and its aliases) will always honor `opts.boolean` or `opts.string`
|
||||
- Short flag groups are treated as `Boolean`s by default:
|
||||
```js
|
||||
minimist(['-abc', 'hello']);
|
||||
//=> { _:[], a:'', b:'', c:'hello' }
|
||||
|
||||
mri(['-abc', 'hello']);
|
||||
//=> { _:[], a:true, b:true, c:'hello' }
|
||||
```
|
||||
- The `opts.unknown` behaves differently:
|
||||
- Unlike `minimist`, `mri` will not continue continue parsing after encountering an unknown flag
|
||||
- Missing `options`:
|
||||
- `opts.stopEarly`
|
||||
- `opts['--']`
|
||||
- Ignores newlines (`\n`) within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L69-L80))
|
||||
- Ignores slashBreaks within args (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L147-L157))
|
||||
- Ignores dot-nested flags (see [test](https://github.com/substack/minimist/blob/master/test/parse.js#L180-L197))
|
||||
|
||||
#### yargs-parser
|
||||
|
||||
- `mri` is 40x faster (see [benchmarks](#benchmarks))
|
||||
- Numerical values are cast as `Number`s when possible
|
||||
- A key (and its aliases) will always honor `opts.boolean` or `opts.string`
|
||||
- Missing `options`:
|
||||
- `opts.array`
|
||||
- `opts.config`
|
||||
- `opts.coerce`
|
||||
- `opts.count`
|
||||
- `opts.envPrefix`
|
||||
- `opts.narg`
|
||||
- `opts.normalize`
|
||||
- `opts.configuration`
|
||||
- `opts.number`
|
||||
- `opts['--']`
|
||||
- Missing [`parser.detailed()`](https://github.com/yargs/yargs-parser#requireyargs-parserdetailedargs-opts) method
|
||||
- No [additional configuration](https://github.com/yargs/yargs-parser#configuration) object
|
||||
- Added [`options.unknown`](#optionsunknown) feature
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
> Running Node.js v10.13.0
|
||||
|
||||
```
|
||||
Load Times:
|
||||
nopt 3.179ms
|
||||
yargs-parser 2.137ms
|
||||
minimist 0.746ms
|
||||
mri 0.517ms
|
||||
|
||||
Benchmark:
|
||||
minimist x 328,747 ops/sec ±1.09% (89 runs sampled)
|
||||
mri x 1,622,801 ops/sec ±0.94% (92 runs sampled)
|
||||
nopt x 888,223 ops/sec ±0.22% (92 runs sampled)
|
||||
yargs-parser x 30,538 ops/sec ±0.81% (91 runs sampled)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
Reference in New Issue
Block a user