hi
This commit is contained in:
parent
865eddfed5
commit
01489ab2d9
1
node_modules/.bin/cssesc
generated
vendored
Symbolic link
1
node_modules/.bin/cssesc
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../cssesc/bin/cssesc
|
1
node_modules/.bin/glob
generated
vendored
Symbolic link
1
node_modules/.bin/glob
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../glob/dist/esm/bin.mjs
|
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
1
node_modules/.bin/nanoid
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../nanoid/bin/nanoid.cjs
|
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
1
node_modules/.bin/node-which
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../which/bin/node-which
|
1
node_modules/.bin/postcss
generated
vendored
Symbolic link
1
node_modules/.bin/postcss
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../postcss-cli/index.js
|
1
node_modules/.bin/prettier
generated
vendored
Symbolic link
1
node_modules/.bin/prettier
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../prettier/bin/prettier.cjs
|
1
node_modules/.bin/purgecss
generated
vendored
Symbolic link
1
node_modules/.bin/purgecss
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../purgecss/bin/purgecss.js
|
1
node_modules/.bin/ulid
generated
vendored
Symbolic link
1
node_modules/.bin/ulid
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../ulid/bin/cli.js
|
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
1
node_modules/.bin/yaml
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../yaml/bin.mjs
|
1237
node_modules/.package-lock.json
generated
vendored
Normal file
1237
node_modules/.package-lock.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
139
node_modules/@fullhuman/postcss-purgecss/README.md
generated
vendored
Normal file
139
node_modules/@fullhuman/postcss-purgecss/README.md
generated
vendored
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
# PostCSS Purgecss
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
[PostCSS] plugin for PurgeCSS.
|
||||||
|
|
||||||
|
[PostCSS]: https://github.com/postcss/postcss
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
npm i -D @fullhuman/postcss-purgecss postcss
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const purgecss = require('@fullhuman/postcss-purgecss')
|
||||||
|
postcss([
|
||||||
|
purgecss({
|
||||||
|
content: ['./src/**/*.html']
|
||||||
|
})
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
See [PostCSS] docs for examples for your environment.
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
All of the options of purgecss are available to use with the plugins.
|
||||||
|
You will find below the main options available. For the complete list, go to the [purgecss documentation website](https://www.purgecss.com/configuration.html#options).
|
||||||
|
|
||||||
|
### `content` (**required** or use `contentFunction` instead)
|
||||||
|
Type: `Array<string>`
|
||||||
|
|
||||||
|
You can specify content that should be analyzed by Purgecss with an array of filenames or globs. The files can be HTML, Pug, Blade, etc.
|
||||||
|
|
||||||
|
### `contentFunction` (as alternative to `content`)
|
||||||
|
Type: `(sourceInputFile: string) => Array<string>`
|
||||||
|
|
||||||
|
The function receives the current source input file. With this you may provide a specific array of globs for each input. E.g. for
|
||||||
|
an angular application only scan the components template counterpart for every component scss file:
|
||||||
|
|
||||||
|
```js
|
||||||
|
purgecss({
|
||||||
|
contentFunction: (sourceInputFileName: string) => {
|
||||||
|
if (/component\.scss$/.test(sourceInputFileName))
|
||||||
|
return [sourceInputFileName.replace(/scss$/, 'html')]
|
||||||
|
else
|
||||||
|
return ['./src/**/*.html']
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### `extractors`
|
||||||
|
Type: `Array<Object>`
|
||||||
|
|
||||||
|
Purgecss can be adapted to suit your needs. If you notice a lot of unused CSS is not being removed, you might want to use a custom extractor.
|
||||||
|
More information about extractors [here](https://www.purgecss.com/extractors.html).
|
||||||
|
|
||||||
|
### `safelist`
|
||||||
|
|
||||||
|
You can indicate which selectors are safe to leave in the final CSS. This can be accomplished with the option `safelist`.
|
||||||
|
|
||||||
|
Two forms are available for this option.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
safelist: ['random', 'yep', 'button', /^nav-/]
|
||||||
|
```
|
||||||
|
|
||||||
|
In this form, safelist is an array that can take a string or a regex.
|
||||||
|
|
||||||
|
The _complex_ form is:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
safelist: {
|
||||||
|
standard: ['random', 'yep', 'button', /^nav-/],
|
||||||
|
deep: [],
|
||||||
|
greedy: [],
|
||||||
|
keyframes: [],
|
||||||
|
variables: []
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `blocklist`
|
||||||
|
|
||||||
|
Blocklist will block the CSS selectors from appearing in the final output CSS. The selectors will be removed even when they are seen as used by PurgeCSS.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
blocklist: ['usedClass', /^nav-/]
|
||||||
|
```
|
||||||
|
Even if nav-links and usedClass are found by an extractor, they will be removed.
|
||||||
|
|
||||||
|
### `skippedContentGlobs`
|
||||||
|
|
||||||
|
If you provide globs for the `content` parameter, you can use this option to exclude certain files or folders that would otherwise be scanned. Pass an array of globs matching items that should be excluded. (Note: this option has no effect if `content` is not globs.)
|
||||||
|
|
||||||
|
```ts
|
||||||
|
skippedContentGlobs: ['node_modules/**', 'components/**']
|
||||||
|
```
|
||||||
|
Here, PurgeCSS will not scan anything in the "node_modules" and "components" folders.
|
||||||
|
|
||||||
|
|
||||||
|
### `rejected`
|
||||||
|
Type: `boolean`
|
||||||
|
Default value: `false`
|
||||||
|
|
||||||
|
If true, purged selectors will be captured and rendered as PostCSS messages.
|
||||||
|
Use with a PostCSS reporter plugin like [`postcss-reporter`](https://github.com/postcss/postcss-reporter)
|
||||||
|
to print the purged selectors to the console as they are processed.
|
||||||
|
|
||||||
|
### `keyframes`
|
||||||
|
Type: `boolean`
|
||||||
|
Default value: `false`
|
||||||
|
|
||||||
|
If you are using a CSS animation library such as animate.css, you can remove unused keyframes by setting the keyframes option to true.
|
||||||
|
|
||||||
|
#### `fontFace`
|
||||||
|
Type: `boolean`
|
||||||
|
Default value: `false`
|
||||||
|
|
||||||
|
If there are any unused @font-face rules in your css, you can remove them by setting the fontFace option to true.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Please read [CONTRIBUTING.md](./../../CONTRIBUTING.md) for details on our code of
|
||||||
|
conduct, and the process for submitting pull requests to us.
|
||||||
|
|
||||||
|
## Versioning
|
||||||
|
|
||||||
|
postcss-purgecss use [SemVer](http://semver.org/) for versioning.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License - see the [LICENSE](./../../LICENSE) file
|
||||||
|
for details.
|
164
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.d.ts
generated
vendored
Normal file
164
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.d.ts
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
/**
|
||||||
|
* PostCSS Plugin for PurgeCSS
|
||||||
|
*
|
||||||
|
* Most bundlers and frameworks to build websites are using PostCSS.
|
||||||
|
* The easiest way to configure PurgeCSS is with its PostCSS plugin.
|
||||||
|
*
|
||||||
|
* @packageDocumentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
import * as postcss from 'postcss';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare type ComplexSafelist = {
|
||||||
|
standard?: StringRegExpArray;
|
||||||
|
/**
|
||||||
|
* You can safelist selectors and their children based on a regular
|
||||||
|
* expression with `safelist.deep`
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const purgecss = await new PurgeCSS().purge({
|
||||||
|
* content: [],
|
||||||
|
* css: [],
|
||||||
|
* safelist: {
|
||||||
|
* deep: [/red$/]
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* In this example, selectors such as `.bg-red .child-of-bg` will be left
|
||||||
|
* in the final CSS, even if `child-of-bg` is not found.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
deep?: RegExp[];
|
||||||
|
greedy?: RegExp[];
|
||||||
|
variables?: StringRegExpArray;
|
||||||
|
keyframes?: StringRegExpArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare type ExtractorFunction<T = string> = (content: T) => ExtractorResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare type ExtractorResult = ExtractorResultDetailed | string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface ExtractorResultDetailed {
|
||||||
|
attributes: {
|
||||||
|
names: string[];
|
||||||
|
values: string[];
|
||||||
|
};
|
||||||
|
classes: string[];
|
||||||
|
ids: string[];
|
||||||
|
tags: string[];
|
||||||
|
undetermined: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface Extractors {
|
||||||
|
extensions: string[];
|
||||||
|
extractor: ExtractorFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PostCSS Plugin for PurgeCSS
|
||||||
|
*
|
||||||
|
* @param opts - PurgeCSS Options
|
||||||
|
* @returns the postCSS plugin
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
declare const purgeCSSPlugin: postcss.PluginCreator<UserDefinedOptions>;
|
||||||
|
export default purgeCSSPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used by PurgeCSS to remove unused CSS
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface PurgeCSSUserDefinedOptions {
|
||||||
|
/** {@inheritDoc purgecss#Options.content} */
|
||||||
|
content: Array<string | RawContent>;
|
||||||
|
/** {@inheritDoc purgecss#Options.css} */
|
||||||
|
css: Array<string | RawCSS>;
|
||||||
|
/** {@inheritDoc purgecss#Options.defaultExtractor} */
|
||||||
|
defaultExtractor?: ExtractorFunction;
|
||||||
|
/** {@inheritDoc purgecss#Options.extractors} */
|
||||||
|
extractors?: Array<Extractors>;
|
||||||
|
/** {@inheritDoc purgecss#Options.fontFace} */
|
||||||
|
fontFace?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.keyframes} */
|
||||||
|
keyframes?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.output} */
|
||||||
|
output?: string;
|
||||||
|
/** {@inheritDoc purgecss#Options.rejected} */
|
||||||
|
rejected?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.rejectedCss} */
|
||||||
|
rejectedCss?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.sourceMap } */
|
||||||
|
sourceMap?: boolean | (postcss.SourceMapOptions & { to?: string });
|
||||||
|
/** {@inheritDoc purgecss#Options.stdin} */
|
||||||
|
stdin?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.stdout} */
|
||||||
|
stdout?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.variables} */
|
||||||
|
variables?: boolean;
|
||||||
|
/** {@inheritDoc purgecss#Options.safelist} */
|
||||||
|
safelist?: UserDefinedSafelist;
|
||||||
|
/** {@inheritDoc purgecss#Options.blocklist} */
|
||||||
|
blocklist?: StringRegExpArray;
|
||||||
|
/** {@inheritDoc purgecss#Options.skippedContentGlobs} */
|
||||||
|
skippedContentGlobs?: Array<string>;
|
||||||
|
/** {@inheritDoc purgecss#Options.dynamicAttributes} */
|
||||||
|
dynamicAttributes?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface RawContent<T = string> {
|
||||||
|
extension: string;
|
||||||
|
raw: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface RawCSS {
|
||||||
|
raw: string;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare type StringRegExpArray = Array<RegExp | string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc purgecss#UserDefinedOptions}
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare interface UserDefinedOptions extends Omit<PurgeCSSUserDefinedOptions, "content" | "css"> {
|
||||||
|
content?: PurgeCSSUserDefinedOptions["content"];
|
||||||
|
contentFunction?: (sourceFile: string) => Array<string | RawContent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export declare type UserDefinedSafelist = StringRegExpArray | ComplexSafelist;
|
||||||
|
|
||||||
|
export { }
|
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.esm.js
generated
vendored
Normal file
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.esm.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
import*as e from"path";import{PurgeCSS as s,defaultOptions as t,standardizeSafelist as o,mergeExtractorSelectors as r}from"purgecss";const n=function(n){if(void 0===n)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(c,i)=>async function(n,c,{result:i}){const a=new s;let l;try{const s=e.resolve(process.cwd(),"purgecss.config.js");l=await import(s)}catch{}const p={...t,...l,...n,safelist:o((null==n?void 0:n.safelist)||(null==l?void 0:l.safelist))};n&&"function"==typeof n.contentFunction&&(p.content=n.contentFunction(c.source&&c.source.input.file||"")),a.options=p,p.variables&&(a.variablesStructure.safelist=p.safelist.variables||[]);const{content:u,extractors:f}=p,m=u.filter((e=>"string"==typeof e)),g=u.filter((e=>"object"==typeof e)),v=await a.extractSelectorsFromFiles(m,f),d=await a.extractSelectorsFromString(g,f),S=r(v,d);a.walkThroughCSS(c,S),a.options.fontFace&&a.removeUnusedFontFaces(),a.options.keyframes&&a.removeUnusedKeyframes(),a.options.variables&&a.removeUnusedCSSVariables(),a.options.rejected&&a.selectorsRemoved.size>0&&(i.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${a.selectorsRemoved.size} selectors:\n ${Array.from(a.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),a.selectorsRemoved.clear())}(n,c,i)}};n.postcss=!0;export{n as default};
|
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.js
generated
vendored
Normal file
1
node_modules/@fullhuman/postcss-purgecss/lib/postcss-purgecss.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
"use strict";var e=require("path"),t=require("purgecss");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s=r(e);const o=function(e){if(void 0===e)throw new Error("PurgeCSS plugin does not have the correct options");return{postcssPlugin:"postcss-purgecss",OnceExit:(o,n)=>async function(e,o,{result:n}){const c=new t.PurgeCSS;let i;try{const e=s.resolve(process.cwd(),"purgecss.config.js");i=await function(e){return Promise.resolve().then((function(){return r(require(e))}))}(e)}catch{}const a={...t.defaultOptions,...i,...e,safelist:t.standardizeSafelist((null==e?void 0:e.safelist)||(null==i?void 0:i.safelist))};e&&"function"==typeof e.contentFunction&&(a.content=e.contentFunction(o.source&&o.source.input.file||"")),c.options=a,a.variables&&(c.variablesStructure.safelist=a.safelist.variables||[]);const{content:u,extractors:l}=a,f=u.filter((e=>"string"==typeof e)),p=u.filter((e=>"object"==typeof e)),d=await c.extractSelectorsFromFiles(f,l),g=await c.extractSelectorsFromString(p,l),v=t.mergeExtractorSelectors(d,g);c.walkThroughCSS(o,v),c.options.fontFace&&c.removeUnusedFontFaces(),c.options.keyframes&&c.removeUnusedKeyframes(),c.options.variables&&c.removeUnusedCSSVariables(),c.options.rejected&&c.selectorsRemoved.size>0&&(n.messages.push({type:"purgecss",plugin:"postcss-purgecss",text:`purging ${c.selectorsRemoved.size} selectors:\n ${Array.from(c.selectorsRemoved).map((e=>e.trim())).join("\n ")}`}),c.selectorsRemoved.clear())}(e,o,n)}};o.postcss=!0,module.exports=o;
|
42
node_modules/@fullhuman/postcss-purgecss/package.json
generated
vendored
Normal file
42
node_modules/@fullhuman/postcss-purgecss/package.json
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "@fullhuman/postcss-purgecss",
|
||||||
|
"version": "6.0.0",
|
||||||
|
"description": "PostCSS plugin for PurgeCSS",
|
||||||
|
"author": "FoundrySH <no-reply@foundry.sh>",
|
||||||
|
"homepage": "https://purgecss.com",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/postcss-purgecss.js",
|
||||||
|
"module": "lib/postcss-purgecss.esm.js",
|
||||||
|
"types": "lib/postcss-purgecss.d.ts",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/FullHuman/purgecss.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "ts-node build.ts",
|
||||||
|
"test": "jest"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/FullHuman/purgecss/issues"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"purgecss": "^6.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"postcss": "^8.4.4"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"postcss": "^8.0.0"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public",
|
||||||
|
"registry": "https://registry.npmjs.org/"
|
||||||
|
}
|
||||||
|
}
|
14
node_modules/@isaacs/cliui/LICENSE.txt
generated
vendored
Normal file
14
node_modules/@isaacs/cliui/LICENSE.txt
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Copyright (c) 2015, Contributors
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
|
for any purpose with or without fee is hereby granted, provided
|
||||||
|
that the above copyright notice and this permission notice
|
||||||
|
appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||||
|
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||||
|
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||||
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
143
node_modules/@isaacs/cliui/README.md
generated
vendored
Normal file
143
node_modules/@isaacs/cliui/README.md
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
# @isaacs/cliui
|
||||||
|
|
||||||
|
Temporary fork of [cliui](http://npm.im/cliui).
|
||||||
|
|
||||||
|

|
||||||
|
[](https://www.npmjs.com/package/cliui)
|
||||||
|
[](https://conventionalcommits.org)
|
||||||
|

|
||||||
|
|
||||||
|
easily create complex multi-column command-line-interfaces.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ui = require('cliui')()
|
||||||
|
|
||||||
|
ui.div('Usage: $0 [command] [options]')
|
||||||
|
|
||||||
|
ui.div({
|
||||||
|
text: 'Options:',
|
||||||
|
padding: [2, 0, 1, 0]
|
||||||
|
})
|
||||||
|
|
||||||
|
ui.div(
|
||||||
|
{
|
||||||
|
text: "-f, --file",
|
||||||
|
width: 20,
|
||||||
|
padding: [0, 4, 0, 4]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "the file to load." +
|
||||||
|
chalk.green("(if this description is long it wraps).")
|
||||||
|
,
|
||||||
|
width: 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: chalk.red("[required]"),
|
||||||
|
align: 'right'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(ui.toString())
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deno/ESM Support
|
||||||
|
|
||||||
|
As of `v7` `cliui` supports [Deno](https://github.com/denoland/deno) and
|
||||||
|
[ESM](https://nodejs.org/api/esm.html#esm_ecmascript_modules):
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import cliui from "https://deno.land/x/cliui/deno.ts";
|
||||||
|
|
||||||
|
const ui = cliui({})
|
||||||
|
|
||||||
|
ui.div('Usage: $0 [command] [options]')
|
||||||
|
|
||||||
|
ui.div({
|
||||||
|
text: 'Options:',
|
||||||
|
padding: [2, 0, 1, 0]
|
||||||
|
})
|
||||||
|
|
||||||
|
ui.div({
|
||||||
|
text: "-f, --file",
|
||||||
|
width: 20,
|
||||||
|
padding: [0, 4, 0, 4]
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(ui.toString())
|
||||||
|
```
|
||||||
|
|
||||||
|
<img width="500" src="screenshot.png">
|
||||||
|
|
||||||
|
## Layout DSL
|
||||||
|
|
||||||
|
cliui exposes a simple layout DSL:
|
||||||
|
|
||||||
|
If you create a single `ui.div`, passing a string rather than an
|
||||||
|
object:
|
||||||
|
|
||||||
|
* `\n`: characters will be interpreted as new rows.
|
||||||
|
* `\t`: characters will be interpreted as new columns.
|
||||||
|
* `\s`: characters will be interpreted as padding.
|
||||||
|
|
||||||
|
**as an example...**
|
||||||
|
|
||||||
|
```js
|
||||||
|
var ui = require('./')({
|
||||||
|
width: 60
|
||||||
|
})
|
||||||
|
|
||||||
|
ui.div(
|
||||||
|
'Usage: node ./bin/foo.js\n' +
|
||||||
|
' <regex>\t provide a regex\n' +
|
||||||
|
' <glob>\t provide a glob\t [required]'
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(ui.toString())
|
||||||
|
```
|
||||||
|
|
||||||
|
**will output:**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
Usage: node ./bin/foo.js
|
||||||
|
<regex> provide a regex
|
||||||
|
<glob> provide a glob [required]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
```js
|
||||||
|
cliui = require('cliui')
|
||||||
|
```
|
||||||
|
|
||||||
|
### cliui({width: integer})
|
||||||
|
|
||||||
|
Specify the maximum width of the UI being generated.
|
||||||
|
If no width is provided, cliui will try to get the current window's width and use it, and if that doesn't work, width will be set to `80`.
|
||||||
|
|
||||||
|
### cliui({wrap: boolean})
|
||||||
|
|
||||||
|
Enable or disable the wrapping of text in a column.
|
||||||
|
|
||||||
|
### cliui.div(column, column, column)
|
||||||
|
|
||||||
|
Create a row with any number of columns, a column
|
||||||
|
can either be a string, or an object with the following
|
||||||
|
options:
|
||||||
|
|
||||||
|
* **text:** some text to place in the column.
|
||||||
|
* **width:** the width of a column.
|
||||||
|
* **align:** alignment, `right` or `center`.
|
||||||
|
* **padding:** `[top, right, bottom, left]`.
|
||||||
|
* **border:** should a border be placed around the div?
|
||||||
|
|
||||||
|
### cliui.span(column, column, column)
|
||||||
|
|
||||||
|
Similar to `div`, except the next row will be appended without
|
||||||
|
a new line being created.
|
||||||
|
|
||||||
|
### cliui.resetOutput()
|
||||||
|
|
||||||
|
Resets the UI elements of the current cliui instance, maintaining the values
|
||||||
|
set for `width` and `wrap`.
|
317
node_modules/@isaacs/cliui/build/index.cjs
generated
vendored
Normal file
317
node_modules/@isaacs/cliui/build/index.cjs
generated
vendored
Normal file
@ -0,0 +1,317 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const align = {
|
||||||
|
right: alignRight,
|
||||||
|
center: alignCenter
|
||||||
|
};
|
||||||
|
const top = 0;
|
||||||
|
const right = 1;
|
||||||
|
const bottom = 2;
|
||||||
|
const left = 3;
|
||||||
|
class UI {
|
||||||
|
constructor(opts) {
|
||||||
|
var _a;
|
||||||
|
this.width = opts.width;
|
||||||
|
/* c8 ignore start */
|
||||||
|
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
this.rows = [];
|
||||||
|
}
|
||||||
|
span(...args) {
|
||||||
|
const cols = this.div(...args);
|
||||||
|
cols.span = true;
|
||||||
|
}
|
||||||
|
resetOutput() {
|
||||||
|
this.rows = [];
|
||||||
|
}
|
||||||
|
div(...args) {
|
||||||
|
if (args.length === 0) {
|
||||||
|
this.div('');
|
||||||
|
}
|
||||||
|
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||||
|
return this.applyLayoutDSL(args[0]);
|
||||||
|
}
|
||||||
|
const cols = args.map(arg => {
|
||||||
|
if (typeof arg === 'string') {
|
||||||
|
return this.colFromString(arg);
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
});
|
||||||
|
this.rows.push(cols);
|
||||||
|
return cols;
|
||||||
|
}
|
||||||
|
shouldApplyLayoutDSL(...args) {
|
||||||
|
return args.length === 1 && typeof args[0] === 'string' &&
|
||||||
|
/[\t\n]/.test(args[0]);
|
||||||
|
}
|
||||||
|
applyLayoutDSL(str) {
|
||||||
|
const rows = str.split('\n').map(row => row.split('\t'));
|
||||||
|
let leftColumnWidth = 0;
|
||||||
|
// simple heuristic for layout, make sure the
|
||||||
|
// second column lines up along the left-hand.
|
||||||
|
// don't allow the first column to take up more
|
||||||
|
// than 50% of the screen.
|
||||||
|
rows.forEach(columns => {
|
||||||
|
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||||
|
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// generate a table:
|
||||||
|
// replacing ' ' with padding calculations.
|
||||||
|
// using the algorithmically generated width.
|
||||||
|
rows.forEach(columns => {
|
||||||
|
this.div(...columns.map((r, i) => {
|
||||||
|
return {
|
||||||
|
text: r.trim(),
|
||||||
|
padding: this.measurePadding(r),
|
||||||
|
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
return this.rows[this.rows.length - 1];
|
||||||
|
}
|
||||||
|
colFromString(text) {
|
||||||
|
return {
|
||||||
|
text,
|
||||||
|
padding: this.measurePadding(text)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
measurePadding(str) {
|
||||||
|
// measure padding without ansi escape codes
|
||||||
|
const noAnsi = mixin.stripAnsi(str);
|
||||||
|
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||||
|
}
|
||||||
|
toString() {
|
||||||
|
const lines = [];
|
||||||
|
this.rows.forEach(row => {
|
||||||
|
this.rowToString(row, lines);
|
||||||
|
});
|
||||||
|
// don't display any lines with the
|
||||||
|
// hidden flag set.
|
||||||
|
return lines
|
||||||
|
.filter(line => !line.hidden)
|
||||||
|
.map(line => line.text)
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
|
rowToString(row, lines) {
|
||||||
|
this.rasterize(row).forEach((rrow, r) => {
|
||||||
|
let str = '';
|
||||||
|
rrow.forEach((col, c) => {
|
||||||
|
const { width } = row[c]; // the width with padding.
|
||||||
|
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||||
|
let ts = col; // temporary string used during alignment/padding.
|
||||||
|
if (wrapWidth > mixin.stringWidth(col)) {
|
||||||
|
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||||
|
}
|
||||||
|
// align the string within its column.
|
||||||
|
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||||
|
const fn = align[row[c].align];
|
||||||
|
ts = fn(ts, wrapWidth);
|
||||||
|
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||||
|
/* c8 ignore start */
|
||||||
|
const w = width || 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// apply border and padding to string.
|
||||||
|
const padding = row[c].padding || [0, 0, 0, 0];
|
||||||
|
if (padding[left]) {
|
||||||
|
str += ' '.repeat(padding[left]);
|
||||||
|
}
|
||||||
|
str += addBorder(row[c], ts, '| ');
|
||||||
|
str += ts;
|
||||||
|
str += addBorder(row[c], ts, ' |');
|
||||||
|
if (padding[right]) {
|
||||||
|
str += ' '.repeat(padding[right]);
|
||||||
|
}
|
||||||
|
// if prior row is span, try to render the
|
||||||
|
// current row on the prior line.
|
||||||
|
if (r === 0 && lines.length > 0) {
|
||||||
|
str = this.renderInline(str, lines[lines.length - 1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// remove trailing whitespace.
|
||||||
|
lines.push({
|
||||||
|
text: str.replace(/ +$/, ''),
|
||||||
|
span: row.span
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
// if the full 'source' can render in
|
||||||
|
// the target line, do so.
|
||||||
|
renderInline(source, previousLine) {
|
||||||
|
const match = source.match(/^ */);
|
||||||
|
/* c8 ignore start */
|
||||||
|
const leadingWhitespace = match ? match[0].length : 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
const target = previousLine.text;
|
||||||
|
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
||||||
|
if (!previousLine.span) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
// if we're not applying wrapping logic,
|
||||||
|
// just always append to the span.
|
||||||
|
if (!this.wrap) {
|
||||||
|
previousLine.hidden = true;
|
||||||
|
return target + source;
|
||||||
|
}
|
||||||
|
if (leadingWhitespace < targetTextWidth) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
previousLine.hidden = true;
|
||||||
|
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
||||||
|
}
|
||||||
|
rasterize(row) {
|
||||||
|
const rrows = [];
|
||||||
|
const widths = this.columnWidths(row);
|
||||||
|
let wrapped;
|
||||||
|
// word wrap all columns, and create
|
||||||
|
// a data-structure that is easy to rasterize.
|
||||||
|
row.forEach((col, c) => {
|
||||||
|
// leave room for left and right padding.
|
||||||
|
col.width = widths[c];
|
||||||
|
if (this.wrap) {
|
||||||
|
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrapped = col.text.split('\n');
|
||||||
|
}
|
||||||
|
if (col.border) {
|
||||||
|
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||||
|
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||||
|
}
|
||||||
|
// add top and bottom padding.
|
||||||
|
if (col.padding) {
|
||||||
|
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||||
|
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||||
|
}
|
||||||
|
wrapped.forEach((str, r) => {
|
||||||
|
if (!rrows[r]) {
|
||||||
|
rrows.push([]);
|
||||||
|
}
|
||||||
|
const rrow = rrows[r];
|
||||||
|
for (let i = 0; i < c; i++) {
|
||||||
|
if (rrow[i] === undefined) {
|
||||||
|
rrow.push('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rrow.push(str);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return rrows;
|
||||||
|
}
|
||||||
|
negatePadding(col) {
|
||||||
|
/* c8 ignore start */
|
||||||
|
let wrapWidth = col.width || 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
if (col.padding) {
|
||||||
|
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||||
|
}
|
||||||
|
if (col.border) {
|
||||||
|
wrapWidth -= 4;
|
||||||
|
}
|
||||||
|
return wrapWidth;
|
||||||
|
}
|
||||||
|
columnWidths(row) {
|
||||||
|
if (!this.wrap) {
|
||||||
|
return row.map(col => {
|
||||||
|
return col.width || mixin.stringWidth(col.text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let unset = row.length;
|
||||||
|
let remainingWidth = this.width;
|
||||||
|
// column widths can be set in config.
|
||||||
|
const widths = row.map(col => {
|
||||||
|
if (col.width) {
|
||||||
|
unset--;
|
||||||
|
remainingWidth -= col.width;
|
||||||
|
return col.width;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
// any unset widths should be calculated.
|
||||||
|
/* c8 ignore start */
|
||||||
|
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
return widths.map((w, i) => {
|
||||||
|
if (w === undefined) {
|
||||||
|
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function addBorder(col, ts, style) {
|
||||||
|
if (col.border) {
|
||||||
|
if (/[.']-+[.']/.test(ts)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (ts.trim().length !== 0) {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// calculates the minimum width of
|
||||||
|
// a column, based on padding preferences.
|
||||||
|
function _minWidth(col) {
|
||||||
|
const padding = col.padding || [];
|
||||||
|
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||||
|
if (col.border) {
|
||||||
|
return minWidth + 4;
|
||||||
|
}
|
||||||
|
return minWidth;
|
||||||
|
}
|
||||||
|
function getWindowWidth() {
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||||
|
return process.stdout.columns;
|
||||||
|
}
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
function alignRight(str, width) {
|
||||||
|
str = str.trim();
|
||||||
|
const strWidth = mixin.stringWidth(str);
|
||||||
|
if (strWidth < width) {
|
||||||
|
return ' '.repeat(width - strWidth) + str;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
function alignCenter(str, width) {
|
||||||
|
str = str.trim();
|
||||||
|
const strWidth = mixin.stringWidth(str);
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (strWidth >= width) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||||
|
}
|
||||||
|
let mixin;
|
||||||
|
function cliui(opts, _mixin) {
|
||||||
|
mixin = _mixin;
|
||||||
|
return new UI({
|
||||||
|
/* c8 ignore start */
|
||||||
|
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||||
|
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||||
|
/* c8 ignore stop */
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap cliui with CommonJS dependencies:
|
||||||
|
const stringWidth = require('string-width-cjs');
|
||||||
|
const stripAnsi = require('strip-ansi-cjs');
|
||||||
|
const wrap = require('wrap-ansi-cjs');
|
||||||
|
function ui(opts) {
|
||||||
|
return cliui(opts, {
|
||||||
|
stringWidth,
|
||||||
|
stripAnsi,
|
||||||
|
wrap
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = ui;
|
43
node_modules/@isaacs/cliui/build/index.d.cts
generated
vendored
Normal file
43
node_modules/@isaacs/cliui/build/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
interface UIOptions {
|
||||||
|
width: number;
|
||||||
|
wrap?: boolean;
|
||||||
|
rows?: string[];
|
||||||
|
}
|
||||||
|
interface Column {
|
||||||
|
text: string;
|
||||||
|
width?: number;
|
||||||
|
align?: "right" | "left" | "center";
|
||||||
|
padding: number[];
|
||||||
|
border?: boolean;
|
||||||
|
}
|
||||||
|
interface ColumnArray extends Array<Column> {
|
||||||
|
span: boolean;
|
||||||
|
}
|
||||||
|
interface Line {
|
||||||
|
hidden?: boolean;
|
||||||
|
text: string;
|
||||||
|
span?: boolean;
|
||||||
|
}
|
||||||
|
declare class UI {
|
||||||
|
width: number;
|
||||||
|
wrap: boolean;
|
||||||
|
rows: ColumnArray[];
|
||||||
|
constructor(opts: UIOptions);
|
||||||
|
span(...args: ColumnArray): void;
|
||||||
|
resetOutput(): void;
|
||||||
|
div(...args: (Column | string)[]): ColumnArray;
|
||||||
|
private shouldApplyLayoutDSL;
|
||||||
|
private applyLayoutDSL;
|
||||||
|
private colFromString;
|
||||||
|
private measurePadding;
|
||||||
|
toString(): string;
|
||||||
|
rowToString(row: ColumnArray, lines: Line[]): Line[];
|
||||||
|
// if the full 'source' can render in
|
||||||
|
// the target line, do so.
|
||||||
|
private renderInline;
|
||||||
|
private rasterize;
|
||||||
|
private negatePadding;
|
||||||
|
private columnWidths;
|
||||||
|
}
|
||||||
|
declare function ui(opts: UIOptions): UI;
|
||||||
|
export { ui as default };
|
302
node_modules/@isaacs/cliui/build/lib/index.js
generated
vendored
Normal file
302
node_modules/@isaacs/cliui/build/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
'use strict';
|
||||||
|
const align = {
|
||||||
|
right: alignRight,
|
||||||
|
center: alignCenter
|
||||||
|
};
|
||||||
|
const top = 0;
|
||||||
|
const right = 1;
|
||||||
|
const bottom = 2;
|
||||||
|
const left = 3;
|
||||||
|
export class UI {
|
||||||
|
constructor(opts) {
|
||||||
|
var _a;
|
||||||
|
this.width = opts.width;
|
||||||
|
/* c8 ignore start */
|
||||||
|
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
this.rows = [];
|
||||||
|
}
|
||||||
|
span(...args) {
|
||||||
|
const cols = this.div(...args);
|
||||||
|
cols.span = true;
|
||||||
|
}
|
||||||
|
resetOutput() {
|
||||||
|
this.rows = [];
|
||||||
|
}
|
||||||
|
div(...args) {
|
||||||
|
if (args.length === 0) {
|
||||||
|
this.div('');
|
||||||
|
}
|
||||||
|
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === 'string') {
|
||||||
|
return this.applyLayoutDSL(args[0]);
|
||||||
|
}
|
||||||
|
const cols = args.map(arg => {
|
||||||
|
if (typeof arg === 'string') {
|
||||||
|
return this.colFromString(arg);
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
});
|
||||||
|
this.rows.push(cols);
|
||||||
|
return cols;
|
||||||
|
}
|
||||||
|
shouldApplyLayoutDSL(...args) {
|
||||||
|
return args.length === 1 && typeof args[0] === 'string' &&
|
||||||
|
/[\t\n]/.test(args[0]);
|
||||||
|
}
|
||||||
|
applyLayoutDSL(str) {
|
||||||
|
const rows = str.split('\n').map(row => row.split('\t'));
|
||||||
|
let leftColumnWidth = 0;
|
||||||
|
// simple heuristic for layout, make sure the
|
||||||
|
// second column lines up along the left-hand.
|
||||||
|
// don't allow the first column to take up more
|
||||||
|
// than 50% of the screen.
|
||||||
|
rows.forEach(columns => {
|
||||||
|
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||||||
|
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// generate a table:
|
||||||
|
// replacing ' ' with padding calculations.
|
||||||
|
// using the algorithmically generated width.
|
||||||
|
rows.forEach(columns => {
|
||||||
|
this.div(...columns.map((r, i) => {
|
||||||
|
return {
|
||||||
|
text: r.trim(),
|
||||||
|
padding: this.measurePadding(r),
|
||||||
|
width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
return this.rows[this.rows.length - 1];
|
||||||
|
}
|
||||||
|
colFromString(text) {
|
||||||
|
return {
|
||||||
|
text,
|
||||||
|
padding: this.measurePadding(text)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
measurePadding(str) {
|
||||||
|
// measure padding without ansi escape codes
|
||||||
|
const noAnsi = mixin.stripAnsi(str);
|
||||||
|
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||||||
|
}
|
||||||
|
toString() {
|
||||||
|
const lines = [];
|
||||||
|
this.rows.forEach(row => {
|
||||||
|
this.rowToString(row, lines);
|
||||||
|
});
|
||||||
|
// don't display any lines with the
|
||||||
|
// hidden flag set.
|
||||||
|
return lines
|
||||||
|
.filter(line => !line.hidden)
|
||||||
|
.map(line => line.text)
|
||||||
|
.join('\n');
|
||||||
|
}
|
||||||
|
rowToString(row, lines) {
|
||||||
|
this.rasterize(row).forEach((rrow, r) => {
|
||||||
|
let str = '';
|
||||||
|
rrow.forEach((col, c) => {
|
||||||
|
const { width } = row[c]; // the width with padding.
|
||||||
|
const wrapWidth = this.negatePadding(row[c]); // the width without padding.
|
||||||
|
let ts = col; // temporary string used during alignment/padding.
|
||||||
|
if (wrapWidth > mixin.stringWidth(col)) {
|
||||||
|
ts += ' '.repeat(wrapWidth - mixin.stringWidth(col));
|
||||||
|
}
|
||||||
|
// align the string within its column.
|
||||||
|
if (row[c].align && row[c].align !== 'left' && this.wrap) {
|
||||||
|
const fn = align[row[c].align];
|
||||||
|
ts = fn(ts, wrapWidth);
|
||||||
|
if (mixin.stringWidth(ts) < wrapWidth) {
|
||||||
|
/* c8 ignore start */
|
||||||
|
const w = width || 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
ts += ' '.repeat(w - mixin.stringWidth(ts) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// apply border and padding to string.
|
||||||
|
const padding = row[c].padding || [0, 0, 0, 0];
|
||||||
|
if (padding[left]) {
|
||||||
|
str += ' '.repeat(padding[left]);
|
||||||
|
}
|
||||||
|
str += addBorder(row[c], ts, '| ');
|
||||||
|
str += ts;
|
||||||
|
str += addBorder(row[c], ts, ' |');
|
||||||
|
if (padding[right]) {
|
||||||
|
str += ' '.repeat(padding[right]);
|
||||||
|
}
|
||||||
|
// if prior row is span, try to render the
|
||||||
|
// current row on the prior line.
|
||||||
|
if (r === 0 && lines.length > 0) {
|
||||||
|
str = this.renderInline(str, lines[lines.length - 1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// remove trailing whitespace.
|
||||||
|
lines.push({
|
||||||
|
text: str.replace(/ +$/, ''),
|
||||||
|
span: row.span
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
// if the full 'source' can render in
|
||||||
|
// the target line, do so.
|
||||||
|
renderInline(source, previousLine) {
|
||||||
|
const match = source.match(/^ */);
|
||||||
|
/* c8 ignore start */
|
||||||
|
const leadingWhitespace = match ? match[0].length : 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
const target = previousLine.text;
|
||||||
|
const targetTextWidth = mixin.stringWidth(target.trimEnd());
|
||||||
|
if (!previousLine.span) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
// if we're not applying wrapping logic,
|
||||||
|
// just always append to the span.
|
||||||
|
if (!this.wrap) {
|
||||||
|
previousLine.hidden = true;
|
||||||
|
return target + source;
|
||||||
|
}
|
||||||
|
if (leadingWhitespace < targetTextWidth) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
previousLine.hidden = true;
|
||||||
|
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart();
|
||||||
|
}
|
||||||
|
rasterize(row) {
|
||||||
|
const rrows = [];
|
||||||
|
const widths = this.columnWidths(row);
|
||||||
|
let wrapped;
|
||||||
|
// word wrap all columns, and create
|
||||||
|
// a data-structure that is easy to rasterize.
|
||||||
|
row.forEach((col, c) => {
|
||||||
|
// leave room for left and right padding.
|
||||||
|
col.width = widths[c];
|
||||||
|
if (this.wrap) {
|
||||||
|
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split('\n');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrapped = col.text.split('\n');
|
||||||
|
}
|
||||||
|
if (col.border) {
|
||||||
|
wrapped.unshift('.' + '-'.repeat(this.negatePadding(col) + 2) + '.');
|
||||||
|
wrapped.push("'" + '-'.repeat(this.negatePadding(col) + 2) + "'");
|
||||||
|
}
|
||||||
|
// add top and bottom padding.
|
||||||
|
if (col.padding) {
|
||||||
|
wrapped.unshift(...new Array(col.padding[top] || 0).fill(''));
|
||||||
|
wrapped.push(...new Array(col.padding[bottom] || 0).fill(''));
|
||||||
|
}
|
||||||
|
wrapped.forEach((str, r) => {
|
||||||
|
if (!rrows[r]) {
|
||||||
|
rrows.push([]);
|
||||||
|
}
|
||||||
|
const rrow = rrows[r];
|
||||||
|
for (let i = 0; i < c; i++) {
|
||||||
|
if (rrow[i] === undefined) {
|
||||||
|
rrow.push('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rrow.push(str);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return rrows;
|
||||||
|
}
|
||||||
|
negatePadding(col) {
|
||||||
|
/* c8 ignore start */
|
||||||
|
let wrapWidth = col.width || 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
if (col.padding) {
|
||||||
|
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||||||
|
}
|
||||||
|
if (col.border) {
|
||||||
|
wrapWidth -= 4;
|
||||||
|
}
|
||||||
|
return wrapWidth;
|
||||||
|
}
|
||||||
|
columnWidths(row) {
|
||||||
|
if (!this.wrap) {
|
||||||
|
return row.map(col => {
|
||||||
|
return col.width || mixin.stringWidth(col.text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let unset = row.length;
|
||||||
|
let remainingWidth = this.width;
|
||||||
|
// column widths can be set in config.
|
||||||
|
const widths = row.map(col => {
|
||||||
|
if (col.width) {
|
||||||
|
unset--;
|
||||||
|
remainingWidth -= col.width;
|
||||||
|
return col.width;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
// any unset widths should be calculated.
|
||||||
|
/* c8 ignore start */
|
||||||
|
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||||||
|
/* c8 ignore stop */
|
||||||
|
return widths.map((w, i) => {
|
||||||
|
if (w === undefined) {
|
||||||
|
return Math.max(unsetWidth, _minWidth(row[i]));
|
||||||
|
}
|
||||||
|
return w;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function addBorder(col, ts, style) {
|
||||||
|
if (col.border) {
|
||||||
|
if (/[.']-+[.']/.test(ts)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
if (ts.trim().length !== 0) {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// calculates the minimum width of
|
||||||
|
// a column, based on padding preferences.
|
||||||
|
function _minWidth(col) {
|
||||||
|
const padding = col.padding || [];
|
||||||
|
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||||||
|
if (col.border) {
|
||||||
|
return minWidth + 4;
|
||||||
|
}
|
||||||
|
return minWidth;
|
||||||
|
}
|
||||||
|
function getWindowWidth() {
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (typeof process === 'object' && process.stdout && process.stdout.columns) {
|
||||||
|
return process.stdout.columns;
|
||||||
|
}
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
function alignRight(str, width) {
|
||||||
|
str = str.trim();
|
||||||
|
const strWidth = mixin.stringWidth(str);
|
||||||
|
if (strWidth < width) {
|
||||||
|
return ' '.repeat(width - strWidth) + str;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
function alignCenter(str, width) {
|
||||||
|
str = str.trim();
|
||||||
|
const strWidth = mixin.stringWidth(str);
|
||||||
|
/* c8 ignore start */
|
||||||
|
if (strWidth >= width) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
/* c8 ignore stop */
|
||||||
|
return ' '.repeat((width - strWidth) >> 1) + str;
|
||||||
|
}
|
||||||
|
let mixin;
|
||||||
|
export function cliui(opts, _mixin) {
|
||||||
|
mixin = _mixin;
|
||||||
|
return new UI({
|
||||||
|
/* c8 ignore start */
|
||||||
|
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||||||
|
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||||||
|
/* c8 ignore stop */
|
||||||
|
});
|
||||||
|
}
|
14
node_modules/@isaacs/cliui/index.mjs
generated
vendored
Normal file
14
node_modules/@isaacs/cliui/index.mjs
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Bootstrap cliui with ESM dependencies:
|
||||||
|
import { cliui } from './build/lib/index.js'
|
||||||
|
|
||||||
|
import stringWidth from 'string-width'
|
||||||
|
import stripAnsi from 'strip-ansi'
|
||||||
|
import wrap from 'wrap-ansi'
|
||||||
|
|
||||||
|
export default function ui (opts) {
|
||||||
|
return cliui(opts, {
|
||||||
|
stringWidth,
|
||||||
|
stripAnsi,
|
||||||
|
wrap
|
||||||
|
})
|
||||||
|
}
|
33
node_modules/@isaacs/cliui/node_modules/ansi-regex/index.d.ts
generated
vendored
Normal file
33
node_modules/@isaacs/cliui/node_modules/ansi-regex/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
export type Options = {
|
||||||
|
/**
|
||||||
|
Match only the first ANSI escape.
|
||||||
|
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
readonly onlyFirst: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Regular expression for matching ANSI escape codes.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import ansiRegex from 'ansi-regex';
|
||||||
|
|
||||||
|
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
ansiRegex().test('cake');
|
||||||
|
//=> false
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||||
|
//=> ['\u001B[4m', '\u001B[0m']
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||||
|
//=> ['\u001B[4m']
|
||||||
|
|
||||||
|
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||||
|
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
export default function ansiRegex(options?: Options): RegExp;
|
10
node_modules/@isaacs/cliui/node_modules/ansi-regex/index.js
generated
vendored
Normal file
10
node_modules/@isaacs/cliui/node_modules/ansi-regex/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export default function ansiRegex({onlyFirst = false} = {}) {
|
||||||
|
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
||||||
|
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
||||||
|
const pattern = [
|
||||||
|
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
||||||
|
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
|
||||||
|
].join('|');
|
||||||
|
|
||||||
|
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
||||||
|
}
|
9
node_modules/@isaacs/cliui/node_modules/ansi-regex/license
generated
vendored
Normal file
9
node_modules/@isaacs/cliui/node_modules/ansi-regex/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
61
node_modules/@isaacs/cliui/node_modules/ansi-regex/package.json
generated
vendored
Normal file
61
node_modules/@isaacs/cliui/node_modules/ansi-regex/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"name": "ansi-regex",
|
||||||
|
"version": "6.1.0",
|
||||||
|
"description": "Regular expression for matching ANSI escape codes",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/ansi-regex",
|
||||||
|
"funding": "https://github.com/chalk/ansi-regex?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"exports": "./index.js",
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"sideEffects": false,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd",
|
||||||
|
"view-supported": "node fixtures/view-codes.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cli",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"command-line",
|
||||||
|
"text",
|
||||||
|
"regex",
|
||||||
|
"regexp",
|
||||||
|
"re",
|
||||||
|
"match",
|
||||||
|
"test",
|
||||||
|
"find",
|
||||||
|
"pattern"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"ansi-escapes": "^5.0.0",
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"tsd": "^0.21.0",
|
||||||
|
"xo": "^0.54.2"
|
||||||
|
}
|
||||||
|
}
|
60
node_modules/@isaacs/cliui/node_modules/ansi-regex/readme.md
generated
vendored
Normal file
60
node_modules/@isaacs/cliui/node_modules/ansi-regex/readme.md
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# ansi-regex
|
||||||
|
|
||||||
|
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install ansi-regex
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import ansiRegex from 'ansi-regex';
|
||||||
|
|
||||||
|
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
ansiRegex().test('cake');
|
||||||
|
//=> false
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||||
|
//=> ['\u001B[4m', '\u001B[0m']
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||||
|
//=> ['\u001B[4m']
|
||||||
|
|
||||||
|
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||||
|
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### ansiRegex(options?)
|
||||||
|
|
||||||
|
Returns a regex for matching ANSI escape codes.
|
||||||
|
|
||||||
|
#### options
|
||||||
|
|
||||||
|
Type: `object`
|
||||||
|
|
||||||
|
##### onlyFirst
|
||||||
|
|
||||||
|
Type: `boolean`\
|
||||||
|
Default: `false` *(Matches any ANSI escape codes in a string)*
|
||||||
|
|
||||||
|
Match only the first ANSI escape.
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Why do you test for codes not in the ECMA 48 standard?
|
||||||
|
|
||||||
|
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
|
||||||
|
|
||||||
|
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
236
node_modules/@isaacs/cliui/node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
236
node_modules/@isaacs/cliui/node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for starting this style.
|
||||||
|
*/
|
||||||
|
readonly open: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for ending this style.
|
||||||
|
*/
|
||||||
|
readonly close: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ColorBase {
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for ending this color.
|
||||||
|
*/
|
||||||
|
readonly close: string;
|
||||||
|
|
||||||
|
ansi(code: number): string;
|
||||||
|
|
||||||
|
ansi256(code: number): string;
|
||||||
|
|
||||||
|
ansi16m(red: number, green: number, blue: number): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Modifier {
|
||||||
|
/**
|
||||||
|
Resets the current color chain.
|
||||||
|
*/
|
||||||
|
readonly reset: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text bold.
|
||||||
|
*/
|
||||||
|
readonly bold: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emitting only a small amount of light.
|
||||||
|
*/
|
||||||
|
readonly dim: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text italic. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly italic: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text underline. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly underline: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text overline.
|
||||||
|
|
||||||
|
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
|
||||||
|
*/
|
||||||
|
readonly overline: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inverse background and foreground colors.
|
||||||
|
*/
|
||||||
|
readonly inverse: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Prints the text, but makes it invisible.
|
||||||
|
*/
|
||||||
|
readonly hidden: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly strikethrough: CSPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ForegroundColor {
|
||||||
|
readonly black: CSPair;
|
||||||
|
readonly red: CSPair;
|
||||||
|
readonly green: CSPair;
|
||||||
|
readonly yellow: CSPair;
|
||||||
|
readonly blue: CSPair;
|
||||||
|
readonly cyan: CSPair;
|
||||||
|
readonly magenta: CSPair;
|
||||||
|
readonly white: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `blackBright`.
|
||||||
|
*/
|
||||||
|
readonly gray: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `blackBright`.
|
||||||
|
*/
|
||||||
|
readonly grey: CSPair;
|
||||||
|
|
||||||
|
readonly blackBright: CSPair;
|
||||||
|
readonly redBright: CSPair;
|
||||||
|
readonly greenBright: CSPair;
|
||||||
|
readonly yellowBright: CSPair;
|
||||||
|
readonly blueBright: CSPair;
|
||||||
|
readonly cyanBright: CSPair;
|
||||||
|
readonly magentaBright: CSPair;
|
||||||
|
readonly whiteBright: CSPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BackgroundColor {
|
||||||
|
readonly bgBlack: CSPair;
|
||||||
|
readonly bgRed: CSPair;
|
||||||
|
readonly bgGreen: CSPair;
|
||||||
|
readonly bgYellow: CSPair;
|
||||||
|
readonly bgBlue: CSPair;
|
||||||
|
readonly bgCyan: CSPair;
|
||||||
|
readonly bgMagenta: CSPair;
|
||||||
|
readonly bgWhite: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `bgBlackBright`.
|
||||||
|
*/
|
||||||
|
readonly bgGray: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `bgBlackBright`.
|
||||||
|
*/
|
||||||
|
readonly bgGrey: CSPair;
|
||||||
|
|
||||||
|
readonly bgBlackBright: CSPair;
|
||||||
|
readonly bgRedBright: CSPair;
|
||||||
|
readonly bgGreenBright: CSPair;
|
||||||
|
readonly bgYellowBright: CSPair;
|
||||||
|
readonly bgBlueBright: CSPair;
|
||||||
|
readonly bgCyanBright: CSPair;
|
||||||
|
readonly bgMagentaBright: CSPair;
|
||||||
|
readonly bgWhiteBright: CSPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConvertColor {
|
||||||
|
/**
|
||||||
|
Convert from the RGB color space to the ANSI 256 color space.
|
||||||
|
|
||||||
|
@param red - (`0...255`)
|
||||||
|
@param green - (`0...255`)
|
||||||
|
@param blue - (`0...255`)
|
||||||
|
*/
|
||||||
|
rgbToAnsi256(red: number, green: number, blue: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert from the RGB HEX color space to the RGB color space.
|
||||||
|
|
||||||
|
@param hex - A hexadecimal string containing RGB data.
|
||||||
|
*/
|
||||||
|
hexToRgb(hex: string): [red: number, green: number, blue: number];
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert from the RGB HEX color space to the ANSI 256 color space.
|
||||||
|
|
||||||
|
@param hex - A hexadecimal string containing RGB data.
|
||||||
|
*/
|
||||||
|
hexToAnsi256(hex: string): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert from the ANSI 256 color space to the ANSI 16 color space.
|
||||||
|
|
||||||
|
@param code - A number representing the ANSI 256 color.
|
||||||
|
*/
|
||||||
|
ansi256ToAnsi(code: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert from the RGB color space to the ANSI 16 color space.
|
||||||
|
|
||||||
|
@param red - (`0...255`)
|
||||||
|
@param green - (`0...255`)
|
||||||
|
@param blue - (`0...255`)
|
||||||
|
*/
|
||||||
|
rgbToAnsi(red: number, green: number, blue: number): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert from the RGB HEX color space to the ANSI 16 color space.
|
||||||
|
|
||||||
|
@param hex - A hexadecimal string containing RGB data.
|
||||||
|
*/
|
||||||
|
hexToAnsi(hex: string): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic modifier names.
|
||||||
|
*/
|
||||||
|
export type ModifierName = keyof Modifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic foreground color names.
|
||||||
|
|
||||||
|
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||||
|
*/
|
||||||
|
export type ForegroundColorName = keyof ForegroundColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic background color names.
|
||||||
|
|
||||||
|
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||||
|
*/
|
||||||
|
export type BackgroundColorName = keyof BackgroundColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic color names. The combination of foreground and background color names.
|
||||||
|
|
||||||
|
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
||||||
|
*/
|
||||||
|
export type ColorName = ForegroundColorName | BackgroundColorName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic modifier names.
|
||||||
|
*/
|
||||||
|
export const modifierNames: readonly ModifierName[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic foreground color names.
|
||||||
|
*/
|
||||||
|
export const foregroundColorNames: readonly ForegroundColorName[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
Basic background color names.
|
||||||
|
*/
|
||||||
|
export const backgroundColorNames: readonly BackgroundColorName[];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Basic color names. The combination of foreground and background color names.
|
||||||
|
*/
|
||||||
|
export const colorNames: readonly ColorName[];
|
||||||
|
|
||||||
|
declare const ansiStyles: {
|
||||||
|
readonly modifier: Modifier;
|
||||||
|
readonly color: ColorBase & ForegroundColor;
|
||||||
|
readonly bgColor: ColorBase & BackgroundColor;
|
||||||
|
readonly codes: ReadonlyMap<number, number>;
|
||||||
|
} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
|
||||||
|
|
||||||
|
export default ansiStyles;
|
223
node_modules/@isaacs/cliui/node_modules/ansi-styles/index.js
generated
vendored
Normal file
223
node_modules/@isaacs/cliui/node_modules/ansi-styles/index.js
generated
vendored
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
const ANSI_BACKGROUND_OFFSET = 10;
|
||||||
|
|
||||||
|
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
||||||
|
|
||||||
|
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
||||||
|
|
||||||
|
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
||||||
|
|
||||||
|
const styles = {
|
||||||
|
modifier: {
|
||||||
|
reset: [0, 0],
|
||||||
|
// 21 isn't widely supported and 22 does the same thing
|
||||||
|
bold: [1, 22],
|
||||||
|
dim: [2, 22],
|
||||||
|
italic: [3, 23],
|
||||||
|
underline: [4, 24],
|
||||||
|
overline: [53, 55],
|
||||||
|
inverse: [7, 27],
|
||||||
|
hidden: [8, 28],
|
||||||
|
strikethrough: [9, 29],
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
black: [30, 39],
|
||||||
|
red: [31, 39],
|
||||||
|
green: [32, 39],
|
||||||
|
yellow: [33, 39],
|
||||||
|
blue: [34, 39],
|
||||||
|
magenta: [35, 39],
|
||||||
|
cyan: [36, 39],
|
||||||
|
white: [37, 39],
|
||||||
|
|
||||||
|
// Bright color
|
||||||
|
blackBright: [90, 39],
|
||||||
|
gray: [90, 39], // Alias of `blackBright`
|
||||||
|
grey: [90, 39], // Alias of `blackBright`
|
||||||
|
redBright: [91, 39],
|
||||||
|
greenBright: [92, 39],
|
||||||
|
yellowBright: [93, 39],
|
||||||
|
blueBright: [94, 39],
|
||||||
|
magentaBright: [95, 39],
|
||||||
|
cyanBright: [96, 39],
|
||||||
|
whiteBright: [97, 39],
|
||||||
|
},
|
||||||
|
bgColor: {
|
||||||
|
bgBlack: [40, 49],
|
||||||
|
bgRed: [41, 49],
|
||||||
|
bgGreen: [42, 49],
|
||||||
|
bgYellow: [43, 49],
|
||||||
|
bgBlue: [44, 49],
|
||||||
|
bgMagenta: [45, 49],
|
||||||
|
bgCyan: [46, 49],
|
||||||
|
bgWhite: [47, 49],
|
||||||
|
|
||||||
|
// Bright color
|
||||||
|
bgBlackBright: [100, 49],
|
||||||
|
bgGray: [100, 49], // Alias of `bgBlackBright`
|
||||||
|
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
||||||
|
bgRedBright: [101, 49],
|
||||||
|
bgGreenBright: [102, 49],
|
||||||
|
bgYellowBright: [103, 49],
|
||||||
|
bgBlueBright: [104, 49],
|
||||||
|
bgMagentaBright: [105, 49],
|
||||||
|
bgCyanBright: [106, 49],
|
||||||
|
bgWhiteBright: [107, 49],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const modifierNames = Object.keys(styles.modifier);
|
||||||
|
export const foregroundColorNames = Object.keys(styles.color);
|
||||||
|
export const backgroundColorNames = Object.keys(styles.bgColor);
|
||||||
|
export const colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
||||||
|
|
||||||
|
function assembleStyles() {
|
||||||
|
const codes = new Map();
|
||||||
|
|
||||||
|
for (const [groupName, group] of Object.entries(styles)) {
|
||||||
|
for (const [styleName, style] of Object.entries(group)) {
|
||||||
|
styles[styleName] = {
|
||||||
|
open: `\u001B[${style[0]}m`,
|
||||||
|
close: `\u001B[${style[1]}m`,
|
||||||
|
};
|
||||||
|
|
||||||
|
group[styleName] = styles[styleName];
|
||||||
|
|
||||||
|
codes.set(style[0], style[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(styles, groupName, {
|
||||||
|
value: group,
|
||||||
|
enumerable: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(styles, 'codes', {
|
||||||
|
value: codes,
|
||||||
|
enumerable: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
styles.color.close = '\u001B[39m';
|
||||||
|
styles.bgColor.close = '\u001B[49m';
|
||||||
|
|
||||||
|
styles.color.ansi = wrapAnsi16();
|
||||||
|
styles.color.ansi256 = wrapAnsi256();
|
||||||
|
styles.color.ansi16m = wrapAnsi16m();
|
||||||
|
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
||||||
|
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
||||||
|
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
||||||
|
|
||||||
|
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
||||||
|
Object.defineProperties(styles, {
|
||||||
|
rgbToAnsi256: {
|
||||||
|
value: (red, green, blue) => {
|
||||||
|
// We use the extended greyscale palette here, with the exception of
|
||||||
|
// black and white. normal palette only has 4 greyscale shades.
|
||||||
|
if (red === green && green === blue) {
|
||||||
|
if (red < 8) {
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (red > 248) {
|
||||||
|
return 231;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(((red - 8) / 247) * 24) + 232;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 16
|
||||||
|
+ (36 * Math.round(red / 255 * 5))
|
||||||
|
+ (6 * Math.round(green / 255 * 5))
|
||||||
|
+ Math.round(blue / 255 * 5);
|
||||||
|
},
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
hexToRgb: {
|
||||||
|
value: hex => {
|
||||||
|
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
||||||
|
if (!matches) {
|
||||||
|
return [0, 0, 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
let [colorString] = matches;
|
||||||
|
|
||||||
|
if (colorString.length === 3) {
|
||||||
|
colorString = [...colorString].map(character => character + character).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
const integer = Number.parseInt(colorString, 16);
|
||||||
|
|
||||||
|
return [
|
||||||
|
/* eslint-disable no-bitwise */
|
||||||
|
(integer >> 16) & 0xFF,
|
||||||
|
(integer >> 8) & 0xFF,
|
||||||
|
integer & 0xFF,
|
||||||
|
/* eslint-enable no-bitwise */
|
||||||
|
];
|
||||||
|
},
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
hexToAnsi256: {
|
||||||
|
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
ansi256ToAnsi: {
|
||||||
|
value: code => {
|
||||||
|
if (code < 8) {
|
||||||
|
return 30 + code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code < 16) {
|
||||||
|
return 90 + (code - 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
let red;
|
||||||
|
let green;
|
||||||
|
let blue;
|
||||||
|
|
||||||
|
if (code >= 232) {
|
||||||
|
red = (((code - 232) * 10) + 8) / 255;
|
||||||
|
green = red;
|
||||||
|
blue = red;
|
||||||
|
} else {
|
||||||
|
code -= 16;
|
||||||
|
|
||||||
|
const remainder = code % 36;
|
||||||
|
|
||||||
|
red = Math.floor(code / 36) / 5;
|
||||||
|
green = Math.floor(remainder / 6) / 5;
|
||||||
|
blue = (remainder % 6) / 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = Math.max(red, green, blue) * 2;
|
||||||
|
|
||||||
|
if (value === 0) {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-bitwise
|
||||||
|
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
||||||
|
|
||||||
|
if (value === 2) {
|
||||||
|
result += 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
rgbToAnsi: {
|
||||||
|
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
hexToAnsi: {
|
||||||
|
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ansiStyles = assembleStyles();
|
||||||
|
|
||||||
|
export default ansiStyles;
|
9
node_modules/@isaacs/cliui/node_modules/ansi-styles/license
generated
vendored
Normal file
9
node_modules/@isaacs/cliui/node_modules/ansi-styles/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
54
node_modules/@isaacs/cliui/node_modules/ansi-styles/package.json
generated
vendored
Normal file
54
node_modules/@isaacs/cliui/node_modules/ansi-styles/package.json
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"name": "ansi-styles",
|
||||||
|
"version": "6.2.1",
|
||||||
|
"description": "ANSI escape codes for styling strings in the terminal",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/ansi-styles",
|
||||||
|
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"exports": "./index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd",
|
||||||
|
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cli",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"log",
|
||||||
|
"logging",
|
||||||
|
"command-line",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"svg-term-cli": "^2.1.1",
|
||||||
|
"tsd": "^0.19.0",
|
||||||
|
"xo": "^0.47.0"
|
||||||
|
}
|
||||||
|
}
|
173
node_modules/@isaacs/cliui/node_modules/ansi-styles/readme.md
generated
vendored
Normal file
173
node_modules/@isaacs/cliui/node_modules/ansi-styles/readme.md
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
# ansi-styles
|
||||||
|
|
||||||
|
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||||
|
|
||||||
|
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install ansi-styles
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import styles from 'ansi-styles';
|
||||||
|
|
||||||
|
console.log(`${styles.green.open}Hello world!${styles.green.close}`);
|
||||||
|
|
||||||
|
|
||||||
|
// Color conversion between 256/truecolor
|
||||||
|
// NOTE: When converting from truecolor to 256 colors, the original color
|
||||||
|
// may be degraded to fit the new color palette. This means terminals
|
||||||
|
// that do not support 16 million colors will best-match the
|
||||||
|
// original color.
|
||||||
|
console.log(`${styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World${styles.color.close}`)
|
||||||
|
console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`)
|
||||||
|
console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`)
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### `open` and `close`
|
||||||
|
|
||||||
|
Each style has an `open` and `close` property.
|
||||||
|
|
||||||
|
### `modifierNames`, `foregroundColorNames`, `backgroundColorNames`, and `colorNames`
|
||||||
|
|
||||||
|
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
||||||
|
|
||||||
|
This can be useful if you need to validate input:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {modifierNames, foregroundColorNames} from 'ansi-styles';
|
||||||
|
|
||||||
|
console.log(modifierNames.includes('bold'));
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
console.log(foregroundColorNames.includes('pink'));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## Styles
|
||||||
|
|
||||||
|
### Modifiers
|
||||||
|
|
||||||
|
- `reset`
|
||||||
|
- `bold`
|
||||||
|
- `dim`
|
||||||
|
- `italic` *(Not widely supported)*
|
||||||
|
- `underline`
|
||||||
|
- `overline` *Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.*
|
||||||
|
- `inverse`
|
||||||
|
- `hidden`
|
||||||
|
- `strikethrough` *(Not widely supported)*
|
||||||
|
|
||||||
|
### Colors
|
||||||
|
|
||||||
|
- `black`
|
||||||
|
- `red`
|
||||||
|
- `green`
|
||||||
|
- `yellow`
|
||||||
|
- `blue`
|
||||||
|
- `magenta`
|
||||||
|
- `cyan`
|
||||||
|
- `white`
|
||||||
|
- `blackBright` (alias: `gray`, `grey`)
|
||||||
|
- `redBright`
|
||||||
|
- `greenBright`
|
||||||
|
- `yellowBright`
|
||||||
|
- `blueBright`
|
||||||
|
- `magentaBright`
|
||||||
|
- `cyanBright`
|
||||||
|
- `whiteBright`
|
||||||
|
|
||||||
|
### Background colors
|
||||||
|
|
||||||
|
- `bgBlack`
|
||||||
|
- `bgRed`
|
||||||
|
- `bgGreen`
|
||||||
|
- `bgYellow`
|
||||||
|
- `bgBlue`
|
||||||
|
- `bgMagenta`
|
||||||
|
- `bgCyan`
|
||||||
|
- `bgWhite`
|
||||||
|
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||||
|
- `bgRedBright`
|
||||||
|
- `bgGreenBright`
|
||||||
|
- `bgYellowBright`
|
||||||
|
- `bgBlueBright`
|
||||||
|
- `bgMagentaBright`
|
||||||
|
- `bgCyanBright`
|
||||||
|
- `bgWhiteBright`
|
||||||
|
|
||||||
|
## Advanced usage
|
||||||
|
|
||||||
|
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||||
|
|
||||||
|
- `styles.modifier`
|
||||||
|
- `styles.color`
|
||||||
|
- `styles.bgColor`
|
||||||
|
|
||||||
|
###### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
import styles from 'ansi-styles';
|
||||||
|
|
||||||
|
console.log(styles.color.green.open);
|
||||||
|
```
|
||||||
|
|
||||||
|
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||||
|
|
||||||
|
###### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
import styles from 'ansi-styles';
|
||||||
|
|
||||||
|
console.log(styles.codes.get(36));
|
||||||
|
//=> 39
|
||||||
|
```
|
||||||
|
|
||||||
|
## 16 / 256 / 16 million (TrueColor) support
|
||||||
|
|
||||||
|
`ansi-styles` allows converting between various color formats and ANSI escapes, with support for 16, 256 and [16 million colors](https://gist.github.com/XVilka/8346728).
|
||||||
|
|
||||||
|
The following color spaces are supported:
|
||||||
|
|
||||||
|
- `rgb`
|
||||||
|
- `hex`
|
||||||
|
- `ansi256`
|
||||||
|
- `ansi`
|
||||||
|
|
||||||
|
To use these, call the associated conversion function with the intended output, for example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import styles from 'ansi-styles';
|
||||||
|
|
||||||
|
styles.color.ansi(styles.rgbToAnsi(100, 200, 15)); // RGB to 16 color ansi foreground code
|
||||||
|
styles.bgColor.ansi(styles.hexToAnsi('#C0FFEE')); // HEX to 16 color ansi foreground code
|
||||||
|
|
||||||
|
styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
|
||||||
|
styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
|
||||||
|
|
||||||
|
styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
|
||||||
|
styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
|
||||||
|
```
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
||||||
|
|
||||||
|
## For enterprise
|
||||||
|
|
||||||
|
Available as part of the Tidelift Subscription.
|
||||||
|
|
||||||
|
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
20
node_modules/@isaacs/cliui/node_modules/emoji-regex/LICENSE-MIT.txt
generated
vendored
Normal file
20
node_modules/@isaacs/cliui/node_modules/emoji-regex/LICENSE-MIT.txt
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||||
|
|
||||||
|
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.
|
137
node_modules/@isaacs/cliui/node_modules/emoji-regex/README.md
generated
vendored
Normal file
137
node_modules/@isaacs/cliui/node_modules/emoji-regex/README.md
generated
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# emoji-regex [](https://travis-ci.org/mathiasbynens/emoji-regex)
|
||||||
|
|
||||||
|
_emoji-regex_ offers a regular expression to match all emoji symbols and sequences (including textual representations of emoji) as per the Unicode Standard.
|
||||||
|
|
||||||
|
This repository contains a script that generates this regular expression based on [Unicode data](https://github.com/node-unicode/node-unicode-data). Because of this, the regular expression can easily be updated whenever new emoji are added to the Unicode standard.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Via [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install emoji-regex
|
||||||
|
```
|
||||||
|
|
||||||
|
In [Node.js](https://nodejs.org/):
|
||||||
|
|
||||||
|
```js
|
||||||
|
const emojiRegex = require('emoji-regex/RGI_Emoji.js');
|
||||||
|
// Note: because the regular expression has the global flag set, this module
|
||||||
|
// exports a function that returns the regex rather than exporting the regular
|
||||||
|
// expression itself, to make it impossible to (accidentally) mutate the
|
||||||
|
// original regular expression.
|
||||||
|
|
||||||
|
const text = `
|
||||||
|
\u{231A}: ⌚ default emoji presentation character (Emoji_Presentation)
|
||||||
|
\u{2194}\u{FE0F}: ↔️ default text presentation character rendered as emoji
|
||||||
|
\u{1F469}: 👩 emoji modifier base (Emoji_Modifier_Base)
|
||||||
|
\u{1F469}\u{1F3FF}: 👩🏿 emoji modifier base followed by a modifier
|
||||||
|
`;
|
||||||
|
|
||||||
|
const regex = emojiRegex();
|
||||||
|
let match;
|
||||||
|
while (match = regex.exec(text)) {
|
||||||
|
const emoji = match[0];
|
||||||
|
console.log(`Matched sequence ${ emoji } — code points: ${ [...emoji].length }`);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Console output:
|
||||||
|
|
||||||
|
```
|
||||||
|
Matched sequence ⌚ — code points: 1
|
||||||
|
Matched sequence ⌚ — code points: 1
|
||||||
|
Matched sequence ↔️ — code points: 2
|
||||||
|
Matched sequence ↔️ — code points: 2
|
||||||
|
Matched sequence 👩 — code points: 1
|
||||||
|
Matched sequence 👩 — code points: 1
|
||||||
|
Matched sequence 👩🏿 — code points: 2
|
||||||
|
Matched sequence 👩🏿 — code points: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Regular expression flavors
|
||||||
|
|
||||||
|
The package comes with three distinct regular expressions:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// This is the recommended regular expression to use. It matches all
|
||||||
|
// emoji recommended for general interchange, as defined via the
|
||||||
|
// `RGI_Emoji` property in the Unicode Standard.
|
||||||
|
// https://unicode.org/reports/tr51/#def_rgi_set
|
||||||
|
// When in doubt, use this!
|
||||||
|
const emojiRegexRGI = require('emoji-regex/RGI_Emoji.js');
|
||||||
|
|
||||||
|
// This is the old regular expression, prior to `RGI_Emoji` being
|
||||||
|
// standardized. In addition to all `RGI_Emoji` sequences, it matches
|
||||||
|
// some emoji you probably don’t want to match (such as emoji component
|
||||||
|
// symbols that are not meant to be used separately).
|
||||||
|
const emojiRegex = require('emoji-regex/index.js');
|
||||||
|
|
||||||
|
// This regular expression matches even more emoji than the previous
|
||||||
|
// one, including emoji that render as text instead of icons (i.e.
|
||||||
|
// emoji that are not `Emoji_Presentation` symbols and that aren’t
|
||||||
|
// forced to render as emoji by a variation selector).
|
||||||
|
const emojiRegexText = require('emoji-regex/text.js');
|
||||||
|
```
|
||||||
|
|
||||||
|
Additionally, in environments which support ES2015 Unicode escapes, you may `require` ES2015-style versions of the regexes:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const emojiRegexRGI = require('emoji-regex/es2015/RGI_Emoji.js');
|
||||||
|
const emojiRegex = require('emoji-regex/es2015/index.js');
|
||||||
|
const emojiRegexText = require('emoji-regex/es2015/text.js');
|
||||||
|
```
|
||||||
|
|
||||||
|
## For maintainers
|
||||||
|
|
||||||
|
### How to update emoji-regex after new Unicode Standard releases
|
||||||
|
|
||||||
|
1. Update the Unicode data dependency in `package.json` by running the following commands:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Example: updating from Unicode v12 to Unicode v13.
|
||||||
|
npm uninstall @unicode/unicode-12.0.0
|
||||||
|
npm install @unicode/unicode-13.0.0 --save-dev
|
||||||
|
````
|
||||||
|
|
||||||
|
1. Generate the new output:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Verify that tests still pass:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Send a pull request with the changes, and get it reviewed & merged.
|
||||||
|
|
||||||
|
1. On the `main` branch, bump the emoji-regex version number in `package.json`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm version patch -m 'Release v%s'
|
||||||
|
```
|
||||||
|
|
||||||
|
Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/).
|
||||||
|
|
||||||
|
Note that this produces a Git commit + tag.
|
||||||
|
|
||||||
|
1. Push the release commit and tag:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git push
|
||||||
|
```
|
||||||
|
|
||||||
|
Our CI then automatically publishes the new release to npm.
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||||
|
|---|
|
||||||
|
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
_emoji-regex_ is available under the [MIT](https://mths.be/mit) license.
|
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/RGI_Emoji.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/RGI_Emoji.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex/RGI_Emoji' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/RGI_Emoji.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/RGI_Emoji.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/RGI_Emoji.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/RGI_Emoji.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex/es2015/RGI_Emoji' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/RGI_Emoji.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/RGI_Emoji.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/index.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex/es2015' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/index.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/text.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/text.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex/es2015/text' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/text.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/es2015/text.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/index.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/index.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52
node_modules/@isaacs/cliui/node_modules/emoji-regex/package.json
generated
vendored
Normal file
52
node_modules/@isaacs/cliui/node_modules/emoji-regex/package.json
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"name": "emoji-regex",
|
||||||
|
"version": "9.2.2",
|
||||||
|
"description": "A regular expression to match all Emoji-only symbols as per the Unicode Standard.",
|
||||||
|
"homepage": "https://mths.be/emoji-regex",
|
||||||
|
"main": "index.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"keywords": [
|
||||||
|
"unicode",
|
||||||
|
"regex",
|
||||||
|
"regexp",
|
||||||
|
"regular expressions",
|
||||||
|
"code points",
|
||||||
|
"symbols",
|
||||||
|
"characters",
|
||||||
|
"emoji"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"author": {
|
||||||
|
"name": "Mathias Bynens",
|
||||||
|
"url": "https://mathiasbynens.be/"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/mathiasbynens/emoji-regex.git"
|
||||||
|
},
|
||||||
|
"bugs": "https://github.com/mathiasbynens/emoji-regex/issues",
|
||||||
|
"files": [
|
||||||
|
"LICENSE-MIT.txt",
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts",
|
||||||
|
"RGI_Emoji.js",
|
||||||
|
"RGI_Emoji.d.ts",
|
||||||
|
"text.js",
|
||||||
|
"text.d.ts",
|
||||||
|
"es2015"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "rm -rf -- es2015; babel src -d .; NODE_ENV=es2015 babel src es2015_types -D -d ./es2015; node script/inject-sequences.js",
|
||||||
|
"test": "mocha",
|
||||||
|
"test:watch": "npm run test -- --watch"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.4.4",
|
||||||
|
"@babel/core": "^7.4.4",
|
||||||
|
"@babel/plugin-proposal-unicode-property-regex": "^7.4.4",
|
||||||
|
"@babel/preset-env": "^7.4.4",
|
||||||
|
"@unicode/unicode-13.0.0": "^1.0.3",
|
||||||
|
"mocha": "^6.1.4",
|
||||||
|
"regexgen": "^1.3.0"
|
||||||
|
}
|
||||||
|
}
|
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/text.d.ts
generated
vendored
Normal file
5
node_modules/@isaacs/cliui/node_modules/emoji-regex/text.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
declare module 'emoji-regex/text' {
|
||||||
|
function emojiRegex(): RegExp;
|
||||||
|
|
||||||
|
export = emojiRegex;
|
||||||
|
}
|
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/text.js
generated
vendored
Normal file
6
node_modules/@isaacs/cliui/node_modules/emoji-regex/text.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
node_modules/@isaacs/cliui/node_modules/string-width/index.d.ts
generated
vendored
Normal file
29
node_modules/@isaacs/cliui/node_modules/string-width/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
export interface Options {
|
||||||
|
/**
|
||||||
|
Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1) instead of wide width (count of 2).
|
||||||
|
|
||||||
|
@default true
|
||||||
|
*/
|
||||||
|
readonly ambiguousIsNarrow: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the visual width of a string - the number of columns required to display it.
|
||||||
|
|
||||||
|
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import stringWidth from 'string-width';
|
||||||
|
|
||||||
|
stringWidth('a');
|
||||||
|
//=> 1
|
||||||
|
|
||||||
|
stringWidth('古');
|
||||||
|
//=> 2
|
||||||
|
|
||||||
|
stringWidth('\u001B[1m古\u001B[22m');
|
||||||
|
//=> 2
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
export default function stringWidth(string: string, options?: Options): number;
|
54
node_modules/@isaacs/cliui/node_modules/string-width/index.js
generated
vendored
Normal file
54
node_modules/@isaacs/cliui/node_modules/string-width/index.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import stripAnsi from 'strip-ansi';
|
||||||
|
import eastAsianWidth from 'eastasianwidth';
|
||||||
|
import emojiRegex from 'emoji-regex';
|
||||||
|
|
||||||
|
export default function stringWidth(string, options = {}) {
|
||||||
|
if (typeof string !== 'string' || string.length === 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
options = {
|
||||||
|
ambiguousIsNarrow: true,
|
||||||
|
...options
|
||||||
|
};
|
||||||
|
|
||||||
|
string = stripAnsi(string);
|
||||||
|
|
||||||
|
if (string.length === 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string = string.replace(emojiRegex(), ' ');
|
||||||
|
|
||||||
|
const ambiguousCharacterWidth = options.ambiguousIsNarrow ? 1 : 2;
|
||||||
|
let width = 0;
|
||||||
|
|
||||||
|
for (const character of string) {
|
||||||
|
const codePoint = character.codePointAt(0);
|
||||||
|
|
||||||
|
// Ignore control characters
|
||||||
|
if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore combining characters
|
||||||
|
if (codePoint >= 0x300 && codePoint <= 0x36F) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const code = eastAsianWidth.eastAsianWidth(character);
|
||||||
|
switch (code) {
|
||||||
|
case 'F':
|
||||||
|
case 'W':
|
||||||
|
width += 2;
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
width += ambiguousCharacterWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
width += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
9
node_modules/@isaacs/cliui/node_modules/string-width/license
generated
vendored
Normal file
9
node_modules/@isaacs/cliui/node_modules/string-width/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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/@isaacs/cliui/node_modules/string-width/package.json
generated
vendored
Normal file
59
node_modules/@isaacs/cliui/node_modules/string-width/package.json
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"name": "string-width",
|
||||||
|
"version": "5.1.2",
|
||||||
|
"description": "Get the visual width of a string - the number of columns required to display it",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "sindresorhus/string-width",
|
||||||
|
"funding": "https://github.com/sponsors/sindresorhus",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"exports": "./index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"string",
|
||||||
|
"character",
|
||||||
|
"unicode",
|
||||||
|
"width",
|
||||||
|
"visual",
|
||||||
|
"column",
|
||||||
|
"columns",
|
||||||
|
"fullwidth",
|
||||||
|
"full-width",
|
||||||
|
"full",
|
||||||
|
"ansi",
|
||||||
|
"escape",
|
||||||
|
"codes",
|
||||||
|
"cli",
|
||||||
|
"command-line",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cjk",
|
||||||
|
"chinese",
|
||||||
|
"japanese",
|
||||||
|
"korean",
|
||||||
|
"fixed-width"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"eastasianwidth": "^0.2.0",
|
||||||
|
"emoji-regex": "^9.2.2",
|
||||||
|
"strip-ansi": "^7.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"tsd": "^0.14.0",
|
||||||
|
"xo": "^0.38.2"
|
||||||
|
}
|
||||||
|
}
|
67
node_modules/@isaacs/cliui/node_modules/string-width/readme.md
generated
vendored
Normal file
67
node_modules/@isaacs/cliui/node_modules/string-width/readme.md
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# string-width
|
||||||
|
|
||||||
|
> Get the visual width of a string - the number of columns required to display it
|
||||||
|
|
||||||
|
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
||||||
|
|
||||||
|
Useful to be able to measure the actual width of command-line output.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install string-width
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import stringWidth from 'string-width';
|
||||||
|
|
||||||
|
stringWidth('a');
|
||||||
|
//=> 1
|
||||||
|
|
||||||
|
stringWidth('古');
|
||||||
|
//=> 2
|
||||||
|
|
||||||
|
stringWidth('\u001B[1m古\u001B[22m');
|
||||||
|
//=> 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### stringWidth(string, options?)
|
||||||
|
|
||||||
|
#### string
|
||||||
|
|
||||||
|
Type: `string`
|
||||||
|
|
||||||
|
The string to be counted.
|
||||||
|
|
||||||
|
#### options
|
||||||
|
|
||||||
|
Type: `object`
|
||||||
|
|
||||||
|
##### ambiguousIsNarrow
|
||||||
|
|
||||||
|
Type: `boolean`\
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Count [ambiguous width characters](https://www.unicode.org/reports/tr11/#Ambiguous) as having narrow width (count of 1) instead of wide width (count of 2).
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module
|
||||||
|
- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string
|
||||||
|
- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<b>
|
||||||
|
<a href="https://tidelift.com/subscription/pkg/npm-string-width?utm_source=npm-string-width&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||||
|
</b>
|
||||||
|
<br>
|
||||||
|
<sub>
|
||||||
|
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||||
|
</sub>
|
||||||
|
</div>
|
15
node_modules/@isaacs/cliui/node_modules/strip-ansi/index.d.ts
generated
vendored
Normal file
15
node_modules/@isaacs/cliui/node_modules/strip-ansi/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import stripAnsi from 'strip-ansi';
|
||||||
|
|
||||||
|
stripAnsi('\u001B[4mUnicorn\u001B[0m');
|
||||||
|
//=> 'Unicorn'
|
||||||
|
|
||||||
|
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||||
|
//=> 'Click'
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
export default function stripAnsi(string: string): string;
|
14
node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
generated
vendored
Normal file
14
node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import ansiRegex from 'ansi-regex';
|
||||||
|
|
||||||
|
const regex = ansiRegex();
|
||||||
|
|
||||||
|
export default function stripAnsi(string) {
|
||||||
|
if (typeof string !== 'string') {
|
||||||
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
||||||
|
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
||||||
|
// and doing it manually has a performance penalty.
|
||||||
|
return string.replace(regex, '');
|
||||||
|
}
|
9
node_modules/@isaacs/cliui/node_modules/strip-ansi/license
generated
vendored
Normal file
9
node_modules/@isaacs/cliui/node_modules/strip-ansi/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
57
node_modules/@isaacs/cliui/node_modules/strip-ansi/package.json
generated
vendored
Normal file
57
node_modules/@isaacs/cliui/node_modules/strip-ansi/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"name": "strip-ansi",
|
||||||
|
"version": "7.1.0",
|
||||||
|
"description": "Strip ANSI escape codes from a string",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/strip-ansi",
|
||||||
|
"funding": "https://github.com/chalk/strip-ansi?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"exports": "./index.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"strip",
|
||||||
|
"trim",
|
||||||
|
"remove",
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"log",
|
||||||
|
"logging",
|
||||||
|
"command-line",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-regex": "^6.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"tsd": "^0.17.0",
|
||||||
|
"xo": "^0.44.0"
|
||||||
|
}
|
||||||
|
}
|
41
node_modules/@isaacs/cliui/node_modules/strip-ansi/readme.md
generated
vendored
Normal file
41
node_modules/@isaacs/cliui/node_modules/strip-ansi/readme.md
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# strip-ansi
|
||||||
|
|
||||||
|
> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install strip-ansi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import stripAnsi from 'strip-ansi';
|
||||||
|
|
||||||
|
stripAnsi('\u001B[4mUnicorn\u001B[0m');
|
||||||
|
//=> 'Unicorn'
|
||||||
|
|
||||||
|
stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
|
||||||
|
//=> 'Click'
|
||||||
|
```
|
||||||
|
|
||||||
|
## strip-ansi for enterprise
|
||||||
|
|
||||||
|
Available as part of the Tidelift Subscription.
|
||||||
|
|
||||||
|
The maintainers of strip-ansi and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-strip-ansi?utm_source=npm-strip-ansi&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
|
||||||
|
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module
|
||||||
|
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||||
|
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||||
|
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
||||||
|
|
41
node_modules/@isaacs/cliui/node_modules/wrap-ansi/index.d.ts
generated
vendored
Normal file
41
node_modules/@isaacs/cliui/node_modules/wrap-ansi/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
export type Options = {
|
||||||
|
/**
|
||||||
|
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
||||||
|
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
readonly hard?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
||||||
|
|
||||||
|
@default true
|
||||||
|
*/
|
||||||
|
readonly wordWrap?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
||||||
|
|
||||||
|
@default true
|
||||||
|
*/
|
||||||
|
readonly trim?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Wrap words to the specified column width.
|
||||||
|
|
||||||
|
@param string - String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
|
||||||
|
@param columns - Number of columns to wrap the text to.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import wrapAnsi from 'wrap-ansi';
|
||||||
|
|
||||||
|
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
||||||
|
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
||||||
|
|
||||||
|
console.log(wrapAnsi(input, 20));
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
export default function wrapAnsi(string: string, columns: number, options?: Options): string;
|
214
node_modules/@isaacs/cliui/node_modules/wrap-ansi/index.js
generated
vendored
Executable file
214
node_modules/@isaacs/cliui/node_modules/wrap-ansi/index.js
generated
vendored
Executable file
@ -0,0 +1,214 @@
|
|||||||
|
import stringWidth from 'string-width';
|
||||||
|
import stripAnsi from 'strip-ansi';
|
||||||
|
import ansiStyles from 'ansi-styles';
|
||||||
|
|
||||||
|
const ESCAPES = new Set([
|
||||||
|
'\u001B',
|
||||||
|
'\u009B',
|
||||||
|
]);
|
||||||
|
|
||||||
|
const END_CODE = 39;
|
||||||
|
const ANSI_ESCAPE_BELL = '\u0007';
|
||||||
|
const ANSI_CSI = '[';
|
||||||
|
const ANSI_OSC = ']';
|
||||||
|
const ANSI_SGR_TERMINATOR = 'm';
|
||||||
|
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
||||||
|
|
||||||
|
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
||||||
|
const wrapAnsiHyperlink = uri => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
|
||||||
|
|
||||||
|
// Calculate the length of words split on ' ', ignoring
|
||||||
|
// the extra characters added by ansi escape codes
|
||||||
|
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
||||||
|
|
||||||
|
// Wrap a long word across multiple rows
|
||||||
|
// Ansi escape codes do not count towards length
|
||||||
|
const wrapWord = (rows, word, columns) => {
|
||||||
|
const characters = [...word];
|
||||||
|
|
||||||
|
let isInsideEscape = false;
|
||||||
|
let isInsideLinkEscape = false;
|
||||||
|
let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
|
||||||
|
|
||||||
|
for (const [index, character] of characters.entries()) {
|
||||||
|
const characterLength = stringWidth(character);
|
||||||
|
|
||||||
|
if (visible + characterLength <= columns) {
|
||||||
|
rows[rows.length - 1] += character;
|
||||||
|
} else {
|
||||||
|
rows.push(character);
|
||||||
|
visible = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ESCAPES.has(character)) {
|
||||||
|
isInsideEscape = true;
|
||||||
|
isInsideLinkEscape = characters.slice(index + 1).join('').startsWith(ANSI_ESCAPE_LINK);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInsideEscape) {
|
||||||
|
if (isInsideLinkEscape) {
|
||||||
|
if (character === ANSI_ESCAPE_BELL) {
|
||||||
|
isInsideEscape = false;
|
||||||
|
isInsideLinkEscape = false;
|
||||||
|
}
|
||||||
|
} else if (character === ANSI_SGR_TERMINATOR) {
|
||||||
|
isInsideEscape = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
visible += characterLength;
|
||||||
|
|
||||||
|
if (visible === columns && index < characters.length - 1) {
|
||||||
|
rows.push('');
|
||||||
|
visible = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's possible that the last row we copy over is only
|
||||||
|
// ansi escape characters, handle this edge-case
|
||||||
|
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
||||||
|
rows[rows.length - 2] += rows.pop();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Trims spaces from a string ignoring invisible sequences
|
||||||
|
const stringVisibleTrimSpacesRight = string => {
|
||||||
|
const words = string.split(' ');
|
||||||
|
let last = words.length;
|
||||||
|
|
||||||
|
while (last > 0) {
|
||||||
|
if (stringWidth(words[last - 1]) > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
last--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last === words.length) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
||||||
|
};
|
||||||
|
|
||||||
|
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
|
||||||
|
//
|
||||||
|
// 'hard' will never allow a string to take up more than columns characters
|
||||||
|
//
|
||||||
|
// 'soft' allows long words to expand past the column length
|
||||||
|
const exec = (string, columns, options = {}) => {
|
||||||
|
if (options.trim !== false && string.trim() === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
let returnValue = '';
|
||||||
|
let escapeCode;
|
||||||
|
let escapeUrl;
|
||||||
|
|
||||||
|
const lengths = wordLengths(string);
|
||||||
|
let rows = [''];
|
||||||
|
|
||||||
|
for (const [index, word] of string.split(' ').entries()) {
|
||||||
|
if (options.trim !== false) {
|
||||||
|
rows[rows.length - 1] = rows[rows.length - 1].trimStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
let rowLength = stringWidth(rows[rows.length - 1]);
|
||||||
|
|
||||||
|
if (index !== 0) {
|
||||||
|
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
||||||
|
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
||||||
|
rows.push('');
|
||||||
|
rowLength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowLength > 0 || options.trim === false) {
|
||||||
|
rows[rows.length - 1] += ' ';
|
||||||
|
rowLength++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
||||||
|
if (options.hard && lengths[index] > columns) {
|
||||||
|
const remainingColumns = (columns - rowLength);
|
||||||
|
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
||||||
|
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
||||||
|
if (breaksStartingNextLine < breaksStartingThisLine) {
|
||||||
|
rows.push('');
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapWord(rows, word, columns);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
||||||
|
if (options.wordWrap === false && rowLength < columns) {
|
||||||
|
wrapWord(rows, word, columns);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rows.push('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
||||||
|
wrapWord(rows, word, columns);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rows[rows.length - 1] += word;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.trim !== false) {
|
||||||
|
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
|
||||||
|
}
|
||||||
|
|
||||||
|
const pre = [...rows.join('\n')];
|
||||||
|
|
||||||
|
for (const [index, character] of pre.entries()) {
|
||||||
|
returnValue += character;
|
||||||
|
|
||||||
|
if (ESCAPES.has(character)) {
|
||||||
|
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join('')) || {groups: {}};
|
||||||
|
if (groups.code !== undefined) {
|
||||||
|
const code = Number.parseFloat(groups.code);
|
||||||
|
escapeCode = code === END_CODE ? undefined : code;
|
||||||
|
} else if (groups.uri !== undefined) {
|
||||||
|
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const code = ansiStyles.codes.get(Number(escapeCode));
|
||||||
|
|
||||||
|
if (pre[index + 1] === '\n') {
|
||||||
|
if (escapeUrl) {
|
||||||
|
returnValue += wrapAnsiHyperlink('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (escapeCode && code) {
|
||||||
|
returnValue += wrapAnsiCode(code);
|
||||||
|
}
|
||||||
|
} else if (character === '\n') {
|
||||||
|
if (escapeCode && code) {
|
||||||
|
returnValue += wrapAnsiCode(escapeCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (escapeUrl) {
|
||||||
|
returnValue += wrapAnsiHyperlink(escapeUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
// For each newline, invoke the method separately
|
||||||
|
export default function wrapAnsi(string, columns, options) {
|
||||||
|
return String(string)
|
||||||
|
.normalize()
|
||||||
|
.replace(/\r\n/g, '\n')
|
||||||
|
.split('\n')
|
||||||
|
.map(line => exec(line, columns, options))
|
||||||
|
.join('\n');
|
||||||
|
}
|
9
node_modules/@isaacs/cliui/node_modules/wrap-ansi/license
generated
vendored
Normal file
9
node_modules/@isaacs/cliui/node_modules/wrap-ansi/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
69
node_modules/@isaacs/cliui/node_modules/wrap-ansi/package.json
generated
vendored
Normal file
69
node_modules/@isaacs/cliui/node_modules/wrap-ansi/package.json
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
"name": "wrap-ansi",
|
||||||
|
"version": "8.1.0",
|
||||||
|
"description": "Wordwrap a string with ANSI escape codes",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/wrap-ansi",
|
||||||
|
"funding": "https://github.com/chalk/wrap-ansi?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "https://sindresorhus.com"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"default": "./index.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && nyc ava && tsd"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"wrap",
|
||||||
|
"break",
|
||||||
|
"wordwrap",
|
||||||
|
"wordbreak",
|
||||||
|
"linewrap",
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cli",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"log",
|
||||||
|
"logging",
|
||||||
|
"command-line",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"ansi-styles": "^6.1.0",
|
||||||
|
"string-width": "^5.0.1",
|
||||||
|
"strip-ansi": "^7.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^3.15.0",
|
||||||
|
"chalk": "^4.1.2",
|
||||||
|
"coveralls": "^3.1.1",
|
||||||
|
"has-ansi": "^5.0.1",
|
||||||
|
"nyc": "^15.1.0",
|
||||||
|
"tsd": "^0.25.0",
|
||||||
|
"xo": "^0.44.0"
|
||||||
|
}
|
||||||
|
}
|
91
node_modules/@isaacs/cliui/node_modules/wrap-ansi/readme.md
generated
vendored
Normal file
91
node_modules/@isaacs/cliui/node_modules/wrap-ansi/readme.md
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# wrap-ansi
|
||||||
|
|
||||||
|
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install wrap-ansi
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import chalk from 'chalk';
|
||||||
|
import wrapAnsi from 'wrap-ansi';
|
||||||
|
|
||||||
|
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
||||||
|
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
||||||
|
|
||||||
|
console.log(wrapAnsi(input, 20));
|
||||||
|
```
|
||||||
|
|
||||||
|
<img width="331" src="screenshot.png">
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### wrapAnsi(string, columns, options?)
|
||||||
|
|
||||||
|
Wrap words to the specified column width.
|
||||||
|
|
||||||
|
#### string
|
||||||
|
|
||||||
|
Type: `string`
|
||||||
|
|
||||||
|
String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
|
||||||
|
|
||||||
|
#### columns
|
||||||
|
|
||||||
|
Type: `number`
|
||||||
|
|
||||||
|
Number of columns to wrap the text to.
|
||||||
|
|
||||||
|
#### options
|
||||||
|
|
||||||
|
Type: `object`
|
||||||
|
|
||||||
|
##### hard
|
||||||
|
|
||||||
|
Type: `boolean`\
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
||||||
|
|
||||||
|
##### wordWrap
|
||||||
|
|
||||||
|
Type: `boolean`\
|
||||||
|
Default: `true`
|
||||||
|
|
||||||
|
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
||||||
|
|
||||||
|
##### trim
|
||||||
|
|
||||||
|
Type: `boolean`\
|
||||||
|
Default: `true`
|
||||||
|
|
||||||
|
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||||
|
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
|
||||||
|
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
||||||
|
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
||||||
|
- [Benjamin Coe](https://github.com/bcoe)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<b>
|
||||||
|
<a href="https://tidelift.com/subscription/pkg/npm-wrap_ansi?utm_source=npm-wrap-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||||
|
</b>
|
||||||
|
<br>
|
||||||
|
<sub>
|
||||||
|
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||||
|
</sub>
|
||||||
|
</div>
|
86
node_modules/@isaacs/cliui/package.json
generated
vendored
Normal file
86
node_modules/@isaacs/cliui/package.json
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
"name": "@isaacs/cliui",
|
||||||
|
"version": "8.0.2",
|
||||||
|
"description": "easily create complex multi-column command-line-interfaces",
|
||||||
|
"main": "build/index.cjs",
|
||||||
|
"exports": {
|
||||||
|
".": [
|
||||||
|
{
|
||||||
|
"import": "./index.mjs",
|
||||||
|
"require": "./build/index.cjs"
|
||||||
|
},
|
||||||
|
"./build/index.cjs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"module": "./index.mjs",
|
||||||
|
"scripts": {
|
||||||
|
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
|
||||||
|
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
|
||||||
|
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
|
||||||
|
"test": "c8 mocha ./test/*.cjs",
|
||||||
|
"test:esm": "c8 mocha ./test/**/*.mjs",
|
||||||
|
"postest": "check",
|
||||||
|
"coverage": "c8 report --check-coverage",
|
||||||
|
"precompile": "rimraf build",
|
||||||
|
"compile": "tsc",
|
||||||
|
"postcompile": "npm run build:cjs",
|
||||||
|
"build:cjs": "rollup -c",
|
||||||
|
"prepare": "npm run compile"
|
||||||
|
},
|
||||||
|
"repository": "yargs/cliui",
|
||||||
|
"standard": {
|
||||||
|
"ignore": [
|
||||||
|
"**/example/**"
|
||||||
|
],
|
||||||
|
"globals": [
|
||||||
|
"it"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"cli",
|
||||||
|
"command-line",
|
||||||
|
"layout",
|
||||||
|
"design",
|
||||||
|
"console",
|
||||||
|
"wrap",
|
||||||
|
"table"
|
||||||
|
],
|
||||||
|
"author": "Ben Coe <ben@npmjs.com>",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"string-width": "^5.1.2",
|
||||||
|
"string-width-cjs": "npm:string-width@^4.2.0",
|
||||||
|
"strip-ansi": "^7.0.1",
|
||||||
|
"strip-ansi-cjs": "npm:strip-ansi@^6.0.1",
|
||||||
|
"wrap-ansi": "^8.1.0",
|
||||||
|
"wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^14.0.27",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.0.0",
|
||||||
|
"@typescript-eslint/parser": "^4.0.0",
|
||||||
|
"c8": "^7.3.0",
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"chalk": "^4.1.0",
|
||||||
|
"cross-env": "^7.0.2",
|
||||||
|
"eslint": "^7.6.0",
|
||||||
|
"eslint-plugin-import": "^2.22.0",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"gts": "^3.0.0",
|
||||||
|
"mocha": "^10.0.0",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"rollup": "^2.23.1",
|
||||||
|
"rollup-plugin-ts": "^3.0.2",
|
||||||
|
"standardx": "^7.0.0",
|
||||||
|
"typescript": "^4.0.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"build",
|
||||||
|
"index.mjs",
|
||||||
|
"!*.d.ts"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
}
|
14
node_modules/@pkgjs/parseargs/.editorconfig
generated
vendored
Normal file
14
node_modules/@pkgjs/parseargs/.editorconfig
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# EditorConfig is awesome: http://EditorConfig.org
|
||||||
|
|
||||||
|
# top-most EditorConfig file
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# Copied from Node.js to ease compatibility in PR.
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
quote_type = single
|
147
node_modules/@pkgjs/parseargs/CHANGELOG.md
generated
vendored
Normal file
147
node_modules/@pkgjs/parseargs/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [0.11.0](https://github.com/pkgjs/parseargs/compare/v0.10.0...v0.11.0) (2022-10-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add `default` option parameter ([#142](https://github.com/pkgjs/parseargs/issues/142)) ([cd20847](https://github.com/pkgjs/parseargs/commit/cd20847a00b2f556aa9c085ac83b942c60868ec1))
|
||||||
|
|
||||||
|
## [0.10.0](https://github.com/pkgjs/parseargs/compare/v0.9.1...v0.10.0) (2022-07-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add parsed meta-data to returned properties ([#129](https://github.com/pkgjs/parseargs/issues/129)) ([91bfb4d](https://github.com/pkgjs/parseargs/commit/91bfb4d3f7b6937efab1b27c91c45d1205f1497e))
|
||||||
|
|
||||||
|
## [0.9.1](https://github.com/pkgjs/parseargs/compare/v0.9.0...v0.9.1) (2022-06-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **runtime:** support node 14+ ([#135](https://github.com/pkgjs/parseargs/issues/135)) ([6a1c5a6](https://github.com/pkgjs/parseargs/commit/6a1c5a6f7cadf2f035e004027e2742e3c4ce554b))
|
||||||
|
|
||||||
|
## [0.9.0](https://github.com/pkgjs/parseargs/compare/v0.8.0...v0.9.0) (2022-05-23)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* drop handling of electron arguments (#121)
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* drop handling of electron arguments ([#121](https://github.com/pkgjs/parseargs/issues/121)) ([a2ffd53](https://github.com/pkgjs/parseargs/commit/a2ffd537c244a062371522b955acb45a404fc9f2))
|
||||||
|
|
||||||
|
## [0.8.0](https://github.com/pkgjs/parseargs/compare/v0.7.1...v0.8.0) (2022-05-16)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode (#88)
|
||||||
|
* positionals now opt-in when strict:true (#116)
|
||||||
|
* create result.values with null prototype (#111)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* create result.values with null prototype ([#111](https://github.com/pkgjs/parseargs/issues/111)) ([9d539c3](https://github.com/pkgjs/parseargs/commit/9d539c3d57f269c160e74e0656ad4fa84ff92ec2))
|
||||||
|
* positionals now opt-in when strict:true ([#116](https://github.com/pkgjs/parseargs/issues/116)) ([3643338](https://github.com/pkgjs/parseargs/commit/364333826b746e8a7dc5505b4b22fd19ac51df3b))
|
||||||
|
* switch type:string option arguments to greedy, but with error for suspect cases in strict mode ([#88](https://github.com/pkgjs/parseargs/issues/88)) ([c2b5e72](https://github.com/pkgjs/parseargs/commit/c2b5e72161991dfdc535909f1327cc9b970fe7e8))
|
||||||
|
|
||||||
|
### [0.7.1](https://github.com/pkgjs/parseargs/compare/v0.7.0...v0.7.1) (2022-04-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* resist pollution ([#106](https://github.com/pkgjs/parseargs/issues/106)) ([ecf2dec](https://github.com/pkgjs/parseargs/commit/ecf2dece0a9f2a76d789384d5d71c68ffe64022a))
|
||||||
|
|
||||||
|
## [0.7.0](https://github.com/pkgjs/parseargs/compare/v0.6.0...v0.7.0) (2022-04-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add strict mode to parser ([#74](https://github.com/pkgjs/parseargs/issues/74)) ([8267d02](https://github.com/pkgjs/parseargs/commit/8267d02083a87b8b8a71fcce08348d1e031ea91c))
|
||||||
|
|
||||||
|
## [0.6.0](https://github.com/pkgjs/parseargs/compare/v0.5.0...v0.6.0) (2022-04-11)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* rework results to remove redundant `flags` property and store value true for boolean options (#83)
|
||||||
|
* switch to existing ERR_INVALID_ARG_VALUE (#97)
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* rework results to remove redundant `flags` property and store value true for boolean options ([#83](https://github.com/pkgjs/parseargs/issues/83)) ([be153db](https://github.com/pkgjs/parseargs/commit/be153dbed1d488cb7b6e27df92f601ba7337713d))
|
||||||
|
* switch to existing ERR_INVALID_ARG_VALUE ([#97](https://github.com/pkgjs/parseargs/issues/97)) ([084a23f](https://github.com/pkgjs/parseargs/commit/084a23f9fde2da030b159edb1c2385f24579ce40))
|
||||||
|
|
||||||
|
## [0.5.0](https://github.com/pkgjs/parseargs/compare/v0.4.0...v0.5.0) (2022-04-10)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* Require type to be specified for each supplied option (#95)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Require type to be specified for each supplied option ([#95](https://github.com/pkgjs/parseargs/issues/95)) ([02cd018](https://github.com/pkgjs/parseargs/commit/02cd01885b8aaa59f2db8308f2d4479e64340068))
|
||||||
|
|
||||||
|
## [0.4.0](https://github.com/pkgjs/parseargs/compare/v0.3.0...v0.4.0) (2022-03-12)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* parsing, revisit short option groups, add support for combined short and value (#75)
|
||||||
|
* restructure configuration to take options bag (#63)
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* parsing, revisit short option groups, add support for combined short and value ([#75](https://github.com/pkgjs/parseargs/issues/75)) ([a92600f](https://github.com/pkgjs/parseargs/commit/a92600fa6c214508ab1e016fa55879a314f541af))
|
||||||
|
* restructure configuration to take options bag ([#63](https://github.com/pkgjs/parseargs/issues/63)) ([b412095](https://github.com/pkgjs/parseargs/commit/b4120957d90e809ee8b607b06e747d3e6a6b213e))
|
||||||
|
|
||||||
|
## [0.3.0](https://github.com/pkgjs/parseargs/compare/v0.2.0...v0.3.0) (2022-02-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **parser:** support short-option groups ([#59](https://github.com/pkgjs/parseargs/issues/59)) ([882067b](https://github.com/pkgjs/parseargs/commit/882067bc2d7cbc6b796f8e5a079a99bc99d4e6ba))
|
||||||
|
|
||||||
|
## [0.2.0](https://github.com/pkgjs/parseargs/compare/v0.1.1...v0.2.0) (2022-02-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* basic support for shorts ([#50](https://github.com/pkgjs/parseargs/issues/50)) ([a2f36d7](https://github.com/pkgjs/parseargs/commit/a2f36d7da4145af1c92f76806b7fe2baf6beeceb))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* always store value for a=b ([#43](https://github.com/pkgjs/parseargs/issues/43)) ([a85e8dc](https://github.com/pkgjs/parseargs/commit/a85e8dc06379fd2696ee195cc625de8fac6aee42))
|
||||||
|
* support single dash as positional ([#49](https://github.com/pkgjs/parseargs/issues/49)) ([d795bf8](https://github.com/pkgjs/parseargs/commit/d795bf877d068fd67aec381f30b30b63f97109ad))
|
||||||
|
|
||||||
|
### [0.1.1](https://github.com/pkgjs/parseargs/compare/v0.1.0...v0.1.1) (2022-01-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* only use arrays in results for multiples ([#42](https://github.com/pkgjs/parseargs/issues/42)) ([c357584](https://github.com/pkgjs/parseargs/commit/c357584847912506319ed34a0840080116f4fd65))
|
||||||
|
|
||||||
|
## 0.1.0 (2022-01-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* expand scenarios covered by default arguments for environments ([#20](https://github.com/pkgjs/parseargs/issues/20)) ([582ada7](https://github.com/pkgjs/parseargs/commit/582ada7be0eca3a73d6e0bd016e7ace43449fa4c))
|
||||||
|
* update readme and include contributing guidelines ([8edd6fc](https://github.com/pkgjs/parseargs/commit/8edd6fc863cd705f6fac732724159ebe8065a2b0))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* do not strip excess leading dashes on long option names ([#21](https://github.com/pkgjs/parseargs/issues/21)) ([f848590](https://github.com/pkgjs/parseargs/commit/f848590ebf3249ed5979ff47e003fa6e1a8ec5c0))
|
||||||
|
* name & readme ([3f057c1](https://github.com/pkgjs/parseargs/commit/3f057c1b158a1bdbe878c64b57460c58e56e465f))
|
||||||
|
* package.json values ([9bac300](https://github.com/pkgjs/parseargs/commit/9bac300e00cd76c77076bf9e75e44f8929512da9))
|
||||||
|
* update readme name ([957d8d9](https://github.com/pkgjs/parseargs/commit/957d8d96e1dcb48297c0a14345d44c0123b2883e))
|
||||||
|
|
||||||
|
|
||||||
|
### Build System
|
||||||
|
|
||||||
|
* first release as minor ([421c6e2](https://github.com/pkgjs/parseargs/commit/421c6e2569a8668ad14fac5a5af5be60479a7571))
|
201
node_modules/@pkgjs/parseargs/LICENSE
generated
vendored
Normal file
201
node_modules/@pkgjs/parseargs/LICENSE
generated
vendored
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
413
node_modules/@pkgjs/parseargs/README.md
generated
vendored
Normal file
413
node_modules/@pkgjs/parseargs/README.md
generated
vendored
Normal file
@ -0,0 +1,413 @@
|
|||||||
|
<!-- omit in toc -->
|
||||||
|
# parseArgs
|
||||||
|
|
||||||
|
[![Coverage][coverage-image]][coverage-url]
|
||||||
|
|
||||||
|
Polyfill of `util.parseArgs()`
|
||||||
|
|
||||||
|
## `util.parseArgs([config])`
|
||||||
|
|
||||||
|
<!-- YAML
|
||||||
|
added: v18.3.0
|
||||||
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/43459
|
||||||
|
description: add support for returning detailed parse information
|
||||||
|
using `tokens` in input `config` and returned properties.
|
||||||
|
-->
|
||||||
|
|
||||||
|
> Stability: 1 - Experimental
|
||||||
|
|
||||||
|
* `config` {Object} Used to provide arguments for parsing and to configure
|
||||||
|
the parser. `config` supports the following properties:
|
||||||
|
* `args` {string\[]} array of argument strings. **Default:** `process.argv`
|
||||||
|
with `execPath` and `filename` removed.
|
||||||
|
* `options` {Object} Used to describe arguments known to the parser.
|
||||||
|
Keys of `options` are the long names of options and values are an
|
||||||
|
{Object} accepting the following properties:
|
||||||
|
* `type` {string} Type of argument, which must be either `boolean` or `string`.
|
||||||
|
* `multiple` {boolean} Whether this option can be provided multiple
|
||||||
|
times. If `true`, all values will be collected in an array. If
|
||||||
|
`false`, values for the option are last-wins. **Default:** `false`.
|
||||||
|
* `short` {string} A single character alias for the option.
|
||||||
|
* `default` {string | boolean | string\[] | boolean\[]} The default option
|
||||||
|
value when it is not set by args. It must be of the same type as the
|
||||||
|
the `type` property. When `multiple` is `true`, it must be an array.
|
||||||
|
* `strict` {boolean} Should an error be thrown when unknown arguments
|
||||||
|
are encountered, or when arguments are passed that do not match the
|
||||||
|
`type` configured in `options`.
|
||||||
|
**Default:** `true`.
|
||||||
|
* `allowPositionals` {boolean} Whether this command accepts positional
|
||||||
|
arguments.
|
||||||
|
**Default:** `false` if `strict` is `true`, otherwise `true`.
|
||||||
|
* `tokens` {boolean} Return the parsed tokens. This is useful for extending
|
||||||
|
the built-in behavior, from adding additional checks through to reprocessing
|
||||||
|
the tokens in different ways.
|
||||||
|
**Default:** `false`.
|
||||||
|
|
||||||
|
* Returns: {Object} The parsed command line arguments:
|
||||||
|
* `values` {Object} A mapping of parsed option names with their {string}
|
||||||
|
or {boolean} values.
|
||||||
|
* `positionals` {string\[]} Positional arguments.
|
||||||
|
* `tokens` {Object\[] | undefined} See [parseArgs tokens](#parseargs-tokens)
|
||||||
|
section. Only returned if `config` includes `tokens: true`.
|
||||||
|
|
||||||
|
Provides a higher level API for command-line argument parsing than interacting
|
||||||
|
with `process.argv` directly. Takes a specification for the expected arguments
|
||||||
|
and returns a structured object with the parsed options and positionals.
|
||||||
|
|
||||||
|
```mjs
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
|
const args = ['-f', '--bar', 'b'];
|
||||||
|
const options = {
|
||||||
|
foo: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'f'
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
values,
|
||||||
|
positionals
|
||||||
|
} = parseArgs({ args, options });
|
||||||
|
console.log(values, positionals);
|
||||||
|
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
||||||
|
```
|
||||||
|
|
||||||
|
```cjs
|
||||||
|
const { parseArgs } = require('node:util');
|
||||||
|
const args = ['-f', '--bar', 'b'];
|
||||||
|
const options = {
|
||||||
|
foo: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'f'
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
values,
|
||||||
|
positionals
|
||||||
|
} = parseArgs({ args, options });
|
||||||
|
console.log(values, positionals);
|
||||||
|
// Prints: [Object: null prototype] { foo: true, bar: 'b' } []
|
||||||
|
```
|
||||||
|
|
||||||
|
`util.parseArgs` is experimental and behavior may change. Join the
|
||||||
|
conversation in [pkgjs/parseargs][] to contribute to the design.
|
||||||
|
|
||||||
|
### `parseArgs` `tokens`
|
||||||
|
|
||||||
|
Detailed parse information is available for adding custom behaviours by
|
||||||
|
specifying `tokens: true` in the configuration.
|
||||||
|
The returned tokens have properties describing:
|
||||||
|
|
||||||
|
* all tokens
|
||||||
|
* `kind` {string} One of 'option', 'positional', or 'option-terminator'.
|
||||||
|
* `index` {number} Index of element in `args` containing token. So the
|
||||||
|
source argument for a token is `args[token.index]`.
|
||||||
|
* option tokens
|
||||||
|
* `name` {string} Long name of option.
|
||||||
|
* `rawName` {string} How option used in args, like `-f` of `--foo`.
|
||||||
|
* `value` {string | undefined} Option value specified in args.
|
||||||
|
Undefined for boolean options.
|
||||||
|
* `inlineValue` {boolean | undefined} Whether option value specified inline,
|
||||||
|
like `--foo=bar`.
|
||||||
|
* positional tokens
|
||||||
|
* `value` {string} The value of the positional argument in args (i.e. `args[index]`).
|
||||||
|
* option-terminator token
|
||||||
|
|
||||||
|
The returned tokens are in the order encountered in the input args. Options
|
||||||
|
that appear more than once in args produce a token for each use. Short option
|
||||||
|
groups like `-xy` expand to a token for each option. So `-xxx` produces
|
||||||
|
three tokens.
|
||||||
|
|
||||||
|
For example to use the returned tokens to add support for a negated option
|
||||||
|
like `--no-color`, the tokens can be reprocessed to change the value stored
|
||||||
|
for the negated option.
|
||||||
|
|
||||||
|
```mjs
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
'color': { type: 'boolean' },
|
||||||
|
'no-color': { type: 'boolean' },
|
||||||
|
'logfile': { type: 'string' },
|
||||||
|
'no-logfile': { type: 'boolean' },
|
||||||
|
};
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
// Reprocess the option tokens and overwrite the returned values.
|
||||||
|
tokens
|
||||||
|
.filter((token) => token.kind === 'option')
|
||||||
|
.forEach((token) => {
|
||||||
|
if (token.name.startsWith('no-')) {
|
||||||
|
// Store foo:false for --no-foo
|
||||||
|
const positiveName = token.name.slice(3);
|
||||||
|
values[positiveName] = false;
|
||||||
|
delete values[token.name];
|
||||||
|
} else {
|
||||||
|
// Resave value so last one wins if both --foo and --no-foo.
|
||||||
|
values[token.name] = token.value ?? true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const color = values.color;
|
||||||
|
const logfile = values.logfile ?? 'default.log';
|
||||||
|
|
||||||
|
console.log({ logfile, color });
|
||||||
|
```
|
||||||
|
|
||||||
|
```cjs
|
||||||
|
const { parseArgs } = require('node:util');
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
'color': { type: 'boolean' },
|
||||||
|
'no-color': { type: 'boolean' },
|
||||||
|
'logfile': { type: 'string' },
|
||||||
|
'no-logfile': { type: 'boolean' },
|
||||||
|
};
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
// Reprocess the option tokens and overwrite the returned values.
|
||||||
|
tokens
|
||||||
|
.filter((token) => token.kind === 'option')
|
||||||
|
.forEach((token) => {
|
||||||
|
if (token.name.startsWith('no-')) {
|
||||||
|
// Store foo:false for --no-foo
|
||||||
|
const positiveName = token.name.slice(3);
|
||||||
|
values[positiveName] = false;
|
||||||
|
delete values[token.name];
|
||||||
|
} else {
|
||||||
|
// Resave value so last one wins if both --foo and --no-foo.
|
||||||
|
values[token.name] = token.value ?? true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const color = values.color;
|
||||||
|
const logfile = values.logfile ?? 'default.log';
|
||||||
|
|
||||||
|
console.log({ logfile, color });
|
||||||
|
```
|
||||||
|
|
||||||
|
Example usage showing negated options, and when an option is used
|
||||||
|
multiple ways then last one wins.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ node negate.js
|
||||||
|
{ logfile: 'default.log', color: undefined }
|
||||||
|
$ node negate.js --no-logfile --no-color
|
||||||
|
{ logfile: false, color: false }
|
||||||
|
$ node negate.js --logfile=test.log --color
|
||||||
|
{ logfile: 'test.log', color: true }
|
||||||
|
$ node negate.js --no-logfile --logfile=test.log --color --no-color
|
||||||
|
{ logfile: 'test.log', color: false }
|
||||||
|
```
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
<!-- omit in toc -->
|
||||||
|
## Table of Contents
|
||||||
|
- [`util.parseArgs([config])`](#utilparseargsconfig)
|
||||||
|
- [Scope](#scope)
|
||||||
|
- [Version Matchups](#version-matchups)
|
||||||
|
- [🚀 Getting Started](#-getting-started)
|
||||||
|
- [🙌 Contributing](#-contributing)
|
||||||
|
- [💡 `process.mainArgs` Proposal](#-processmainargs-proposal)
|
||||||
|
- [Implementation:](#implementation)
|
||||||
|
- [📃 Examples](#-examples)
|
||||||
|
- [F.A.Qs](#faqs)
|
||||||
|
- [Links & Resources](#links--resources)
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
It is already possible to build great arg parsing modules on top of what Node.js provides; the prickly API is abstracted away by these modules. Thus, process.parseArgs() is not necessarily intended for library authors; it is intended for developers of simple CLI tools, ad-hoc scripts, deployed Node.js applications, and learning materials.
|
||||||
|
|
||||||
|
It is exceedingly difficult to provide an API which would both be friendly to these Node.js users while being extensible enough for libraries to build upon. We chose to prioritize these use cases because these are currently not well-served by Node.js' API.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## Version Matchups
|
||||||
|
|
||||||
|
| Node.js | @pkgjs/parseArgs |
|
||||||
|
| -- | -- |
|
||||||
|
| [v18.3.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [v0.9.1](https://github.com/pkgjs/parseargs/tree/v0.9.1#utilparseargsconfig) |
|
||||||
|
| [v16.17.0](https://nodejs.org/dist/latest-v16.x/docs/api/util.html#utilparseargsconfig), [v18.7.0](https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig) | [0.10.0](https://github.com/pkgjs/parseargs/tree/v0.10.0#utilparseargsconfig) |
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## 🚀 Getting Started
|
||||||
|
|
||||||
|
1. **Install dependencies.**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Open the index.js file and start editing!**
|
||||||
|
|
||||||
|
3. **Test your code by calling parseArgs through our test file**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## 🙌 Contributing
|
||||||
|
|
||||||
|
Any person who wants to contribute to the initiative is welcome! Please first read the [Contributing Guide](CONTRIBUTING.md)
|
||||||
|
|
||||||
|
Additionally, reading the [`Examples w/ Output`](#-examples-w-output) section of this document will be the best way to familiarize yourself with the target expected behavior for parseArgs() once it is fully implemented.
|
||||||
|
|
||||||
|
This package was implemented using [tape](https://www.npmjs.com/package/tape) as its test harness.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## 💡 `process.mainArgs` Proposal
|
||||||
|
|
||||||
|
> Note: This can be moved forward independently of the `util.parseArgs()` proposal/work.
|
||||||
|
|
||||||
|
### Implementation:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
process.mainArgs = process.argv.slice(process._exec ? 1 : 2)
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## 📃 Examples
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { parseArgs } = require('@pkgjs/parseargs');
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { parseArgs } = require('@pkgjs/parseargs');
|
||||||
|
// specify the options that may be used
|
||||||
|
const options = {
|
||||||
|
foo: { type: 'string'},
|
||||||
|
bar: { type: 'boolean' },
|
||||||
|
};
|
||||||
|
const args = ['--foo=a', '--bar'];
|
||||||
|
const { values, positionals } = parseArgs({ args, options });
|
||||||
|
// values = { foo: 'a', bar: true }
|
||||||
|
// positionals = []
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { parseArgs } = require('@pkgjs/parseargs');
|
||||||
|
// type:string & multiple
|
||||||
|
const options = {
|
||||||
|
foo: {
|
||||||
|
type: 'string',
|
||||||
|
multiple: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const args = ['--foo=a', '--foo', 'b'];
|
||||||
|
const { values, positionals } = parseArgs({ args, options });
|
||||||
|
// values = { foo: [ 'a', 'b' ] }
|
||||||
|
// positionals = []
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { parseArgs } = require('@pkgjs/parseargs');
|
||||||
|
// shorts
|
||||||
|
const options = {
|
||||||
|
foo: {
|
||||||
|
short: 'f',
|
||||||
|
type: 'boolean'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const args = ['-f', 'b'];
|
||||||
|
const { values, positionals } = parseArgs({ args, options, allowPositionals: true });
|
||||||
|
// values = { foo: true }
|
||||||
|
// positionals = ['b']
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { parseArgs } = require('@pkgjs/parseargs');
|
||||||
|
// unconfigured
|
||||||
|
const options = {};
|
||||||
|
const args = ['-f', '--foo=a', '--bar', 'b'];
|
||||||
|
const { values, positionals } = parseArgs({ strict: false, args, options, allowPositionals: true });
|
||||||
|
// values = { f: true, foo: 'a', bar: true }
|
||||||
|
// positionals = ['b']
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
## F.A.Qs
|
||||||
|
|
||||||
|
- Is `cmd --foo=bar baz` the same as `cmd baz --foo=bar`?
|
||||||
|
- yes
|
||||||
|
- Does the parser execute a function?
|
||||||
|
- no
|
||||||
|
- Does the parser execute one of several functions, depending on input?
|
||||||
|
- no
|
||||||
|
- Can subcommands take options that are distinct from the main command?
|
||||||
|
- no
|
||||||
|
- Does it output generated help when no options match?
|
||||||
|
- no
|
||||||
|
- Does it generated short usage? Like: `usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]`
|
||||||
|
- no (no usage/help at all)
|
||||||
|
- Does the user provide the long usage text? For each option? For the whole command?
|
||||||
|
- no
|
||||||
|
- Do subcommands (if implemented) have their own usage output?
|
||||||
|
- no
|
||||||
|
- Does usage print if the user runs `cmd --help`?
|
||||||
|
- no
|
||||||
|
- Does it set `process.exitCode`?
|
||||||
|
- no
|
||||||
|
- Does usage print to stderr or stdout?
|
||||||
|
- N/A
|
||||||
|
- Does it check types? (Say, specify that an option is a boolean, number, etc.)
|
||||||
|
- no
|
||||||
|
- Can an option have more than one type? (string or false, for example)
|
||||||
|
- no
|
||||||
|
- Can the user define a type? (Say, `type: path` to call `path.resolve()` on the argument.)
|
||||||
|
- no
|
||||||
|
- Does a `--foo=0o22` mean 0, 22, 18, or "0o22"?
|
||||||
|
- `"0o22"`
|
||||||
|
- Does it coerce types?
|
||||||
|
- no
|
||||||
|
- Does `--no-foo` coerce to `--foo=false`? For all options? Only boolean options?
|
||||||
|
- no, it sets `{values:{'no-foo': true}}`
|
||||||
|
- Is `--foo` the same as `--foo=true`? Only for known booleans? Only at the end?
|
||||||
|
- no, they are not the same. There is no special handling of `true` as a value so it is just another string.
|
||||||
|
- Does it read environment variables? Ie, is `FOO=1 cmd` the same as `cmd --foo=1`?
|
||||||
|
- no
|
||||||
|
- Do unknown arguments raise an error? Are they parsed? Are they treated as positional arguments?
|
||||||
|
- no, they are parsed, not treated as positionals
|
||||||
|
- Does `--` signal the end of options?
|
||||||
|
- yes
|
||||||
|
- Is `--` included as a positional?
|
||||||
|
- no
|
||||||
|
- Is `program -- foo` the same as `program foo`?
|
||||||
|
- yes, both store `{positionals:['foo']}`
|
||||||
|
- Does the API specify whether a `--` was present/relevant?
|
||||||
|
- no
|
||||||
|
- Is `-bar` the same as `--bar`?
|
||||||
|
- no, `-bar` is a short option or options, with expansion logic that follows the
|
||||||
|
[Utility Syntax Guidelines in POSIX.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html). `-bar` expands to `-b`, `-a`, `-r`.
|
||||||
|
- Is `---foo` the same as `--foo`?
|
||||||
|
- no
|
||||||
|
- the first is a long option named `'-foo'`
|
||||||
|
- the second is a long option named `'foo'`
|
||||||
|
- Is `-` a positional? ie, `bash some-test.sh | tap -`
|
||||||
|
- yes
|
||||||
|
|
||||||
|
## Links & Resources
|
||||||
|
|
||||||
|
* [Initial Tooling Issue](https://github.com/nodejs/tooling/issues/19)
|
||||||
|
* [Initial Proposal](https://github.com/nodejs/node/pull/35015)
|
||||||
|
* [parseArgs Proposal](https://github.com/nodejs/node/pull/42675)
|
||||||
|
|
||||||
|
[coverage-image]: https://img.shields.io/nycrc/pkgjs/parseargs
|
||||||
|
[coverage-url]: https://github.com/pkgjs/parseargs/blob/main/.nycrc
|
||||||
|
[pkgjs/parseargs]: https://github.com/pkgjs/parseargs
|
25
node_modules/@pkgjs/parseargs/examples/is-default-value.js
generated
vendored
Normal file
25
node_modules/@pkgjs/parseargs/examples/is-default-value.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This example shows how to understand if a default value is used or not.
|
||||||
|
|
||||||
|
// 1. const { parseArgs } = require('node:util'); // from node
|
||||||
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||||
|
const { parseArgs } = require('..'); // in repo
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
file: { short: 'f', type: 'string', default: 'FOO' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
const isFileDefault = !tokens.some((token) => token.kind === 'option' &&
|
||||||
|
token.name === 'file'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(values);
|
||||||
|
console.log(`Is the file option [${values.file}] the default value? ${isFileDefault}`);
|
||||||
|
|
||||||
|
// Try the following:
|
||||||
|
// node is-default-value.js
|
||||||
|
// node is-default-value.js -f FILE
|
||||||
|
// node is-default-value.js --file FILE
|
35
node_modules/@pkgjs/parseargs/examples/limit-long-syntax.js
generated
vendored
Normal file
35
node_modules/@pkgjs/parseargs/examples/limit-long-syntax.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This is an example of using tokens to add a custom behaviour.
|
||||||
|
//
|
||||||
|
// Require the use of `=` for long options and values by blocking
|
||||||
|
// the use of space separated values.
|
||||||
|
// So allow `--foo=bar`, and not allow `--foo bar`.
|
||||||
|
//
|
||||||
|
// Note: this is not a common behaviour, most CLIs allow both forms.
|
||||||
|
|
||||||
|
// 1. const { parseArgs } = require('node:util'); // from node
|
||||||
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||||
|
const { parseArgs } = require('..'); // in repo
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
file: { short: 'f', type: 'string' },
|
||||||
|
log: { type: 'string' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
const badToken = tokens.find((token) => token.kind === 'option' &&
|
||||||
|
token.value != null &&
|
||||||
|
token.rawName.startsWith('--') &&
|
||||||
|
!token.inlineValue
|
||||||
|
);
|
||||||
|
if (badToken) {
|
||||||
|
throw new Error(`Option value for '${badToken.rawName}' must be inline, like '${badToken.rawName}=VALUE'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(values);
|
||||||
|
|
||||||
|
// Try the following:
|
||||||
|
// node limit-long-syntax.js -f FILE --log=LOG
|
||||||
|
// node limit-long-syntax.js --file FILE
|
43
node_modules/@pkgjs/parseargs/examples/negate.js
generated
vendored
Normal file
43
node_modules/@pkgjs/parseargs/examples/negate.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This example is used in the documentation.
|
||||||
|
|
||||||
|
// How might I add my own support for --no-foo?
|
||||||
|
|
||||||
|
// 1. const { parseArgs } = require('node:util'); // from node
|
||||||
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||||
|
const { parseArgs } = require('..'); // in repo
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
'color': { type: 'boolean' },
|
||||||
|
'no-color': { type: 'boolean' },
|
||||||
|
'logfile': { type: 'string' },
|
||||||
|
'no-logfile': { type: 'boolean' },
|
||||||
|
};
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
// Reprocess the option tokens and overwrite the returned values.
|
||||||
|
tokens
|
||||||
|
.filter((token) => token.kind === 'option')
|
||||||
|
.forEach((token) => {
|
||||||
|
if (token.name.startsWith('no-')) {
|
||||||
|
// Store foo:false for --no-foo
|
||||||
|
const positiveName = token.name.slice(3);
|
||||||
|
values[positiveName] = false;
|
||||||
|
delete values[token.name];
|
||||||
|
} else {
|
||||||
|
// Resave value so last one wins if both --foo and --no-foo.
|
||||||
|
values[token.name] = token.value ?? true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const color = values.color;
|
||||||
|
const logfile = values.logfile ?? 'default.log';
|
||||||
|
|
||||||
|
console.log({ logfile, color });
|
||||||
|
|
||||||
|
// Try the following:
|
||||||
|
// node negate.js
|
||||||
|
// node negate.js --no-logfile --no-color
|
||||||
|
// negate.js --logfile=test.log --color
|
||||||
|
// node negate.js --no-logfile --logfile=test.log --color --no-color
|
31
node_modules/@pkgjs/parseargs/examples/no-repeated-options.js
generated
vendored
Normal file
31
node_modules/@pkgjs/parseargs/examples/no-repeated-options.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This is an example of using tokens to add a custom behaviour.
|
||||||
|
//
|
||||||
|
// Throw an error if an option is used more than once.
|
||||||
|
|
||||||
|
// 1. const { parseArgs } = require('node:util'); // from node
|
||||||
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||||
|
const { parseArgs } = require('..'); // in repo
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
ding: { type: 'boolean', short: 'd' },
|
||||||
|
beep: { type: 'boolean', short: 'b' }
|
||||||
|
};
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
const seenBefore = new Set();
|
||||||
|
tokens.forEach((token) => {
|
||||||
|
if (token.kind !== 'option') return;
|
||||||
|
if (seenBefore.has(token.name)) {
|
||||||
|
throw new Error(`option '${token.name}' used multiple times`);
|
||||||
|
}
|
||||||
|
seenBefore.add(token.name);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(values);
|
||||||
|
|
||||||
|
// Try the following:
|
||||||
|
// node no-repeated-options --ding --beep
|
||||||
|
// node no-repeated-options --beep -b
|
||||||
|
// node no-repeated-options -ddd
|
41
node_modules/@pkgjs/parseargs/examples/ordered-options.mjs
generated
vendored
Normal file
41
node_modules/@pkgjs/parseargs/examples/ordered-options.mjs
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// This is an example of using tokens to add a custom behaviour.
|
||||||
|
//
|
||||||
|
// This adds a option order check so that --some-unstable-option
|
||||||
|
// may only be used after --enable-experimental-options
|
||||||
|
//
|
||||||
|
// Note: this is not a common behaviour, the order of different options
|
||||||
|
// does not usually matter.
|
||||||
|
|
||||||
|
import { parseArgs } from '../index.js';
|
||||||
|
|
||||||
|
function findTokenIndex(tokens, target) {
|
||||||
|
return tokens.findIndex((token) => token.kind === 'option' &&
|
||||||
|
token.name === target
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const experimentalName = 'enable-experimental-options';
|
||||||
|
const unstableName = 'some-unstable-option';
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
[experimentalName]: { type: 'boolean' },
|
||||||
|
[unstableName]: { type: 'boolean' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const { values, tokens } = parseArgs({ options, tokens: true });
|
||||||
|
|
||||||
|
const experimentalIndex = findTokenIndex(tokens, experimentalName);
|
||||||
|
const unstableIndex = findTokenIndex(tokens, unstableName);
|
||||||
|
if (unstableIndex !== -1 &&
|
||||||
|
((experimentalIndex === -1) || (unstableIndex < experimentalIndex))) {
|
||||||
|
throw new Error(`'--${experimentalName}' must be specified before '--${unstableName}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(values);
|
||||||
|
|
||||||
|
/* eslint-disable max-len */
|
||||||
|
// Try the following:
|
||||||
|
// node ordered-options.mjs
|
||||||
|
// node ordered-options.mjs --some-unstable-option
|
||||||
|
// node ordered-options.mjs --some-unstable-option --enable-experimental-options
|
||||||
|
// node ordered-options.mjs --enable-experimental-options --some-unstable-option
|
26
node_modules/@pkgjs/parseargs/examples/simple-hard-coded.js
generated
vendored
Normal file
26
node_modules/@pkgjs/parseargs/examples/simple-hard-coded.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This example is used in the documentation.
|
||||||
|
|
||||||
|
// 1. const { parseArgs } = require('node:util'); // from node
|
||||||
|
// 2. const { parseArgs } = require('@pkgjs/parseargs'); // from package
|
||||||
|
const { parseArgs } = require('..'); // in repo
|
||||||
|
|
||||||
|
const args = ['-f', '--bar', 'b'];
|
||||||
|
const options = {
|
||||||
|
foo: {
|
||||||
|
type: 'boolean',
|
||||||
|
short: 'f'
|
||||||
|
},
|
||||||
|
bar: {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const {
|
||||||
|
values,
|
||||||
|
positionals
|
||||||
|
} = parseArgs({ args, options });
|
||||||
|
console.log(values, positionals);
|
||||||
|
|
||||||
|
// Try the following:
|
||||||
|
// node simple-hard-coded.js
|
396
node_modules/@pkgjs/parseargs/index.js
generated
vendored
Normal file
396
node_modules/@pkgjs/parseargs/index.js
generated
vendored
Normal file
@ -0,0 +1,396 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const {
|
||||||
|
ArrayPrototypeForEach,
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
|
ArrayPrototypeMap,
|
||||||
|
ArrayPrototypePush,
|
||||||
|
ArrayPrototypePushApply,
|
||||||
|
ArrayPrototypeShift,
|
||||||
|
ArrayPrototypeSlice,
|
||||||
|
ArrayPrototypeUnshiftApply,
|
||||||
|
ObjectEntries,
|
||||||
|
ObjectPrototypeHasOwnProperty: ObjectHasOwn,
|
||||||
|
StringPrototypeCharAt,
|
||||||
|
StringPrototypeIndexOf,
|
||||||
|
StringPrototypeSlice,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
|
} = require('./internal/primordials');
|
||||||
|
|
||||||
|
const {
|
||||||
|
validateArray,
|
||||||
|
validateBoolean,
|
||||||
|
validateBooleanArray,
|
||||||
|
validateObject,
|
||||||
|
validateString,
|
||||||
|
validateStringArray,
|
||||||
|
validateUnion,
|
||||||
|
} = require('./internal/validators');
|
||||||
|
|
||||||
|
const {
|
||||||
|
kEmptyObject,
|
||||||
|
} = require('./internal/util');
|
||||||
|
|
||||||
|
const {
|
||||||
|
findLongOptionForShort,
|
||||||
|
isLoneLongOption,
|
||||||
|
isLoneShortOption,
|
||||||
|
isLongOptionAndValue,
|
||||||
|
isOptionValue,
|
||||||
|
isOptionLikeValue,
|
||||||
|
isShortOptionAndValue,
|
||||||
|
isShortOptionGroup,
|
||||||
|
useDefaultValueOption,
|
||||||
|
objectGetOwn,
|
||||||
|
optionsGetOwn,
|
||||||
|
} = require('./utils');
|
||||||
|
|
||||||
|
const {
|
||||||
|
codes: {
|
||||||
|
ERR_INVALID_ARG_VALUE,
|
||||||
|
ERR_PARSE_ARGS_INVALID_OPTION_VALUE,
|
||||||
|
ERR_PARSE_ARGS_UNKNOWN_OPTION,
|
||||||
|
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL,
|
||||||
|
},
|
||||||
|
} = require('./internal/errors');
|
||||||
|
|
||||||
|
function getMainArgs() {
|
||||||
|
// Work out where to slice process.argv for user supplied arguments.
|
||||||
|
|
||||||
|
// Check node options for scenarios where user CLI args follow executable.
|
||||||
|
const execArgv = process.execArgv;
|
||||||
|
if (ArrayPrototypeIncludes(execArgv, '-e') ||
|
||||||
|
ArrayPrototypeIncludes(execArgv, '--eval') ||
|
||||||
|
ArrayPrototypeIncludes(execArgv, '-p') ||
|
||||||
|
ArrayPrototypeIncludes(execArgv, '--print')) {
|
||||||
|
return ArrayPrototypeSlice(process.argv, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normally first two arguments are executable and script, then CLI arguments
|
||||||
|
return ArrayPrototypeSlice(process.argv, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In strict mode, throw for possible usage errors like --foo --bar
|
||||||
|
*
|
||||||
|
* @param {object} token - from tokens as available from parseArgs
|
||||||
|
*/
|
||||||
|
function checkOptionLikeValue(token) {
|
||||||
|
if (!token.inlineValue && isOptionLikeValue(token.value)) {
|
||||||
|
// Only show short example if user used short option.
|
||||||
|
const example = StringPrototypeStartsWith(token.rawName, '--') ?
|
||||||
|
`'${token.rawName}=-XYZ'` :
|
||||||
|
`'--${token.name}=-XYZ' or '${token.rawName}-XYZ'`;
|
||||||
|
const errorMessage = `Option '${token.rawName}' argument is ambiguous.
|
||||||
|
Did you forget to specify the option argument for '${token.rawName}'?
|
||||||
|
To specify an option argument starting with a dash use ${example}.`;
|
||||||
|
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In strict mode, throw for usage errors.
|
||||||
|
*
|
||||||
|
* @param {object} config - from config passed to parseArgs
|
||||||
|
* @param {object} token - from tokens as available from parseArgs
|
||||||
|
*/
|
||||||
|
function checkOptionUsage(config, token) {
|
||||||
|
if (!ObjectHasOwn(config.options, token.name)) {
|
||||||
|
throw new ERR_PARSE_ARGS_UNKNOWN_OPTION(
|
||||||
|
token.rawName, config.allowPositionals);
|
||||||
|
}
|
||||||
|
|
||||||
|
const short = optionsGetOwn(config.options, token.name, 'short');
|
||||||
|
const shortAndLong = `${short ? `-${short}, ` : ''}--${token.name}`;
|
||||||
|
const type = optionsGetOwn(config.options, token.name, 'type');
|
||||||
|
if (type === 'string' && typeof token.value !== 'string') {
|
||||||
|
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong} <value>' argument missing`);
|
||||||
|
}
|
||||||
|
// (Idiomatic test for undefined||null, expecting undefined.)
|
||||||
|
if (type === 'boolean' && token.value != null) {
|
||||||
|
throw new ERR_PARSE_ARGS_INVALID_OPTION_VALUE(`Option '${shortAndLong}' does not take an argument`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the option value in `values`.
|
||||||
|
*
|
||||||
|
* @param {string} longOption - long option name e.g. 'foo'
|
||||||
|
* @param {string|undefined} optionValue - value from user args
|
||||||
|
* @param {object} options - option configs, from parseArgs({ options })
|
||||||
|
* @param {object} values - option values returned in `values` by parseArgs
|
||||||
|
*/
|
||||||
|
function storeOption(longOption, optionValue, options, values) {
|
||||||
|
if (longOption === '__proto__') {
|
||||||
|
return; // No. Just no.
|
||||||
|
}
|
||||||
|
|
||||||
|
// We store based on the option value rather than option type,
|
||||||
|
// preserving the users intent for author to deal with.
|
||||||
|
const newValue = optionValue ?? true;
|
||||||
|
if (optionsGetOwn(options, longOption, 'multiple')) {
|
||||||
|
// Always store value in array, including for boolean.
|
||||||
|
// values[longOption] starts out not present,
|
||||||
|
// first value is added as new array [newValue],
|
||||||
|
// subsequent values are pushed to existing array.
|
||||||
|
// (note: values has null prototype, so simpler usage)
|
||||||
|
if (values[longOption]) {
|
||||||
|
ArrayPrototypePush(values[longOption], newValue);
|
||||||
|
} else {
|
||||||
|
values[longOption] = [newValue];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
values[longOption] = newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the default option value in `values`.
|
||||||
|
*
|
||||||
|
* @param {string} longOption - long option name e.g. 'foo'
|
||||||
|
* @param {string
|
||||||
|
* | boolean
|
||||||
|
* | string[]
|
||||||
|
* | boolean[]} optionValue - default value from option config
|
||||||
|
* @param {object} values - option values returned in `values` by parseArgs
|
||||||
|
*/
|
||||||
|
function storeDefaultOption(longOption, optionValue, values) {
|
||||||
|
if (longOption === '__proto__') {
|
||||||
|
return; // No. Just no.
|
||||||
|
}
|
||||||
|
|
||||||
|
values[longOption] = optionValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process args and turn into identified tokens:
|
||||||
|
* - option (along with value, if any)
|
||||||
|
* - positional
|
||||||
|
* - option-terminator
|
||||||
|
*
|
||||||
|
* @param {string[]} args - from parseArgs({ args }) or mainArgs
|
||||||
|
* @param {object} options - option configs, from parseArgs({ options })
|
||||||
|
*/
|
||||||
|
function argsToTokens(args, options) {
|
||||||
|
const tokens = [];
|
||||||
|
let index = -1;
|
||||||
|
let groupCount = 0;
|
||||||
|
|
||||||
|
const remainingArgs = ArrayPrototypeSlice(args);
|
||||||
|
while (remainingArgs.length > 0) {
|
||||||
|
const arg = ArrayPrototypeShift(remainingArgs);
|
||||||
|
const nextArg = remainingArgs[0];
|
||||||
|
if (groupCount > 0)
|
||||||
|
groupCount--;
|
||||||
|
else
|
||||||
|
index++;
|
||||||
|
|
||||||
|
// Check if `arg` is an options terminator.
|
||||||
|
// Guideline 10 in https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html
|
||||||
|
if (arg === '--') {
|
||||||
|
// Everything after a bare '--' is considered a positional argument.
|
||||||
|
ArrayPrototypePush(tokens, { kind: 'option-terminator', index });
|
||||||
|
ArrayPrototypePushApply(
|
||||||
|
tokens, ArrayPrototypeMap(remainingArgs, (arg) => {
|
||||||
|
return { kind: 'positional', index: ++index, value: arg };
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break; // Finished processing args, leave while loop.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoneShortOption(arg)) {
|
||||||
|
// e.g. '-f'
|
||||||
|
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||||
|
const longOption = findLongOptionForShort(shortOption, options);
|
||||||
|
let value;
|
||||||
|
let inlineValue;
|
||||||
|
if (optionsGetOwn(options, longOption, 'type') === 'string' &&
|
||||||
|
isOptionValue(nextArg)) {
|
||||||
|
// e.g. '-f', 'bar'
|
||||||
|
value = ArrayPrototypeShift(remainingArgs);
|
||||||
|
inlineValue = false;
|
||||||
|
}
|
||||||
|
ArrayPrototypePush(
|
||||||
|
tokens,
|
||||||
|
{ kind: 'option', name: longOption, rawName: arg,
|
||||||
|
index, value, inlineValue });
|
||||||
|
if (value != null) ++index;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShortOptionGroup(arg, options)) {
|
||||||
|
// Expand -fXzy to -f -X -z -y
|
||||||
|
const expanded = [];
|
||||||
|
for (let index = 1; index < arg.length; index++) {
|
||||||
|
const shortOption = StringPrototypeCharAt(arg, index);
|
||||||
|
const longOption = findLongOptionForShort(shortOption, options);
|
||||||
|
if (optionsGetOwn(options, longOption, 'type') !== 'string' ||
|
||||||
|
index === arg.length - 1) {
|
||||||
|
// Boolean option, or last short in group. Well formed.
|
||||||
|
ArrayPrototypePush(expanded, `-${shortOption}`);
|
||||||
|
} else {
|
||||||
|
// String option in middle. Yuck.
|
||||||
|
// Expand -abfFILE to -a -b -fFILE
|
||||||
|
ArrayPrototypePush(expanded, `-${StringPrototypeSlice(arg, index)}`);
|
||||||
|
break; // finished short group
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayPrototypeUnshiftApply(remainingArgs, expanded);
|
||||||
|
groupCount = expanded.length;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShortOptionAndValue(arg, options)) {
|
||||||
|
// e.g. -fFILE
|
||||||
|
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||||
|
const longOption = findLongOptionForShort(shortOption, options);
|
||||||
|
const value = StringPrototypeSlice(arg, 2);
|
||||||
|
ArrayPrototypePush(
|
||||||
|
tokens,
|
||||||
|
{ kind: 'option', name: longOption, rawName: `-${shortOption}`,
|
||||||
|
index, value, inlineValue: true });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoneLongOption(arg)) {
|
||||||
|
// e.g. '--foo'
|
||||||
|
const longOption = StringPrototypeSlice(arg, 2);
|
||||||
|
let value;
|
||||||
|
let inlineValue;
|
||||||
|
if (optionsGetOwn(options, longOption, 'type') === 'string' &&
|
||||||
|
isOptionValue(nextArg)) {
|
||||||
|
// e.g. '--foo', 'bar'
|
||||||
|
value = ArrayPrototypeShift(remainingArgs);
|
||||||
|
inlineValue = false;
|
||||||
|
}
|
||||||
|
ArrayPrototypePush(
|
||||||
|
tokens,
|
||||||
|
{ kind: 'option', name: longOption, rawName: arg,
|
||||||
|
index, value, inlineValue });
|
||||||
|
if (value != null) ++index;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLongOptionAndValue(arg)) {
|
||||||
|
// e.g. --foo=bar
|
||||||
|
const equalIndex = StringPrototypeIndexOf(arg, '=');
|
||||||
|
const longOption = StringPrototypeSlice(arg, 2, equalIndex);
|
||||||
|
const value = StringPrototypeSlice(arg, equalIndex + 1);
|
||||||
|
ArrayPrototypePush(
|
||||||
|
tokens,
|
||||||
|
{ kind: 'option', name: longOption, rawName: `--${longOption}`,
|
||||||
|
index, value, inlineValue: true });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayPrototypePush(tokens, { kind: 'positional', index, value: arg });
|
||||||
|
}
|
||||||
|
|
||||||
|
return tokens;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parseArgs = (config = kEmptyObject) => {
|
||||||
|
const args = objectGetOwn(config, 'args') ?? getMainArgs();
|
||||||
|
const strict = objectGetOwn(config, 'strict') ?? true;
|
||||||
|
const allowPositionals = objectGetOwn(config, 'allowPositionals') ?? !strict;
|
||||||
|
const returnTokens = objectGetOwn(config, 'tokens') ?? false;
|
||||||
|
const options = objectGetOwn(config, 'options') ?? { __proto__: null };
|
||||||
|
// Bundle these up for passing to strict-mode checks.
|
||||||
|
const parseConfig = { args, strict, options, allowPositionals };
|
||||||
|
|
||||||
|
// Validate input configuration.
|
||||||
|
validateArray(args, 'args');
|
||||||
|
validateBoolean(strict, 'strict');
|
||||||
|
validateBoolean(allowPositionals, 'allowPositionals');
|
||||||
|
validateBoolean(returnTokens, 'tokens');
|
||||||
|
validateObject(options, 'options');
|
||||||
|
ArrayPrototypeForEach(
|
||||||
|
ObjectEntries(options),
|
||||||
|
({ 0: longOption, 1: optionConfig }) => {
|
||||||
|
validateObject(optionConfig, `options.${longOption}`);
|
||||||
|
|
||||||
|
// type is required
|
||||||
|
const optionType = objectGetOwn(optionConfig, 'type');
|
||||||
|
validateUnion(optionType, `options.${longOption}.type`, ['string', 'boolean']);
|
||||||
|
|
||||||
|
if (ObjectHasOwn(optionConfig, 'short')) {
|
||||||
|
const shortOption = optionConfig.short;
|
||||||
|
validateString(shortOption, `options.${longOption}.short`);
|
||||||
|
if (shortOption.length !== 1) {
|
||||||
|
throw new ERR_INVALID_ARG_VALUE(
|
||||||
|
`options.${longOption}.short`,
|
||||||
|
shortOption,
|
||||||
|
'must be a single character'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const multipleOption = objectGetOwn(optionConfig, 'multiple');
|
||||||
|
if (ObjectHasOwn(optionConfig, 'multiple')) {
|
||||||
|
validateBoolean(multipleOption, `options.${longOption}.multiple`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultValue = objectGetOwn(optionConfig, 'default');
|
||||||
|
if (defaultValue !== undefined) {
|
||||||
|
let validator;
|
||||||
|
switch (optionType) {
|
||||||
|
case 'string':
|
||||||
|
validator = multipleOption ? validateStringArray : validateString;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'boolean':
|
||||||
|
validator = multipleOption ? validateBooleanArray : validateBoolean;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
validator(defaultValue, `options.${longOption}.default`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Phase 1: identify tokens
|
||||||
|
const tokens = argsToTokens(args, options);
|
||||||
|
|
||||||
|
// Phase 2: process tokens into parsed option values and positionals
|
||||||
|
const result = {
|
||||||
|
values: { __proto__: null },
|
||||||
|
positionals: [],
|
||||||
|
};
|
||||||
|
if (returnTokens) {
|
||||||
|
result.tokens = tokens;
|
||||||
|
}
|
||||||
|
ArrayPrototypeForEach(tokens, (token) => {
|
||||||
|
if (token.kind === 'option') {
|
||||||
|
if (strict) {
|
||||||
|
checkOptionUsage(parseConfig, token);
|
||||||
|
checkOptionLikeValue(token);
|
||||||
|
}
|
||||||
|
storeOption(token.name, token.value, options, result.values);
|
||||||
|
} else if (token.kind === 'positional') {
|
||||||
|
if (!allowPositionals) {
|
||||||
|
throw new ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL(token.value);
|
||||||
|
}
|
||||||
|
ArrayPrototypePush(result.positionals, token.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Phase 3: fill in default values for missing args
|
||||||
|
ArrayPrototypeForEach(ObjectEntries(options), ({ 0: longOption,
|
||||||
|
1: optionConfig }) => {
|
||||||
|
const mustSetDefault = useDefaultValueOption(longOption,
|
||||||
|
optionConfig,
|
||||||
|
result.values);
|
||||||
|
if (mustSetDefault) {
|
||||||
|
storeDefaultOption(longOption,
|
||||||
|
objectGetOwn(optionConfig, 'default'),
|
||||||
|
result.values);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
parseArgs,
|
||||||
|
};
|
47
node_modules/@pkgjs/parseargs/internal/errors.js
generated
vendored
Normal file
47
node_modules/@pkgjs/parseargs/internal/errors.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
class ERR_INVALID_ARG_TYPE extends TypeError {
|
||||||
|
constructor(name, expected, actual) {
|
||||||
|
super(`${name} must be ${expected} got ${actual}`);
|
||||||
|
this.code = 'ERR_INVALID_ARG_TYPE';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_INVALID_ARG_VALUE extends TypeError {
|
||||||
|
constructor(arg1, arg2, expected) {
|
||||||
|
super(`The property ${arg1} ${expected}. Received '${arg2}'`);
|
||||||
|
this.code = 'ERR_INVALID_ARG_VALUE';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_PARSE_ARGS_INVALID_OPTION_VALUE extends Error {
|
||||||
|
constructor(message) {
|
||||||
|
super(message);
|
||||||
|
this.code = 'ERR_PARSE_ARGS_INVALID_OPTION_VALUE';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_PARSE_ARGS_UNKNOWN_OPTION extends Error {
|
||||||
|
constructor(option, allowPositionals) {
|
||||||
|
const suggestDashDash = allowPositionals ? `. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- ${JSON.stringify(option)}` : '';
|
||||||
|
super(`Unknown option '${option}'${suggestDashDash}`);
|
||||||
|
this.code = 'ERR_PARSE_ARGS_UNKNOWN_OPTION';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL extends Error {
|
||||||
|
constructor(positional) {
|
||||||
|
super(`Unexpected argument '${positional}'. This command does not take positional arguments`);
|
||||||
|
this.code = 'ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
codes: {
|
||||||
|
ERR_INVALID_ARG_TYPE,
|
||||||
|
ERR_INVALID_ARG_VALUE,
|
||||||
|
ERR_PARSE_ARGS_INVALID_OPTION_VALUE,
|
||||||
|
ERR_PARSE_ARGS_UNKNOWN_OPTION,
|
||||||
|
ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL,
|
||||||
|
}
|
||||||
|
};
|
393
node_modules/@pkgjs/parseargs/internal/primordials.js
generated
vendored
Normal file
393
node_modules/@pkgjs/parseargs/internal/primordials.js
generated
vendored
Normal file
@ -0,0 +1,393 @@
|
|||||||
|
/*
|
||||||
|
This file is copied from https://github.com/nodejs/node/blob/v14.19.3/lib/internal/per_context/primordials.js
|
||||||
|
under the following license:
|
||||||
|
|
||||||
|
Copyright Node.js contributors. All rights reserved.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-disable node-core/prefer-primordials */
|
||||||
|
|
||||||
|
// This file subclasses and stores the JS builtins that come from the VM
|
||||||
|
// so that Node.js's builtin modules do not need to later look these up from
|
||||||
|
// the global proxy, which can be mutated by users.
|
||||||
|
|
||||||
|
// Use of primordials have sometimes a dramatic impact on performance, please
|
||||||
|
// benchmark all changes made in performance-sensitive areas of the codebase.
|
||||||
|
// See: https://github.com/nodejs/node/pull/38248
|
||||||
|
|
||||||
|
const primordials = {};
|
||||||
|
|
||||||
|
const {
|
||||||
|
defineProperty: ReflectDefineProperty,
|
||||||
|
getOwnPropertyDescriptor: ReflectGetOwnPropertyDescriptor,
|
||||||
|
ownKeys: ReflectOwnKeys,
|
||||||
|
} = Reflect;
|
||||||
|
|
||||||
|
// `uncurryThis` is equivalent to `func => Function.prototype.call.bind(func)`.
|
||||||
|
// It is using `bind.bind(call)` to avoid using `Function.prototype.bind`
|
||||||
|
// and `Function.prototype.call` after it may have been mutated by users.
|
||||||
|
const { apply, bind, call } = Function.prototype;
|
||||||
|
const uncurryThis = bind.bind(call);
|
||||||
|
primordials.uncurryThis = uncurryThis;
|
||||||
|
|
||||||
|
// `applyBind` is equivalent to `func => Function.prototype.apply.bind(func)`.
|
||||||
|
// It is using `bind.bind(apply)` to avoid using `Function.prototype.bind`
|
||||||
|
// and `Function.prototype.apply` after it may have been mutated by users.
|
||||||
|
const applyBind = bind.bind(apply);
|
||||||
|
primordials.applyBind = applyBind;
|
||||||
|
|
||||||
|
// Methods that accept a variable number of arguments, and thus it's useful to
|
||||||
|
// also create `${prefix}${key}Apply`, which uses `Function.prototype.apply`,
|
||||||
|
// instead of `Function.prototype.call`, and thus doesn't require iterator
|
||||||
|
// destructuring.
|
||||||
|
const varargsMethods = [
|
||||||
|
// 'ArrayPrototypeConcat' is omitted, because it performs the spread
|
||||||
|
// on its own for arrays and array-likes with a truthy
|
||||||
|
// @@isConcatSpreadable symbol property.
|
||||||
|
'ArrayOf',
|
||||||
|
'ArrayPrototypePush',
|
||||||
|
'ArrayPrototypeUnshift',
|
||||||
|
// 'FunctionPrototypeCall' is omitted, since there's 'ReflectApply'
|
||||||
|
// and 'FunctionPrototypeApply'.
|
||||||
|
'MathHypot',
|
||||||
|
'MathMax',
|
||||||
|
'MathMin',
|
||||||
|
'StringPrototypeConcat',
|
||||||
|
'TypedArrayOf',
|
||||||
|
];
|
||||||
|
|
||||||
|
function getNewKey(key) {
|
||||||
|
return typeof key === 'symbol' ?
|
||||||
|
`Symbol${key.description[7].toUpperCase()}${key.description.slice(8)}` :
|
||||||
|
`${key[0].toUpperCase()}${key.slice(1)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyAccessor(dest, prefix, key, { enumerable, get, set }) {
|
||||||
|
ReflectDefineProperty(dest, `${prefix}Get${key}`, {
|
||||||
|
value: uncurryThis(get),
|
||||||
|
enumerable
|
||||||
|
});
|
||||||
|
if (set !== undefined) {
|
||||||
|
ReflectDefineProperty(dest, `${prefix}Set${key}`, {
|
||||||
|
value: uncurryThis(set),
|
||||||
|
enumerable
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPropsRenamed(src, dest, prefix) {
|
||||||
|
for (const key of ReflectOwnKeys(src)) {
|
||||||
|
const newKey = getNewKey(key);
|
||||||
|
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||||
|
if ('get' in desc) {
|
||||||
|
copyAccessor(dest, prefix, newKey, desc);
|
||||||
|
} else {
|
||||||
|
const name = `${prefix}${newKey}`;
|
||||||
|
ReflectDefineProperty(dest, name, desc);
|
||||||
|
if (varargsMethods.includes(name)) {
|
||||||
|
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||||
|
// `src` is bound as the `this` so that the static `this` points
|
||||||
|
// to the object it was defined on,
|
||||||
|
// e.g.: `ArrayOfApply` gets a `this` of `Array`:
|
||||||
|
value: applyBind(desc.value, src),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPropsRenamedBound(src, dest, prefix) {
|
||||||
|
for (const key of ReflectOwnKeys(src)) {
|
||||||
|
const newKey = getNewKey(key);
|
||||||
|
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||||
|
if ('get' in desc) {
|
||||||
|
copyAccessor(dest, prefix, newKey, desc);
|
||||||
|
} else {
|
||||||
|
const { value } = desc;
|
||||||
|
if (typeof value === 'function') {
|
||||||
|
desc.value = value.bind(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = `${prefix}${newKey}`;
|
||||||
|
ReflectDefineProperty(dest, name, desc);
|
||||||
|
if (varargsMethods.includes(name)) {
|
||||||
|
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||||
|
value: applyBind(value, src),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPrototype(src, dest, prefix) {
|
||||||
|
for (const key of ReflectOwnKeys(src)) {
|
||||||
|
const newKey = getNewKey(key);
|
||||||
|
const desc = ReflectGetOwnPropertyDescriptor(src, key);
|
||||||
|
if ('get' in desc) {
|
||||||
|
copyAccessor(dest, prefix, newKey, desc);
|
||||||
|
} else {
|
||||||
|
const { value } = desc;
|
||||||
|
if (typeof value === 'function') {
|
||||||
|
desc.value = uncurryThis(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = `${prefix}${newKey}`;
|
||||||
|
ReflectDefineProperty(dest, name, desc);
|
||||||
|
if (varargsMethods.includes(name)) {
|
||||||
|
ReflectDefineProperty(dest, `${name}Apply`, {
|
||||||
|
value: applyBind(value),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create copies of configurable value properties of the global object
|
||||||
|
[
|
||||||
|
'Proxy',
|
||||||
|
'globalThis',
|
||||||
|
].forEach((name) => {
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
primordials[name] = globalThis[name];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create copies of URI handling functions
|
||||||
|
[
|
||||||
|
decodeURI,
|
||||||
|
decodeURIComponent,
|
||||||
|
encodeURI,
|
||||||
|
encodeURIComponent,
|
||||||
|
].forEach((fn) => {
|
||||||
|
primordials[fn.name] = fn;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create copies of the namespace objects
|
||||||
|
[
|
||||||
|
'JSON',
|
||||||
|
'Math',
|
||||||
|
'Proxy',
|
||||||
|
'Reflect',
|
||||||
|
].forEach((name) => {
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
copyPropsRenamed(global[name], primordials, name);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create copies of intrinsic objects
|
||||||
|
[
|
||||||
|
'Array',
|
||||||
|
'ArrayBuffer',
|
||||||
|
'BigInt',
|
||||||
|
'BigInt64Array',
|
||||||
|
'BigUint64Array',
|
||||||
|
'Boolean',
|
||||||
|
'DataView',
|
||||||
|
'Date',
|
||||||
|
'Error',
|
||||||
|
'EvalError',
|
||||||
|
'Float32Array',
|
||||||
|
'Float64Array',
|
||||||
|
'Function',
|
||||||
|
'Int16Array',
|
||||||
|
'Int32Array',
|
||||||
|
'Int8Array',
|
||||||
|
'Map',
|
||||||
|
'Number',
|
||||||
|
'Object',
|
||||||
|
'RangeError',
|
||||||
|
'ReferenceError',
|
||||||
|
'RegExp',
|
||||||
|
'Set',
|
||||||
|
'String',
|
||||||
|
'Symbol',
|
||||||
|
'SyntaxError',
|
||||||
|
'TypeError',
|
||||||
|
'URIError',
|
||||||
|
'Uint16Array',
|
||||||
|
'Uint32Array',
|
||||||
|
'Uint8Array',
|
||||||
|
'Uint8ClampedArray',
|
||||||
|
'WeakMap',
|
||||||
|
'WeakSet',
|
||||||
|
].forEach((name) => {
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
const original = global[name];
|
||||||
|
primordials[name] = original;
|
||||||
|
copyPropsRenamed(original, primordials, name);
|
||||||
|
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create copies of intrinsic objects that require a valid `this` to call
|
||||||
|
// static methods.
|
||||||
|
// Refs: https://www.ecma-international.org/ecma-262/#sec-promise.all
|
||||||
|
[
|
||||||
|
'Promise',
|
||||||
|
].forEach((name) => {
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
const original = global[name];
|
||||||
|
primordials[name] = original;
|
||||||
|
copyPropsRenamedBound(original, primordials, name);
|
||||||
|
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create copies of abstract intrinsic objects that are not directly exposed
|
||||||
|
// on the global object.
|
||||||
|
// Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object
|
||||||
|
[
|
||||||
|
{ name: 'TypedArray', original: Reflect.getPrototypeOf(Uint8Array) },
|
||||||
|
{ name: 'ArrayIterator', original: {
|
||||||
|
prototype: Reflect.getPrototypeOf(Array.prototype[Symbol.iterator]()),
|
||||||
|
} },
|
||||||
|
{ name: 'StringIterator', original: {
|
||||||
|
prototype: Reflect.getPrototypeOf(String.prototype[Symbol.iterator]()),
|
||||||
|
} },
|
||||||
|
].forEach(({ name, original }) => {
|
||||||
|
primordials[name] = original;
|
||||||
|
// The static %TypedArray% methods require a valid `this`, but can't be bound,
|
||||||
|
// as they need a subclass constructor as the receiver:
|
||||||
|
copyPrototype(original, primordials, name);
|
||||||
|
copyPrototype(original.prototype, primordials, `${name}Prototype`);
|
||||||
|
});
|
||||||
|
|
||||||
|
/* eslint-enable node-core/prefer-primordials */
|
||||||
|
|
||||||
|
const {
|
||||||
|
ArrayPrototypeForEach,
|
||||||
|
FunctionPrototypeCall,
|
||||||
|
Map,
|
||||||
|
ObjectFreeze,
|
||||||
|
ObjectSetPrototypeOf,
|
||||||
|
Set,
|
||||||
|
SymbolIterator,
|
||||||
|
WeakMap,
|
||||||
|
WeakSet,
|
||||||
|
} = primordials;
|
||||||
|
|
||||||
|
// Because these functions are used by `makeSafe`, which is exposed
|
||||||
|
// on the `primordials` object, it's important to use const references
|
||||||
|
// to the primordials that they use:
|
||||||
|
const createSafeIterator = (factory, next) => {
|
||||||
|
class SafeIterator {
|
||||||
|
constructor(iterable) {
|
||||||
|
this._iterator = factory(iterable);
|
||||||
|
}
|
||||||
|
next() {
|
||||||
|
return next(this._iterator);
|
||||||
|
}
|
||||||
|
[SymbolIterator]() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ObjectSetPrototypeOf(SafeIterator.prototype, null);
|
||||||
|
ObjectFreeze(SafeIterator.prototype);
|
||||||
|
ObjectFreeze(SafeIterator);
|
||||||
|
return SafeIterator;
|
||||||
|
};
|
||||||
|
|
||||||
|
primordials.SafeArrayIterator = createSafeIterator(
|
||||||
|
primordials.ArrayPrototypeSymbolIterator,
|
||||||
|
primordials.ArrayIteratorPrototypeNext
|
||||||
|
);
|
||||||
|
primordials.SafeStringIterator = createSafeIterator(
|
||||||
|
primordials.StringPrototypeSymbolIterator,
|
||||||
|
primordials.StringIteratorPrototypeNext
|
||||||
|
);
|
||||||
|
|
||||||
|
const copyProps = (src, dest) => {
|
||||||
|
ArrayPrototypeForEach(ReflectOwnKeys(src), (key) => {
|
||||||
|
if (!ReflectGetOwnPropertyDescriptor(dest, key)) {
|
||||||
|
ReflectDefineProperty(
|
||||||
|
dest,
|
||||||
|
key,
|
||||||
|
ReflectGetOwnPropertyDescriptor(src, key));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const makeSafe = (unsafe, safe) => {
|
||||||
|
if (SymbolIterator in unsafe.prototype) {
|
||||||
|
const dummy = new unsafe();
|
||||||
|
let next; // We can reuse the same `next` method.
|
||||||
|
|
||||||
|
ArrayPrototypeForEach(ReflectOwnKeys(unsafe.prototype), (key) => {
|
||||||
|
if (!ReflectGetOwnPropertyDescriptor(safe.prototype, key)) {
|
||||||
|
const desc = ReflectGetOwnPropertyDescriptor(unsafe.prototype, key);
|
||||||
|
if (
|
||||||
|
typeof desc.value === 'function' &&
|
||||||
|
desc.value.length === 0 &&
|
||||||
|
SymbolIterator in (FunctionPrototypeCall(desc.value, dummy) ?? {})
|
||||||
|
) {
|
||||||
|
const createIterator = uncurryThis(desc.value);
|
||||||
|
next = next ?? uncurryThis(createIterator(dummy).next);
|
||||||
|
const SafeIterator = createSafeIterator(createIterator, next);
|
||||||
|
desc.value = function() {
|
||||||
|
return new SafeIterator(this);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
ReflectDefineProperty(safe.prototype, key, desc);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
copyProps(unsafe.prototype, safe.prototype);
|
||||||
|
}
|
||||||
|
copyProps(unsafe, safe);
|
||||||
|
|
||||||
|
ObjectSetPrototypeOf(safe.prototype, null);
|
||||||
|
ObjectFreeze(safe.prototype);
|
||||||
|
ObjectFreeze(safe);
|
||||||
|
return safe;
|
||||||
|
};
|
||||||
|
primordials.makeSafe = makeSafe;
|
||||||
|
|
||||||
|
// Subclass the constructors because we need to use their prototype
|
||||||
|
// methods later.
|
||||||
|
// Defining the `constructor` is necessary here to avoid the default
|
||||||
|
// constructor which uses the user-mutable `%ArrayIteratorPrototype%.next`.
|
||||||
|
primordials.SafeMap = makeSafe(
|
||||||
|
Map,
|
||||||
|
class SafeMap extends Map {
|
||||||
|
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||||
|
}
|
||||||
|
);
|
||||||
|
primordials.SafeWeakMap = makeSafe(
|
||||||
|
WeakMap,
|
||||||
|
class SafeWeakMap extends WeakMap {
|
||||||
|
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||||
|
}
|
||||||
|
);
|
||||||
|
primordials.SafeSet = makeSafe(
|
||||||
|
Set,
|
||||||
|
class SafeSet extends Set {
|
||||||
|
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||||
|
}
|
||||||
|
);
|
||||||
|
primordials.SafeWeakSet = makeSafe(
|
||||||
|
WeakSet,
|
||||||
|
class SafeWeakSet extends WeakSet {
|
||||||
|
constructor(i) { super(i); } // eslint-disable-line no-useless-constructor
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ObjectSetPrototypeOf(primordials, null);
|
||||||
|
ObjectFreeze(primordials);
|
||||||
|
|
||||||
|
module.exports = primordials;
|
14
node_modules/@pkgjs/parseargs/internal/util.js
generated
vendored
Normal file
14
node_modules/@pkgjs/parseargs/internal/util.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This is a placeholder for util.js in node.js land.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ObjectCreate,
|
||||||
|
ObjectFreeze,
|
||||||
|
} = require('./primordials');
|
||||||
|
|
||||||
|
const kEmptyObject = ObjectFreeze(ObjectCreate(null));
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
kEmptyObject,
|
||||||
|
};
|
89
node_modules/@pkgjs/parseargs/internal/validators.js
generated
vendored
Normal file
89
node_modules/@pkgjs/parseargs/internal/validators.js
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This file is a proxy of the original file located at:
|
||||||
|
// https://github.com/nodejs/node/blob/main/lib/internal/validators.js
|
||||||
|
// Every addition or modification to this file must be evaluated
|
||||||
|
// during the PR review.
|
||||||
|
|
||||||
|
const {
|
||||||
|
ArrayIsArray,
|
||||||
|
ArrayPrototypeIncludes,
|
||||||
|
ArrayPrototypeJoin,
|
||||||
|
} = require('./primordials');
|
||||||
|
|
||||||
|
const {
|
||||||
|
codes: {
|
||||||
|
ERR_INVALID_ARG_TYPE
|
||||||
|
}
|
||||||
|
} = require('./errors');
|
||||||
|
|
||||||
|
function validateString(value, name) {
|
||||||
|
if (typeof value !== 'string') {
|
||||||
|
throw new ERR_INVALID_ARG_TYPE(name, 'String', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateUnion(value, name, union) {
|
||||||
|
if (!ArrayPrototypeIncludes(union, value)) {
|
||||||
|
throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateBoolean(value, name) {
|
||||||
|
if (typeof value !== 'boolean') {
|
||||||
|
throw new ERR_INVALID_ARG_TYPE(name, 'Boolean', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateArray(value, name) {
|
||||||
|
if (!ArrayIsArray(value)) {
|
||||||
|
throw new ERR_INVALID_ARG_TYPE(name, 'Array', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateStringArray(value, name) {
|
||||||
|
validateArray(value, name);
|
||||||
|
for (let i = 0; i < value.length; i++) {
|
||||||
|
validateString(value[i], `${name}[${i}]`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateBooleanArray(value, name) {
|
||||||
|
validateArray(value, name);
|
||||||
|
for (let i = 0; i < value.length; i++) {
|
||||||
|
validateBoolean(value[i], `${name}[${i}]`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {unknown} value
|
||||||
|
* @param {string} name
|
||||||
|
* @param {{
|
||||||
|
* allowArray?: boolean,
|
||||||
|
* allowFunction?: boolean,
|
||||||
|
* nullable?: boolean
|
||||||
|
* }} [options]
|
||||||
|
*/
|
||||||
|
function validateObject(value, name, options) {
|
||||||
|
const useDefaultOptions = options == null;
|
||||||
|
const allowArray = useDefaultOptions ? false : options.allowArray;
|
||||||
|
const allowFunction = useDefaultOptions ? false : options.allowFunction;
|
||||||
|
const nullable = useDefaultOptions ? false : options.nullable;
|
||||||
|
if ((!nullable && value === null) ||
|
||||||
|
(!allowArray && ArrayIsArray(value)) ||
|
||||||
|
(typeof value !== 'object' && (
|
||||||
|
!allowFunction || typeof value !== 'function'
|
||||||
|
))) {
|
||||||
|
throw new ERR_INVALID_ARG_TYPE(name, 'Object', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
validateArray,
|
||||||
|
validateObject,
|
||||||
|
validateString,
|
||||||
|
validateStringArray,
|
||||||
|
validateUnion,
|
||||||
|
validateBoolean,
|
||||||
|
validateBooleanArray,
|
||||||
|
};
|
36
node_modules/@pkgjs/parseargs/package.json
generated
vendored
Normal file
36
node_modules/@pkgjs/parseargs/package.json
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "@pkgjs/parseargs",
|
||||||
|
"version": "0.11.0",
|
||||||
|
"description": "Polyfill of future proposal for `util.parseArgs()`",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"main": "index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./index.js",
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"coverage": "c8 --check-coverage tape 'test/*.js'",
|
||||||
|
"test": "c8 tape 'test/*.js'",
|
||||||
|
"posttest": "eslint .",
|
||||||
|
"fix": "npm run posttest -- --fix"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:pkgjs/parseargs.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/pkgjs/parseargs/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/pkgjs/parseargs#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"c8": "^7.10.0",
|
||||||
|
"eslint": "^8.2.0",
|
||||||
|
"eslint-plugin-node-core": "iansu/eslint-plugin-node-core",
|
||||||
|
"tape": "^5.2.2"
|
||||||
|
}
|
||||||
|
}
|
198
node_modules/@pkgjs/parseargs/utils.js
generated
vendored
Normal file
198
node_modules/@pkgjs/parseargs/utils.js
generated
vendored
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const {
|
||||||
|
ArrayPrototypeFind,
|
||||||
|
ObjectEntries,
|
||||||
|
ObjectPrototypeHasOwnProperty: ObjectHasOwn,
|
||||||
|
StringPrototypeCharAt,
|
||||||
|
StringPrototypeIncludes,
|
||||||
|
StringPrototypeStartsWith,
|
||||||
|
} = require('./internal/primordials');
|
||||||
|
|
||||||
|
const {
|
||||||
|
validateObject,
|
||||||
|
} = require('./internal/validators');
|
||||||
|
|
||||||
|
// These are internal utilities to make the parsing logic easier to read, and
|
||||||
|
// add lots of detail for the curious. They are in a separate file to allow
|
||||||
|
// unit testing, although that is not essential (this could be rolled into
|
||||||
|
// main file and just tested implicitly via API).
|
||||||
|
//
|
||||||
|
// These routines are for internal use, not for export to client.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the named property, but only if it is an own property.
|
||||||
|
*/
|
||||||
|
function objectGetOwn(obj, prop) {
|
||||||
|
if (ObjectHasOwn(obj, prop))
|
||||||
|
return obj[prop];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the named options property, but only if it is an own property.
|
||||||
|
*/
|
||||||
|
function optionsGetOwn(options, longOption, prop) {
|
||||||
|
if (ObjectHasOwn(options, longOption))
|
||||||
|
return objectGetOwn(options[longOption], prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the argument may be used as an option value.
|
||||||
|
* @example
|
||||||
|
* isOptionValue('V') // returns true
|
||||||
|
* isOptionValue('-v') // returns true (greedy)
|
||||||
|
* isOptionValue('--foo') // returns true (greedy)
|
||||||
|
* isOptionValue(undefined) // returns false
|
||||||
|
*/
|
||||||
|
function isOptionValue(value) {
|
||||||
|
if (value == null) return false;
|
||||||
|
|
||||||
|
// Open Group Utility Conventions are that an option-argument
|
||||||
|
// is the argument after the option, and may start with a dash.
|
||||||
|
return true; // greedy!
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect whether there is possible confusion and user may have omitted
|
||||||
|
* the option argument, like `--port --verbose` when `port` of type:string.
|
||||||
|
* In strict mode we throw errors if value is option-like.
|
||||||
|
*/
|
||||||
|
function isOptionLikeValue(value) {
|
||||||
|
if (value == null) return false;
|
||||||
|
|
||||||
|
return value.length > 1 && StringPrototypeCharAt(value, 0) === '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if `arg` is just a short option.
|
||||||
|
* @example '-f'
|
||||||
|
*/
|
||||||
|
function isLoneShortOption(arg) {
|
||||||
|
return arg.length === 2 &&
|
||||||
|
StringPrototypeCharAt(arg, 0) === '-' &&
|
||||||
|
StringPrototypeCharAt(arg, 1) !== '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if `arg` is a lone long option.
|
||||||
|
* @example
|
||||||
|
* isLoneLongOption('a') // returns false
|
||||||
|
* isLoneLongOption('-a') // returns false
|
||||||
|
* isLoneLongOption('--foo') // returns true
|
||||||
|
* isLoneLongOption('--foo=bar') // returns false
|
||||||
|
*/
|
||||||
|
function isLoneLongOption(arg) {
|
||||||
|
return arg.length > 2 &&
|
||||||
|
StringPrototypeStartsWith(arg, '--') &&
|
||||||
|
!StringPrototypeIncludes(arg, '=', 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if `arg` is a long option and value in the same argument.
|
||||||
|
* @example
|
||||||
|
* isLongOptionAndValue('--foo') // returns false
|
||||||
|
* isLongOptionAndValue('--foo=bar') // returns true
|
||||||
|
*/
|
||||||
|
function isLongOptionAndValue(arg) {
|
||||||
|
return arg.length > 2 &&
|
||||||
|
StringPrototypeStartsWith(arg, '--') &&
|
||||||
|
StringPrototypeIncludes(arg, '=', 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if `arg` is a short option group.
|
||||||
|
*
|
||||||
|
* See Guideline 5 of the [Open Group Utility Conventions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html).
|
||||||
|
* One or more options without option-arguments, followed by at most one
|
||||||
|
* option that takes an option-argument, should be accepted when grouped
|
||||||
|
* behind one '-' delimiter.
|
||||||
|
* @example
|
||||||
|
* isShortOptionGroup('-a', {}) // returns false
|
||||||
|
* isShortOptionGroup('-ab', {}) // returns true
|
||||||
|
* // -fb is an option and a value, not a short option group
|
||||||
|
* isShortOptionGroup('-fb', {
|
||||||
|
* options: { f: { type: 'string' } }
|
||||||
|
* }) // returns false
|
||||||
|
* isShortOptionGroup('-bf', {
|
||||||
|
* options: { f: { type: 'string' } }
|
||||||
|
* }) // returns true
|
||||||
|
* // -bfb is an edge case, return true and caller sorts it out
|
||||||
|
* isShortOptionGroup('-bfb', {
|
||||||
|
* options: { f: { type: 'string' } }
|
||||||
|
* }) // returns true
|
||||||
|
*/
|
||||||
|
function isShortOptionGroup(arg, options) {
|
||||||
|
if (arg.length <= 2) return false;
|
||||||
|
if (StringPrototypeCharAt(arg, 0) !== '-') return false;
|
||||||
|
if (StringPrototypeCharAt(arg, 1) === '-') return false;
|
||||||
|
|
||||||
|
const firstShort = StringPrototypeCharAt(arg, 1);
|
||||||
|
const longOption = findLongOptionForShort(firstShort, options);
|
||||||
|
return optionsGetOwn(options, longOption, 'type') !== 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if arg is a short string option followed by its value.
|
||||||
|
* @example
|
||||||
|
* isShortOptionAndValue('-a', {}); // returns false
|
||||||
|
* isShortOptionAndValue('-ab', {}); // returns false
|
||||||
|
* isShortOptionAndValue('-fFILE', {
|
||||||
|
* options: { foo: { short: 'f', type: 'string' }}
|
||||||
|
* }) // returns true
|
||||||
|
*/
|
||||||
|
function isShortOptionAndValue(arg, options) {
|
||||||
|
validateObject(options, 'options');
|
||||||
|
|
||||||
|
if (arg.length <= 2) return false;
|
||||||
|
if (StringPrototypeCharAt(arg, 0) !== '-') return false;
|
||||||
|
if (StringPrototypeCharAt(arg, 1) === '-') return false;
|
||||||
|
|
||||||
|
const shortOption = StringPrototypeCharAt(arg, 1);
|
||||||
|
const longOption = findLongOptionForShort(shortOption, options);
|
||||||
|
return optionsGetOwn(options, longOption, 'type') === 'string';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the long option associated with a short option. Looks for a configured
|
||||||
|
* `short` and returns the short option itself if a long option is not found.
|
||||||
|
* @example
|
||||||
|
* findLongOptionForShort('a', {}) // returns 'a'
|
||||||
|
* findLongOptionForShort('b', {
|
||||||
|
* options: { bar: { short: 'b' } }
|
||||||
|
* }) // returns 'bar'
|
||||||
|
*/
|
||||||
|
function findLongOptionForShort(shortOption, options) {
|
||||||
|
validateObject(options, 'options');
|
||||||
|
const longOptionEntry = ArrayPrototypeFind(
|
||||||
|
ObjectEntries(options),
|
||||||
|
({ 1: optionConfig }) => objectGetOwn(optionConfig, 'short') === shortOption
|
||||||
|
);
|
||||||
|
return longOptionEntry?.[0] ?? shortOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given option includes a default value
|
||||||
|
* and that option has not been set by the input args.
|
||||||
|
*
|
||||||
|
* @param {string} longOption - long option name e.g. 'foo'
|
||||||
|
* @param {object} optionConfig - the option configuration properties
|
||||||
|
* @param {object} values - option values returned in `values` by parseArgs
|
||||||
|
*/
|
||||||
|
function useDefaultValueOption(longOption, optionConfig, values) {
|
||||||
|
return objectGetOwn(optionConfig, 'default') !== undefined &&
|
||||||
|
values[longOption] === undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
findLongOptionForShort,
|
||||||
|
isLoneLongOption,
|
||||||
|
isLoneShortOption,
|
||||||
|
isLongOptionAndValue,
|
||||||
|
isOptionValue,
|
||||||
|
isOptionLikeValue,
|
||||||
|
isShortOptionAndValue,
|
||||||
|
isShortOptionGroup,
|
||||||
|
useDefaultValueOption,
|
||||||
|
objectGetOwn,
|
||||||
|
optionsGetOwn,
|
||||||
|
};
|
37
node_modules/ansi-regex/index.d.ts
generated
vendored
Normal file
37
node_modules/ansi-regex/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
declare namespace ansiRegex {
|
||||||
|
interface Options {
|
||||||
|
/**
|
||||||
|
Match only the first ANSI escape.
|
||||||
|
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
onlyFirst: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Regular expression for matching ANSI escape codes.
|
||||||
|
|
||||||
|
@example
|
||||||
|
```
|
||||||
|
import ansiRegex = require('ansi-regex');
|
||||||
|
|
||||||
|
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
ansiRegex().test('cake');
|
||||||
|
//=> false
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||||
|
//=> ['\u001B[4m', '\u001B[0m']
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||||
|
//=> ['\u001B[4m']
|
||||||
|
|
||||||
|
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||||
|
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
declare function ansiRegex(options?: ansiRegex.Options): RegExp;
|
||||||
|
|
||||||
|
export = ansiRegex;
|
10
node_modules/ansi-regex/index.js
generated
vendored
Normal file
10
node_modules/ansi-regex/index.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = ({onlyFirst = false} = {}) => {
|
||||||
|
const pattern = [
|
||||||
|
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
||||||
|
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
||||||
|
].join('|');
|
||||||
|
|
||||||
|
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
||||||
|
};
|
9
node_modules/ansi-regex/license
generated
vendored
Normal file
9
node_modules/ansi-regex/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
55
node_modules/ansi-regex/package.json
generated
vendored
Normal file
55
node_modules/ansi-regex/package.json
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"name": "ansi-regex",
|
||||||
|
"version": "5.0.1",
|
||||||
|
"description": "Regular expression for matching ANSI escape codes",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/ansi-regex",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "sindresorhus.com"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd",
|
||||||
|
"view-supported": "node fixtures/view-codes.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cli",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"command-line",
|
||||||
|
"text",
|
||||||
|
"regex",
|
||||||
|
"regexp",
|
||||||
|
"re",
|
||||||
|
"match",
|
||||||
|
"test",
|
||||||
|
"find",
|
||||||
|
"pattern"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^2.4.0",
|
||||||
|
"tsd": "^0.9.0",
|
||||||
|
"xo": "^0.25.3"
|
||||||
|
}
|
||||||
|
}
|
78
node_modules/ansi-regex/readme.md
generated
vendored
Normal file
78
node_modules/ansi-regex/readme.md
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# ansi-regex
|
||||||
|
|
||||||
|
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
||||||
|
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install ansi-regex
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const ansiRegex = require('ansi-regex');
|
||||||
|
|
||||||
|
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||||
|
//=> true
|
||||||
|
|
||||||
|
ansiRegex().test('cake');
|
||||||
|
//=> false
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||||
|
//=> ['\u001B[4m', '\u001B[0m']
|
||||||
|
|
||||||
|
'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
|
||||||
|
//=> ['\u001B[4m']
|
||||||
|
|
||||||
|
'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
|
||||||
|
//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### ansiRegex(options?)
|
||||||
|
|
||||||
|
Returns a regex for matching ANSI escape codes.
|
||||||
|
|
||||||
|
#### options
|
||||||
|
|
||||||
|
Type: `object`
|
||||||
|
|
||||||
|
##### onlyFirst
|
||||||
|
|
||||||
|
Type: `boolean`<br>
|
||||||
|
Default: `false` *(Matches any ANSI escape codes in a string)*
|
||||||
|
|
||||||
|
Match only the first ANSI escape.
|
||||||
|
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
### Why do you test for codes not in the ECMA 48 standard?
|
||||||
|
|
||||||
|
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
|
||||||
|
|
||||||
|
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
||||||
|
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<b>
|
||||||
|
<a href="https://tidelift.com/subscription/pkg/npm-ansi-regex?utm_source=npm-ansi-regex&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||||
|
</b>
|
||||||
|
<br>
|
||||||
|
<sub>
|
||||||
|
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||||
|
</sub>
|
||||||
|
</div>
|
345
node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
345
node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
declare type CSSColor =
|
||||||
|
| 'aliceblue'
|
||||||
|
| 'antiquewhite'
|
||||||
|
| 'aqua'
|
||||||
|
| 'aquamarine'
|
||||||
|
| 'azure'
|
||||||
|
| 'beige'
|
||||||
|
| 'bisque'
|
||||||
|
| 'black'
|
||||||
|
| 'blanchedalmond'
|
||||||
|
| 'blue'
|
||||||
|
| 'blueviolet'
|
||||||
|
| 'brown'
|
||||||
|
| 'burlywood'
|
||||||
|
| 'cadetblue'
|
||||||
|
| 'chartreuse'
|
||||||
|
| 'chocolate'
|
||||||
|
| 'coral'
|
||||||
|
| 'cornflowerblue'
|
||||||
|
| 'cornsilk'
|
||||||
|
| 'crimson'
|
||||||
|
| 'cyan'
|
||||||
|
| 'darkblue'
|
||||||
|
| 'darkcyan'
|
||||||
|
| 'darkgoldenrod'
|
||||||
|
| 'darkgray'
|
||||||
|
| 'darkgreen'
|
||||||
|
| 'darkgrey'
|
||||||
|
| 'darkkhaki'
|
||||||
|
| 'darkmagenta'
|
||||||
|
| 'darkolivegreen'
|
||||||
|
| 'darkorange'
|
||||||
|
| 'darkorchid'
|
||||||
|
| 'darkred'
|
||||||
|
| 'darksalmon'
|
||||||
|
| 'darkseagreen'
|
||||||
|
| 'darkslateblue'
|
||||||
|
| 'darkslategray'
|
||||||
|
| 'darkslategrey'
|
||||||
|
| 'darkturquoise'
|
||||||
|
| 'darkviolet'
|
||||||
|
| 'deeppink'
|
||||||
|
| 'deepskyblue'
|
||||||
|
| 'dimgray'
|
||||||
|
| 'dimgrey'
|
||||||
|
| 'dodgerblue'
|
||||||
|
| 'firebrick'
|
||||||
|
| 'floralwhite'
|
||||||
|
| 'forestgreen'
|
||||||
|
| 'fuchsia'
|
||||||
|
| 'gainsboro'
|
||||||
|
| 'ghostwhite'
|
||||||
|
| 'gold'
|
||||||
|
| 'goldenrod'
|
||||||
|
| 'gray'
|
||||||
|
| 'green'
|
||||||
|
| 'greenyellow'
|
||||||
|
| 'grey'
|
||||||
|
| 'honeydew'
|
||||||
|
| 'hotpink'
|
||||||
|
| 'indianred'
|
||||||
|
| 'indigo'
|
||||||
|
| 'ivory'
|
||||||
|
| 'khaki'
|
||||||
|
| 'lavender'
|
||||||
|
| 'lavenderblush'
|
||||||
|
| 'lawngreen'
|
||||||
|
| 'lemonchiffon'
|
||||||
|
| 'lightblue'
|
||||||
|
| 'lightcoral'
|
||||||
|
| 'lightcyan'
|
||||||
|
| 'lightgoldenrodyellow'
|
||||||
|
| 'lightgray'
|
||||||
|
| 'lightgreen'
|
||||||
|
| 'lightgrey'
|
||||||
|
| 'lightpink'
|
||||||
|
| 'lightsalmon'
|
||||||
|
| 'lightseagreen'
|
||||||
|
| 'lightskyblue'
|
||||||
|
| 'lightslategray'
|
||||||
|
| 'lightslategrey'
|
||||||
|
| 'lightsteelblue'
|
||||||
|
| 'lightyellow'
|
||||||
|
| 'lime'
|
||||||
|
| 'limegreen'
|
||||||
|
| 'linen'
|
||||||
|
| 'magenta'
|
||||||
|
| 'maroon'
|
||||||
|
| 'mediumaquamarine'
|
||||||
|
| 'mediumblue'
|
||||||
|
| 'mediumorchid'
|
||||||
|
| 'mediumpurple'
|
||||||
|
| 'mediumseagreen'
|
||||||
|
| 'mediumslateblue'
|
||||||
|
| 'mediumspringgreen'
|
||||||
|
| 'mediumturquoise'
|
||||||
|
| 'mediumvioletred'
|
||||||
|
| 'midnightblue'
|
||||||
|
| 'mintcream'
|
||||||
|
| 'mistyrose'
|
||||||
|
| 'moccasin'
|
||||||
|
| 'navajowhite'
|
||||||
|
| 'navy'
|
||||||
|
| 'oldlace'
|
||||||
|
| 'olive'
|
||||||
|
| 'olivedrab'
|
||||||
|
| 'orange'
|
||||||
|
| 'orangered'
|
||||||
|
| 'orchid'
|
||||||
|
| 'palegoldenrod'
|
||||||
|
| 'palegreen'
|
||||||
|
| 'paleturquoise'
|
||||||
|
| 'palevioletred'
|
||||||
|
| 'papayawhip'
|
||||||
|
| 'peachpuff'
|
||||||
|
| 'peru'
|
||||||
|
| 'pink'
|
||||||
|
| 'plum'
|
||||||
|
| 'powderblue'
|
||||||
|
| 'purple'
|
||||||
|
| 'rebeccapurple'
|
||||||
|
| 'red'
|
||||||
|
| 'rosybrown'
|
||||||
|
| 'royalblue'
|
||||||
|
| 'saddlebrown'
|
||||||
|
| 'salmon'
|
||||||
|
| 'sandybrown'
|
||||||
|
| 'seagreen'
|
||||||
|
| 'seashell'
|
||||||
|
| 'sienna'
|
||||||
|
| 'silver'
|
||||||
|
| 'skyblue'
|
||||||
|
| 'slateblue'
|
||||||
|
| 'slategray'
|
||||||
|
| 'slategrey'
|
||||||
|
| 'snow'
|
||||||
|
| 'springgreen'
|
||||||
|
| 'steelblue'
|
||||||
|
| 'tan'
|
||||||
|
| 'teal'
|
||||||
|
| 'thistle'
|
||||||
|
| 'tomato'
|
||||||
|
| 'turquoise'
|
||||||
|
| 'violet'
|
||||||
|
| 'wheat'
|
||||||
|
| 'white'
|
||||||
|
| 'whitesmoke'
|
||||||
|
| 'yellow'
|
||||||
|
| 'yellowgreen';
|
||||||
|
|
||||||
|
declare namespace ansiStyles {
|
||||||
|
interface ColorConvert {
|
||||||
|
/**
|
||||||
|
The RGB color space.
|
||||||
|
|
||||||
|
@param red - (`0`-`255`)
|
||||||
|
@param green - (`0`-`255`)
|
||||||
|
@param blue - (`0`-`255`)
|
||||||
|
*/
|
||||||
|
rgb(red: number, green: number, blue: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The RGB HEX color space.
|
||||||
|
|
||||||
|
@param hex - A hexadecimal string containing RGB data.
|
||||||
|
*/
|
||||||
|
hex(hex: string): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param keyword - A CSS color name.
|
||||||
|
*/
|
||||||
|
keyword(keyword: CSSColor): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The HSL color space.
|
||||||
|
|
||||||
|
@param hue - (`0`-`360`)
|
||||||
|
@param saturation - (`0`-`100`)
|
||||||
|
@param lightness - (`0`-`100`)
|
||||||
|
*/
|
||||||
|
hsl(hue: number, saturation: number, lightness: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The HSV color space.
|
||||||
|
|
||||||
|
@param hue - (`0`-`360`)
|
||||||
|
@param saturation - (`0`-`100`)
|
||||||
|
@param value - (`0`-`100`)
|
||||||
|
*/
|
||||||
|
hsv(hue: number, saturation: number, value: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The HSV color space.
|
||||||
|
|
||||||
|
@param hue - (`0`-`360`)
|
||||||
|
@param whiteness - (`0`-`100`)
|
||||||
|
@param blackness - (`0`-`100`)
|
||||||
|
*/
|
||||||
|
hwb(hue: number, whiteness: number, blackness: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
||||||
|
*/
|
||||||
|
ansi(ansi: number): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||||
|
*/
|
||||||
|
ansi256(ansi: number): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CSPair {
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for starting this style.
|
||||||
|
*/
|
||||||
|
readonly open: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for ending this style.
|
||||||
|
*/
|
||||||
|
readonly close: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ColorBase {
|
||||||
|
readonly ansi: ColorConvert;
|
||||||
|
readonly ansi256: ColorConvert;
|
||||||
|
readonly ansi16m: ColorConvert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The ANSI terminal control sequence for ending this color.
|
||||||
|
*/
|
||||||
|
readonly close: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Modifier {
|
||||||
|
/**
|
||||||
|
Resets the current color chain.
|
||||||
|
*/
|
||||||
|
readonly reset: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text bold.
|
||||||
|
*/
|
||||||
|
readonly bold: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emitting only a small amount of light.
|
||||||
|
*/
|
||||||
|
readonly dim: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text italic. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly italic: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Make text underline. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly underline: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inverse background and foreground colors.
|
||||||
|
*/
|
||||||
|
readonly inverse: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Prints the text, but makes it invisible.
|
||||||
|
*/
|
||||||
|
readonly hidden: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||||
|
*/
|
||||||
|
readonly strikethrough: CSPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ForegroundColor {
|
||||||
|
readonly black: CSPair;
|
||||||
|
readonly red: CSPair;
|
||||||
|
readonly green: CSPair;
|
||||||
|
readonly yellow: CSPair;
|
||||||
|
readonly blue: CSPair;
|
||||||
|
readonly cyan: CSPair;
|
||||||
|
readonly magenta: CSPair;
|
||||||
|
readonly white: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `blackBright`.
|
||||||
|
*/
|
||||||
|
readonly gray: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `blackBright`.
|
||||||
|
*/
|
||||||
|
readonly grey: CSPair;
|
||||||
|
|
||||||
|
readonly blackBright: CSPair;
|
||||||
|
readonly redBright: CSPair;
|
||||||
|
readonly greenBright: CSPair;
|
||||||
|
readonly yellowBright: CSPair;
|
||||||
|
readonly blueBright: CSPair;
|
||||||
|
readonly cyanBright: CSPair;
|
||||||
|
readonly magentaBright: CSPair;
|
||||||
|
readonly whiteBright: CSPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BackgroundColor {
|
||||||
|
readonly bgBlack: CSPair;
|
||||||
|
readonly bgRed: CSPair;
|
||||||
|
readonly bgGreen: CSPair;
|
||||||
|
readonly bgYellow: CSPair;
|
||||||
|
readonly bgBlue: CSPair;
|
||||||
|
readonly bgCyan: CSPair;
|
||||||
|
readonly bgMagenta: CSPair;
|
||||||
|
readonly bgWhite: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `bgBlackBright`.
|
||||||
|
*/
|
||||||
|
readonly bgGray: CSPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Alias for `bgBlackBright`.
|
||||||
|
*/
|
||||||
|
readonly bgGrey: CSPair;
|
||||||
|
|
||||||
|
readonly bgBlackBright: CSPair;
|
||||||
|
readonly bgRedBright: CSPair;
|
||||||
|
readonly bgGreenBright: CSPair;
|
||||||
|
readonly bgYellowBright: CSPair;
|
||||||
|
readonly bgBlueBright: CSPair;
|
||||||
|
readonly bgCyanBright: CSPair;
|
||||||
|
readonly bgMagentaBright: CSPair;
|
||||||
|
readonly bgWhiteBright: CSPair;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const ansiStyles: {
|
||||||
|
readonly modifier: ansiStyles.Modifier;
|
||||||
|
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
||||||
|
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
||||||
|
readonly codes: ReadonlyMap<number, number>;
|
||||||
|
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
|
||||||
|
|
||||||
|
export = ansiStyles;
|
163
node_modules/ansi-styles/index.js
generated
vendored
Normal file
163
node_modules/ansi-styles/index.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const wrapAnsi16 = (fn, offset) => (...args) => {
|
||||||
|
const code = fn(...args);
|
||||||
|
return `\u001B[${code + offset}m`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapAnsi256 = (fn, offset) => (...args) => {
|
||||||
|
const code = fn(...args);
|
||||||
|
return `\u001B[${38 + offset};5;${code}m`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapAnsi16m = (fn, offset) => (...args) => {
|
||||||
|
const rgb = fn(...args);
|
||||||
|
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ansi2ansi = n => n;
|
||||||
|
const rgb2rgb = (r, g, b) => [r, g, b];
|
||||||
|
|
||||||
|
const setLazyProperty = (object, property, get) => {
|
||||||
|
Object.defineProperty(object, property, {
|
||||||
|
get: () => {
|
||||||
|
const value = get();
|
||||||
|
|
||||||
|
Object.defineProperty(object, property, {
|
||||||
|
value,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @type {typeof import('color-convert')} */
|
||||||
|
let colorConvert;
|
||||||
|
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
||||||
|
if (colorConvert === undefined) {
|
||||||
|
colorConvert = require('color-convert');
|
||||||
|
}
|
||||||
|
|
||||||
|
const offset = isBackground ? 10 : 0;
|
||||||
|
const styles = {};
|
||||||
|
|
||||||
|
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
||||||
|
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
||||||
|
if (sourceSpace === targetSpace) {
|
||||||
|
styles[name] = wrap(identity, offset);
|
||||||
|
} else if (typeof suite === 'object') {
|
||||||
|
styles[name] = wrap(suite[targetSpace], offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
};
|
||||||
|
|
||||||
|
function assembleStyles() {
|
||||||
|
const codes = new Map();
|
||||||
|
const styles = {
|
||||||
|
modifier: {
|
||||||
|
reset: [0, 0],
|
||||||
|
// 21 isn't widely supported and 22 does the same thing
|
||||||
|
bold: [1, 22],
|
||||||
|
dim: [2, 22],
|
||||||
|
italic: [3, 23],
|
||||||
|
underline: [4, 24],
|
||||||
|
inverse: [7, 27],
|
||||||
|
hidden: [8, 28],
|
||||||
|
strikethrough: [9, 29]
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
black: [30, 39],
|
||||||
|
red: [31, 39],
|
||||||
|
green: [32, 39],
|
||||||
|
yellow: [33, 39],
|
||||||
|
blue: [34, 39],
|
||||||
|
magenta: [35, 39],
|
||||||
|
cyan: [36, 39],
|
||||||
|
white: [37, 39],
|
||||||
|
|
||||||
|
// Bright color
|
||||||
|
blackBright: [90, 39],
|
||||||
|
redBright: [91, 39],
|
||||||
|
greenBright: [92, 39],
|
||||||
|
yellowBright: [93, 39],
|
||||||
|
blueBright: [94, 39],
|
||||||
|
magentaBright: [95, 39],
|
||||||
|
cyanBright: [96, 39],
|
||||||
|
whiteBright: [97, 39]
|
||||||
|
},
|
||||||
|
bgColor: {
|
||||||
|
bgBlack: [40, 49],
|
||||||
|
bgRed: [41, 49],
|
||||||
|
bgGreen: [42, 49],
|
||||||
|
bgYellow: [43, 49],
|
||||||
|
bgBlue: [44, 49],
|
||||||
|
bgMagenta: [45, 49],
|
||||||
|
bgCyan: [46, 49],
|
||||||
|
bgWhite: [47, 49],
|
||||||
|
|
||||||
|
// Bright color
|
||||||
|
bgBlackBright: [100, 49],
|
||||||
|
bgRedBright: [101, 49],
|
||||||
|
bgGreenBright: [102, 49],
|
||||||
|
bgYellowBright: [103, 49],
|
||||||
|
bgBlueBright: [104, 49],
|
||||||
|
bgMagentaBright: [105, 49],
|
||||||
|
bgCyanBright: [106, 49],
|
||||||
|
bgWhiteBright: [107, 49]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Alias bright black as gray (and grey)
|
||||||
|
styles.color.gray = styles.color.blackBright;
|
||||||
|
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
||||||
|
styles.color.grey = styles.color.blackBright;
|
||||||
|
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
||||||
|
|
||||||
|
for (const [groupName, group] of Object.entries(styles)) {
|
||||||
|
for (const [styleName, style] of Object.entries(group)) {
|
||||||
|
styles[styleName] = {
|
||||||
|
open: `\u001B[${style[0]}m`,
|
||||||
|
close: `\u001B[${style[1]}m`
|
||||||
|
};
|
||||||
|
|
||||||
|
group[styleName] = styles[styleName];
|
||||||
|
|
||||||
|
codes.set(style[0], style[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(styles, groupName, {
|
||||||
|
value: group,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(styles, 'codes', {
|
||||||
|
value: codes,
|
||||||
|
enumerable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
styles.color.close = '\u001B[39m';
|
||||||
|
styles.bgColor.close = '\u001B[49m';
|
||||||
|
|
||||||
|
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
||||||
|
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
||||||
|
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
||||||
|
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
||||||
|
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
||||||
|
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
||||||
|
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the export immutable
|
||||||
|
Object.defineProperty(module, 'exports', {
|
||||||
|
enumerable: true,
|
||||||
|
get: assembleStyles
|
||||||
|
});
|
9
node_modules/ansi-styles/license
generated
vendored
Normal file
9
node_modules/ansi-styles/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
|
56
node_modules/ansi-styles/package.json
generated
vendored
Normal file
56
node_modules/ansi-styles/package.json
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"name": "ansi-styles",
|
||||||
|
"version": "4.3.0",
|
||||||
|
"description": "ANSI escape codes for styling strings in the terminal",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "chalk/ansi-styles",
|
||||||
|
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "sindresorhus.com"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava && tsd",
|
||||||
|
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"ansi",
|
||||||
|
"styles",
|
||||||
|
"color",
|
||||||
|
"colour",
|
||||||
|
"colors",
|
||||||
|
"terminal",
|
||||||
|
"console",
|
||||||
|
"cli",
|
||||||
|
"string",
|
||||||
|
"tty",
|
||||||
|
"escape",
|
||||||
|
"formatting",
|
||||||
|
"rgb",
|
||||||
|
"256",
|
||||||
|
"shell",
|
||||||
|
"xterm",
|
||||||
|
"log",
|
||||||
|
"logging",
|
||||||
|
"command-line",
|
||||||
|
"text"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"color-convert": "^2.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/color-convert": "^1.9.0",
|
||||||
|
"ava": "^2.3.0",
|
||||||
|
"svg-term-cli": "^2.1.1",
|
||||||
|
"tsd": "^0.11.0",
|
||||||
|
"xo": "^0.25.3"
|
||||||
|
}
|
||||||
|
}
|
152
node_modules/ansi-styles/readme.md
generated
vendored
Normal file
152
node_modules/ansi-styles/readme.md
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
||||||
|
|
||||||
|
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||||
|
|
||||||
|
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||||
|
|
||||||
|
<img src="screenshot.svg" width="900">
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
$ npm install ansi-styles
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
const style = require('ansi-styles');
|
||||||
|
|
||||||
|
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
||||||
|
|
||||||
|
|
||||||
|
// Color conversion between 16/256/truecolor
|
||||||
|
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
||||||
|
// may be degraded to fit that color palette. This means terminals
|
||||||
|
// that do not support 16 million colors will best-match the
|
||||||
|
// original color.
|
||||||
|
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
||||||
|
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
||||||
|
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
Each style has an `open` and `close` property.
|
||||||
|
|
||||||
|
## Styles
|
||||||
|
|
||||||
|
### Modifiers
|
||||||
|
|
||||||
|
- `reset`
|
||||||
|
- `bold`
|
||||||
|
- `dim`
|
||||||
|
- `italic` *(Not widely supported)*
|
||||||
|
- `underline`
|
||||||
|
- `inverse`
|
||||||
|
- `hidden`
|
||||||
|
- `strikethrough` *(Not widely supported)*
|
||||||
|
|
||||||
|
### Colors
|
||||||
|
|
||||||
|
- `black`
|
||||||
|
- `red`
|
||||||
|
- `green`
|
||||||
|
- `yellow`
|
||||||
|
- `blue`
|
||||||
|
- `magenta`
|
||||||
|
- `cyan`
|
||||||
|
- `white`
|
||||||
|
- `blackBright` (alias: `gray`, `grey`)
|
||||||
|
- `redBright`
|
||||||
|
- `greenBright`
|
||||||
|
- `yellowBright`
|
||||||
|
- `blueBright`
|
||||||
|
- `magentaBright`
|
||||||
|
- `cyanBright`
|
||||||
|
- `whiteBright`
|
||||||
|
|
||||||
|
### Background colors
|
||||||
|
|
||||||
|
- `bgBlack`
|
||||||
|
- `bgRed`
|
||||||
|
- `bgGreen`
|
||||||
|
- `bgYellow`
|
||||||
|
- `bgBlue`
|
||||||
|
- `bgMagenta`
|
||||||
|
- `bgCyan`
|
||||||
|
- `bgWhite`
|
||||||
|
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||||
|
- `bgRedBright`
|
||||||
|
- `bgGreenBright`
|
||||||
|
- `bgYellowBright`
|
||||||
|
- `bgBlueBright`
|
||||||
|
- `bgMagentaBright`
|
||||||
|
- `bgCyanBright`
|
||||||
|
- `bgWhiteBright`
|
||||||
|
|
||||||
|
## Advanced usage
|
||||||
|
|
||||||
|
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||||
|
|
||||||
|
- `style.modifier`
|
||||||
|
- `style.color`
|
||||||
|
- `style.bgColor`
|
||||||
|
|
||||||
|
###### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(style.color.green.open);
|
||||||
|
```
|
||||||
|
|
||||||
|
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||||
|
|
||||||
|
###### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log(style.codes.get(36));
|
||||||
|
//=> 39
|
||||||
|
```
|
||||||
|
|
||||||
|
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
||||||
|
|
||||||
|
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
||||||
|
|
||||||
|
The following color spaces from `color-convert` are supported:
|
||||||
|
|
||||||
|
- `rgb`
|
||||||
|
- `hex`
|
||||||
|
- `keyword`
|
||||||
|
- `hsl`
|
||||||
|
- `hsv`
|
||||||
|
- `hwb`
|
||||||
|
- `ansi`
|
||||||
|
- `ansi256`
|
||||||
|
|
||||||
|
To use these, call the associated conversion function with the intended output, for example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
||||||
|
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
||||||
|
|
||||||
|
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||||
|
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||||
|
|
||||||
|
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
||||||
|
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
||||||
|
```
|
||||||
|
|
||||||
|
## Related
|
||||||
|
|
||||||
|
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||||
|
|
||||||
|
## Maintainers
|
||||||
|
|
||||||
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
- [Josh Junon](https://github.com/qix-)
|
||||||
|
|
||||||
|
## For enterprise
|
||||||
|
|
||||||
|
Available as part of the Tidelift Subscription.
|
||||||
|
|
||||||
|
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
15
node_modules/anymatch/LICENSE
generated
vendored
Normal file
15
node_modules/anymatch/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
The ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Elan Shanker, Paul Miller (https://paulmillr.com)
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
87
node_modules/anymatch/README.md
generated
vendored
Normal file
87
node_modules/anymatch/README.md
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
anymatch [](https://travis-ci.org/micromatch/anymatch) [](https://coveralls.io/r/micromatch/anymatch?branch=master)
|
||||||
|
======
|
||||||
|
Javascript module to match a string against a regular expression, glob, string,
|
||||||
|
or function that takes the string as an argument and returns a truthy or falsy
|
||||||
|
value. The matcher can also be an array of any or all of these. Useful for
|
||||||
|
allowing a very flexible user-defined config to define things like file paths.
|
||||||
|
|
||||||
|
__Note: This module has Bash-parity, please be aware that Windows-style backslashes are not supported as separators. See https://github.com/micromatch/micromatch#backslashes for more information.__
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
```sh
|
||||||
|
npm install anymatch
|
||||||
|
```
|
||||||
|
|
||||||
|
#### anymatch(matchers, testString, [returnIndex], [options])
|
||||||
|
* __matchers__: (_Array|String|RegExp|Function_)
|
||||||
|
String to be directly matched, string with glob patterns, regular expression
|
||||||
|
test, function that takes the testString as an argument and returns a truthy
|
||||||
|
value if it should be matched, or an array of any number and mix of these types.
|
||||||
|
* __testString__: (_String|Array_) The string to test against the matchers. If
|
||||||
|
passed as an array, the first element of the array will be used as the
|
||||||
|
`testString` for non-function matchers, while the entire array will be applied
|
||||||
|
as the arguments for function matchers.
|
||||||
|
* __options__: (_Object_ [optional]_) Any of the [picomatch](https://github.com/micromatch/picomatch#options) options.
|
||||||
|
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of
|
||||||
|
the first matcher that that testString matched, or -1 if no match, instead of a
|
||||||
|
boolean result.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const anymatch = require('anymatch');
|
||||||
|
|
||||||
|
const matchers = [ 'path/to/file.js', 'path/anyjs/**/*.js', /foo.js$/, string => string.includes('bar') && string.length > 10 ] ;
|
||||||
|
|
||||||
|
anymatch(matchers, 'path/to/file.js'); // true
|
||||||
|
anymatch(matchers, 'path/anyjs/baz.js'); // true
|
||||||
|
anymatch(matchers, 'path/to/foo.js'); // true
|
||||||
|
anymatch(matchers, 'path/to/bar.js'); // true
|
||||||
|
anymatch(matchers, 'bar.js'); // false
|
||||||
|
|
||||||
|
// returnIndex = true
|
||||||
|
anymatch(matchers, 'foo.js', {returnIndex: true}); // 2
|
||||||
|
anymatch(matchers, 'path/anyjs/foo.js', {returnIndex: true}); // 1
|
||||||
|
|
||||||
|
// any picomatc
|
||||||
|
|
||||||
|
// using globs to match directories and their children
|
||||||
|
anymatch('node_modules', 'node_modules'); // true
|
||||||
|
anymatch('node_modules', 'node_modules/somelib/index.js'); // false
|
||||||
|
anymatch('node_modules/**', 'node_modules/somelib/index.js'); // true
|
||||||
|
anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // false
|
||||||
|
anymatch('**/node_modules/**', '/absolute/path/to/node_modules/somelib/index.js'); // true
|
||||||
|
|
||||||
|
const matcher = anymatch(matchers);
|
||||||
|
['foo.js', 'bar.js'].filter(matcher); // [ 'foo.js' ]
|
||||||
|
anymatch master* ❯
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### anymatch(matchers)
|
||||||
|
You can also pass in only your matcher(s) to get a curried function that has
|
||||||
|
already been bound to the provided matching criteria. This can be used as an
|
||||||
|
`Array#filter` callback.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var matcher = anymatch(matchers);
|
||||||
|
|
||||||
|
matcher('path/to/file.js'); // true
|
||||||
|
matcher('path/anyjs/baz.js', true); // 1
|
||||||
|
|
||||||
|
['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
|
||||||
|
```
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
----------
|
||||||
|
[See release notes page on GitHub](https://github.com/micromatch/anymatch/releases)
|
||||||
|
|
||||||
|
- **v3.0:** Removed `startIndex` and `endIndex` arguments. Node 8.x-only.
|
||||||
|
- **v2.0:** [micromatch](https://github.com/jonschlinkert/micromatch) moves away from minimatch-parity and inline with Bash. This includes handling backslashes differently (see https://github.com/micromatch/micromatch#backslashes for more information).
|
||||||
|
- **v1.2:** anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
|
||||||
|
for glob pattern matching. Issues with glob pattern matching should be
|
||||||
|
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues).
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
[ISC](https://raw.github.com/micromatch/anymatch/master/LICENSE)
|
20
node_modules/anymatch/index.d.ts
generated
vendored
Normal file
20
node_modules/anymatch/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
type AnymatchFn = (testString: string) => boolean;
|
||||||
|
type AnymatchPattern = string|RegExp|AnymatchFn;
|
||||||
|
type AnymatchMatcher = AnymatchPattern|AnymatchPattern[]
|
||||||
|
type AnymatchTester = {
|
||||||
|
(testString: string|any[], returnIndex: true): number;
|
||||||
|
(testString: string|any[]): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type PicomatchOptions = {dot: boolean};
|
||||||
|
|
||||||
|
declare const anymatch: {
|
||||||
|
(matchers: AnymatchMatcher): AnymatchTester;
|
||||||
|
(matchers: AnymatchMatcher, testString: null, returnIndex: true | PicomatchOptions): AnymatchTester;
|
||||||
|
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number;
|
||||||
|
(matchers: AnymatchMatcher, testString: string|any[]): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export {AnymatchMatcher as Matcher}
|
||||||
|
export {AnymatchTester as Tester}
|
||||||
|
export default anymatch
|
104
node_modules/anymatch/index.js
generated
vendored
Normal file
104
node_modules/anymatch/index.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
||||||
|
const picomatch = require('picomatch');
|
||||||
|
const normalizePath = require('normalize-path');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {(testString: string) => boolean} AnymatchFn
|
||||||
|
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern
|
||||||
|
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher
|
||||||
|
*/
|
||||||
|
const BANG = '!';
|
||||||
|
const DEFAULT_OPTIONS = {returnIndex: false};
|
||||||
|
const arrify = (item) => Array.isArray(item) ? item : [item];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AnymatchPattern} matcher
|
||||||
|
* @param {object} options
|
||||||
|
* @returns {AnymatchFn}
|
||||||
|
*/
|
||||||
|
const createPattern = (matcher, options) => {
|
||||||
|
if (typeof matcher === 'function') {
|
||||||
|
return matcher;
|
||||||
|
}
|
||||||
|
if (typeof matcher === 'string') {
|
||||||
|
const glob = picomatch(matcher, options);
|
||||||
|
return (string) => matcher === string || glob(string);
|
||||||
|
}
|
||||||
|
if (matcher instanceof RegExp) {
|
||||||
|
return (string) => matcher.test(string);
|
||||||
|
}
|
||||||
|
return (string) => false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<Function>} patterns
|
||||||
|
* @param {Array<Function>} negPatterns
|
||||||
|
* @param {String|Array} args
|
||||||
|
* @param {Boolean} returnIndex
|
||||||
|
* @returns {boolean|number}
|
||||||
|
*/
|
||||||
|
const matchPatterns = (patterns, negPatterns, args, returnIndex) => {
|
||||||
|
const isList = Array.isArray(args);
|
||||||
|
const _path = isList ? args[0] : args;
|
||||||
|
if (!isList && typeof _path !== 'string') {
|
||||||
|
throw new TypeError('anymatch: second argument must be a string: got ' +
|
||||||
|
Object.prototype.toString.call(_path))
|
||||||
|
}
|
||||||
|
const path = normalizePath(_path, false);
|
||||||
|
|
||||||
|
for (let index = 0; index < negPatterns.length; index++) {
|
||||||
|
const nglob = negPatterns[index];
|
||||||
|
if (nglob(path)) {
|
||||||
|
return returnIndex ? -1 : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const applied = isList && [path].concat(args.slice(1));
|
||||||
|
for (let index = 0; index < patterns.length; index++) {
|
||||||
|
const pattern = patterns[index];
|
||||||
|
if (isList ? pattern(...applied) : pattern(path)) {
|
||||||
|
return returnIndex ? index : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnIndex ? -1 : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {AnymatchMatcher} matchers
|
||||||
|
* @param {Array|string} testString
|
||||||
|
* @param {object} options
|
||||||
|
* @returns {boolean|number|Function}
|
||||||
|
*/
|
||||||
|
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS) => {
|
||||||
|
if (matchers == null) {
|
||||||
|
throw new TypeError('anymatch: specify first argument');
|
||||||
|
}
|
||||||
|
const opts = typeof options === 'boolean' ? {returnIndex: options} : options;
|
||||||
|
const returnIndex = opts.returnIndex || false;
|
||||||
|
|
||||||
|
// Early cache for matchers.
|
||||||
|
const mtchers = arrify(matchers);
|
||||||
|
const negatedGlobs = mtchers
|
||||||
|
.filter(item => typeof item === 'string' && item.charAt(0) === BANG)
|
||||||
|
.map(item => item.slice(1))
|
||||||
|
.map(item => picomatch(item, opts));
|
||||||
|
const patterns = mtchers
|
||||||
|
.filter(item => typeof item !== 'string' || (typeof item === 'string' && item.charAt(0) !== BANG))
|
||||||
|
.map(matcher => createPattern(matcher, opts));
|
||||||
|
|
||||||
|
if (testString == null) {
|
||||||
|
return (testString, ri = false) => {
|
||||||
|
const returnIndex = typeof ri === 'boolean' ? ri : false;
|
||||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
anymatch.default = anymatch;
|
||||||
|
module.exports = anymatch;
|
48
node_modules/anymatch/package.json
generated
vendored
Normal file
48
node_modules/anymatch/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "anymatch",
|
||||||
|
"version": "3.1.3",
|
||||||
|
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"normalize-path": "^3.0.0",
|
||||||
|
"picomatch": "^2.0.4"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Elan Shanker",
|
||||||
|
"url": "https://github.com/es128"
|
||||||
|
},
|
||||||
|
"license": "ISC",
|
||||||
|
"homepage": "https://github.com/micromatch/anymatch",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/micromatch/anymatch"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"match",
|
||||||
|
"any",
|
||||||
|
"string",
|
||||||
|
"file",
|
||||||
|
"fs",
|
||||||
|
"list",
|
||||||
|
"glob",
|
||||||
|
"regex",
|
||||||
|
"regexp",
|
||||||
|
"regular",
|
||||||
|
"expression",
|
||||||
|
"function"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"test": "nyc mocha",
|
||||||
|
"mocha": "mocha"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^6.1.3",
|
||||||
|
"nyc": "^14.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
}
|
2
node_modules/balanced-match/.github/FUNDING.yml
generated
vendored
Normal file
2
node_modules/balanced-match/.github/FUNDING.yml
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
tidelift: "npm/balanced-match"
|
||||||
|
patreon: juliangruber
|
21
node_modules/balanced-match/LICENSE.md
generated
vendored
Normal file
21
node_modules/balanced-match/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
(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.
|
97
node_modules/balanced-match/README.md
generated
vendored
Normal file
97
node_modules/balanced-match/README.md
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
# balanced-match
|
||||||
|
|
||||||
|
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||||
|
|
||||||
|
[](http://travis-ci.org/juliangruber/balanced-match)
|
||||||
|
[](https://www.npmjs.org/package/balanced-match)
|
||||||
|
|
||||||
|
[](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
|
||||||
|
```
|
||||||
|
|
||||||
|
## Security contact information
|
||||||
|
|
||||||
|
To report a security vulnerability, please use the
|
||||||
|
[Tidelift security contact](https://tidelift.com/security).
|
||||||
|
Tidelift will coordinate the fix and disclosure.
|
||||||
|
|
||||||
|
## 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.
|
62
node_modules/balanced-match/index.js
generated
vendored
Normal file
62
node_modules/balanced-match/index.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
'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) {
|
||||||
|
if(a===b) {
|
||||||
|
return [ai, bi];
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
48
node_modules/balanced-match/package.json
generated
vendored
Normal file
48
node_modules/balanced-match/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "balanced-match",
|
||||||
|
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "tape test/test.js",
|
||||||
|
"bench": "matcha test/bench.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"matcha": "^0.7.0",
|
||||||
|
"tape": "^4.6.0"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"match",
|
||||||
|
"regexp",
|
||||||
|
"test",
|
||||||
|
"balanced",
|
||||||
|
"parse"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Julian Gruber",
|
||||||
|
"email": "mail@juliangruber.com",
|
||||||
|
"url": "http://juliangruber.com"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
263
node_modules/binary-extensions/binary-extensions.json
generated
vendored
Normal file
263
node_modules/binary-extensions/binary-extensions.json
generated
vendored
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
[
|
||||||
|
"3dm",
|
||||||
|
"3ds",
|
||||||
|
"3g2",
|
||||||
|
"3gp",
|
||||||
|
"7z",
|
||||||
|
"a",
|
||||||
|
"aac",
|
||||||
|
"adp",
|
||||||
|
"afdesign",
|
||||||
|
"afphoto",
|
||||||
|
"afpub",
|
||||||
|
"ai",
|
||||||
|
"aif",
|
||||||
|
"aiff",
|
||||||
|
"alz",
|
||||||
|
"ape",
|
||||||
|
"apk",
|
||||||
|
"appimage",
|
||||||
|
"ar",
|
||||||
|
"arj",
|
||||||
|
"asf",
|
||||||
|
"au",
|
||||||
|
"avi",
|
||||||
|
"bak",
|
||||||
|
"baml",
|
||||||
|
"bh",
|
||||||
|
"bin",
|
||||||
|
"bk",
|
||||||
|
"bmp",
|
||||||
|
"btif",
|
||||||
|
"bz2",
|
||||||
|
"bzip2",
|
||||||
|
"cab",
|
||||||
|
"caf",
|
||||||
|
"cgm",
|
||||||
|
"class",
|
||||||
|
"cmx",
|
||||||
|
"cpio",
|
||||||
|
"cr2",
|
||||||
|
"cur",
|
||||||
|
"dat",
|
||||||
|
"dcm",
|
||||||
|
"deb",
|
||||||
|
"dex",
|
||||||
|
"djvu",
|
||||||
|
"dll",
|
||||||
|
"dmg",
|
||||||
|
"dng",
|
||||||
|
"doc",
|
||||||
|
"docm",
|
||||||
|
"docx",
|
||||||
|
"dot",
|
||||||
|
"dotm",
|
||||||
|
"dra",
|
||||||
|
"DS_Store",
|
||||||
|
"dsk",
|
||||||
|
"dts",
|
||||||
|
"dtshd",
|
||||||
|
"dvb",
|
||||||
|
"dwg",
|
||||||
|
"dxf",
|
||||||
|
"ecelp4800",
|
||||||
|
"ecelp7470",
|
||||||
|
"ecelp9600",
|
||||||
|
"egg",
|
||||||
|
"eol",
|
||||||
|
"eot",
|
||||||
|
"epub",
|
||||||
|
"exe",
|
||||||
|
"f4v",
|
||||||
|
"fbs",
|
||||||
|
"fh",
|
||||||
|
"fla",
|
||||||
|
"flac",
|
||||||
|
"flatpak",
|
||||||
|
"fli",
|
||||||
|
"flv",
|
||||||
|
"fpx",
|
||||||
|
"fst",
|
||||||
|
"fvt",
|
||||||
|
"g3",
|
||||||
|
"gh",
|
||||||
|
"gif",
|
||||||
|
"graffle",
|
||||||
|
"gz",
|
||||||
|
"gzip",
|
||||||
|
"h261",
|
||||||
|
"h263",
|
||||||
|
"h264",
|
||||||
|
"icns",
|
||||||
|
"ico",
|
||||||
|
"ief",
|
||||||
|
"img",
|
||||||
|
"ipa",
|
||||||
|
"iso",
|
||||||
|
"jar",
|
||||||
|
"jpeg",
|
||||||
|
"jpg",
|
||||||
|
"jpgv",
|
||||||
|
"jpm",
|
||||||
|
"jxr",
|
||||||
|
"key",
|
||||||
|
"ktx",
|
||||||
|
"lha",
|
||||||
|
"lib",
|
||||||
|
"lvp",
|
||||||
|
"lz",
|
||||||
|
"lzh",
|
||||||
|
"lzma",
|
||||||
|
"lzo",
|
||||||
|
"m3u",
|
||||||
|
"m4a",
|
||||||
|
"m4v",
|
||||||
|
"mar",
|
||||||
|
"mdi",
|
||||||
|
"mht",
|
||||||
|
"mid",
|
||||||
|
"midi",
|
||||||
|
"mj2",
|
||||||
|
"mka",
|
||||||
|
"mkv",
|
||||||
|
"mmr",
|
||||||
|
"mng",
|
||||||
|
"mobi",
|
||||||
|
"mov",
|
||||||
|
"movie",
|
||||||
|
"mp3",
|
||||||
|
"mp4",
|
||||||
|
"mp4a",
|
||||||
|
"mpeg",
|
||||||
|
"mpg",
|
||||||
|
"mpga",
|
||||||
|
"mxu",
|
||||||
|
"nef",
|
||||||
|
"npx",
|
||||||
|
"numbers",
|
||||||
|
"nupkg",
|
||||||
|
"o",
|
||||||
|
"odp",
|
||||||
|
"ods",
|
||||||
|
"odt",
|
||||||
|
"oga",
|
||||||
|
"ogg",
|
||||||
|
"ogv",
|
||||||
|
"otf",
|
||||||
|
"ott",
|
||||||
|
"pages",
|
||||||
|
"pbm",
|
||||||
|
"pcx",
|
||||||
|
"pdb",
|
||||||
|
"pdf",
|
||||||
|
"pea",
|
||||||
|
"pgm",
|
||||||
|
"pic",
|
||||||
|
"png",
|
||||||
|
"pnm",
|
||||||
|
"pot",
|
||||||
|
"potm",
|
||||||
|
"potx",
|
||||||
|
"ppa",
|
||||||
|
"ppam",
|
||||||
|
"ppm",
|
||||||
|
"pps",
|
||||||
|
"ppsm",
|
||||||
|
"ppsx",
|
||||||
|
"ppt",
|
||||||
|
"pptm",
|
||||||
|
"pptx",
|
||||||
|
"psd",
|
||||||
|
"pya",
|
||||||
|
"pyc",
|
||||||
|
"pyo",
|
||||||
|
"pyv",
|
||||||
|
"qt",
|
||||||
|
"rar",
|
||||||
|
"ras",
|
||||||
|
"raw",
|
||||||
|
"resources",
|
||||||
|
"rgb",
|
||||||
|
"rip",
|
||||||
|
"rlc",
|
||||||
|
"rmf",
|
||||||
|
"rmvb",
|
||||||
|
"rpm",
|
||||||
|
"rtf",
|
||||||
|
"rz",
|
||||||
|
"s3m",
|
||||||
|
"s7z",
|
||||||
|
"scpt",
|
||||||
|
"sgi",
|
||||||
|
"shar",
|
||||||
|
"snap",
|
||||||
|
"sil",
|
||||||
|
"sketch",
|
||||||
|
"slk",
|
||||||
|
"smv",
|
||||||
|
"snk",
|
||||||
|
"so",
|
||||||
|
"stl",
|
||||||
|
"suo",
|
||||||
|
"sub",
|
||||||
|
"swf",
|
||||||
|
"tar",
|
||||||
|
"tbz",
|
||||||
|
"tbz2",
|
||||||
|
"tga",
|
||||||
|
"tgz",
|
||||||
|
"thmx",
|
||||||
|
"tif",
|
||||||
|
"tiff",
|
||||||
|
"tlz",
|
||||||
|
"ttc",
|
||||||
|
"ttf",
|
||||||
|
"txz",
|
||||||
|
"udf",
|
||||||
|
"uvh",
|
||||||
|
"uvi",
|
||||||
|
"uvm",
|
||||||
|
"uvp",
|
||||||
|
"uvs",
|
||||||
|
"uvu",
|
||||||
|
"viv",
|
||||||
|
"vob",
|
||||||
|
"war",
|
||||||
|
"wav",
|
||||||
|
"wax",
|
||||||
|
"wbmp",
|
||||||
|
"wdp",
|
||||||
|
"weba",
|
||||||
|
"webm",
|
||||||
|
"webp",
|
||||||
|
"whl",
|
||||||
|
"wim",
|
||||||
|
"wm",
|
||||||
|
"wma",
|
||||||
|
"wmv",
|
||||||
|
"wmx",
|
||||||
|
"woff",
|
||||||
|
"woff2",
|
||||||
|
"wrm",
|
||||||
|
"wvx",
|
||||||
|
"xbm",
|
||||||
|
"xif",
|
||||||
|
"xla",
|
||||||
|
"xlam",
|
||||||
|
"xls",
|
||||||
|
"xlsb",
|
||||||
|
"xlsm",
|
||||||
|
"xlsx",
|
||||||
|
"xlt",
|
||||||
|
"xltm",
|
||||||
|
"xltx",
|
||||||
|
"xm",
|
||||||
|
"xmind",
|
||||||
|
"xpi",
|
||||||
|
"xpm",
|
||||||
|
"xwd",
|
||||||
|
"xz",
|
||||||
|
"z",
|
||||||
|
"zip",
|
||||||
|
"zipx"
|
||||||
|
]
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user