From 261affd5c061c68a64ab4c546717f9dfc74dd190 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 23 Sep 2022 18:00:18 -0700 Subject: [PATCH] JS: Update Flow Definitions for `yargs` to v17 Summary: Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D39677869 fbshipit-source-id: 4495b0c6c5e245d20034906fff4547265c7cc157 --- .../{yargs_v15.x.x.js => yargs_v17.x.x.js} | 88 ++++++++++++++----- packages/metro-inspector-proxy/src/cli.js | 3 +- 2 files changed, 66 insertions(+), 25 deletions(-) rename flow-typed/npm/{yargs_v15.x.x.js => yargs_v17.x.x.js} (79%) diff --git a/flow-typed/npm/yargs_v15.x.x.js b/flow-typed/npm/yargs_v17.x.x.js similarity index 79% rename from flow-typed/npm/yargs_v15.x.x.js rename to flow-typed/npm/yargs_v17.x.x.js index 1685c21600..2750236797 100644 --- a/flow-typed/npm/yargs_v15.x.x.js +++ b/flow-typed/npm/yargs_v17.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 1f51ede354b708d1bf2ac3d98fd21d0b -// flow-typed version: fe275d55fd/yargs_v15.x.x/flow_>=v0.118.x +// flow-typed signature: cab38813101e0a162deaae556391abc8 +// flow-typed version: f7c859e705/yargs_v17.x.x/flow_>=v0.104.x declare module "yargs" { declare type Argv = { @@ -27,6 +27,7 @@ declare module "yargs" { description: string, global: boolean, group: string, + hidden: boolean, implies: string | { [key: string]: string, ... }, nargs: number, normalize: boolean, @@ -39,27 +40,27 @@ declare module "yargs" { ... }>; - declare type CommonModuleObject = { + declare type CommonModuleObject = {| command?: string | Array, aliases?: Array | string, builder?: { [key: string]: Options, ... } | ((yargsInstance: Yargs) => mixed), handler?: ((argv: Argv) => void) | ((argv: Argv) => Promise) - }; + |}; - declare type ModuleObjectDesc = { + declare type ModuleObjectDesc = {| ...CommonModuleObject, desc?: string | false - }; + |}; - declare type ModuleObjectDescribe = { + declare type ModuleObjectDescribe = {| ...CommonModuleObject, describe?: string | false - }; + |}; - declare type ModuleObjectDescription = { + declare type ModuleObjectDescription = {| ...CommonModuleObject, description?: string | false - }; + |}; declare type ModuleObject = | ModuleObjectDesc @@ -77,10 +78,10 @@ declare module "yargs" { alias(key: string, alias: string): this; alias(alias: { [key: string]: string | Array, ... }): this; - argv: Argv; + argv: Argv | Promise; array(key: string | Array): this; boolean(parameter: string | Array): this; - check(fn: (argv: Argv, options: Array) => ?boolean): this; + check(fn: (argv: Argv, options: Array) => mixed): this; choices(key: string, allowed: Array): this; choices(allowed: { [key: string]: Array, ... }): this; coerce(key: string, fn: (value: any) => mixed): this; @@ -90,18 +91,33 @@ declare module "yargs" { command( cmd: string | Array, desc: string | false, - builder?: { [key: string]: Options, ... } | ((yargsInstance: Yargs) => mixed), + builder?: + | { [key: string]: Options, ... } + | ((yargsInstance: Yargs) => mixed), handler?: Function ): this; - command( cmd: string | Array, desc: string | false, module: ModuleObject ): this; - command(module: ModuleObject): this; + commands( + cmd: string | Array, + desc: string | false, + builder?: + | { [key: string]: Options, ... } + | ((yargsInstance: Yargs) => mixed), + handler?: Function + ): this; + commands( + cmd: string | Array, + desc: string | false, + module: ModuleObject + ): this; + commands(module: ModuleObject): this; + commandDir( directory: string, options?: { @@ -178,7 +194,10 @@ declare module "yargs" { fail(fn: (failureMessage: string, err: Error, yargs: Yargs) => mixed): this; - getCompletion(args: Array, fn: () => void): this; + getCompletion( + args: Array, + fn: (err: Error | null, completions: Array | void) => void + ): Promise | void>; global(globals: string | Array, isGlobal?: boolean): this; @@ -227,8 +246,6 @@ declare module "yargs" { number(key: string | Array): this; - onFinishCommand(handler: () => mixed): this; - option(key: string, options?: Options): this; option(optionMap: { [key: string]: Options, ... }): this; @@ -239,10 +256,30 @@ declare module "yargs" { args?: string | Array, context?: { [key: string]: any, ... }, parseCallback?: (err: Error, argv: Argv, output?: string) => void - ): Argv; + ): Argv | Promise; parse( args?: string | Array, parseCallback?: (err: Error, argv: Argv, output?: string) => void + ): Argv | Promise; + + parseAsync( + args?: string | Array, + context?: { [key: string]: any, ... }, + parseCallback?: (err: Error, argv: Argv, output?: string) => void + ): Promise; + parseAsync( + args?: string | Array, + parseCallback?: (err: Error, argv: Argv, output?: string) => void + ): Promise; + + parseSync( + args?: string | Array, + context?: { [key: string]: any, ... }, + parseCallback?: (err: Error, argv: Argv, output?: string) => void + ): Argv; + parseSync( + args?: string | Array, + parseCallback?: (err: Error, argv: Argv, output?: string) => void ): Argv; parserConfiguration(configuration: {[key: string]: any, ...}): this; @@ -259,8 +296,6 @@ declare module "yargs" { requiresArg(key: string | Array): this; - reset(): this; - scriptName(name: string): this; showCompletionScript(): this; @@ -270,11 +305,16 @@ declare module "yargs" { showHelpOnFail(enable: boolean, message?: string): this; - strict(): this; - skipValidation(key: string): this; - strict(global?: boolean): this; + showVersion(consoleLevel?: "error" | "warn" | "log"): this; + showVersion(printCallback: (usageData: string) => void): this; + + strict(enabled?: boolean): this; + + strictCommands(enabled?: boolean): this; + + strictOptions(enabled?: boolean): this; string(key: string | Array): this; diff --git a/packages/metro-inspector-proxy/src/cli.js b/packages/metro-inspector-proxy/src/cli.js index c2062fd483..8445cd3f64 100755 --- a/packages/metro-inspector-proxy/src/cli.js +++ b/packages/metro-inspector-proxy/src/cli.js @@ -25,6 +25,7 @@ const argv = yargs describe: 'root folder of metro project', type: 'string', default: '', - }).argv; + }) + .parseSync(); runInspectorProxy((argv.port: any), (argv.root: any));