Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
88
node_modules/yargs/CHANGELOG.md
generated
vendored
88
node_modules/yargs/CHANGELOG.md
generated
vendored
|
|
@ -1,88 +0,0 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [16.2.0](https://www.github.com/yargs/yargs/compare/v16.1.1...v16.2.0) (2020-12-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* command() now accepts an array of modules ([f415388](https://www.github.com/yargs/yargs/commit/f415388cc454d02786c65c50dd6c7a0cf9d8b842))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add package.json to module exports ([#1818](https://www.github.com/yargs/yargs/issues/1818)) ([d783a49](https://www.github.com/yargs/yargs/commit/d783a49a7f21c9bbd4eec2990268f3244c4d5662)), closes [#1817](https://www.github.com/yargs/yargs/issues/1817)
|
||||
|
||||
### [16.1.1](https://www.github.com/yargs/yargs/compare/v16.1.0...v16.1.1) (2020-11-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* expose helpers for legacy versions of Node.js ([#1801](https://www.github.com/yargs/yargs/issues/1801)) ([107deaa](https://www.github.com/yargs/yargs/commit/107deaa4f68b7bc3f2386041e1f4fe0272b29c0a))
|
||||
* **deno:** get yargs working on deno@1.5.x ([#1799](https://www.github.com/yargs/yargs/issues/1799)) ([cb01c98](https://www.github.com/yargs/yargs/commit/cb01c98c44e30f55c2dc9434caef524ae433d9a4))
|
||||
|
||||
## [16.1.0](https://www.github.com/yargs/yargs/compare/v16.0.3...v16.1.0) (2020-10-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose hideBin helper for CJS ([#1768](https://www.github.com/yargs/yargs/issues/1768)) ([63e1173](https://www.github.com/yargs/yargs/commit/63e1173bb47dc651c151973a16ef659082a9ae66))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deno:** update types for deno ^1.4.0 ([#1772](https://www.github.com/yargs/yargs/issues/1772)) ([0801752](https://www.github.com/yargs/yargs/commit/080175207d281be63edf90adfe4f0568700b0bf5))
|
||||
* **exports:** node 13.0-13.6 require a string fallback ([#1776](https://www.github.com/yargs/yargs/issues/1776)) ([b45c43a](https://www.github.com/yargs/yargs/commit/b45c43a5f64b565c3794f9792150eaeec4e00b69))
|
||||
* **modules:** module path was incorrect ([#1759](https://www.github.com/yargs/yargs/issues/1759)) ([95a4a0a](https://www.github.com/yargs/yargs/commit/95a4a0ac573cfe158e6e4bc8c8682ebd1644a198))
|
||||
* **positional:** positional strings no longer drop decimals ([#1761](https://www.github.com/yargs/yargs/issues/1761)) ([e1a300f](https://www.github.com/yargs/yargs/commit/e1a300f1293ad821c900284616337f080b207980))
|
||||
* make positionals in -- count towards validation ([#1752](https://www.github.com/yargs/yargs/issues/1752)) ([eb2b29d](https://www.github.com/yargs/yargs/commit/eb2b29d34f1a41e0fd6c4e841960e5bfc329dc3c))
|
||||
|
||||
### [16.0.3](https://www.github.com/yargs/yargs/compare/v16.0.2...v16.0.3) (2020-09-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* move yargs.cjs to yargs to fix Node 10 imports ([#1747](https://www.github.com/yargs/yargs/issues/1747)) ([5bfb85b](https://www.github.com/yargs/yargs/commit/5bfb85b33b85db8a44b5f7a700a8e4dbaf022df0))
|
||||
|
||||
### [16.0.2](https://www.github.com/yargs/yargs/compare/v16.0.1...v16.0.2) (2020-09-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **typescript:** yargs-parser was breaking @types/yargs ([#1745](https://www.github.com/yargs/yargs/issues/1745)) ([2253284](https://www.github.com/yargs/yargs/commit/2253284b233cceabd8db677b81c5bf1755eef230))
|
||||
|
||||
### [16.0.1](https://www.github.com/yargs/yargs/compare/v16.0.0...v16.0.1) (2020-09-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* code was not passed to process.exit ([#1742](https://www.github.com/yargs/yargs/issues/1742)) ([d1a9930](https://www.github.com/yargs/yargs/commit/d1a993035a2f76c138460052cf19425f9684b637))
|
||||
|
||||
## [16.0.0](https://www.github.com/yargs/yargs/compare/v15.4.2...v16.0.0) (2020-09-09)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* tweaks to ESM/Deno API surface: now exports yargs function by default; getProcessArgvWithoutBin becomes hideBin; types now exported for Deno.
|
||||
* find-up replaced with escalade; export map added (limits importable files in Node >= 12); yarser-parser@19.x.x (new decamelize/camelcase implementation).
|
||||
* **usage:** single character aliases are now shown first in help output
|
||||
* rebase helper is no longer provided on yargs instance.
|
||||
* drop support for EOL Node 8 (#1686)
|
||||
|
||||
### Features
|
||||
|
||||
* adds strictOptions() ([#1738](https://www.github.com/yargs/yargs/issues/1738)) ([b215fba](https://www.github.com/yargs/yargs/commit/b215fba0ed6e124e5aad6cf22c8d5875661c63a3))
|
||||
* **helpers:** rebase, Parser, applyExtends now blessed helpers ([#1733](https://www.github.com/yargs/yargs/issues/1733)) ([c7debe8](https://www.github.com/yargs/yargs/commit/c7debe8eb1e5bc6ea20b5ed68026c56e5ebec9e1))
|
||||
* adds support for ESM and Deno ([#1708](https://www.github.com/yargs/yargs/issues/1708)) ([ac6d5d1](https://www.github.com/yargs/yargs/commit/ac6d5d105a75711fe703f6a39dad5181b383d6c6))
|
||||
* drop support for EOL Node 8 ([#1686](https://www.github.com/yargs/yargs/issues/1686)) ([863937f](https://www.github.com/yargs/yargs/commit/863937f23c3102f804cdea78ee3097e28c7c289f))
|
||||
* i18n for ESM and Deno ([#1735](https://www.github.com/yargs/yargs/issues/1735)) ([c71783a](https://www.github.com/yargs/yargs/commit/c71783a5a898a0c0e92ac501c939a3ec411ac0c1))
|
||||
* tweaks to API surface based on user feedback ([#1726](https://www.github.com/yargs/yargs/issues/1726)) ([4151fee](https://www.github.com/yargs/yargs/commit/4151fee4c33a97d26bc40de7e623e5b0eb87e9bb))
|
||||
* **usage:** single char aliases first in help ([#1574](https://www.github.com/yargs/yargs/issues/1574)) ([a552990](https://www.github.com/yargs/yargs/commit/a552990c120646c2d85a5c9b628e1ce92a68e797))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **yargs:** add missing command(module) signature ([#1707](https://www.github.com/yargs/yargs/issues/1707)) ([0f81024](https://www.github.com/yargs/yargs/commit/0f810245494ccf13a35b7786d021b30fc95ecad5)), closes [#1704](https://www.github.com/yargs/yargs/issues/1704)
|
||||
|
||||
[Older CHANGELOG Entries](https://github.com/yargs/yargs/blob/master/docs/CHANGELOG-historical.md)
|
||||
14
node_modules/yargs/README.md
generated
vendored
14
node_modules/yargs/README.md
generated
vendored
|
|
@ -1,5 +1,5 @@
|
|||
<p align="center">
|
||||
<img width="250" src="https://raw.githubusercontent.com/yargs/yargs/master/yargs-logo.png">
|
||||
<img width="250" src="https://raw.githubusercontent.com/yargs/yargs/main/yargs-logo.png">
|
||||
</p>
|
||||
<h1 align="center"> Yargs </h1>
|
||||
<p align="center">
|
||||
|
|
@ -78,6 +78,8 @@ $ ./plunder.js --ships 12 --distance 98.7
|
|||
Retreat from the xupptumblers!
|
||||
```
|
||||
|
||||
> Note: `hideBin` is a shorthand for [`process.argv.slice(2)`](https://nodejs.org/en/knowledge/command-line/how-to-parse-command-line-arguments/). It has the benefit that it takes into account variations in some environments, e.g., [Electron](https://github.com/electron/electron/issues/4690).
|
||||
|
||||
### Complex Example
|
||||
|
||||
```javascript
|
||||
|
|
@ -87,7 +89,7 @@ const { hideBin } = require('yargs/helpers')
|
|||
|
||||
yargs(hideBin(process.argv))
|
||||
.command('serve [port]', 'start the server', (yargs) => {
|
||||
yargs
|
||||
return yargs
|
||||
.positional('port', {
|
||||
describe: 'port to bind on',
|
||||
default: 5000
|
||||
|
|
@ -101,7 +103,7 @@ yargs(hideBin(process.argv))
|
|||
type: 'boolean',
|
||||
description: 'Run with verbose logging'
|
||||
})
|
||||
.argv
|
||||
.parse()
|
||||
```
|
||||
|
||||
Run the example above with `--help` to see the help for the application.
|
||||
|
|
@ -136,7 +138,7 @@ yargs(Deno.args)
|
|||
})
|
||||
.strictCommands()
|
||||
.demandCommand(1)
|
||||
.argv
|
||||
.parse()
|
||||
```
|
||||
|
||||
### ESM
|
||||
|
|
@ -152,7 +154,7 @@ yargs(hideBin(process.argv))
|
|||
console.info(argv)
|
||||
})
|
||||
.demandCommand(1)
|
||||
.argv
|
||||
.parse()
|
||||
```
|
||||
|
||||
### Usage in Browser
|
||||
|
|
@ -199,4 +201,4 @@ post on why we think this is important](https://medium.com/the-node-js-collectio
|
|||
[slack-url]: http://devtoolscommunity.herokuapp.com
|
||||
[type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
|
||||
[coverage-image]: https://img.shields.io/nycrc/yargs/yargs
|
||||
[coverage-url]: https://github.com/yargs/yargs/blob/master/.nycrc
|
||||
[coverage-url]: https://github.com/yargs/yargs/blob/main/.nycrc
|
||||
|
|
|
|||
4
node_modules/yargs/browser.mjs
generated
vendored
4
node_modules/yargs/browser.mjs
generated
vendored
|
|
@ -1,7 +1,7 @@
|
|||
// Bootstrap yargs for browser:
|
||||
import browserPlatformShim from './lib/platform-shims/browser.mjs';
|
||||
import {YargsWithShim} from './build/lib/yargs-factory.js';
|
||||
import {YargsFactory} from './build/lib/yargs-factory.js';
|
||||
|
||||
const Yargs = YargsWithShim(browserPlatformShim);
|
||||
const Yargs = YargsFactory(browserPlatformShim);
|
||||
|
||||
export default Yargs;
|
||||
|
|
|
|||
2921
node_modules/yargs/build/index.cjs
generated
vendored
2921
node_modules/yargs/build/index.cjs
generated
vendored
File diff suppressed because one or more lines are too long
500
node_modules/yargs/build/lib/command.js
generated
vendored
500
node_modules/yargs/build/lib/command.js
generated
vendored
|
|
@ -3,14 +3,41 @@ import { isPromise } from './utils/is-promise.js';
|
|||
import { applyMiddleware, commandMiddlewareFactory, } from './middleware.js';
|
||||
import { parseCommand } from './parse-command.js';
|
||||
import { isYargsInstance, } from './yargs-factory.js';
|
||||
import { maybeAsyncResult } from './utils/maybe-async-result.js';
|
||||
import whichModule from './utils/which-module.js';
|
||||
const DEFAULT_MARKER = /(^\*)|(^\$0)/;
|
||||
export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
||||
const self = {};
|
||||
let handlers = {};
|
||||
let aliasMap = {};
|
||||
let defaultCommand;
|
||||
self.addHandler = function addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
|
||||
export class CommandInstance {
|
||||
constructor(usage, validation, globalMiddleware, shim) {
|
||||
this.requireCache = new Set();
|
||||
this.handlers = {};
|
||||
this.aliasMap = {};
|
||||
this.frozens = [];
|
||||
this.shim = shim;
|
||||
this.usage = usage;
|
||||
this.globalMiddleware = globalMiddleware;
|
||||
this.validation = validation;
|
||||
}
|
||||
addDirectory(dir, req, callerFile, opts) {
|
||||
opts = opts || {};
|
||||
if (typeof opts.recurse !== 'boolean')
|
||||
opts.recurse = false;
|
||||
if (!Array.isArray(opts.extensions))
|
||||
opts.extensions = ['js'];
|
||||
const parentVisit = typeof opts.visit === 'function' ? opts.visit : (o) => o;
|
||||
opts.visit = (obj, joined, filename) => {
|
||||
const visited = parentVisit(obj, joined, filename);
|
||||
if (visited) {
|
||||
if (this.requireCache.has(joined))
|
||||
return visited;
|
||||
else
|
||||
this.requireCache.add(joined);
|
||||
this.addHandler(visited);
|
||||
}
|
||||
return visited;
|
||||
};
|
||||
this.shim.requireDirectory({ require: req, filename: callerFile }, dir, opts);
|
||||
}
|
||||
addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
|
||||
let aliases = [];
|
||||
const middlewares = commandMiddlewareFactory(commandMiddleware);
|
||||
handler = handler || (() => { });
|
||||
|
|
@ -20,21 +47,21 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
}
|
||||
else {
|
||||
for (const command of cmd) {
|
||||
self.addHandler(command);
|
||||
this.addHandler(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isCommandHandlerDefinition(cmd)) {
|
||||
let command = Array.isArray(cmd.command) || typeof cmd.command === 'string'
|
||||
? cmd.command
|
||||
: moduleName(cmd);
|
||||
: this.moduleName(cmd);
|
||||
if (cmd.aliases)
|
||||
command = [].concat(command).concat(cmd.aliases);
|
||||
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
||||
this.addHandler(command, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
||||
return;
|
||||
}
|
||||
else if (isCommandBuilderDefinition(builder)) {
|
||||
self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
|
||||
this.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
|
||||
return;
|
||||
}
|
||||
if (typeof cmd === 'string') {
|
||||
|
|
@ -56,12 +83,12 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
|
||||
}
|
||||
aliases.forEach(alias => {
|
||||
aliasMap[alias] = parsedCommand.cmd;
|
||||
this.aliasMap[alias] = parsedCommand.cmd;
|
||||
});
|
||||
if (description !== false) {
|
||||
usage.command(cmd, description, isDefault, aliases, deprecated);
|
||||
this.usage.command(cmd, description, isDefault, aliases, deprecated);
|
||||
}
|
||||
handlers[parsedCommand.cmd] = {
|
||||
this.handlers[parsedCommand.cmd] = {
|
||||
original: cmd,
|
||||
description,
|
||||
handler,
|
||||
|
|
@ -72,147 +99,81 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
optional: parsedCommand.optional,
|
||||
};
|
||||
if (isDefault)
|
||||
defaultCommand = handlers[parsedCommand.cmd];
|
||||
this.defaultCommand = this.handlers[parsedCommand.cmd];
|
||||
}
|
||||
};
|
||||
self.addDirectory = function addDirectory(dir, context, req, callerFile, opts) {
|
||||
opts = opts || {};
|
||||
if (typeof opts.recurse !== 'boolean')
|
||||
opts.recurse = false;
|
||||
if (!Array.isArray(opts.extensions))
|
||||
opts.extensions = ['js'];
|
||||
const parentVisit = typeof opts.visit === 'function' ? opts.visit : (o) => o;
|
||||
opts.visit = function visit(obj, joined, filename) {
|
||||
const visited = parentVisit(obj, joined, filename);
|
||||
if (visited) {
|
||||
if (~context.files.indexOf(joined))
|
||||
return visited;
|
||||
context.files.push(joined);
|
||||
self.addHandler(visited);
|
||||
}
|
||||
return visited;
|
||||
};
|
||||
shim.requireDirectory({ require: req, filename: callerFile }, dir, opts);
|
||||
};
|
||||
function moduleName(obj) {
|
||||
const mod = whichModule(obj);
|
||||
if (!mod)
|
||||
throw new Error(`No command name given for module: ${shim.inspect(obj)}`);
|
||||
return commandFromFilename(mod.filename);
|
||||
}
|
||||
function commandFromFilename(filename) {
|
||||
return shim.path.basename(filename, shim.path.extname(filename));
|
||||
getCommandHandlers() {
|
||||
return this.handlers;
|
||||
}
|
||||
function extractDesc({ describe, description, desc, }) {
|
||||
for (const test of [describe, description, desc]) {
|
||||
if (typeof test === 'string' || test === false)
|
||||
return test;
|
||||
assertNotStrictEqual(test, true, shim);
|
||||
}
|
||||
return false;
|
||||
getCommands() {
|
||||
return Object.keys(this.handlers).concat(Object.keys(this.aliasMap));
|
||||
}
|
||||
self.getCommands = () => Object.keys(handlers).concat(Object.keys(aliasMap));
|
||||
self.getCommandHandlers = () => handlers;
|
||||
self.hasDefaultCommand = () => !!defaultCommand;
|
||||
self.runCommand = function runCommand(command, yargs, parsed, commandIndex) {
|
||||
let aliases = parsed.aliases;
|
||||
const commandHandler = handlers[command] || handlers[aliasMap[command]] || defaultCommand;
|
||||
const currentContext = yargs.getContext();
|
||||
let numFiles = currentContext.files.length;
|
||||
hasDefaultCommand() {
|
||||
return !!this.defaultCommand;
|
||||
}
|
||||
runCommand(command, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) {
|
||||
const commandHandler = this.handlers[command] ||
|
||||
this.handlers[this.aliasMap[command]] ||
|
||||
this.defaultCommand;
|
||||
const currentContext = yargs.getInternalMethods().getContext();
|
||||
const parentCommands = currentContext.commands.slice();
|
||||
let innerArgv = parsed.argv;
|
||||
let positionalMap = {};
|
||||
const isDefaultCommand = !command;
|
||||
if (command) {
|
||||
currentContext.commands.push(command);
|
||||
currentContext.fullCommands.push(commandHandler.original);
|
||||
}
|
||||
const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet);
|
||||
return isPromise(builderResult)
|
||||
? builderResult.then(result => this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, result.innerArgv, currentContext, helpOnly, result.aliases, yargs))
|
||||
: this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, builderResult.innerArgv, currentContext, helpOnly, builderResult.aliases, yargs);
|
||||
}
|
||||
applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) {
|
||||
const builder = commandHandler.builder;
|
||||
let innerYargs = yargs;
|
||||
if (isCommandBuilderCallback(builder)) {
|
||||
const builderOutput = builder(yargs.reset(parsed.aliases));
|
||||
const innerYargs = isYargsInstance(builderOutput) ? builderOutput : yargs;
|
||||
if (shouldUpdateUsage(innerYargs)) {
|
||||
innerYargs
|
||||
.getUsageInstance()
|
||||
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
||||
const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
|
||||
if (isPromise(builderOutput)) {
|
||||
return builderOutput.then(output => {
|
||||
innerYargs = isYargsInstance(output) ? output : yargs;
|
||||
return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
|
||||
});
|
||||
}
|
||||
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
|
||||
aliases = innerYargs.parsed.aliases;
|
||||
}
|
||||
else if (isCommandBuilderOptionDefinitions(builder)) {
|
||||
const innerYargs = yargs.reset(parsed.aliases);
|
||||
if (shouldUpdateUsage(innerYargs)) {
|
||||
innerYargs
|
||||
.getUsageInstance()
|
||||
.usage(usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
||||
}
|
||||
innerYargs = yargs.getInternalMethods().reset(aliases);
|
||||
Object.keys(commandHandler.builder).forEach(key => {
|
||||
innerYargs.option(key, builder[key]);
|
||||
});
|
||||
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex);
|
||||
aliases = innerYargs.parsed.aliases;
|
||||
}
|
||||
if (!yargs._hasOutput()) {
|
||||
positionalMap = populatePositionals(commandHandler, innerArgv, currentContext);
|
||||
}
|
||||
const middlewares = globalMiddleware
|
||||
.slice(0)
|
||||
.concat(commandHandler.middlewares);
|
||||
applyMiddleware(innerArgv, yargs, middlewares, true);
|
||||
if (!yargs._hasOutput()) {
|
||||
yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error, !command);
|
||||
}
|
||||
if (commandHandler.handler && !yargs._hasOutput()) {
|
||||
yargs._setHasOutput();
|
||||
const populateDoubleDash = !!yargs.getOptions().configuration['populate--'];
|
||||
yargs._postProcess(innerArgv, populateDoubleDash);
|
||||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
|
||||
let handlerResult;
|
||||
if (isPromise(innerArgv)) {
|
||||
handlerResult = innerArgv.then(argv => commandHandler.handler(argv));
|
||||
}
|
||||
else {
|
||||
handlerResult = commandHandler.handler(innerArgv);
|
||||
}
|
||||
const handlerFinishCommand = yargs.getHandlerFinishCommand();
|
||||
if (isPromise(handlerResult)) {
|
||||
yargs.getUsageInstance().cacheHelpMessage();
|
||||
handlerResult
|
||||
.then(value => {
|
||||
if (handlerFinishCommand) {
|
||||
handlerFinishCommand(value);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
try {
|
||||
yargs.getUsageInstance().fail(null, error);
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
yargs.getUsageInstance().clearCachedHelpMessage();
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (handlerFinishCommand) {
|
||||
handlerFinishCommand(handlerResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command) {
|
||||
currentContext.commands.pop();
|
||||
currentContext.fullCommands.pop();
|
||||
}
|
||||
numFiles = currentContext.files.length - numFiles;
|
||||
if (numFiles > 0)
|
||||
currentContext.files.splice(numFiles * -1, numFiles);
|
||||
return innerArgv;
|
||||
};
|
||||
function shouldUpdateUsage(yargs) {
|
||||
return (!yargs.getUsageInstance().getUsageDisabled() &&
|
||||
yargs.getUsageInstance().getUsage().length === 0);
|
||||
return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
|
||||
}
|
||||
function usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
|
||||
parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
|
||||
if (isDefaultCommand)
|
||||
innerYargs.getInternalMethods().getUsageInstance().unfreeze();
|
||||
if (this.shouldUpdateUsage(innerYargs)) {
|
||||
innerYargs
|
||||
.getInternalMethods()
|
||||
.getUsageInstance()
|
||||
.usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
||||
}
|
||||
const innerArgv = innerYargs
|
||||
.getInternalMethods()
|
||||
.runYargsParserAndExecuteCommands(null, undefined, true, commandIndex, helpOnly);
|
||||
return isPromise(innerArgv)
|
||||
? innerArgv.then(argv => ({
|
||||
aliases: innerYargs.parsed.aliases,
|
||||
innerArgv: argv,
|
||||
}))
|
||||
: {
|
||||
aliases: innerYargs.parsed.aliases,
|
||||
innerArgv: innerArgv,
|
||||
};
|
||||
}
|
||||
shouldUpdateUsage(yargs) {
|
||||
return (!yargs.getInternalMethods().getUsageInstance().getUsageDisabled() &&
|
||||
yargs.getInternalMethods().getUsageInstance().getUsage().length === 0);
|
||||
}
|
||||
usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
|
||||
const c = DEFAULT_MARKER.test(commandHandler.original)
|
||||
? commandHandler.original.replace(DEFAULT_MARKER, '').trim()
|
||||
: commandHandler.original;
|
||||
|
|
@ -222,43 +183,79 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
pc.push(c);
|
||||
return `$0 ${pc.join(' ')}`;
|
||||
}
|
||||
self.runDefaultBuilderOn = function (yargs) {
|
||||
assertNotStrictEqual(defaultCommand, undefined, shim);
|
||||
if (shouldUpdateUsage(yargs)) {
|
||||
const commandString = DEFAULT_MARKER.test(defaultCommand.original)
|
||||
? defaultCommand.original
|
||||
: defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ');
|
||||
yargs.getUsageInstance().usage(commandString, defaultCommand.description);
|
||||
applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
|
||||
let positionalMap = {};
|
||||
if (helpOnly)
|
||||
return innerArgv;
|
||||
if (!yargs.getInternalMethods().getHasOutput()) {
|
||||
positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
|
||||
}
|
||||
const builder = defaultCommand.builder;
|
||||
if (isCommandBuilderCallback(builder)) {
|
||||
builder(yargs);
|
||||
}
|
||||
else if (!isCommandBuilderDefinition(builder)) {
|
||||
Object.keys(builder).forEach(key => {
|
||||
yargs.option(key, builder[key]);
|
||||
const middlewares = this.globalMiddleware
|
||||
.getMiddleware()
|
||||
.slice(0)
|
||||
.concat(commandHandler.middlewares);
|
||||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
|
||||
if (!yargs.getInternalMethods().getHasOutput()) {
|
||||
const validation = yargs
|
||||
.getInternalMethods()
|
||||
.runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
|
||||
innerArgv = maybeAsyncResult(innerArgv, result => {
|
||||
validation(result);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
};
|
||||
function populatePositionals(commandHandler, argv, context) {
|
||||
if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
|
||||
yargs.getInternalMethods().setHasOutput();
|
||||
const populateDoubleDash = !!yargs.getOptions().configuration['populate--'];
|
||||
yargs
|
||||
.getInternalMethods()
|
||||
.postProcess(innerArgv, populateDoubleDash, false, false);
|
||||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
|
||||
innerArgv = maybeAsyncResult(innerArgv, result => {
|
||||
const handlerResult = commandHandler.handler(result);
|
||||
return isPromise(handlerResult)
|
||||
? handlerResult.then(() => result)
|
||||
: result;
|
||||
});
|
||||
if (!isDefaultCommand) {
|
||||
yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
|
||||
}
|
||||
if (isPromise(innerArgv) &&
|
||||
!yargs.getInternalMethods().hasParseCallback()) {
|
||||
innerArgv.catch(error => {
|
||||
try {
|
||||
yargs.getInternalMethods().getUsageInstance().fail(null, error);
|
||||
}
|
||||
catch (_err) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!isDefaultCommand) {
|
||||
currentContext.commands.pop();
|
||||
currentContext.fullCommands.pop();
|
||||
}
|
||||
return innerArgv;
|
||||
}
|
||||
populatePositionals(commandHandler, argv, context, yargs) {
|
||||
argv._ = argv._.slice(context.commands.length);
|
||||
const demanded = commandHandler.demanded.slice(0);
|
||||
const optional = commandHandler.optional.slice(0);
|
||||
const positionalMap = {};
|
||||
validation.positionalCount(demanded.length, argv._.length);
|
||||
this.validation.positionalCount(demanded.length, argv._.length);
|
||||
while (demanded.length) {
|
||||
const demand = demanded.shift();
|
||||
populatePositional(demand, argv, positionalMap);
|
||||
this.populatePositional(demand, argv, positionalMap);
|
||||
}
|
||||
while (optional.length) {
|
||||
const maybe = optional.shift();
|
||||
populatePositional(maybe, argv, positionalMap);
|
||||
this.populatePositional(maybe, argv, positionalMap);
|
||||
}
|
||||
argv._ = context.commands.concat(argv._.map(a => '' + a));
|
||||
postProcessPositionals(argv, positionalMap, self.cmdToParseOptions(commandHandler.original));
|
||||
this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs);
|
||||
return positionalMap;
|
||||
}
|
||||
function populatePositional(positional, argv, positionalMap) {
|
||||
populatePositional(positional, argv, positionalMap) {
|
||||
const cmd = positional.cmd[0];
|
||||
if (positional.variadic) {
|
||||
positionalMap[cmd] = argv._.splice(0).map(String);
|
||||
|
|
@ -268,49 +265,7 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
positionalMap[cmd] = [String(argv._.shift())];
|
||||
}
|
||||
}
|
||||
function postProcessPositionals(argv, positionalMap, parseOptions) {
|
||||
const options = Object.assign({}, yargs.getOptions());
|
||||
options.default = Object.assign(parseOptions.default, options.default);
|
||||
for (const key of Object.keys(parseOptions.alias)) {
|
||||
options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
|
||||
}
|
||||
options.array = options.array.concat(parseOptions.array);
|
||||
options.config = {};
|
||||
const unparsed = [];
|
||||
Object.keys(positionalMap).forEach(key => {
|
||||
positionalMap[key].map(value => {
|
||||
if (options.configuration['unknown-options-as-args'])
|
||||
options.key[key] = true;
|
||||
unparsed.push(`--${key}`);
|
||||
unparsed.push(value);
|
||||
});
|
||||
});
|
||||
if (!unparsed.length)
|
||||
return;
|
||||
const config = Object.assign({}, options.configuration, {
|
||||
'populate--': true,
|
||||
});
|
||||
const parsed = shim.Parser.detailed(unparsed, Object.assign({}, options, {
|
||||
configuration: config,
|
||||
}));
|
||||
if (parsed.error) {
|
||||
yargs.getUsageInstance().fail(parsed.error.message, parsed.error);
|
||||
}
|
||||
else {
|
||||
const positionalKeys = Object.keys(positionalMap);
|
||||
Object.keys(positionalMap).forEach(key => {
|
||||
positionalKeys.push(...parsed.aliases[key]);
|
||||
});
|
||||
Object.keys(parsed.argv).forEach(key => {
|
||||
if (positionalKeys.indexOf(key) !== -1) {
|
||||
if (!positionalMap[key])
|
||||
positionalMap[key] = parsed.argv[key];
|
||||
argv[key] = parsed.argv[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
self.cmdToParseOptions = function (cmdString) {
|
||||
cmdToParseOptions(cmdString) {
|
||||
const parseOptions = {
|
||||
array: [],
|
||||
default: {},
|
||||
|
|
@ -336,27 +291,127 @@ export function command(yargs, usage, validation, globalMiddleware = [], shim) {
|
|||
parseOptions.alias[cmd] = aliases;
|
||||
});
|
||||
return parseOptions;
|
||||
};
|
||||
self.reset = () => {
|
||||
handlers = {};
|
||||
aliasMap = {};
|
||||
defaultCommand = undefined;
|
||||
return self;
|
||||
};
|
||||
const frozens = [];
|
||||
self.freeze = () => {
|
||||
frozens.push({
|
||||
handlers,
|
||||
aliasMap,
|
||||
defaultCommand,
|
||||
}
|
||||
postProcessPositionals(argv, positionalMap, parseOptions, yargs) {
|
||||
const options = Object.assign({}, yargs.getOptions());
|
||||
options.default = Object.assign(parseOptions.default, options.default);
|
||||
for (const key of Object.keys(parseOptions.alias)) {
|
||||
options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
|
||||
}
|
||||
options.array = options.array.concat(parseOptions.array);
|
||||
options.config = {};
|
||||
const unparsed = [];
|
||||
Object.keys(positionalMap).forEach(key => {
|
||||
positionalMap[key].map(value => {
|
||||
if (options.configuration['unknown-options-as-args'])
|
||||
options.key[key] = true;
|
||||
unparsed.push(`--${key}`);
|
||||
unparsed.push(value);
|
||||
});
|
||||
});
|
||||
};
|
||||
self.unfreeze = () => {
|
||||
const frozen = frozens.pop();
|
||||
assertNotStrictEqual(frozen, undefined, shim);
|
||||
({ handlers, aliasMap, defaultCommand } = frozen);
|
||||
};
|
||||
return self;
|
||||
if (!unparsed.length)
|
||||
return;
|
||||
const config = Object.assign({}, options.configuration, {
|
||||
'populate--': false,
|
||||
});
|
||||
const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, {
|
||||
configuration: config,
|
||||
}));
|
||||
if (parsed.error) {
|
||||
yargs
|
||||
.getInternalMethods()
|
||||
.getUsageInstance()
|
||||
.fail(parsed.error.message, parsed.error);
|
||||
}
|
||||
else {
|
||||
const positionalKeys = Object.keys(positionalMap);
|
||||
Object.keys(positionalMap).forEach(key => {
|
||||
positionalKeys.push(...parsed.aliases[key]);
|
||||
});
|
||||
const defaults = yargs.getOptions().default;
|
||||
Object.keys(parsed.argv).forEach(key => {
|
||||
if (positionalKeys.includes(key)) {
|
||||
if (!positionalMap[key])
|
||||
positionalMap[key] = parsed.argv[key];
|
||||
if (!Object.prototype.hasOwnProperty.call(defaults, key) &&
|
||||
Object.prototype.hasOwnProperty.call(argv, key) &&
|
||||
Object.prototype.hasOwnProperty.call(parsed.argv, key) &&
|
||||
(Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
|
||||
argv[key] = [].concat(argv[key], parsed.argv[key]);
|
||||
}
|
||||
else {
|
||||
argv[key] = parsed.argv[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
runDefaultBuilderOn(yargs) {
|
||||
if (!this.defaultCommand)
|
||||
return;
|
||||
if (this.shouldUpdateUsage(yargs)) {
|
||||
const commandString = DEFAULT_MARKER.test(this.defaultCommand.original)
|
||||
? this.defaultCommand.original
|
||||
: this.defaultCommand.original.replace(/^[^[\]<>]*/, '$0 ');
|
||||
yargs
|
||||
.getInternalMethods()
|
||||
.getUsageInstance()
|
||||
.usage(commandString, this.defaultCommand.description);
|
||||
}
|
||||
const builder = this.defaultCommand.builder;
|
||||
if (isCommandBuilderCallback(builder)) {
|
||||
return builder(yargs, true);
|
||||
}
|
||||
else if (!isCommandBuilderDefinition(builder)) {
|
||||
Object.keys(builder).forEach(key => {
|
||||
yargs.option(key, builder[key]);
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
moduleName(obj) {
|
||||
const mod = whichModule(obj);
|
||||
if (!mod)
|
||||
throw new Error(`No command name given for module: ${this.shim.inspect(obj)}`);
|
||||
return this.commandFromFilename(mod.filename);
|
||||
}
|
||||
commandFromFilename(filename) {
|
||||
return this.shim.path.basename(filename, this.shim.path.extname(filename));
|
||||
}
|
||||
extractDesc({ describe, description, desc }) {
|
||||
for (const test of [describe, description, desc]) {
|
||||
if (typeof test === 'string' || test === false)
|
||||
return test;
|
||||
assertNotStrictEqual(test, true, this.shim);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
freeze() {
|
||||
this.frozens.push({
|
||||
handlers: this.handlers,
|
||||
aliasMap: this.aliasMap,
|
||||
defaultCommand: this.defaultCommand,
|
||||
});
|
||||
}
|
||||
unfreeze() {
|
||||
const frozen = this.frozens.pop();
|
||||
assertNotStrictEqual(frozen, undefined, this.shim);
|
||||
({
|
||||
handlers: this.handlers,
|
||||
aliasMap: this.aliasMap,
|
||||
defaultCommand: this.defaultCommand,
|
||||
} = frozen);
|
||||
}
|
||||
reset() {
|
||||
this.handlers = {};
|
||||
this.aliasMap = {};
|
||||
this.defaultCommand = undefined;
|
||||
this.requireCache = new Set();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
export function command(usage, validation, globalMiddleware, shim) {
|
||||
return new CommandInstance(usage, validation, globalMiddleware, shim);
|
||||
}
|
||||
export function isCommandBuilderDefinition(builder) {
|
||||
return (typeof builder === 'object' &&
|
||||
|
|
@ -364,12 +419,7 @@ export function isCommandBuilderDefinition(builder) {
|
|||
typeof builder.handler === 'function');
|
||||
}
|
||||
function isCommandAndAliases(cmd) {
|
||||
if (cmd.every(c => typeof c === 'string')) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return cmd.every(c => typeof c === 'string');
|
||||
}
|
||||
export function isCommandBuilderCallback(builder) {
|
||||
return typeof builder === 'function';
|
||||
|
|
|
|||
7
node_modules/yargs/build/lib/completion-templates.js
generated
vendored
7
node_modules/yargs/build/lib/completion-templates.js
generated
vendored
|
|
@ -5,7 +5,7 @@ export const completionShTemplate = `###-begin-{{app_name}}-completions-###
|
|||
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
||||
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
||||
#
|
||||
_yargs_completions()
|
||||
_{{app_name}}_yargs_completions()
|
||||
{
|
||||
local cur_word args type_list
|
||||
|
||||
|
|
@ -24,10 +24,11 @@ _yargs_completions()
|
|||
|
||||
return 0
|
||||
}
|
||||
complete -o default -F _yargs_completions {{app_name}}
|
||||
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
||||
###-end-{{app_name}}-completions-###
|
||||
`;
|
||||
export const completionZshTemplate = `###-begin-{{app_name}}-completions-###
|
||||
export const completionZshTemplate = `#compdef {{app_name}}
|
||||
###-begin-{{app_name}}-completions-###
|
||||
#
|
||||
# yargs command completion script
|
||||
#
|
||||
|
|
|
|||
244
node_modules/yargs/build/lib/completion.js
generated
vendored
244
node_modules/yargs/build/lib/completion.js
generated
vendored
|
|
@ -3,68 +3,49 @@ import { assertNotStrictEqual } from './typings/common-types.js';
|
|||
import * as templates from './completion-templates.js';
|
||||
import { isPromise } from './utils/is-promise.js';
|
||||
import { parseCommand } from './parse-command.js';
|
||||
export function completion(yargs, usage, command, shim) {
|
||||
const self = {
|
||||
completionKey: 'get-yargs-completions',
|
||||
};
|
||||
let aliases;
|
||||
self.setParsed = function setParsed(parsed) {
|
||||
aliases = parsed.aliases;
|
||||
};
|
||||
const zshShell = (shim.getEnv('SHELL') && shim.getEnv('SHELL').indexOf('zsh') !== -1) ||
|
||||
(shim.getEnv('ZSH_NAME') && shim.getEnv('ZSH_NAME').indexOf('zsh') !== -1);
|
||||
self.getCompletion = function getCompletion(args, done) {
|
||||
const completions = [];
|
||||
const current = args.length ? args[args.length - 1] : '';
|
||||
const argv = yargs.parse(args, true);
|
||||
const parentCommands = yargs.getContext().commands;
|
||||
function runCompletionFunction(argv) {
|
||||
assertNotStrictEqual(completionFunction, null, shim);
|
||||
if (isSyncCompletionFunction(completionFunction)) {
|
||||
const result = completionFunction(current, argv);
|
||||
if (isPromise(result)) {
|
||||
return result
|
||||
.then(list => {
|
||||
shim.process.nextTick(() => {
|
||||
done(list);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
shim.process.nextTick(() => {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
}
|
||||
return done(result);
|
||||
}
|
||||
else {
|
||||
return completionFunction(current, argv, completions => {
|
||||
done(completions);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (completionFunction) {
|
||||
return isPromise(argv)
|
||||
? argv.then(runCompletionFunction)
|
||||
: runCompletionFunction(argv);
|
||||
}
|
||||
const handlers = command.getCommandHandlers();
|
||||
export class Completion {
|
||||
constructor(yargs, usage, command, shim) {
|
||||
var _a, _b, _c;
|
||||
this.yargs = yargs;
|
||||
this.usage = usage;
|
||||
this.command = command;
|
||||
this.shim = shim;
|
||||
this.completionKey = 'get-yargs-completions';
|
||||
this.aliases = null;
|
||||
this.customCompletionFunction = null;
|
||||
this.zshShell =
|
||||
(_c = (((_a = this.shim.getEnv('SHELL')) === null || _a === void 0 ? void 0 : _a.includes('zsh')) ||
|
||||
((_b = this.shim.getEnv('ZSH_NAME')) === null || _b === void 0 ? void 0 : _b.includes('zsh')))) !== null && _c !== void 0 ? _c : false;
|
||||
}
|
||||
defaultCompletion(args, argv, current, done) {
|
||||
const handlers = this.command.getCommandHandlers();
|
||||
for (let i = 0, ii = args.length; i < ii; ++i) {
|
||||
if (handlers[args[i]] && handlers[args[i]].builder) {
|
||||
const builder = handlers[args[i]].builder;
|
||||
if (isCommandBuilderCallback(builder)) {
|
||||
const y = yargs.reset();
|
||||
builder(y);
|
||||
const y = this.yargs.getInternalMethods().reset();
|
||||
builder(y, true);
|
||||
return y.argv;
|
||||
}
|
||||
}
|
||||
}
|
||||
const completions = [];
|
||||
this.commandCompletions(completions, args, current);
|
||||
this.optionCompletions(completions, args, argv, current);
|
||||
this.choicesCompletions(completions, args, argv, current);
|
||||
done(null, completions);
|
||||
}
|
||||
commandCompletions(completions, args, current) {
|
||||
const parentCommands = this.yargs
|
||||
.getInternalMethods()
|
||||
.getContext().commands;
|
||||
if (!current.match(/^-/) &&
|
||||
parentCommands[parentCommands.length - 1] !== current) {
|
||||
usage.getCommands().forEach(usageCommand => {
|
||||
parentCommands[parentCommands.length - 1] !== current &&
|
||||
!this.previousArgHasChoices(args)) {
|
||||
this.usage.getCommands().forEach(usageCommand => {
|
||||
const commandName = parseCommand(usageCommand[0]).cmd;
|
||||
if (args.indexOf(commandName) === -1) {
|
||||
if (!zshShell) {
|
||||
if (!this.zshShell) {
|
||||
completions.push(commandName);
|
||||
}
|
||||
else {
|
||||
|
|
@ -74,55 +55,146 @@ export function completion(yargs, usage, command, shim) {
|
|||
}
|
||||
});
|
||||
}
|
||||
if (current.match(/^-/) || (current === '' && completions.length === 0)) {
|
||||
const descs = usage.getDescriptions();
|
||||
const options = yargs.getOptions();
|
||||
}
|
||||
optionCompletions(completions, args, argv, current) {
|
||||
if ((current.match(/^-/) || (current === '' && completions.length === 0)) &&
|
||||
!this.previousArgHasChoices(args)) {
|
||||
const options = this.yargs.getOptions();
|
||||
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
|
||||
Object.keys(options.key).forEach(key => {
|
||||
const negable = !!options.configuration['boolean-negation'] &&
|
||||
options.boolean.includes(key);
|
||||
let keyAndAliases = [key].concat(aliases[key] || []);
|
||||
if (negable)
|
||||
keyAndAliases = keyAndAliases.concat(keyAndAliases.map(key => `no-${key}`));
|
||||
function completeOptionKey(key) {
|
||||
const notInArgs = keyAndAliases.every(val => args.indexOf(`--${val}`) === -1);
|
||||
if (notInArgs) {
|
||||
const startsByTwoDashes = (s) => /^--/.test(s);
|
||||
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
||||
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--';
|
||||
if (!zshShell) {
|
||||
completions.push(dashes + key);
|
||||
}
|
||||
else {
|
||||
const desc = descs[key] || '';
|
||||
completions.push(dashes +
|
||||
`${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`);
|
||||
}
|
||||
}
|
||||
const isPositionalKey = positionalKeys.includes(key);
|
||||
if (!isPositionalKey &&
|
||||
!this.argsContainKey(args, argv, key, negable)) {
|
||||
this.completeOptionKey(key, completions, current);
|
||||
if (negable && !!options.default[key])
|
||||
this.completeOptionKey(`no-${key}`, completions, current);
|
||||
}
|
||||
completeOptionKey(key);
|
||||
if (negable && !!options.default[key])
|
||||
completeOptionKey(`no-${key}`);
|
||||
});
|
||||
}
|
||||
done(completions);
|
||||
};
|
||||
self.generateCompletionScript = function generateCompletionScript($0, cmd) {
|
||||
let script = zshShell
|
||||
}
|
||||
choicesCompletions(completions, args, argv, current) {
|
||||
if (this.previousArgHasChoices(args)) {
|
||||
const choices = this.getPreviousArgChoices(args);
|
||||
if (choices && choices.length > 0) {
|
||||
completions.push(...choices);
|
||||
}
|
||||
}
|
||||
}
|
||||
getPreviousArgChoices(args) {
|
||||
if (args.length < 1)
|
||||
return;
|
||||
let previousArg = args[args.length - 1];
|
||||
let filter = '';
|
||||
if (!previousArg.startsWith('--') && args.length > 1) {
|
||||
filter = previousArg;
|
||||
previousArg = args[args.length - 2];
|
||||
}
|
||||
if (!previousArg.startsWith('--'))
|
||||
return;
|
||||
const previousArgKey = previousArg.replace(/-/g, '');
|
||||
const options = this.yargs.getOptions();
|
||||
if (Object.keys(options.key).some(key => key === previousArgKey) &&
|
||||
Array.isArray(options.choices[previousArgKey])) {
|
||||
return options.choices[previousArgKey].filter(choice => !filter || choice.startsWith(filter));
|
||||
}
|
||||
}
|
||||
previousArgHasChoices(args) {
|
||||
const choices = this.getPreviousArgChoices(args);
|
||||
return choices !== undefined && choices.length > 0;
|
||||
}
|
||||
argsContainKey(args, argv, key, negable) {
|
||||
if (args.indexOf(`--${key}`) !== -1)
|
||||
return true;
|
||||
if (negable && args.indexOf(`--no-${key}`) !== -1)
|
||||
return true;
|
||||
if (this.aliases) {
|
||||
for (const alias of this.aliases[key]) {
|
||||
if (argv[alias] !== undefined)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
completeOptionKey(key, completions, current) {
|
||||
const descs = this.usage.getDescriptions();
|
||||
const startsByTwoDashes = (s) => /^--/.test(s);
|
||||
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
||||
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? '-' : '--';
|
||||
if (!this.zshShell) {
|
||||
completions.push(dashes + key);
|
||||
}
|
||||
else {
|
||||
const desc = descs[key] || '';
|
||||
completions.push(dashes +
|
||||
`${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`);
|
||||
}
|
||||
}
|
||||
customCompletion(args, argv, current, done) {
|
||||
assertNotStrictEqual(this.customCompletionFunction, null, this.shim);
|
||||
if (isSyncCompletionFunction(this.customCompletionFunction)) {
|
||||
const result = this.customCompletionFunction(current, argv);
|
||||
if (isPromise(result)) {
|
||||
return result
|
||||
.then(list => {
|
||||
this.shim.process.nextTick(() => {
|
||||
done(null, list);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
this.shim.process.nextTick(() => {
|
||||
done(err, undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
return done(null, result);
|
||||
}
|
||||
else if (isFallbackCompletionFunction(this.customCompletionFunction)) {
|
||||
return this.customCompletionFunction(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), completions => {
|
||||
done(null, completions);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return this.customCompletionFunction(current, argv, completions => {
|
||||
done(null, completions);
|
||||
});
|
||||
}
|
||||
}
|
||||
getCompletion(args, done) {
|
||||
const current = args.length ? args[args.length - 1] : '';
|
||||
const argv = this.yargs.parse(args, true);
|
||||
const completionFunction = this.customCompletionFunction
|
||||
? (argv) => this.customCompletion(args, argv, current, done)
|
||||
: (argv) => this.defaultCompletion(args, argv, current, done);
|
||||
return isPromise(argv)
|
||||
? argv.then(completionFunction)
|
||||
: completionFunction(argv);
|
||||
}
|
||||
generateCompletionScript($0, cmd) {
|
||||
let script = this.zshShell
|
||||
? templates.completionZshTemplate
|
||||
: templates.completionShTemplate;
|
||||
const name = shim.path.basename($0);
|
||||
const name = this.shim.path.basename($0);
|
||||
if ($0.match(/\.js$/))
|
||||
$0 = `./${$0}`;
|
||||
script = script.replace(/{{app_name}}/g, name);
|
||||
script = script.replace(/{{completion_command}}/g, cmd);
|
||||
return script.replace(/{{app_path}}/g, $0);
|
||||
};
|
||||
let completionFunction = null;
|
||||
self.registerFunction = fn => {
|
||||
completionFunction = fn;
|
||||
};
|
||||
return self;
|
||||
}
|
||||
registerFunction(fn) {
|
||||
this.customCompletionFunction = fn;
|
||||
}
|
||||
setParsed(parsed) {
|
||||
this.aliases = parsed.aliases;
|
||||
}
|
||||
}
|
||||
export function completion(yargs, usage, command, shim) {
|
||||
return new Completion(yargs, usage, command, shim);
|
||||
}
|
||||
function isSyncCompletionFunction(completionFunction) {
|
||||
return completionFunction.length < 3;
|
||||
}
|
||||
function isFallbackCompletionFunction(completionFunction) {
|
||||
return completionFunction.length > 3;
|
||||
}
|
||||
|
|
|
|||
67
node_modules/yargs/build/lib/middleware.js
generated
vendored
67
node_modules/yargs/build/lib/middleware.js
generated
vendored
|
|
@ -1,23 +1,59 @@
|
|||
import { argsert } from './argsert.js';
|
||||
import { isPromise } from './utils/is-promise.js';
|
||||
export function globalMiddlewareFactory(globalMiddleware, context) {
|
||||
return function (callback, applyBeforeValidation = false) {
|
||||
argsert('<array|function> [boolean]', [callback, applyBeforeValidation], arguments.length);
|
||||
export class GlobalMiddleware {
|
||||
constructor(yargs) {
|
||||
this.globalMiddleware = [];
|
||||
this.frozens = [];
|
||||
this.yargs = yargs;
|
||||
}
|
||||
addMiddleware(callback, applyBeforeValidation, global = true, mutates = false) {
|
||||
argsert('<array|function> [boolean] [boolean] [boolean]', [callback, applyBeforeValidation, global], arguments.length);
|
||||
if (Array.isArray(callback)) {
|
||||
for (let i = 0; i < callback.length; i++) {
|
||||
if (typeof callback[i] !== 'function') {
|
||||
throw Error('middleware must be a function');
|
||||
}
|
||||
callback[i].applyBeforeValidation = applyBeforeValidation;
|
||||
const m = callback[i];
|
||||
m.applyBeforeValidation = applyBeforeValidation;
|
||||
m.global = global;
|
||||
}
|
||||
Array.prototype.push.apply(globalMiddleware, callback);
|
||||
Array.prototype.push.apply(this.globalMiddleware, callback);
|
||||
}
|
||||
else if (typeof callback === 'function') {
|
||||
callback.applyBeforeValidation = applyBeforeValidation;
|
||||
globalMiddleware.push(callback);
|
||||
const m = callback;
|
||||
m.applyBeforeValidation = applyBeforeValidation;
|
||||
m.global = global;
|
||||
m.mutates = mutates;
|
||||
this.globalMiddleware.push(callback);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
return this.yargs;
|
||||
}
|
||||
addCoerceMiddleware(callback, option) {
|
||||
const aliases = this.yargs.getAliases();
|
||||
this.globalMiddleware = this.globalMiddleware.filter(m => {
|
||||
const toCheck = [...(aliases[option] || []), option];
|
||||
if (!m.option)
|
||||
return true;
|
||||
else
|
||||
return !toCheck.includes(m.option);
|
||||
});
|
||||
callback.option = option;
|
||||
return this.addMiddleware(callback, true, true, true);
|
||||
}
|
||||
getMiddleware() {
|
||||
return this.globalMiddleware;
|
||||
}
|
||||
freeze() {
|
||||
this.frozens.push([...this.globalMiddleware]);
|
||||
}
|
||||
unfreeze() {
|
||||
const frozen = this.frozens.pop();
|
||||
if (frozen !== undefined)
|
||||
this.globalMiddleware = frozen;
|
||||
}
|
||||
reset() {
|
||||
this.globalMiddleware = this.globalMiddleware.filter(m => m.global);
|
||||
}
|
||||
}
|
||||
export function commandMiddlewareFactory(commandMiddleware) {
|
||||
if (!commandMiddleware)
|
||||
|
|
@ -28,23 +64,22 @@ export function commandMiddlewareFactory(commandMiddleware) {
|
|||
});
|
||||
}
|
||||
export function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
|
||||
const beforeValidationError = new Error('middleware cannot return a promise when applyBeforeValidation is true');
|
||||
return middlewares.reduce((acc, middleware) => {
|
||||
if (middleware.applyBeforeValidation !== beforeValidation) {
|
||||
return acc;
|
||||
}
|
||||
if (middleware.mutates) {
|
||||
if (middleware.applied)
|
||||
return acc;
|
||||
middleware.applied = true;
|
||||
}
|
||||
if (isPromise(acc)) {
|
||||
return acc
|
||||
.then(initialObj => Promise.all([
|
||||
initialObj,
|
||||
middleware(initialObj, yargs),
|
||||
]))
|
||||
.then(initialObj => Promise.all([initialObj, middleware(initialObj, yargs)]))
|
||||
.then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
|
||||
}
|
||||
else {
|
||||
const result = middleware(acc, yargs);
|
||||
if (beforeValidation && isPromise(result))
|
||||
throw beforeValidationError;
|
||||
return isPromise(result)
|
||||
? result.then(middlewareObj => Object.assign(acc, middlewareObj))
|
||||
: Object.assign(acc, result);
|
||||
|
|
|
|||
84
node_modules/yargs/build/lib/usage.js
generated
vendored
84
node_modules/yargs/build/lib/usage.js
generated
vendored
|
|
@ -1,9 +1,11 @@
|
|||
import { assertNotStrictEqual, } from './typings/common-types.js';
|
||||
import { objFilter } from './utils/obj-filter.js';
|
||||
import { YError } from './yerror.js';
|
||||
import setBlocking from './utils/set-blocking.js';
|
||||
export function usage(yargs, y18n, shim) {
|
||||
const __ = y18n.__;
|
||||
function isBoolean(fail) {
|
||||
return typeof fail === 'boolean';
|
||||
}
|
||||
export function usage(yargs, shim) {
|
||||
const __ = shim.y18n.__;
|
||||
const self = {};
|
||||
const fails = [];
|
||||
self.failFn = function failFn(f) {
|
||||
|
|
@ -22,10 +24,19 @@ export function usage(yargs, y18n, shim) {
|
|||
};
|
||||
let failureOutput = false;
|
||||
self.fail = function fail(msg, err) {
|
||||
const logger = yargs._getLoggerInstance();
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (fails.length) {
|
||||
for (let i = fails.length - 1; i >= 0; --i) {
|
||||
fails[i](msg, err, self);
|
||||
const fail = fails[i];
|
||||
if (isBoolean(fail)) {
|
||||
if (err)
|
||||
throw err;
|
||||
else if (msg)
|
||||
throw Error(msg);
|
||||
}
|
||||
else {
|
||||
fail(msg, err, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -49,7 +60,7 @@ export function usage(yargs, y18n, shim) {
|
|||
if (yargs.getExitProcess()) {
|
||||
return yargs.exit(1);
|
||||
}
|
||||
else if (yargs._hasParseCallback()) {
|
||||
else if (yargs.getInternalMethods().hasParseCallback()) {
|
||||
return yargs.exit(1, err);
|
||||
}
|
||||
else {
|
||||
|
|
@ -160,7 +171,7 @@ export function usage(yargs, y18n, shim) {
|
|||
if (!usageDisabled) {
|
||||
if (usages.length) {
|
||||
usages.forEach(usage => {
|
||||
ui.div(`${usage[0].replace(/\$0/g, base$0)}`);
|
||||
ui.div({ text: `${usage[0].replace(/\$0/g, base$0)}` });
|
||||
if (usage[1]) {
|
||||
ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] });
|
||||
}
|
||||
|
|
@ -178,17 +189,19 @@ export function usage(yargs, y18n, shim) {
|
|||
ui.div(`${u}`);
|
||||
}
|
||||
}
|
||||
if (commands.length) {
|
||||
if (commands.length > 1 || (commands.length === 1 && !commands[0][2])) {
|
||||
ui.div(__('Commands:'));
|
||||
const context = yargs.getContext();
|
||||
const context = yargs.getInternalMethods().getContext();
|
||||
const parentCommands = context.commands.length
|
||||
? `${context.commands.join(' ')} `
|
||||
: '';
|
||||
if (yargs.getParserConfiguration()['sort-commands'] === true) {
|
||||
if (yargs.getInternalMethods().getParserConfiguration()['sort-commands'] ===
|
||||
true) {
|
||||
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
|
||||
}
|
||||
const prefix = base$0 ? `${base$0} ` : '';
|
||||
commands.forEach(command => {
|
||||
const commandString = `${base$0} ${parentCommands}${command[0].replace(/^\$0 ?/, '')}`;
|
||||
const commandString = `${prefix}${parentCommands}${command[0].replace(/^\$0 ?/, '')}`;
|
||||
ui.span({
|
||||
text: commandString,
|
||||
padding: [0, 2, 0, 2],
|
||||
|
|
@ -235,10 +248,10 @@ export function usage(yargs, y18n, shim) {
|
|||
const normalizedKeys = groups[groupName]
|
||||
.filter(filterHiddenOptions)
|
||||
.map(key => {
|
||||
if (~aliasKeys.indexOf(key))
|
||||
if (aliasKeys.includes(key))
|
||||
return key;
|
||||
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== undefined; i++) {
|
||||
if (~(options.alias[aliasKey] || []).indexOf(key))
|
||||
if ((options.alias[aliasKey] || []).includes(key))
|
||||
return aliasKey;
|
||||
}
|
||||
return key;
|
||||
|
|
@ -255,7 +268,7 @@ export function usage(yargs, y18n, shim) {
|
|||
return sw;
|
||||
else {
|
||||
return ((/^[0-9]$/.test(sw)
|
||||
? ~options.boolean.indexOf(key)
|
||||
? options.boolean.includes(key)
|
||||
? '-'
|
||||
: '--'
|
||||
: sw.length > 1
|
||||
|
|
@ -293,19 +306,19 @@ export function usage(yargs, y18n, shim) {
|
|||
const kswitch = switches[key];
|
||||
let desc = descriptions[key] || '';
|
||||
let type = null;
|
||||
if (~desc.lastIndexOf(deferY18nLookupPrefix))
|
||||
if (desc.includes(deferY18nLookupPrefix))
|
||||
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
||||
if (~options.boolean.indexOf(key))
|
||||
if (options.boolean.includes(key))
|
||||
type = `[${__('boolean')}]`;
|
||||
if (~options.count.indexOf(key))
|
||||
if (options.count.includes(key))
|
||||
type = `[${__('count')}]`;
|
||||
if (~options.string.indexOf(key))
|
||||
if (options.string.includes(key))
|
||||
type = `[${__('string')}]`;
|
||||
if (~options.normalize.indexOf(key))
|
||||
if (options.normalize.includes(key))
|
||||
type = `[${__('string')}]`;
|
||||
if (~options.array.indexOf(key))
|
||||
if (options.array.includes(key))
|
||||
type = `[${__('array')}]`;
|
||||
if (~options.number.indexOf(key))
|
||||
if (options.number.includes(key))
|
||||
type = `[${__('number')}]`;
|
||||
const deprecatedExtra = (deprecated) => typeof deprecated === 'string'
|
||||
? `[${__('deprecated: %s', deprecated)}]`
|
||||
|
|
@ -388,17 +401,17 @@ export function usage(yargs, y18n, shim) {
|
|||
self.describe(key, descriptions[alias]);
|
||||
if (alias in demandedOptions)
|
||||
yargs.demandOption(key, demandedOptions[alias]);
|
||||
if (~options.boolean.indexOf(alias))
|
||||
if (options.boolean.includes(alias))
|
||||
yargs.boolean(key);
|
||||
if (~options.count.indexOf(alias))
|
||||
if (options.count.includes(alias))
|
||||
yargs.count(key);
|
||||
if (~options.string.indexOf(alias))
|
||||
if (options.string.includes(alias))
|
||||
yargs.string(key);
|
||||
if (~options.normalize.indexOf(alias))
|
||||
if (options.normalize.includes(alias))
|
||||
yargs.normalize(key);
|
||||
if (~options.array.indexOf(alias))
|
||||
if (options.array.includes(alias))
|
||||
yargs.array(key);
|
||||
if (~options.number.indexOf(alias))
|
||||
if (options.number.includes(alias))
|
||||
yargs.number(key);
|
||||
});
|
||||
});
|
||||
|
|
@ -410,6 +423,9 @@ export function usage(yargs, y18n, shim) {
|
|||
self.clearCachedHelpMessage = function () {
|
||||
cachedHelpMessage = undefined;
|
||||
};
|
||||
self.hasCachedHelpMessage = function () {
|
||||
return !!cachedHelpMessage;
|
||||
};
|
||||
function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
|
||||
let groupedKeys = [];
|
||||
let toCheck = null;
|
||||
|
|
@ -429,7 +445,7 @@ export function usage(yargs, y18n, shim) {
|
|||
yargs.parsed.argv[yargs.getOptions().showHiddenOpt]);
|
||||
}
|
||||
self.showHelp = (level) => {
|
||||
const logger = yargs._getLoggerInstance();
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (!level)
|
||||
level = 'error';
|
||||
const emit = typeof level === 'function' ? level : logger[level];
|
||||
|
|
@ -488,9 +504,12 @@ export function usage(yargs, y18n, shim) {
|
|||
self.version = ver => {
|
||||
version = ver;
|
||||
};
|
||||
self.showVersion = () => {
|
||||
const logger = yargs._getLoggerInstance();
|
||||
logger.log(version);
|
||||
self.showVersion = level => {
|
||||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||||
if (!level)
|
||||
level = 'error';
|
||||
const emit = typeof level === 'function' ? level : logger[level];
|
||||
emit(version);
|
||||
};
|
||||
self.reset = function reset(localLookup) {
|
||||
failMessage = null;
|
||||
|
|
@ -518,7 +537,8 @@ export function usage(yargs, y18n, shim) {
|
|||
};
|
||||
self.unfreeze = function unfreeze() {
|
||||
const frozen = frozens.pop();
|
||||
assertNotStrictEqual(frozen, undefined, shim);
|
||||
if (!frozen)
|
||||
return;
|
||||
({
|
||||
failMessage,
|
||||
failureOutput,
|
||||
|
|
|
|||
10
node_modules/yargs/build/lib/utils/levenshtein.js
generated
vendored
10
node_modules/yargs/build/lib/utils/levenshtein.js
generated
vendored
|
|
@ -18,7 +18,15 @@ export function levenshtein(a, b) {
|
|||
matrix[i][j] = matrix[i - 1][j - 1];
|
||||
}
|
||||
else {
|
||||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
|
||||
if (i > 1 &&
|
||||
j > 1 &&
|
||||
b.charAt(i - 2) === a.charAt(j - 1) &&
|
||||
b.charAt(i - 1) === a.charAt(j - 2)) {
|
||||
matrix[i][j] = matrix[i - 2][j - 2] + 1;
|
||||
}
|
||||
else {
|
||||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
node_modules/yargs/build/lib/utils/maybe-async-result.js
generated
vendored
Normal file
17
node_modules/yargs/build/lib/utils/maybe-async-result.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { isPromise } from './is-promise.js';
|
||||
export function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
|
||||
throw err;
|
||||
}) {
|
||||
try {
|
||||
const result = isFunction(getResult) ? getResult() : getResult;
|
||||
return isPromise(result)
|
||||
? result.then((result) => resultHandler(result))
|
||||
: resultHandler(result);
|
||||
}
|
||||
catch (err) {
|
||||
return errorHandler(err);
|
||||
}
|
||||
}
|
||||
function isFunction(arg) {
|
||||
return typeof arg === 'function';
|
||||
}
|
||||
103
node_modules/yargs/build/lib/validation.js
generated
vendored
103
node_modules/yargs/build/lib/validation.js
generated
vendored
|
|
@ -3,14 +3,14 @@ import { assertNotStrictEqual, } from './typings/common-types.js';
|
|||
import { levenshtein as distance } from './utils/levenshtein.js';
|
||||
import { objFilter } from './utils/obj-filter.js';
|
||||
const specialKeys = ['$0', '--', '_'];
|
||||
export function validation(yargs, usage, y18n, shim) {
|
||||
const __ = y18n.__;
|
||||
const __n = y18n.__n;
|
||||
export function validation(yargs, usage, shim) {
|
||||
const __ = shim.y18n.__;
|
||||
const __n = shim.y18n.__n;
|
||||
const self = {};
|
||||
self.nonOptionCount = function nonOptionCount(argv) {
|
||||
const demandedCommands = yargs.getDemandedCommands();
|
||||
const positionalCount = argv._.length + (argv['--'] ? argv['--'].length : 0);
|
||||
const _s = positionalCount - yargs.getContext().commands.length;
|
||||
const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length;
|
||||
if (demandedCommands._ &&
|
||||
(_s < demandedCommands._.min || _s > demandedCommands._.max)) {
|
||||
if (_s < demandedCommands._.min) {
|
||||
|
|
@ -44,8 +44,7 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
usage.fail(__n('Not enough non-option arguments: got %s, need at least %s', 'Not enough non-option arguments: got %s, need at least %s', observed, observed + '', required + ''));
|
||||
}
|
||||
};
|
||||
self.requiredArguments = function requiredArguments(argv) {
|
||||
const demandedOptions = yargs.getDemandedOptions();
|
||||
self.requiredArguments = function requiredArguments(argv, demandedOptions) {
|
||||
let missing = null;
|
||||
for (const key of Object.keys(demandedOptions)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(argv, key) ||
|
||||
|
|
@ -67,13 +66,17 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
}
|
||||
};
|
||||
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
|
||||
const commandKeys = yargs.getCommandInstance().getCommands();
|
||||
var _a;
|
||||
const commandKeys = yargs
|
||||
.getInternalMethods()
|
||||
.getCommandInstance()
|
||||
.getCommands();
|
||||
const unknown = [];
|
||||
const currentContext = yargs.getContext();
|
||||
const currentContext = yargs.getInternalMethods().getContext();
|
||||
Object.keys(argv).forEach(key => {
|
||||
if (specialKeys.indexOf(key) === -1 &&
|
||||
if (!specialKeys.includes(key) &&
|
||||
!Object.prototype.hasOwnProperty.call(positionalMap, key) &&
|
||||
!Object.prototype.hasOwnProperty.call(yargs._getParseContext(), key) &&
|
||||
!Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) &&
|
||||
!self.isValidAndSomeAliasIsNotNew(key, aliases)) {
|
||||
unknown.push(key);
|
||||
}
|
||||
|
|
@ -83,22 +86,39 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
commandKeys.length > 0 ||
|
||||
isDefaultCommand)) {
|
||||
argv._.slice(currentContext.commands.length).forEach(key => {
|
||||
if (commandKeys.indexOf('' + key) === -1) {
|
||||
if (!commandKeys.includes('' + key)) {
|
||||
unknown.push('' + key);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (unknown.length > 0) {
|
||||
if (checkPositionals) {
|
||||
const demandedCommands = yargs.getDemandedCommands();
|
||||
const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
|
||||
const expected = currentContext.commands.length + maxNonOptDemanded;
|
||||
if (expected < argv._.length) {
|
||||
argv._.slice(expected).forEach(key => {
|
||||
key = String(key);
|
||||
if (!currentContext.commands.includes(key) &&
|
||||
!unknown.includes(key)) {
|
||||
unknown.push(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (unknown.length) {
|
||||
usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.join(', ')));
|
||||
}
|
||||
};
|
||||
self.unknownCommands = function unknownCommands(argv) {
|
||||
const commandKeys = yargs.getCommandInstance().getCommands();
|
||||
const commandKeys = yargs
|
||||
.getInternalMethods()
|
||||
.getCommandInstance()
|
||||
.getCommands();
|
||||
const unknown = [];
|
||||
const currentContext = yargs.getContext();
|
||||
const currentContext = yargs.getInternalMethods().getContext();
|
||||
if (currentContext.commands.length > 0 || commandKeys.length > 0) {
|
||||
argv._.slice(currentContext.commands.length).forEach(key => {
|
||||
if (commandKeys.indexOf('' + key) === -1) {
|
||||
if (!commandKeys.includes('' + key)) {
|
||||
unknown.push('' + key);
|
||||
}
|
||||
});
|
||||
|
|
@ -116,13 +136,7 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
return false;
|
||||
}
|
||||
const newAliases = yargs.parsed.newAliases;
|
||||
for (const a of [key, ...aliases[key]]) {
|
||||
if (!Object.prototype.hasOwnProperty.call(newAliases, a) ||
|
||||
!newAliases[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return [key, ...aliases[key]].some(a => !Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
|
||||
};
|
||||
self.limitedChoices = function limitedChoices(argv) {
|
||||
const options = yargs.getOptions();
|
||||
|
|
@ -149,32 +163,6 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
});
|
||||
usage.fail(msg);
|
||||
};
|
||||
let checks = [];
|
||||
self.check = function check(f, global) {
|
||||
checks.push({
|
||||
func: f,
|
||||
global,
|
||||
});
|
||||
};
|
||||
self.customChecks = function customChecks(argv, aliases) {
|
||||
for (let i = 0, f; (f = checks[i]) !== undefined; i++) {
|
||||
const func = f.func;
|
||||
let result = null;
|
||||
try {
|
||||
result = func(argv, aliases);
|
||||
}
|
||||
catch (err) {
|
||||
usage.fail(err.message ? err.message : err, err);
|
||||
continue;
|
||||
}
|
||||
if (!result) {
|
||||
usage.fail(__('Argument check failed: %s', func.toString()));
|
||||
}
|
||||
else if (typeof result === 'string' || result instanceof Error) {
|
||||
usage.fail(result.toString(), result);
|
||||
}
|
||||
}
|
||||
};
|
||||
let implied = {};
|
||||
self.implies = function implies(key, value) {
|
||||
argsert('<string|object> [array|number|string]', [key, value], arguments.length);
|
||||
|
|
@ -208,10 +196,10 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
}
|
||||
else if (val.match(/^--no-.+/)) {
|
||||
val = val.match(/^--no-(.+)/)[1];
|
||||
val = !argv[val];
|
||||
val = !Object.prototype.hasOwnProperty.call(argv, val);
|
||||
}
|
||||
else {
|
||||
val = argv[val];
|
||||
val = Object.prototype.hasOwnProperty.call(argv, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
|
@ -269,6 +257,17 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
});
|
||||
}
|
||||
});
|
||||
if (yargs.getInternalMethods().getParserConfiguration()['strip-dashed']) {
|
||||
Object.keys(conflicting).forEach(key => {
|
||||
conflicting[key].forEach(value => {
|
||||
if (value &&
|
||||
argv[shim.Parser.camelCase(key)] !== undefined &&
|
||||
argv[shim.Parser.camelCase(value)] !== undefined) {
|
||||
usage.fail(__('Arguments %s and %s are mutually exclusive', key, value));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
self.recommendCommands = function recommendCommands(cmd, potentialCommands) {
|
||||
const threshold = 3;
|
||||
|
|
@ -288,21 +287,19 @@ export function validation(yargs, usage, y18n, shim) {
|
|||
self.reset = function reset(localLookup) {
|
||||
implied = objFilter(implied, k => !localLookup[k]);
|
||||
conflicting = objFilter(conflicting, k => !localLookup[k]);
|
||||
checks = checks.filter(c => c.global);
|
||||
return self;
|
||||
};
|
||||
const frozens = [];
|
||||
self.freeze = function freeze() {
|
||||
frozens.push({
|
||||
implied,
|
||||
checks,
|
||||
conflicting,
|
||||
});
|
||||
};
|
||||
self.unfreeze = function unfreeze() {
|
||||
const frozen = frozens.pop();
|
||||
assertNotStrictEqual(frozen, undefined, shim);
|
||||
({ implied, checks, conflicting } = frozen);
|
||||
({ implied, conflicting } = frozen);
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
2388
node_modules/yargs/build/lib/yargs-factory.js
generated
vendored
2388
node_modules/yargs/build/lib/yargs-factory.js
generated
vendored
File diff suppressed because it is too large
Load diff
30
node_modules/yargs/index.cjs
generated
vendored
30
node_modules/yargs/index.cjs
generated
vendored
|
|
@ -11,9 +11,24 @@ module.exports = Argv;
|
|||
function Argv(processArgs, cwd) {
|
||||
const argv = Yargs(processArgs, cwd, require);
|
||||
singletonify(argv);
|
||||
// TODO(bcoe): warn if argv.parse() or argv.argv is used directly.
|
||||
return argv;
|
||||
}
|
||||
|
||||
function defineGetter(obj, key, getter) {
|
||||
Object.defineProperty(obj, key, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: getter,
|
||||
});
|
||||
}
|
||||
function lookupGetter(obj, key) {
|
||||
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
||||
if (typeof desc !== 'undefined') {
|
||||
return desc.get;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hack an instance of Argv with process.argv into Argv
|
||||
so people can do
|
||||
require('yargs')(['--beeble=1','-z','zizzle']).argv
|
||||
|
|
@ -22,18 +37,17 @@ function Argv(processArgs, cwd) {
|
|||
to get a parsed version of process.argv.
|
||||
*/
|
||||
function singletonify(inst) {
|
||||
Object.keys(inst).forEach(key => {
|
||||
[
|
||||
...Object.keys(inst),
|
||||
...Object.getOwnPropertyNames(inst.constructor.prototype),
|
||||
].forEach(key => {
|
||||
if (key === 'argv') {
|
||||
Argv.__defineGetter__(key, inst.__lookupGetter__(key));
|
||||
defineGetter(Argv, key, lookupGetter(inst, key));
|
||||
} else if (typeof inst[key] === 'function') {
|
||||
Argv[key] = inst[key].bind(inst);
|
||||
} else {
|
||||
Argv.__defineGetter__('$0', () => {
|
||||
return inst.$0;
|
||||
});
|
||||
Argv.__defineGetter__('parsed', () => {
|
||||
return inst.parsed;
|
||||
});
|
||||
defineGetter(Argv, '$0', () => inst.$0);
|
||||
defineGetter(Argv, 'parsed', () => inst.parsed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
4
node_modules/yargs/index.mjs
generated
vendored
4
node_modules/yargs/index.mjs
generated
vendored
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Bootstraps yargs for ESM:
|
||||
import esmPlatformShim from './lib/platform-shims/esm.mjs';
|
||||
import {YargsWithShim} from './build/lib/yargs-factory.js';
|
||||
import {YargsFactory} from './build/lib/yargs-factory.js';
|
||||
|
||||
const Yargs = YargsWithShim(esmPlatformShim);
|
||||
const Yargs = YargsFactory(esmPlatformShim);
|
||||
export default Yargs;
|
||||
|
|
|
|||
3
node_modules/yargs/lib/platform-shims/browser.mjs
generated
vendored
3
node_modules/yargs/lib/platform-shims/browser.mjs
generated
vendored
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-unused-vars */
|
||||
'use strict';
|
||||
|
||||
import cliui from 'https://unpkg.com/cliui@7.0.1/index.mjs'; // eslint-disable-line
|
||||
|
|
@ -40,10 +41,12 @@ export default {
|
|||
process: {
|
||||
argv: () => [],
|
||||
cwd: () => '',
|
||||
emitWarning: (warning, name) => {},
|
||||
execPath: () => '',
|
||||
// exit is noop browser:
|
||||
exit: () => {},
|
||||
nextTick: cb => {
|
||||
// eslint-disable-next-line no-undef
|
||||
window.setTimeout(cb, 1);
|
||||
},
|
||||
stdColumns: 80,
|
||||
|
|
|
|||
12
node_modules/yargs/lib/platform-shims/esm.mjs
generated
vendored
12
node_modules/yargs/lib/platform-shims/esm.mjs
generated
vendored
|
|
@ -3,7 +3,7 @@
|
|||
import { notStrictEqual, strictEqual } from 'assert'
|
||||
import cliui from 'cliui'
|
||||
import escalade from 'escalade/sync'
|
||||
import { format, inspect } from 'util'
|
||||
import { inspect } from 'util'
|
||||
import { readFileSync } from 'fs'
|
||||
import { fileURLToPath } from 'url';
|
||||
import Parser from 'yargs-parser'
|
||||
|
|
@ -15,8 +15,13 @@ import y18n from 'y18n'
|
|||
const REQUIRE_ERROR = 'require is not supported by ESM'
|
||||
const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
|
||||
|
||||
const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
|
||||
const __dirname = fileURLToPath(import.meta.url)
|
||||
let __dirname;
|
||||
try {
|
||||
__dirname = fileURLToPath(import.meta.url);
|
||||
} catch (e) {
|
||||
__dirname = process.cwd();
|
||||
}
|
||||
const mainFilename = __dirname.split('node_modules')[0]
|
||||
|
||||
export default {
|
||||
assert: {
|
||||
|
|
@ -45,6 +50,7 @@ export default {
|
|||
process: {
|
||||
argv: () => process.argv,
|
||||
cwd: process.cwd,
|
||||
emitWarning: (warning, type) => process.emitWarning(warning, type),
|
||||
execPath: () => process.execPath,
|
||||
exit: process.exit,
|
||||
nextTick: process.nextTick,
|
||||
|
|
|
|||
50
node_modules/yargs/locales/ko.json
generated
vendored
50
node_modules/yargs/locales/ko.json
generated
vendored
|
|
@ -2,48 +2,48 @@
|
|||
"Commands:": "명령:",
|
||||
"Options:": "옵션:",
|
||||
"Examples:": "예시:",
|
||||
"boolean": "여부",
|
||||
"boolean": "불리언",
|
||||
"count": "개수",
|
||||
"string": "문자열",
|
||||
"number": "숫자",
|
||||
"array": "배열",
|
||||
"required": "필수",
|
||||
"default": "기본",
|
||||
"default:": "기본:",
|
||||
"choices:": "선택:",
|
||||
"default": "기본값",
|
||||
"default:": "기본값:",
|
||||
"choices:": "선택지:",
|
||||
"aliases:": "별칭:",
|
||||
"generated-value": "생성된 값",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "옵션이 아닌 인자가 충분치 않습니다: %s개를 받았지만, 적어도 %s개는 필요합니다",
|
||||
"other": "옵션이 아닌 인자가 충분치 않습니다: %s개를 받았지만, 적어도 %s개는 필요합니다"
|
||||
"one": "옵션이 아닌 인수가 충분하지 않습니다: %s개 입력받음, 최소 %s개 입력 필요",
|
||||
"other": "옵션이 아닌 인수가 충분하지 않습니다: %s개 입력받음, 최소 %s개 입력 필요"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "옵션이 아닌 인자가 너무 많습니다: %s개를 받았지만, %s개 이하여야 합니다",
|
||||
"other": "옵션이 아닌 인자가 너무 많습니다: %s개를 받았지만, %s개 이하여야 합니다"
|
||||
"one": "옵션이 아닌 인수가 너무 많습니다: %s개 입력받음, 최대 %s개 입력 가능",
|
||||
"other": "옵션이 아닌 인수가 너무 많습니다: %s개 입력받음, 최대 %s개 입력 가능"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "인자값을 받지 못했습니다: %s",
|
||||
"other": "인자값들을 받지 못했습니다: %s"
|
||||
"one": "인수가 주어지지 않았습니다: %s",
|
||||
"other": "인수가 주어지지 않았습니다: %s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "필수 인자를 받지 못했습니다: %s",
|
||||
"other": "필수 인자들을 받지 못했습니다: %s"
|
||||
"one": "필수 인수가 주어지지 않았습니다: %s",
|
||||
"other": "필수 인수가 주어지지 않았습니다: %s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "알 수 없는 인자입니다: %s",
|
||||
"other": "알 수 없는 인자들입니다: %s"
|
||||
"one": "알 수 없는 인수입니다: %s",
|
||||
"other": "알 수 없는 인수입니다: %s"
|
||||
},
|
||||
"Invalid values:": "잘못된 값입니다:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "인자: %s, 입력받은 값: %s, 선택지: %s",
|
||||
"Argument check failed: %s": "유효하지 않은 인자입니다: %s",
|
||||
"Implications failed:": "옵션의 조합이 잘못되었습니다:",
|
||||
"Not enough arguments following: %s": "인자가 충분하게 주어지지 않았습니다: %s",
|
||||
"Invalid JSON config file: %s": "유효하지 않은 JSON 설정파일입니다: %s",
|
||||
"Path to JSON config file": "JSON 설정파일 경로",
|
||||
"Show help": "도움말을 보여줍니다",
|
||||
"Show version number": "버전 넘버를 보여줍니다",
|
||||
"Did you mean %s?": "찾고계신게 %s입니까?",
|
||||
"Arguments %s and %s are mutually exclusive" : "%s와 %s 인자는 같이 사용될 수 없습니다",
|
||||
"Invalid values:": "유효하지 않은 값:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "인수: %s, 주어진 값: %s, 선택지: %s",
|
||||
"Argument check failed: %s": "인수 체크에 실패했습니다: %s",
|
||||
"Implications failed:": "주어진 인수에 필요한 추가 인수가 주어지지 않았습니다:",
|
||||
"Not enough arguments following: %s": "다음 인수가 주어지지 않았습니다: %s",
|
||||
"Invalid JSON config file: %s": "유효하지 않은 JSON 설정 파일: %s",
|
||||
"Path to JSON config file": "JSON 설정 파일 경로",
|
||||
"Show help": "도움말 표시",
|
||||
"Show version number": "버전 표시",
|
||||
"Did you mean %s?": "%s을(를) 찾으시나요?",
|
||||
"Arguments %s and %s are mutually exclusive" : "인수 %s과(와) %s은(는) 동시에 지정할 수 없습니다",
|
||||
"Positionals:": "위치:",
|
||||
"command": "명령"
|
||||
}
|
||||
|
|
|
|||
51
node_modules/yargs/locales/uk_UA.json
generated
vendored
Normal file
51
node_modules/yargs/locales/uk_UA.json
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"Commands:": "Команди:",
|
||||
"Options:": "Опції:",
|
||||
"Examples:": "Приклади:",
|
||||
"boolean": "boolean",
|
||||
"count": "кількість",
|
||||
"string": "строка",
|
||||
"number": "число",
|
||||
"array": "масива",
|
||||
"required": "обов'язково",
|
||||
"default": "за замовчуванням",
|
||||
"default:": "за замовчуванням:",
|
||||
"choices:": "доступні варіанти:",
|
||||
"aliases:": "псевдоніми:",
|
||||
"generated-value": "згенероване значення",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "Недостатньо аргументів: наразі %s, потрібно %s або більше",
|
||||
"other": "Недостатньо аргументів: наразі %s, потрібно %s або більше"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "Забагато аргументів: наразі %s, максимум %s",
|
||||
"other": "Too many non-option arguments: наразі %s, максимум of %s"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "Відсутнє значення для аргументу: %s",
|
||||
"other": "Відсутні значення для аргументу: %s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "Відсутній обов'язковий аргумент: %s",
|
||||
"other": "Відсутні обов'язкові аргументи: %s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "Аргумент %s не підтримується",
|
||||
"other": "Аргументи %s не підтримуються"
|
||||
},
|
||||
"Invalid values:": "Некоректні значення:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "Аргумент: %s, Введено: %s, Доступні варіанти: %s",
|
||||
"Argument check failed: %s": "Аргумент не пройшов перевірку: %s",
|
||||
"Implications failed:": "Відсутні залежні аргументи:",
|
||||
"Not enough arguments following: %s": "Не достатньо аргументів після: %s",
|
||||
"Invalid JSON config file: %s": "Некоректний JSON-файл конфігурації: %s",
|
||||
"Path to JSON config file": "Шлях до JSON-файлу конфігурації",
|
||||
"Show help": "Показати довідку",
|
||||
"Show version number": "Показати версію",
|
||||
"Did you mean %s?": "Можливо, ви мали на увазі %s?",
|
||||
"Arguments %s and %s are mutually exclusive" : "Аргументи %s та %s взаємовиключні",
|
||||
"Positionals:": "Позиційні:",
|
||||
"command": "команда",
|
||||
"deprecated": "застарілий",
|
||||
"deprecated: %s": "застарілий: %s"
|
||||
}
|
||||
52
node_modules/yargs/locales/uz.json
generated
vendored
Normal file
52
node_modules/yargs/locales/uz.json
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"Commands:": "Buyruqlar:",
|
||||
"Options:": "Imkoniyatlar:",
|
||||
"Examples:": "Misollar:",
|
||||
"boolean": "boolean",
|
||||
"count": "sanoq",
|
||||
"string": "satr",
|
||||
"number": "raqam",
|
||||
"array": "massiv",
|
||||
"required": "majburiy",
|
||||
"default": "boshlang'ich",
|
||||
"default:": "boshlang'ich:",
|
||||
"choices:": "tanlovlar:",
|
||||
"aliases:": "taxalluslar:",
|
||||
"generated-value": "yaratilgan-qiymat",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "No-imkoniyat argumentlar yetarli emas: berilgan %s, minimum %s",
|
||||
"other": "No-imkoniyat argumentlar yetarli emas: berilgan %s, minimum %s"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "No-imkoniyat argumentlar juda ko'p: berilgan %s, maksimum %s",
|
||||
"other": "No-imkoniyat argumentlar juda ko'p: got %s, maksimum %s"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "Argument qiymati berilmagan: %s",
|
||||
"other": "Argument qiymatlari berilmagan: %s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "Majburiy argument berilmagan: %s",
|
||||
"other": "Majburiy argumentlar berilmagan: %s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "Noma'lum argument berilmagan: %s",
|
||||
"other": "Noma'lum argumentlar berilmagan: %s"
|
||||
},
|
||||
"Invalid values:": "Nosoz qiymatlar:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Berilgan: %s, Tanlovlar: %s",
|
||||
"Argument check failed: %s": "Muvaffaqiyatsiz argument tekshiruvi: %s",
|
||||
"Implications failed:": "Bog'liq argumentlar berilmagan:",
|
||||
"Not enough arguments following: %s": "Quyidagi argumentlar yetarli emas: %s",
|
||||
"Invalid JSON config file: %s": "Nosoz JSON konfiguratsiya fayli: %s",
|
||||
"Path to JSON config file": "JSON konfiguratsiya fayli joylashuvi",
|
||||
"Show help": "Yordam ko'rsatish",
|
||||
"Show version number": "Versiyani ko'rsatish",
|
||||
"Did you mean %s?": "%s ni nazarda tutyapsizmi?",
|
||||
"Arguments %s and %s are mutually exclusive" : "%s va %s argumentlari alohida",
|
||||
"Positionals:": "Positsionallar:",
|
||||
"command": "buyruq",
|
||||
"deprecated": "eskirgan",
|
||||
"deprecated: %s": "eskirgan: %s"
|
||||
}
|
||||
|
||||
96
node_modules/yargs/locales/zh_TW.json
generated
vendored
96
node_modules/yargs/locales/zh_TW.json
generated
vendored
|
|
@ -1,47 +1,51 @@
|
|||
{
|
||||
"Commands:": "命令:",
|
||||
"Options:": "選項:",
|
||||
"Examples:": "例:",
|
||||
"boolean": "布林",
|
||||
"count": "次數",
|
||||
"string": "字串",
|
||||
"number": "數字",
|
||||
"array": "陣列",
|
||||
"required": "必須",
|
||||
"default": "預設值",
|
||||
"default:": "預設值:",
|
||||
"choices:": "可選值:",
|
||||
"aliases:": "別名:",
|
||||
"generated-value": "生成的值",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個",
|
||||
"other": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個",
|
||||
"other": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "此引數無指定值:%s",
|
||||
"other": "這些引數無指定值:%s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "缺少必須的引數:%s",
|
||||
"other": "缺少這些必須的引數:%s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "未知的引數:%s",
|
||||
"other": "未知的這些引數:%s"
|
||||
},
|
||||
"Invalid values:": "無效的選項值:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "引數名稱: %s, 傳入的值: %s, 可選的值:%s",
|
||||
"Argument check failed: %s": "引數驗證失敗:%s",
|
||||
"Implications failed:": "缺少依賴的選項:",
|
||||
"Not enough arguments following: %s": "沒有提供足夠的值給此引數:%s",
|
||||
"Invalid JSON config file: %s": "無效的 JSON 設置文件:%s",
|
||||
"Path to JSON config file": "JSON 設置文件的路徑",
|
||||
"Show help": "顯示說明",
|
||||
"Show version number": "顯示版本",
|
||||
"Did you mean %s?": "是指 %s?",
|
||||
"Arguments %s and %s are mutually exclusive" : "引數 %s 和 %s 是互斥的"
|
||||
}
|
||||
"Commands:": "命令:",
|
||||
"Options:": "選項:",
|
||||
"Examples:": "範例:",
|
||||
"boolean": "布林",
|
||||
"count": "次數",
|
||||
"string": "字串",
|
||||
"number": "數字",
|
||||
"array": "陣列",
|
||||
"required": "必填",
|
||||
"default": "預設值",
|
||||
"default:": "預設值:",
|
||||
"choices:": "可選值:",
|
||||
"aliases:": "別名:",
|
||||
"generated-value": "生成的值",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個",
|
||||
"other": "non-option 引數不足:只傳入了 %s 個, 至少要 %s 個"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個",
|
||||
"other": "non-option 引數過多:傳入了 %s 個, 但最多 %s 個"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "此引數無指定值:%s",
|
||||
"other": "這些引數無指定值:%s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "缺少必須的引數:%s",
|
||||
"other": "缺少這些必須的引數:%s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "未知的引數:%s",
|
||||
"other": "未知的引數:%s"
|
||||
},
|
||||
"Invalid values:": "無效的選項值:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "引數名稱: %s, 傳入的值: %s, 可選的值:%s",
|
||||
"Argument check failed: %s": "引數驗證失敗:%s",
|
||||
"Implications failed:": "缺少依賴引數:",
|
||||
"Not enough arguments following: %s": "沒有提供足夠的值給此引數:%s",
|
||||
"Invalid JSON config file: %s": "無效的 JSON 設置文件:%s",
|
||||
"Path to JSON config file": "JSON 設置文件的路徑",
|
||||
"Show help": "顯示說明",
|
||||
"Show version number": "顯示版本",
|
||||
"Did you mean %s?": "您是指 %s 嗎?",
|
||||
"Arguments %s and %s are mutually exclusive" : "引數 %s 和 %s 互斥",
|
||||
"Positionals:": "位置:",
|
||||
"command": "命令",
|
||||
"deprecated": "已淘汰",
|
||||
"deprecated: %s": "已淘汰:%s"
|
||||
}
|
||||
|
|
|
|||
40
node_modules/yargs/package.json
generated
vendored
40
node_modules/yargs/package.json
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "yargs",
|
||||
"version": "16.2.0",
|
||||
"version": "17.3.1",
|
||||
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
||||
"main": "./index.cjs",
|
||||
"exports": {
|
||||
|
|
@ -42,46 +42,48 @@
|
|||
"locales",
|
||||
"LICENSE",
|
||||
"lib/platform-shims/*.mjs",
|
||||
"!*.d.ts"
|
||||
"!*.d.ts",
|
||||
"!**/*.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"cliui": "^7.0.2",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"require-directory": "^2.1.1",
|
||||
"string-width": "^4.2.0",
|
||||
"string-width": "^4.2.3",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^20.2.2"
|
||||
"yargs-parser": "^21.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/mocha": "^8.0.0",
|
||||
"@types/node": "^14.11.2",
|
||||
"@wessberg/rollup-plugin-ts": "^1.3.2",
|
||||
"c8": "^7.0.0",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.11.4",
|
||||
"c8": "^7.7.0",
|
||||
"chai": "^4.2.0",
|
||||
"chalk": "^4.0.0",
|
||||
"coveralls": "^3.0.9",
|
||||
"cpr": "^3.0.1",
|
||||
"cross-env": "^7.0.2",
|
||||
"cross-spawn": "^7.0.0",
|
||||
"eslint": "^7.23.0",
|
||||
"gts": "^3.0.0",
|
||||
"hashish": "0.0.4",
|
||||
"mocha": "^8.0.0",
|
||||
"mocha": "^9.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.23.0",
|
||||
"rollup-plugin-cleanup": "^3.1.1",
|
||||
"standardx": "^5.0.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-ts": "^2.0.4",
|
||||
"typescript": "^4.0.2",
|
||||
"which": "^2.0.0",
|
||||
"yargs-test-extends": "^1.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"fix": "gts fix && npm run fix:js",
|
||||
"fix:js": "standardx --fix '**/*.mjs' && standardx --fix '**/*.cjs' && standardx --fix './*.mjs' && standardx --fix './*.cjs'",
|
||||
"fix:js": "eslint . --ext cjs --ext mjs --ext js --fix",
|
||||
"posttest": "npm run check",
|
||||
"test": "c8 mocha ./test/*.cjs --require ./test/before.cjs --timeout=12000 --check-leaks",
|
||||
"test:esm": "c8 mocha ./test/esm/*.mjs --check-leaks",
|
||||
"test": "c8 mocha --enable-source-maps ./test/*.cjs --require ./test/before.cjs --timeout=12000 --check-leaks",
|
||||
"test:esm": "c8 mocha --enable-source-maps ./test/esm/*.mjs --check-leaks",
|
||||
"coverage": "c8 report --check-coverage",
|
||||
"prepare": "npm run compile",
|
||||
"pretest": "npm run compile -- -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
|
||||
|
|
@ -90,7 +92,7 @@
|
|||
"build:cjs": "rollup -c rollup.config.cjs",
|
||||
"postbuild:cjs": "rimraf ./build/index.cjs.d.ts",
|
||||
"check": "gts lint && npm run check:js",
|
||||
"check:js": "standardx '**/*.mjs' && standardx '**/*.cjs' && standardx './*.mjs' && standardx './*.cjs'",
|
||||
"check:js": "eslint . --ext cjs --ext mjs --ext js",
|
||||
"clean": "gts clean"
|
||||
},
|
||||
"repository": {
|
||||
|
|
@ -98,14 +100,6 @@
|
|||
"url": "https://github.com/yargs/yargs.git"
|
||||
},
|
||||
"homepage": "https://yargs.js.org/",
|
||||
"standardx": {
|
||||
"ignore": [
|
||||
"build",
|
||||
"helpers",
|
||||
"**/example/**",
|
||||
"**/platform-shims/esm.mjs"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"argument",
|
||||
"args",
|
||||
|
|
@ -117,6 +111,6 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue