Update ava to 4.3.3

The [release notes](https://github.com/avajs/ava/releases/tag/v4.3.3)
mention compatibility with Node 18.8.
This commit is contained in:
Henry Mercer 2022-09-02 18:02:07 +01:00
parent 21530f507f
commit bea5e4b220
160 changed files with 2647 additions and 2263 deletions

2
node_modules/yargs/build/index.cjs generated vendored

File diff suppressed because one or more lines are too long

View file

@ -149,7 +149,7 @@ export class CommandInstance {
}
parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
if (isDefaultCommand)
innerYargs.getInternalMethods().getUsageInstance().unfreeze();
innerYargs.getInternalMethods().getUsageInstance().unfreeze(true);
if (this.shouldUpdateUsage(innerYargs)) {
innerYargs
.getInternalMethods()
@ -183,18 +183,7 @@ export class CommandInstance {
pc.push(c);
return `$0 ${pc.join(' ')}`;
}
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 middlewares = this.globalMiddleware
.getMiddleware()
.slice(0)
.concat(commandHandler.middlewares);
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
if (!yargs.getInternalMethods().getHasOutput()) {
const validation = yargs
.getInternalMethods()
@ -237,6 +226,22 @@ export class CommandInstance {
}
return innerArgv;
}
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 middlewares = this.globalMiddleware
.getMiddleware()
.slice(0)
.concat(commandHandler.middlewares);
const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
return isPromise(maybePromiseArgv)
? maybePromiseArgv.then(resolvedInnerArgv => this.handleValidationAndGetResult(isDefaultCommand, commandHandler, resolvedInnerArgv, currentContext, aliases, yargs, middlewares, positionalMap))
: this.handleValidationAndGetResult(isDefaultCommand, commandHandler, maybePromiseArgv, currentContext, aliases, yargs, middlewares, positionalMap);
}
populatePositionals(commandHandler, argv, context, yargs) {
argv._ = argv._.slice(context.commands.length);
const demanded = commandHandler.demanded.slice(0);
@ -328,12 +333,12 @@ export class CommandInstance {
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) &&
if (!this.isInConfigs(yargs, key) &&
!this.isDefaulted(yargs, key) &&
Object.prototype.hasOwnProperty.call(argv, key) &&
Object.prototype.hasOwnProperty.call(parsed.argv, key) &&
(Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
@ -346,6 +351,16 @@ export class CommandInstance {
});
}
}
isDefaulted(yargs, key) {
const { default: defaults } = yargs.getOptions();
return (Object.prototype.hasOwnProperty.call(defaults, key) ||
Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key)));
}
isInConfigs(yargs, key) {
const { configObjects } = yargs.getOptions();
return (configObjects.some(c => Object.prototype.hasOwnProperty.call(c, key)) ||
configObjects.some(c => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key))));
}
runDefaultBuilderOn(yargs) {
if (!this.defaultCommand)
return;

View file

@ -33,7 +33,7 @@ export const completionZshTemplate = `#compdef {{app_name}}
# yargs command completion script
#
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
# or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
#
_{{app_name}}_yargs_completions()
{

View file

@ -13,6 +13,7 @@ export class Completion {
this.completionKey = 'get-yargs-completions';
this.aliases = null;
this.customCompletionFunction = null;
this.indexAfterLastReset = 0;
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;
@ -23,6 +24,7 @@ export class Completion {
if (handlers[args[i]] && handlers[args[i]].builder) {
const builder = handlers[args[i]].builder;
if (isCommandBuilderCallback(builder)) {
this.indexAfterLastReset = i + 1;
const y = this.yargs.getInternalMethods().reset();
builder(y, true);
return y.argv;
@ -32,7 +34,8 @@ export class Completion {
const completions = [];
this.commandCompletions(completions, args, current);
this.optionCompletions(completions, args, argv, current);
this.choicesCompletions(completions, args, argv, current);
this.choicesFromOptionsCompletions(completions, args, argv, current);
this.choicesFromPositionalsCompletions(completions, args, argv, current);
done(null, completions);
}
commandCompletions(completions, args, current) {
@ -66,7 +69,8 @@ export class Completion {
options.boolean.includes(key);
const isPositionalKey = positionalKeys.includes(key);
if (!isPositionalKey &&
!this.argsContainKey(args, argv, key, negable)) {
!options.hiddenOptions.includes(key) &&
!this.argsContainKey(args, key, negable)) {
this.completeOptionKey(key, completions, current);
if (negable && !!options.default[key])
this.completeOptionKey(`no-${key}`, completions, current);
@ -74,11 +78,31 @@ export class Completion {
});
}
}
choicesCompletions(completions, args, argv, current) {
choicesFromOptionsCompletions(completions, args, argv, current) {
if (this.previousArgHasChoices(args)) {
const choices = this.getPreviousArgChoices(args);
if (choices && choices.length > 0) {
completions.push(...choices);
completions.push(...choices.map(c => c.replace(/:/g, '\\:')));
}
}
}
choicesFromPositionalsCompletions(completions, args, argv, current) {
if (current === '' &&
completions.length > 0 &&
this.previousArgHasChoices(args)) {
return;
}
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
const offset = Math.max(this.indexAfterLastReset, this.yargs.getInternalMethods().getContext().commands.length +
1);
const positionalKey = positionalKeys[argv._.length - offset - 1];
if (!positionalKey) {
return;
}
const choices = this.yargs.getOptions().choices[positionalKey] || [];
for (const choice of choices) {
if (choice.startsWith(current)) {
completions.push(choice.replace(/:/g, '\\:'));
}
}
}
@ -87,31 +111,43 @@ export class Completion {
return;
let previousArg = args[args.length - 1];
let filter = '';
if (!previousArg.startsWith('--') && args.length > 1) {
if (!previousArg.startsWith('-') && args.length > 1) {
filter = previousArg;
previousArg = args[args.length - 2];
}
if (!previousArg.startsWith('--'))
if (!previousArg.startsWith('-'))
return;
const previousArgKey = previousArg.replace(/-/g, '');
const previousArgKey = previousArg.replace(/^-+/, '');
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));
const possibleAliases = [
previousArgKey,
...(this.yargs.getAliases()[previousArgKey] || []),
];
let choices;
for (const possibleAlias of possibleAliases) {
if (Object.prototype.hasOwnProperty.call(options.key, possibleAlias) &&
Array.isArray(options.choices[possibleAlias])) {
choices = options.choices[possibleAlias];
break;
}
}
if (choices) {
return choices.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)
argsContainKey(args, key, negable) {
const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? '-' : '--') + s) !== -1;
if (argsContains(key))
return true;
if (negable && args.indexOf(`--no-${key}`) !== -1)
if (negable && argsContains(`no-${key}`))
return true;
if (this.aliases) {
for (const alias of this.aliases[key]) {
if (argv[alias] !== undefined)
if (argsContains(alias))
return true;
}
}

View file

@ -12,12 +12,13 @@ export function usage(yargs, shim) {
fails.push(f);
};
let failMessage = null;
let globalFailMessage = null;
let showHelpOnFail = true;
self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
function parseFunctionArgs() {
return typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2];
const [enabled, message] = typeof arg1 === 'string' ? [true, arg1] : [arg1, arg2];
if (yargs.getInternalMethods().isGlobalContext()) {
globalFailMessage = message;
}
const [enabled, message] = parseFunctionArgs();
failMessage = message;
showHelpOnFail = enabled;
return self;
@ -50,10 +51,11 @@ export function usage(yargs, shim) {
}
if (msg || err)
logger.error(msg || err);
if (failMessage) {
const globalOrCommandFailMessage = failMessage || globalFailMessage;
if (globalOrCommandFailMessage) {
if (msg || err)
logger.error('');
logger.error(failMessage);
logger.error(globalOrCommandFailMessage);
}
}
err = err || new YError(msg);
@ -535,20 +537,29 @@ export function usage(yargs, shim) {
descriptions,
});
};
self.unfreeze = function unfreeze() {
self.unfreeze = function unfreeze(defaultCommand = false) {
const frozen = frozens.pop();
if (!frozen)
return;
({
failMessage,
failureOutput,
usages,
usageDisabled,
epilogs,
examples,
commands,
descriptions,
} = frozen);
if (defaultCommand) {
descriptions = { ...frozen.descriptions, ...descriptions };
commands = [...frozen.commands, ...commands];
usages = [...frozen.usages, ...usages];
examples = [...frozen.examples, ...examples];
epilogs = [...frozen.epilogs, ...epilogs];
}
else {
({
failMessage,
failureOutput,
usages,
usageDisabled,
epilogs,
examples,
commands,
descriptions,
} = frozen);
}
};
return self;
}

View file

@ -106,7 +106,7 @@ export function validation(yargs, usage, shim) {
}
}
if (unknown.length) {
usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.join(', ')));
usage.fail(__n('Unknown argument: %s', 'Unknown arguments: %s', unknown.length, unknown.map(s => (s.trim() ? s : `"${s}"`)).join(', ')));
}
};
self.unknownCommands = function unknownCommands(argv) {

View file

@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _YargsInstance_command, _YargsInstance_cwd, _YargsInstance_context, _YargsInstance_completion, _YargsInstance_completionCommand, _YargsInstance_defaultShowHiddenOpt, _YargsInstance_exitError, _YargsInstance_detectLocale, _YargsInstance_emittedWarnings, _YargsInstance_exitProcess, _YargsInstance_frozens, _YargsInstance_globalMiddleware, _YargsInstance_groups, _YargsInstance_hasOutput, _YargsInstance_helpOpt, _YargsInstance_logger, _YargsInstance_output, _YargsInstance_options, _YargsInstance_parentRequire, _YargsInstance_parserConfig, _YargsInstance_parseFn, _YargsInstance_parseContext, _YargsInstance_pkgs, _YargsInstance_preservedGroups, _YargsInstance_processArgs, _YargsInstance_recommendCommands, _YargsInstance_shim, _YargsInstance_strict, _YargsInstance_strictCommands, _YargsInstance_strictOptions, _YargsInstance_usage, _YargsInstance_versionOpt, _YargsInstance_validation;
var _YargsInstance_command, _YargsInstance_cwd, _YargsInstance_context, _YargsInstance_completion, _YargsInstance_completionCommand, _YargsInstance_defaultShowHiddenOpt, _YargsInstance_exitError, _YargsInstance_detectLocale, _YargsInstance_emittedWarnings, _YargsInstance_exitProcess, _YargsInstance_frozens, _YargsInstance_globalMiddleware, _YargsInstance_groups, _YargsInstance_hasOutput, _YargsInstance_helpOpt, _YargsInstance_isGlobalContext, _YargsInstance_logger, _YargsInstance_output, _YargsInstance_options, _YargsInstance_parentRequire, _YargsInstance_parserConfig, _YargsInstance_parseFn, _YargsInstance_parseContext, _YargsInstance_pkgs, _YargsInstance_preservedGroups, _YargsInstance_processArgs, _YargsInstance_recommendCommands, _YargsInstance_shim, _YargsInstance_strict, _YargsInstance_strictCommands, _YargsInstance_strictOptions, _YargsInstance_usage, _YargsInstance_versionOpt, _YargsInstance_validation;
import { command as Command, } from './command.js';
import { assertNotStrictEqual, assertSingleKey, objectKeys, } from './typings/common-types.js';
import { YError } from './yerror.js';
@ -64,6 +64,7 @@ const kGetParseContext = Symbol('getParseContext');
const kGetUsageInstance = Symbol('getUsageInstance');
const kGetValidationInstance = Symbol('getValidationInstance');
const kHasParseCallback = Symbol('hasParseCallback');
const kIsGlobalContext = Symbol('isGlobalContext');
const kPostProcess = Symbol('postProcess');
const kRebase = Symbol('rebase');
const kReset = Symbol('reset');
@ -90,6 +91,7 @@ export class YargsInstance {
_YargsInstance_groups.set(this, {});
_YargsInstance_hasOutput.set(this, false);
_YargsInstance_helpOpt.set(this, null);
_YargsInstance_isGlobalContext.set(this, true);
_YargsInstance_logger.set(this, void 0);
_YargsInstance_output.set(this, '');
_YargsInstance_options.set(this, void 0);
@ -217,12 +219,19 @@ export class YargsInstance {
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
let aliases;
const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
if (!shouldCoerce) {
return argv;
}
return maybeAsyncResult(() => {
aliases = yargs.getAliases();
return value(argv[keys]);
}, (result) => {
argv[keys] = result;
if (aliases[keys]) {
const stripAliased = yargs
.getInternalMethods()
.getParserConfiguration()['strip-aliased'];
if (aliases[keys] && stripAliased !== true) {
for (const alias of aliases[keys]) {
argv[alias] = result;
}
@ -535,7 +544,7 @@ export class YargsInstance {
}
locale(locale) {
argsert('[string]', [locale], arguments.length);
if (!locale) {
if (locale === undefined) {
this[kGuessLocale]();
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
}
@ -946,7 +955,7 @@ export class YargsInstance {
__classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
return this;
}
[(_YargsInstance_command = new WeakMap(), _YargsInstance_cwd = new WeakMap(), _YargsInstance_context = new WeakMap(), _YargsInstance_completion = new WeakMap(), _YargsInstance_completionCommand = new WeakMap(), _YargsInstance_defaultShowHiddenOpt = new WeakMap(), _YargsInstance_exitError = new WeakMap(), _YargsInstance_detectLocale = new WeakMap(), _YargsInstance_emittedWarnings = new WeakMap(), _YargsInstance_exitProcess = new WeakMap(), _YargsInstance_frozens = new WeakMap(), _YargsInstance_globalMiddleware = new WeakMap(), _YargsInstance_groups = new WeakMap(), _YargsInstance_hasOutput = new WeakMap(), _YargsInstance_helpOpt = new WeakMap(), _YargsInstance_logger = new WeakMap(), _YargsInstance_output = new WeakMap(), _YargsInstance_options = new WeakMap(), _YargsInstance_parentRequire = new WeakMap(), _YargsInstance_parserConfig = new WeakMap(), _YargsInstance_parseFn = new WeakMap(), _YargsInstance_parseContext = new WeakMap(), _YargsInstance_pkgs = new WeakMap(), _YargsInstance_preservedGroups = new WeakMap(), _YargsInstance_processArgs = new WeakMap(), _YargsInstance_recommendCommands = new WeakMap(), _YargsInstance_shim = new WeakMap(), _YargsInstance_strict = new WeakMap(), _YargsInstance_strictCommands = new WeakMap(), _YargsInstance_strictOptions = new WeakMap(), _YargsInstance_usage = new WeakMap(), _YargsInstance_versionOpt = new WeakMap(), _YargsInstance_validation = new WeakMap(), kCopyDoubleDash)](argv) {
[(_YargsInstance_command = new WeakMap(), _YargsInstance_cwd = new WeakMap(), _YargsInstance_context = new WeakMap(), _YargsInstance_completion = new WeakMap(), _YargsInstance_completionCommand = new WeakMap(), _YargsInstance_defaultShowHiddenOpt = new WeakMap(), _YargsInstance_exitError = new WeakMap(), _YargsInstance_detectLocale = new WeakMap(), _YargsInstance_emittedWarnings = new WeakMap(), _YargsInstance_exitProcess = new WeakMap(), _YargsInstance_frozens = new WeakMap(), _YargsInstance_globalMiddleware = new WeakMap(), _YargsInstance_groups = new WeakMap(), _YargsInstance_hasOutput = new WeakMap(), _YargsInstance_helpOpt = new WeakMap(), _YargsInstance_isGlobalContext = new WeakMap(), _YargsInstance_logger = new WeakMap(), _YargsInstance_output = new WeakMap(), _YargsInstance_options = new WeakMap(), _YargsInstance_parentRequire = new WeakMap(), _YargsInstance_parserConfig = new WeakMap(), _YargsInstance_parseFn = new WeakMap(), _YargsInstance_parseContext = new WeakMap(), _YargsInstance_pkgs = new WeakMap(), _YargsInstance_preservedGroups = new WeakMap(), _YargsInstance_processArgs = new WeakMap(), _YargsInstance_recommendCommands = new WeakMap(), _YargsInstance_shim = new WeakMap(), _YargsInstance_strict = new WeakMap(), _YargsInstance_strictCommands = new WeakMap(), _YargsInstance_strictOptions = new WeakMap(), _YargsInstance_usage = new WeakMap(), _YargsInstance_versionOpt = new WeakMap(), _YargsInstance_validation = new WeakMap(), kCopyDoubleDash)](argv) {
if (!argv._ || !argv['--'])
return argv;
argv._.push.apply(argv._, argv['--']);
@ -1180,6 +1189,7 @@ export class YargsInstance {
getUsageInstance: this[kGetUsageInstance].bind(this),
getValidationInstance: this[kGetValidationInstance].bind(this),
hasParseCallback: this[kHasParseCallback].bind(this),
isGlobalContext: this[kIsGlobalContext].bind(this),
postProcess: this[kPostProcess].bind(this),
reset: this[kReset].bind(this),
runValidation: this[kRunValidation].bind(this),
@ -1211,6 +1221,9 @@ export class YargsInstance {
[kHasParseCallback]() {
return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
}
[kIsGlobalContext]() {
return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
}
[kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
if (calledFromCommand)
return argv;
@ -1345,6 +1358,7 @@ export class YargsInstance {
helpOptSet = true;
}
}
__classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
const skipRecommendation = helpOptSet || requestCompletions || helpOnly;

View file

@ -2,6 +2,8 @@ export class YError extends Error {
constructor(msg) {
super(msg || 'yargs error');
this.name = 'YError';
Error.captureStackTrace(this, YError);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, YError);
}
}
}

View file

@ -21,7 +21,7 @@ try {
} catch (e) {
__dirname = process.cwd();
}
const mainFilename = __dirname.split('node_modules')[0]
const mainFilename = __dirname.substring(0, __dirname.lastIndexOf('node_modules'));
export default {
assert: {

7
node_modules/yargs/locales/ru.json generated vendored
View file

@ -42,5 +42,10 @@
"Path to JSON config file": "Путь к файлу конфигурации JSON",
"Show help": "Показать помощь",
"Show version number": "Показать номер версии",
"Did you mean %s?": "Вы имели в виду %s?"
"Did you mean %s?": "Вы имели в виду %s?",
"Arguments %s and %s are mutually exclusive": "Аргументы %s и %s являются взаимоисключающими",
"Positionals:": "Позиционные аргументы:",
"command": "команда",
"deprecated": "устар.",
"deprecated: %s": "устар.: %s"
}

9
node_modules/yargs/package.json generated vendored
View file

@ -1,6 +1,6 @@
{
"name": "yargs",
"version": "17.3.1",
"version": "17.5.1",
"description": "yargs the modern, pirate-themed, successor to optimist.",
"main": "./index.cjs",
"exports": {
@ -16,8 +16,13 @@
"import": "./helpers/helpers.mjs",
"require": "./helpers/index.js"
},
"./browser": {
"import": "./browser.mjs",
"types": "./browser.d.ts"
},
"./yargs": [
{
"import": "./yargs.mjs",
"require": "./yargs"
},
"./yargs"
@ -33,11 +38,13 @@
],
"files": [
"browser.mjs",
"browser.d.ts",
"index.cjs",
"helpers/*.js",
"helpers/*",
"index.mjs",
"yargs",
"yargs.mjs",
"build",
"locales",
"LICENSE",

10
node_modules/yargs/yargs.mjs generated vendored Normal file
View file

@ -0,0 +1,10 @@
// TODO: consolidate on using a helpers file at some point in the future, which
// is the approach currently used to export Parser and applyExtends for ESM:
import pkg from './build/index.cjs';
const {applyExtends, cjsPlatformShim, Parser, processArgv, Yargs} = pkg;
Yargs.applyExtends = (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
};
Yargs.hideBin = processArgv.hideBin;
Yargs.Parser = Parser;
export default Yargs;