fdsfd
This commit is contained in:
parent
628618df89
commit
e031240dff
3749 changed files with 1120848 additions and 1 deletions
59
node_modules/yargs-parser/build/lib/index.js
generated
vendored
Normal file
59
node_modules/yargs-parser/build/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
||||
* CJS and ESM environments.
|
||||
*
|
||||
* @license
|
||||
* Copyright (c) 2016, Contributors
|
||||
* SPDX-License-Identifier: ISC
|
||||
*/
|
||||
import { format } from 'util';
|
||||
import { readFileSync } from 'fs';
|
||||
import { normalize, resolve } from 'path';
|
||||
import { camelCase, decamelize, looksLikeNumber } from './string-utils.js';
|
||||
import { YargsParser } from './yargs-parser.js';
|
||||
// See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our
|
||||
// version support policy. The YARGS_MIN_NODE_VERSION is used for testing only.
|
||||
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
|
||||
? Number(process.env.YARGS_MIN_NODE_VERSION)
|
||||
: 10;
|
||||
if (process && process.version) {
|
||||
const major = Number(process.version.match(/v([^.]+)/)[1]);
|
||||
if (major < minNodeVersion) {
|
||||
throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
|
||||
}
|
||||
}
|
||||
// Creates a yargs-parser instance using Node.js standard libraries:
|
||||
const env = process ? process.env : {};
|
||||
const parser = new YargsParser({
|
||||
cwd: process.cwd,
|
||||
env: () => {
|
||||
return env;
|
||||
},
|
||||
format,
|
||||
normalize,
|
||||
resolve,
|
||||
// TODO: figure out a way to combine ESM and CJS coverage, such that
|
||||
// we can exercise all the lines below:
|
||||
require: (path) => {
|
||||
if (typeof require !== 'undefined') {
|
||||
return require(path);
|
||||
}
|
||||
else if (path.match(/\.json$/)) {
|
||||
return readFileSync(path, 'utf8');
|
||||
}
|
||||
else {
|
||||
throw Error('only .json config files are supported in ESM');
|
||||
}
|
||||
}
|
||||
});
|
||||
const yargsParser = function Parser(args, opts) {
|
||||
const result = parser.parse(args.slice(), opts);
|
||||
return result.argv;
|
||||
};
|
||||
yargsParser.detailed = function (args, opts) {
|
||||
return parser.parse(args.slice(), opts);
|
||||
};
|
||||
yargsParser.camelCase = camelCase;
|
||||
yargsParser.decamelize = decamelize;
|
||||
yargsParser.looksLikeNumber = looksLikeNumber;
|
||||
export default yargsParser;
|
65
node_modules/yargs-parser/build/lib/string-utils.js
generated
vendored
Normal file
65
node_modules/yargs-parser/build/lib/string-utils.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright (c) 2016, Contributors
|
||||
* SPDX-License-Identifier: ISC
|
||||
*/
|
||||
export function camelCase(str) {
|
||||
// Handle the case where an argument is provided as camel case, e.g., fooBar.
|
||||
// by ensuring that the string isn't already mixed case:
|
||||
const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
|
||||
if (!isCamelCase) {
|
||||
str = str.toLowerCase();
|
||||
}
|
||||
if (str.indexOf('-') === -1 && str.indexOf('_') === -1) {
|
||||
return str;
|
||||
}
|
||||
else {
|
||||
let camelcase = '';
|
||||
let nextChrUpper = false;
|
||||
const leadingHyphens = str.match(/^-+/);
|
||||
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
|
||||
let chr = str.charAt(i);
|
||||
if (nextChrUpper) {
|
||||
nextChrUpper = false;
|
||||
chr = chr.toUpperCase();
|
||||
}
|
||||
if (i !== 0 && (chr === '-' || chr === '_')) {
|
||||
nextChrUpper = true;
|
||||
}
|
||||
else if (chr !== '-' && chr !== '_') {
|
||||
camelcase += chr;
|
||||
}
|
||||
}
|
||||
return camelcase;
|
||||
}
|
||||
}
|
||||
export function decamelize(str, joinString) {
|
||||
const lowercase = str.toLowerCase();
|
||||
joinString = joinString || '-';
|
||||
let notCamelcase = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const chrLower = lowercase.charAt(i);
|
||||
const chrString = str.charAt(i);
|
||||
if (chrLower !== chrString && i > 0) {
|
||||
notCamelcase += `${joinString}${lowercase.charAt(i)}`;
|
||||
}
|
||||
else {
|
||||
notCamelcase += chrString;
|
||||
}
|
||||
}
|
||||
return notCamelcase;
|
||||
}
|
||||
export function looksLikeNumber(x) {
|
||||
if (x === null || x === undefined)
|
||||
return false;
|
||||
// if loaded from config, may already be a number.
|
||||
if (typeof x === 'number')
|
||||
return true;
|
||||
// hexadecimal.
|
||||
if (/^0x[0-9a-f]+$/i.test(x))
|
||||
return true;
|
||||
// don't treat 0123 as a number; as it drops the leading '0'.
|
||||
if (/^0[^.]/.test(x))
|
||||
return false;
|
||||
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
||||
}
|
40
node_modules/yargs-parser/build/lib/tokenize-arg-string.js
generated
vendored
Normal file
40
node_modules/yargs-parser/build/lib/tokenize-arg-string.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright (c) 2016, Contributors
|
||||
* SPDX-License-Identifier: ISC
|
||||
*/
|
||||
// take an un-split argv string and tokenize it.
|
||||
export function tokenizeArgString(argString) {
|
||||
if (Array.isArray(argString)) {
|
||||
return argString.map(e => typeof e !== 'string' ? e + '' : e);
|
||||
}
|
||||
argString = argString.trim();
|
||||
let i = 0;
|
||||
let prevC = null;
|
||||
let c = null;
|
||||
let opening = null;
|
||||
const args = [];
|
||||
for (let ii = 0; ii < argString.length; ii++) {
|
||||
prevC = c;
|
||||
c = argString.charAt(ii);
|
||||
// split on spaces unless we're in quotes.
|
||||
if (c === ' ' && !opening) {
|
||||
if (!(prevC === ' ')) {
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// don't split the string if we're in matching
|
||||
// opening or closing single and double quotes.
|
||||
if (c === opening) {
|
||||
opening = null;
|
||||
}
|
||||
else if ((c === "'" || c === '"') && !opening) {
|
||||
opening = c;
|
||||
}
|
||||
if (!args[i])
|
||||
args[i] = '';
|
||||
args[i] += c;
|
||||
}
|
||||
return args;
|
||||
}
|
12
node_modules/yargs-parser/build/lib/yargs-parser-types.js
generated
vendored
Normal file
12
node_modules/yargs-parser/build/lib/yargs-parser-types.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright (c) 2016, Contributors
|
||||
* SPDX-License-Identifier: ISC
|
||||
*/
|
||||
export var DefaultValuesForTypeKey;
|
||||
(function (DefaultValuesForTypeKey) {
|
||||
DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
|
||||
DefaultValuesForTypeKey["STRING"] = "string";
|
||||
DefaultValuesForTypeKey["NUMBER"] = "number";
|
||||
DefaultValuesForTypeKey["ARRAY"] = "array";
|
||||
})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
|
1037
node_modules/yargs-parser/build/lib/yargs-parser.js
generated
vendored
Normal file
1037
node_modules/yargs-parser/build/lib/yargs-parser.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue