Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yargs

Package Overview
Dependencies
Maintainers
2
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yargs - npm Package Compare versions

Comparing version 15.3.2-beta.0 to 15.4.0-beta.0

build/lib/command-types.d.ts

2

build/lib/apply-extends.d.ts

@@ -1,2 +0,2 @@

import { Dictionary } from './types';
import { Dictionary } from './common-types';
export declare function applyExtends(config: Dictionary, cwd: string, mergeExtends: boolean): Dictionary<any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyExtends = void 0;
const fs = require("fs");

@@ -4,0 +5,0 @@ const path = require("path");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.argsert = void 0;
const yerror_1 = require("./yerror");

@@ -4,0 +5,0 @@ const parse_command_1 = require("./parse-command");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.completionZshTemplate = exports.completionShTemplate = void 0;
exports.completionShTemplate = `###-begin-{{app_name}}-completions-###

@@ -4,0 +5,0 @@ #

@@ -1,2 +0,21 @@

import { CommandInstance, CompletionInstance, UsageInstance, YargsInstance } from './types';
import { CommandInstance } from './command-types';
import { UsageInstance } from './usage';
import { YargsInstance } from './yargs-types';
import { Arguments, DetailedArguments } from 'yargs-parser';
export declare function completion(yargs: YargsInstance, usage: UsageInstance, command: CommandInstance): CompletionInstance;
/** Instance of the completion module. */
interface CompletionInstance {
completionKey: string;
generateCompletionScript($0: string, cmd: string): string;
getCompletion(args: string[], done: (completions: string[]) => any): any;
registerFunction(fn: CompletionFunction): void;
setParsed(parsed: DetailedArguments): void;
}
declare type CompletionFunction = SyncCompletionFunction | AsyncCompletionFunction;
interface SyncCompletionFunction {
(current: string, argv: Arguments): string[] | Promise<string[]>;
}
interface AsyncCompletionFunction {
(current: string, argv: Arguments, done: (completions: string[]) => any): any;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
exports.completion = void 0;
const command_types_1 = require("./command-types");
const templates = require("./completion-templates");
const is_promise_1 = require("./is-promise");
const parse_command_1 = require("./parse-command");
const type_helpers_1 = require("./type-helpers");
const path = require("path");
// add bash completions to your

@@ -30,3 +31,3 @@ // yargs-powered applications.

if (completionFunction) {
if (type_helpers_1.isSyncCompletionFunction(completionFunction)) {
if (isSyncCompletionFunction(completionFunction)) {
const result = completionFunction(current, argv);

@@ -55,3 +56,3 @@ // promise based completion function.

const builder = handlers[args[i]].builder;
if (type_helpers_1.isFunctionCommandBuilder(builder)) {
if (command_types_1.isFunctionCommandBuilder(builder)) {
const y = yargs.reset();

@@ -129,1 +130,4 @@ builder(y);

exports.completion = completion;
function isSyncCompletionFunction(completionFunction) {
return completionFunction.length < 3;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPromise = void 0;
function isPromise(maybePromise) {

@@ -4,0 +5,0 @@ return !!maybePromise &&

@@ -23,2 +23,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.levenshtein = void 0;
// levenshtein distance algorithm, pulled from Andrei Mackenzie's MIT licensed.

@@ -25,0 +26,0 @@ // gist, which can be found here: https://gist.github.com/andrei-m/982927

@@ -1,2 +0,2 @@

import { Dictionary } from './types';
import { Dictionary } from './common-types';
export declare function objFilter<T = any>(original: Dictionary<T>, filter?: (k: string, v: T) => boolean): Dictionary<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.objFilter = void 0;
function objFilter(original, filter = () => true) {

@@ -4,0 +5,0 @@ const obj = {};

@@ -1,2 +0,11 @@

import { ParsedCommand } from './types';
export declare function parseCommand(cmd: string): ParsedCommand;
export interface ParsedCommand {
cmd: string;
demanded: Positional[];
optional: Positional[];
}
interface Positional {
cmd: string[];
variadic: boolean;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCommand = void 0;
function parseCommand(cmd) {

@@ -4,0 +5,0 @@ const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' ');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProcessArgvBin = exports.getProcessArgvWithoutBin = void 0;
function getProcessArgvBinIndex() {

@@ -4,0 +5,0 @@ // The binary name is the first command line argument for:

@@ -1,3 +0,53 @@

import { UsageInstance, YargsInstance } from './types';
import { Dictionary } from './common-types';
import { YargsInstance } from './yargs-types';
import { YError } from './yerror';
import Y18N = require('y18n');
export declare function usage(yargs: YargsInstance, y18n: Y18N): UsageInstance;
/** Instance of the usage module. */
export interface UsageInstance {
cacheHelpMessage(): void;
clearCachedHelpMessage(): void;
command(cmd: string, description: string | undefined, isDefault: boolean, aliases: string[], deprecated: boolean): void;
deferY18nLookup(str: string): string;
describe(key: string, desc?: string): void;
describe(keys: Dictionary<string>): void;
epilog(msg: string): void;
example(cmd: string, description?: string): void;
fail(msg?: string | null, err?: YError | string): void;
failFn(f: FailureFunction): void;
freeze(): void;
functionDescription(fn: {
name?: string;
}): string;
getCommands(): [string, string, boolean, string[], boolean][];
getDescriptions(): Dictionary<string | undefined>;
getPositionalGroupName(): string;
getUsage(): [string, string][];
getUsageDisabled(): boolean;
help(): string;
reset(localLookup: Dictionary<boolean>): UsageInstance;
showHelp(level: 'error' | 'log'): void;
showHelp(level: (message: string) => void): void;
showHelpOnFail(message?: string): UsageInstance;
showHelpOnFail(enabled: boolean, message: string): UsageInstance;
showVersion(): void;
stringifiedValues(values?: any[], separator?: string): string;
unfreeze(): void;
usage(msg: string | null, description?: string): UsageInstance;
version(ver: any): void;
wrap(cols: number): void;
}
interface FailureFunction {
(msg: string | undefined | null, err: YError | string | undefined, usage: UsageInstance): void;
}
export interface FrozenUsageInstance {
failMessage: string | undefined | null;
failureOutput: boolean;
usages: [string, string][];
usageDisabled: boolean;
epilogs: string[];
examples: [string, string][];
commands: [string, string, boolean, string[], boolean][];
descriptions: Dictionary<string | undefined>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// this file handles outputting usage instructions,
// failures, etc. keeps logging in one place.
exports.usage = void 0;
const obj_filter_1 = require("./obj-filter");

@@ -95,3 +94,3 @@ const path = require("path");

let commands = [];
self.command = function command(cmd, description, isDefault, aliases) {
self.command = function command(cmd, description, isDefault, aliases, deprecated = false) {
// the last default wins, so cancel out any previously set default

@@ -104,3 +103,3 @@ if (isDefault) {

}
commands.push([cmd, description || '', isDefault, aliases]);
commands.push([cmd, description || '', isDefault, aliases, deprecated]);
};

@@ -212,2 +211,10 @@ self.getCommands = () => commands;

}
if (command[4]) {
if (typeof command[4] === 'string') {
hints.push(`[${__('deprecated: %s', command[4])}]`);
}
else {
hints.push(`[${__('deprecated')}]`);
}
}
if (hints.length) {

@@ -214,0 +221,0 @@ ui.div({ text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right' });

@@ -1,3 +0,36 @@

import { YargsInstance, UsageInstance, ValidationInstance } from './types';
import { Dictionary } from './common-types';
import { UsageInstance } from './usage';
import { YargsInstance } from './yargs-types';
import { Arguments, DetailedArguments } from 'yargs-parser';
import Y18N = require('y18n');
export declare function validation(yargs: YargsInstance, usage: UsageInstance, y18n: Y18N): ValidationInstance;
/** Instance of the validation module. */
export interface ValidationInstance {
check(f: CustomCheck['func'], global: boolean): void;
conflicting(argv: Arguments): void;
conflicts(key: string, value: string | string[]): void;
conflicts(key: Dictionary<string | string[]>): void;
customChecks(argv: Arguments, aliases: DetailedArguments['aliases']): void;
freeze(): void;
getConflicting(): Dictionary<(string | undefined)[]>;
getImplied(): Dictionary<KeyOrPos[]>;
implications(argv: Arguments): void;
implies(key: string, value: KeyOrPos | KeyOrPos[]): void;
implies(key: Dictionary<KeyOrPos | KeyOrPos[]>): void;
isValidAndSomeAliasIsNotNew(key: string, aliases: DetailedArguments['aliases']): boolean;
limitedChoices(argv: Arguments): void;
nonOptionCount(argv: Arguments): void;
positionalCount(required: number, observed: number): void;
recommendCommands(cmd: string, potentialCommands: string[]): void;
requiredArguments(argv: Arguments): void;
reset(localLookup: Dictionary): ValidationInstance;
unfreeze(): void;
unknownArguments(argv: Arguments, aliases: DetailedArguments['aliases'], positionalMap: Dictionary, isDefaultCommand: boolean): void;
unknownCommands(argv: Arguments): boolean;
}
interface CustomCheck {
func: (argv: Arguments, aliases: DetailedArguments['aliases']) => any;
global: boolean;
}
declare type KeyOrPos = string | number | undefined;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validation = void 0;
const argsert_1 = require("./argsert");

@@ -76,3 +77,3 @@ const levenshtein_1 = require("./levenshtein");

// check for unknown arguments (strict-mode).
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap) {
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand) {
const commandKeys = yargs.getCommandInstance().getCommands();

@@ -89,3 +90,3 @@ const unknown = [];

});
if ((currentContext.commands.length > 0) || (commandKeys.length > 0)) {
if ((currentContext.commands.length > 0) || (commandKeys.length > 0) || isDefaultCommand) {
argv._.slice(currentContext.commands.length).forEach((key) => {

@@ -92,0 +93,0 @@ if (commandKeys.indexOf(key) === -1) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.YError = void 0;
class YError extends Error {

@@ -4,0 +5,0 @@ constructor(msg) {

@@ -5,3 +5,3 @@ 'use strict'

const { isPromise } = require('../build/lib/is-promise')
const { applyMiddleware, commandMiddlewareFactory } = require('./middleware')
const { applyMiddleware, commandMiddlewareFactory } = require('../build/lib/middleware')
const { parseCommand } = require('../build/lib/parse-command')

@@ -23,3 +23,3 @@ const path = require('path')

self.addHandler = function addHandler (cmd, description, builder, handler, commandMiddleware) {
self.addHandler = function addHandler (cmd, description, builder, handler, commandMiddleware, deprecated) {
let aliases = []

@@ -35,3 +35,3 @@ const middlewares = commandMiddlewareFactory(commandMiddleware)

if (cmd.aliases) command = [].concat(command).concat(cmd.aliases)
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares)
self.addHandler(command, extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated)
return

@@ -42,3 +42,3 @@ }

if (typeof builder === 'object' && builder.builder && typeof builder.handler === 'function') {
self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares)
self.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated)
return

@@ -79,3 +79,3 @@ }

if (description !== false) {
usage.command(cmd, description, isDefault, aliases)
usage.command(cmd, description, isDefault, aliases, deprecated)
}

@@ -89,2 +89,3 @@

middlewares,
deprecated,
demanded: parsedCommand.demanded,

@@ -205,3 +206,3 @@ optional: parsedCommand.optional

// checks get passed populated positional arguments.
if (!yargs._hasOutput()) yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error)
if (!yargs._hasOutput()) yargs._runValidation(innerArgv, aliases, positionalMap, yargs.parsed.error, !command)

@@ -208,0 +209,0 @@ if (commandHandler.handler && !yargs._hasOutput()) {

{
"name": "yargs",
"version": "15.3.2-beta.0",
"version": "15.4.0-beta.0",
"description": "yargs the modern, pirate-themed, successor to optimist.",

@@ -49,3 +49,3 @@ "main": "./index.js",

"es6-promise": "^4.2.5",
"eslint": "^6.8.0",
"eslint": "^7.0.0",
"eslint-plugin-import": "^2.20.1",

@@ -52,0 +52,0 @@ "eslint-plugin-node": "^11.0.0",

@@ -47,5 +47,5 @@ <p align="center">

````javascript
```javascript
#!/usr/bin/env node
const argv = require('yargs').argv
const {argv} = require('yargs')

@@ -57,3 +57,3 @@ if (argv.ships > 3 && argv.distance < 53.5) {

}
````
```

@@ -142,2 +142,2 @@ ```bash

[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/master/.nycrc

@@ -19,3 +19,3 @@ 'use strict'

const { applyExtends } = require('./build/lib/apply-extends')
const { globalMiddlewareFactory } = require('./lib/middleware')
const { globalMiddlewareFactory } = require('./build/lib/middleware')
const { YError } = require('./build/lib/yerror')

@@ -393,5 +393,5 @@ const processArgv = require('./build/lib/process-argv')

self.command = function (cmd, description, builder, handler, middlewares) {
argsert('<string|array|object> [string|boolean] [function|object] [function] [array]', [cmd, description, builder, handler, middlewares], arguments.length)
command.addHandler(cmd, description, builder, handler, middlewares)
self.command = function (cmd, description, builder, handler, middlewares, deprecated) {
argsert('<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]', [cmd, description, builder, handler, middlewares, deprecated], arguments.length)
command.addHandler(cmd, description, builder, handler, middlewares, deprecated)
return self

@@ -1266,3 +1266,3 @@ }

self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors) {
self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors, isDefaultCommand = false) {
if (parseErrors) throw new YError(parseErrors.message)

@@ -1276,3 +1276,3 @@ validation.nonOptionCount(argv)

if (strict && !failedStrictCommands) {
validation.unknownArguments(argv, aliases, positionalMap)
validation.unknownArguments(argv, aliases, positionalMap, isDefaultCommand)
}

@@ -1279,0 +1279,0 @@ validation.customChecks(argv, aliases)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc