@reliverse/rempts 1.7.50 → 1.7.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -52
- package/dist-npm/bin/mod.d.mts +62 -607
- package/dist-npm/bin/mod.mjs +629 -2071
- package/package.json +3 -41
package/dist-npm/bin/mod.d.mts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { AnimationName as AnimationName$1, Animation } from '@figliolia/chalk-animation';
|
|
2
2
|
import { Readable, Writable } from 'node:stream';
|
|
3
3
|
import { Fonts } from 'figlet';
|
|
4
|
-
import { ReliArgParserOptions } from '@reliverse/reliarg';
|
|
5
|
-
import { JSONSchema7 } from 'json-schema';
|
|
6
|
-
import { JsonSchema7Type, JsonSchema7ObjectType } from 'zod-to-json-schema';
|
|
7
|
-
import { Command as Command$1, Argument, Option } from 'commander';
|
|
8
4
|
import * as _reliverse_relinka from '@reliverse/relinka';
|
|
9
5
|
import { SpinnerName } from 'cli-spinners';
|
|
10
6
|
import * as _reliverse_runtime from '@reliverse/runtime';
|
|
11
|
-
import * as server from '@trpc/server';
|
|
12
|
-
export { server as trpcServer };
|
|
13
|
-
export { z } from 'zod/v4';
|
|
14
|
-
import * as zod from 'zod';
|
|
15
|
-
export { zod };
|
|
16
7
|
|
|
17
8
|
type MsgType = "M_NULL" | "M_INFO_NULL" | "M_START" | "M_MIDDLE" | "M_GENERAL" | "M_GENERAL_NULL" | "M_INFO" | "M_ERROR" | "M_ERROR_NULL" | "M_END" | "M_NEWLINE" | "M_BAR";
|
|
18
9
|
type TypographyName = "bold" | "strikethrough" | "underline" | "italic" | "none";
|
|
@@ -1023,130 +1014,68 @@ declare function introPrompt(optionsOrTitle: StartPromptOptions | string): Promi
|
|
|
1023
1014
|
declare const startPrompt: typeof introPrompt;
|
|
1024
1015
|
declare const intro: typeof introPrompt;
|
|
1025
1016
|
|
|
1026
|
-
/** The Standard Schema interface. */
|
|
1027
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
1028
|
-
/** The Standard Schema properties. */
|
|
1029
|
-
readonly "~standard": StandardSchemaV1Props<Input, Output>;
|
|
1030
|
-
}
|
|
1031
|
-
/** The Standard Schema properties interface. */
|
|
1032
|
-
interface StandardSchemaV1Props<Input = unknown, Output = Input> {
|
|
1033
|
-
/** The version number of the standard. */
|
|
1034
|
-
readonly version: 1;
|
|
1035
|
-
/** The vendor name of the schema library. */
|
|
1036
|
-
readonly vendor: string;
|
|
1037
|
-
/** Validates unknown input values. */
|
|
1038
|
-
readonly validate: (value: unknown) => StandardSchemaV1Result<Output> | Promise<StandardSchemaV1Result<Output>>;
|
|
1039
|
-
/** Inferred types associated with the schema. */
|
|
1040
|
-
readonly types?: StandardSchemaV1Types<Input, Output> | undefined;
|
|
1041
|
-
}
|
|
1042
|
-
/** The result interface of the validate function. */
|
|
1043
|
-
type StandardSchemaV1Result<Output> = StandardSchemaV1SuccessResult<Output> | StandardSchemaV1FailureResult;
|
|
1044
|
-
/** The result interface if validation succeeds. */
|
|
1045
|
-
interface StandardSchemaV1SuccessResult<Output> {
|
|
1046
|
-
/** The typed output value. */
|
|
1047
|
-
readonly value: Output;
|
|
1048
|
-
/** The non-existent issues. */
|
|
1049
|
-
readonly issues?: undefined;
|
|
1050
|
-
}
|
|
1051
|
-
/** The result interface if validation fails. */
|
|
1052
|
-
interface StandardSchemaV1FailureResult {
|
|
1053
|
-
/** The issues of failed validation. */
|
|
1054
|
-
readonly issues: readonly StandardSchemaV1Issue[];
|
|
1055
|
-
}
|
|
1056
|
-
/** The issue interface of the failure output. */
|
|
1057
|
-
interface StandardSchemaV1Issue {
|
|
1058
|
-
/** The error message of the issue. */
|
|
1059
|
-
readonly message: string;
|
|
1060
|
-
/** The path of the issue, if any. */
|
|
1061
|
-
readonly path?: readonly (PropertyKey | StandardSchemaV1PathSegment)[] | undefined;
|
|
1062
|
-
}
|
|
1063
|
-
/** The path segment interface of the issue. */
|
|
1064
|
-
interface StandardSchemaV1PathSegment {
|
|
1065
|
-
/** The key representing a path segment. */
|
|
1066
|
-
readonly key: PropertyKey;
|
|
1067
|
-
}
|
|
1068
|
-
/** The Standard Schema types interface. */
|
|
1069
|
-
interface StandardSchemaV1Types<Input = unknown, Output = Input> {
|
|
1070
|
-
/** The input type of the schema. */
|
|
1071
|
-
readonly input: Input;
|
|
1072
|
-
/** The output type of the schema. */
|
|
1073
|
-
readonly output: Output;
|
|
1074
|
-
}
|
|
1075
|
-
/** Infers the input type of a Standard Schema. */
|
|
1076
|
-
type StandardSchemaV1InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
1077
|
-
/** Infers the output type of a Standard Schema. */
|
|
1078
|
-
type StandardSchemaV1InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
1079
|
-
|
|
1080
1017
|
/**
|
|
1081
|
-
*
|
|
1082
|
-
* This is written from scratch to avoid any kind of dependency on @trpc/server v11+
|
|
1018
|
+
* Options passed to the ReliArgParser.
|
|
1083
1019
|
*/
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
}
|
|
1143
|
-
type CreateCallerFactoryLike<Procedures = Record<string, (input: unknown) => unknown>> = (router: any) => (context: any) => Procedures;
|
|
1144
|
-
type AnyRouter = Trpc10RouterLike | Trpc11RouterLike | OrpcRouterLike<any>;
|
|
1145
|
-
type AnyProcedure = Trpc10ProcedureLike | Trpc11ProcedureLike;
|
|
1146
|
-
type inferRouterContext<R extends AnyRouter> = R extends Trpc10RouterLike | Trpc11RouterLike ? R["_def"]["_config"]["$types"]["ctx"] : R extends OrpcRouterLike<infer Ctx> ? Ctx : never;
|
|
1147
|
-
declare const isTrpc11Procedure: (procedure: AnyProcedure) => procedure is Trpc11ProcedureLike;
|
|
1148
|
-
declare const isTrpc11Router: (router: AnyRouter) => router is Trpc11RouterLike;
|
|
1149
|
-
declare const isOrpcRouter: (router: AnyRouter) => router is OrpcRouterLike<any>;
|
|
1020
|
+
type ReliArgParserOptions = {
|
|
1021
|
+
/**
|
|
1022
|
+
* A list of flags that should be treated as booleans.
|
|
1023
|
+
*/
|
|
1024
|
+
boolean?: string[];
|
|
1025
|
+
/**
|
|
1026
|
+
* Whether to print a warning if an unknown flag is encountered.
|
|
1027
|
+
*/
|
|
1028
|
+
warnOnUnknown?: boolean;
|
|
1029
|
+
/**
|
|
1030
|
+
* Whether encountering an unknown flag should cause a thrown error.
|
|
1031
|
+
*/
|
|
1032
|
+
strict?: boolean;
|
|
1033
|
+
/**
|
|
1034
|
+
* An object that maps a flag to one or more aliases (e.g. { force: "f" } or { f: ["force", "fast"] }).
|
|
1035
|
+
*/
|
|
1036
|
+
alias?: Record<string, string | string[]>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Default values for flags (e.g. { force: false, count: 0 }).
|
|
1039
|
+
*/
|
|
1040
|
+
defaults?: Record<string, unknown>;
|
|
1041
|
+
/**
|
|
1042
|
+
* If true, allows --no-foo to set foo=false (negated booleans).
|
|
1043
|
+
* Defaults to `true`.
|
|
1044
|
+
*/
|
|
1045
|
+
negatedBoolean?: boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* A callback to determine if a flag is considered "unknown."
|
|
1048
|
+
* If it returns false, the parser may warn or throw, depending on config.
|
|
1049
|
+
*/
|
|
1050
|
+
unknown?: (flagName: string) => boolean;
|
|
1051
|
+
/**
|
|
1052
|
+
* If true, attempt to parse non-boolean string values as numbers when possible.
|
|
1053
|
+
* Defaults to false.
|
|
1054
|
+
*/
|
|
1055
|
+
parseNumbers?: boolean;
|
|
1056
|
+
/**
|
|
1057
|
+
* If true, negative numbers like -123 will not be treated as short flags
|
|
1058
|
+
* and will be parsed as positional values.
|
|
1059
|
+
* Defaults to true (commonly desired).
|
|
1060
|
+
*/
|
|
1061
|
+
allowNegativeNumbers?: boolean;
|
|
1062
|
+
/**
|
|
1063
|
+
* If true, stop parsing flags at the first positional argument,
|
|
1064
|
+
* pushing all subsequent arguments into result._.
|
|
1065
|
+
* Defaults to false.
|
|
1066
|
+
*/
|
|
1067
|
+
stopEarly?: boolean;
|
|
1068
|
+
/**
|
|
1069
|
+
* A list of flags that should be collected as arrays if repeated.
|
|
1070
|
+
* e.g. { array: ["include"] } => --include file1 --include file2
|
|
1071
|
+
* results in { include: ["file1", "file2"] }
|
|
1072
|
+
*/
|
|
1073
|
+
array?: string[];
|
|
1074
|
+
/**
|
|
1075
|
+
* A list of flags that should always be treated as strings (ignoring parseNumbers).
|
|
1076
|
+
*/
|
|
1077
|
+
string?: string[];
|
|
1078
|
+
};
|
|
1150
1079
|
|
|
1151
1080
|
type EmptyArgs = Record<string, never>;
|
|
1152
1081
|
interface BaseArgProps {
|
|
@@ -1252,11 +1181,6 @@ interface DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> {
|
|
|
1252
1181
|
* Called once per CLI process, after all command/run() logic is finished
|
|
1253
1182
|
*/
|
|
1254
1183
|
onLauncherExit?: () => void | Promise<void>;
|
|
1255
|
-
/**
|
|
1256
|
-
* tRPC/oRPC router for RPC mode. When provided, the command will automatically
|
|
1257
|
-
* switch to RPC mode and use the router's procedures as CLI commands.
|
|
1258
|
-
*/
|
|
1259
|
-
router?: AnyRouter;
|
|
1260
1184
|
}
|
|
1261
1185
|
interface Command<A extends ArgDefinitions = EmptyArgs> {
|
|
1262
1186
|
meta?: CommandMeta;
|
|
@@ -1294,11 +1218,6 @@ interface Command<A extends ArgDefinitions = EmptyArgs> {
|
|
|
1294
1218
|
* Called once per CLI process, after all command/run() logic is finished
|
|
1295
1219
|
*/
|
|
1296
1220
|
onLauncherExit?: () => void | Promise<void>;
|
|
1297
|
-
/**
|
|
1298
|
-
* tRPC/oRPC router for RPC mode. When provided, the command will automatically
|
|
1299
|
-
* switch to RPC mode and use the router's procedures as CLI commands.
|
|
1300
|
-
*/
|
|
1301
|
-
router?: AnyRouter;
|
|
1302
1221
|
}
|
|
1303
1222
|
type ExtractAllowed<T extends ArgDefinition> = T extends {
|
|
1304
1223
|
type: "positional";
|
|
@@ -1364,323 +1283,6 @@ interface CallCmdOptions {
|
|
|
1364
1283
|
*/
|
|
1365
1284
|
declare function callCmd<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, input: string[] | Partial<InferArgTypes<A>>, options?: CallCmdOptions): Promise<CommandContext<InferArgTypes<A>>>;
|
|
1366
1285
|
|
|
1367
|
-
/**
|
|
1368
|
-
* JSON representation of a commander `Command` instance
|
|
1369
|
-
* Note: this is not necessarily a _complete_ representation of the command - it aims to be a big enough subset to be useful for generating documentation etc.
|
|
1370
|
-
*/
|
|
1371
|
-
interface CommandJSON {
|
|
1372
|
-
name?: string;
|
|
1373
|
-
version?: string;
|
|
1374
|
-
description?: string;
|
|
1375
|
-
usage?: string;
|
|
1376
|
-
commands?: CommandJSON[];
|
|
1377
|
-
arguments?: {
|
|
1378
|
-
name: string;
|
|
1379
|
-
description?: string;
|
|
1380
|
-
required: boolean;
|
|
1381
|
-
defaultValue?: {};
|
|
1382
|
-
defaultValueDescription?: string;
|
|
1383
|
-
variadic: boolean;
|
|
1384
|
-
choices?: string[];
|
|
1385
|
-
}[];
|
|
1386
|
-
options?: {
|
|
1387
|
-
name: string;
|
|
1388
|
-
description?: string;
|
|
1389
|
-
required: boolean;
|
|
1390
|
-
defaultValue?: {};
|
|
1391
|
-
defaultValueDescription?: string;
|
|
1392
|
-
variadic: boolean;
|
|
1393
|
-
attributeName?: string;
|
|
1394
|
-
flags?: string;
|
|
1395
|
-
short?: string;
|
|
1396
|
-
negate: boolean;
|
|
1397
|
-
optional: boolean;
|
|
1398
|
-
choices?: string[];
|
|
1399
|
-
}[];
|
|
1400
|
-
}
|
|
1401
|
-
/**
|
|
1402
|
-
* Convert a commander `Command` instance to a JSON object.
|
|
1403
|
-
*
|
|
1404
|
-
* Note: in theory you could use this with any `Command` instance, it doesn't have
|
|
1405
|
-
* to be one built by `@reliverse/rempts`. Implementing here because it's pretty simple to do and `commander` doesn't seem to provide a way to do it.
|
|
1406
|
-
*
|
|
1407
|
-
* Note: falsy values for strings are replaced with `undefined` in the output - e.g. if there's an empty description, it will be `undefined` in the output.
|
|
1408
|
-
*/
|
|
1409
|
-
declare const commandToJSON: (command: Command$1) => CommandJSON;
|
|
1410
|
-
|
|
1411
|
-
interface TrpcCliParams<R extends AnyRouter> extends Dependencies {
|
|
1412
|
-
/** A tRPC router. Procedures will become CLI commands. */
|
|
1413
|
-
router: R;
|
|
1414
|
-
name?: string;
|
|
1415
|
-
version?: string;
|
|
1416
|
-
description?: string;
|
|
1417
|
-
usage?: string | string[];
|
|
1418
|
-
/** Context to be supplied when invoking the router. */
|
|
1419
|
-
context?: inferRouterContext<R>;
|
|
1420
|
-
/** @deprecated this is actually **removed** not deprecated; use `aliases` on each procedure `meta` instead */
|
|
1421
|
-
alias?: never;
|
|
1422
|
-
/** @deprecated this is actually **removed** not deprecated; set `default: true` on the procedure `meta` instead */
|
|
1423
|
-
_default?: never;
|
|
1424
|
-
/** The `@trpc/server` module to use for calling procedures. Required when using trpc v10. */
|
|
1425
|
-
trpcServer?: TrpcServerModuleLike | Promise<TrpcServerModuleLike>;
|
|
1426
|
-
}
|
|
1427
|
-
/** Rough shape of the `@trpc/server` (v10) module. Needed to pass in to `createRpcCli` when using trpc v10. */
|
|
1428
|
-
interface TrpcServerModuleLike {
|
|
1429
|
-
initTRPC: {
|
|
1430
|
-
create: () => {
|
|
1431
|
-
createCallerFactory: CreateCallerFactoryLike<{}>;
|
|
1432
|
-
};
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
/**
|
|
1436
|
-
* Optional interface for describing procedures via meta - if your router conforms to this meta shape, it will contribute to the CLI help text.
|
|
1437
|
-
*/
|
|
1438
|
-
interface TrpcCliMeta {
|
|
1439
|
-
/** Version of the script displayed in `--help` output. Use to avoid enabling `--version` option. */
|
|
1440
|
-
version?: string;
|
|
1441
|
-
/** Description of the script or command to display in `--help` output. */
|
|
1442
|
-
description?: string;
|
|
1443
|
-
/** Usage code examples to display in `--help` output. */
|
|
1444
|
-
usage?: false | string | string[];
|
|
1445
|
-
/** Example code snippets to display in `--help` output. */
|
|
1446
|
-
examples?: string | string[];
|
|
1447
|
-
/** If true, this command will be run if no command is specified. */
|
|
1448
|
-
default?: boolean;
|
|
1449
|
-
aliases?: {
|
|
1450
|
-
/** Aliases for the command. Note: take care to avoid conflicts with other commands. */
|
|
1451
|
-
command?: string[];
|
|
1452
|
-
/** Aliases for the options. Note: take care to avoid conflicts with other options. An error will be thrown if an alias is defined for a non-existent option. */
|
|
1453
|
-
options?: Record<string, string>;
|
|
1454
|
-
};
|
|
1455
|
-
/** If true, will use a single CLI option expect the entire input to be parsed in as JSON, e.g. `--input '{"foo": "bar"}`. Can be useful to opt out of the default mapping of input schemas to CLI options. */
|
|
1456
|
-
jsonInput?: boolean;
|
|
1457
|
-
/** Sub-property for the CLI meta. If present, will take precedence over the top-level meta, to avoid conflicts with other tools. */
|
|
1458
|
-
cliMeta?: TrpcCliMeta;
|
|
1459
|
-
}
|
|
1460
|
-
interface ParsedProcedure {
|
|
1461
|
-
positionalParameters: {
|
|
1462
|
-
name: string;
|
|
1463
|
-
description: string;
|
|
1464
|
-
type: "string" | "number" | "boolean" | (string & {});
|
|
1465
|
-
required: boolean;
|
|
1466
|
-
array: boolean;
|
|
1467
|
-
}[];
|
|
1468
|
-
/** JSON Schema type describing the flags for the procedure */
|
|
1469
|
-
optionsJsonSchema: JsonSchema7Type;
|
|
1470
|
-
/**
|
|
1471
|
-
* Function for taking parsed argv output and transforming it so it can be passed into the procedure.
|
|
1472
|
-
* Needed because this function is where inspect the input schema(s) and determine how to map the argv to the input
|
|
1473
|
-
*/
|
|
1474
|
-
getPojoInput: (argv: {
|
|
1475
|
-
positionalValues: (string | string[])[];
|
|
1476
|
-
options: Record<string, unknown>;
|
|
1477
|
-
}) => unknown;
|
|
1478
|
-
}
|
|
1479
|
-
type Result<T> = {
|
|
1480
|
-
success: true;
|
|
1481
|
-
value: T;
|
|
1482
|
-
} | {
|
|
1483
|
-
success: false;
|
|
1484
|
-
error: string;
|
|
1485
|
-
};
|
|
1486
|
-
/** A function that logs any inputs. e.g. `console.info` */
|
|
1487
|
-
type Log = (...args: unknown[]) => void;
|
|
1488
|
-
/**
|
|
1489
|
-
* A struct which has `info` and `error` functions for logging. Easiest example: `console`
|
|
1490
|
-
* But most loggers like pino, winston etc. have a similar interface.
|
|
1491
|
-
*/
|
|
1492
|
-
interface Logger {
|
|
1493
|
-
info?: Log;
|
|
1494
|
-
error?: Log;
|
|
1495
|
-
}
|
|
1496
|
-
/**
|
|
1497
|
-
* Slim reconstruction of an `omelette` instance. Hand-written here to avoid a hard dependency on `omelette` or its types.
|
|
1498
|
-
* Usually you will just pass in an `omelette` instance by doing something like
|
|
1499
|
-
*
|
|
1500
|
-
* ```ts
|
|
1501
|
-
* import omelette from 'omelette'
|
|
1502
|
-
* import {createRpcCli} from '@reliverse/rempts'
|
|
1503
|
-
*
|
|
1504
|
-
* const cli = createRpcCli({
|
|
1505
|
-
* router: myRouter,
|
|
1506
|
-
* completion: omelette('myprogram'),
|
|
1507
|
-
* })
|
|
1508
|
-
* ```
|
|
1509
|
-
*
|
|
1510
|
-
* Or it also accepts an async function that resolves to an `omelette` instance, so you can use dynamic import:
|
|
1511
|
-
*
|
|
1512
|
-
* ```ts
|
|
1513
|
-
* import {createRpcCli} from '@reliverse/rempts'
|
|
1514
|
-
*
|
|
1515
|
-
* const cli = await createRpcCli({
|
|
1516
|
-
* router: myRouter,
|
|
1517
|
-
* completion: () => import('omelette').then(omelette => omelette.default('myprogram')),
|
|
1518
|
-
* })
|
|
1519
|
-
* ```
|
|
1520
|
-
*/
|
|
1521
|
-
interface OmeletteInstanceLike {
|
|
1522
|
-
on: (event: "complete", callback: (fragment: string, params: {
|
|
1523
|
-
line: string;
|
|
1524
|
-
fragment: number;
|
|
1525
|
-
reply: (suggestions: string[]) => void;
|
|
1526
|
-
}) => void) => void;
|
|
1527
|
-
init: () => void;
|
|
1528
|
-
setupShellInitFile: () => void;
|
|
1529
|
-
cleanupShellInitFile: () => void;
|
|
1530
|
-
tree: (value: any) => this;
|
|
1531
|
-
}
|
|
1532
|
-
interface InquirerPromptOptions {
|
|
1533
|
-
message: string;
|
|
1534
|
-
required?: boolean;
|
|
1535
|
-
validate?: (input: string) => boolean | string;
|
|
1536
|
-
default?: any;
|
|
1537
|
-
}
|
|
1538
|
-
/** looks like the `@inquirer/prompts` package */
|
|
1539
|
-
interface InquirerPromptsLike {
|
|
1540
|
-
input: (params: InquirerPromptOptions) => Promise<string>;
|
|
1541
|
-
confirm: (params: InquirerPromptOptions) => Promise<boolean>;
|
|
1542
|
-
}
|
|
1543
|
-
/** looks like the `prompts` package */
|
|
1544
|
-
interface PromptsLike {
|
|
1545
|
-
prompt: Function;
|
|
1546
|
-
inject: Function;
|
|
1547
|
-
}
|
|
1548
|
-
/** looks like the `enquirer` package */
|
|
1549
|
-
interface EnquirerLike {
|
|
1550
|
-
prompt: <T>(params: {
|
|
1551
|
-
type: "input";
|
|
1552
|
-
name: string;
|
|
1553
|
-
message: string;
|
|
1554
|
-
validate?: (input: string) => boolean | string;
|
|
1555
|
-
initial?: unknown;
|
|
1556
|
-
}) => Promise<T>;
|
|
1557
|
-
}
|
|
1558
|
-
interface ClackPromptsLike {
|
|
1559
|
-
intro: (title: string) => void;
|
|
1560
|
-
outro: (title: string) => void;
|
|
1561
|
-
}
|
|
1562
|
-
type Promptable = InquirerPromptsLike | EnquirerLike | PromptsLike | Prompter | ClackPromptsLike | ((command: CommanderProgramLike) => Prompter);
|
|
1563
|
-
interface TrpcCliRunParams {
|
|
1564
|
-
argv?: string[];
|
|
1565
|
-
logger?: Logger;
|
|
1566
|
-
completion?: OmeletteInstanceLike | (() => Promise<OmeletteInstanceLike>);
|
|
1567
|
-
prompts?: Promptable;
|
|
1568
|
-
/** Format an error thrown by the root procedure before logging to `logger.error` */
|
|
1569
|
-
formatError?: (error: unknown) => string;
|
|
1570
|
-
process?: {
|
|
1571
|
-
exit: (code: number) => never;
|
|
1572
|
-
};
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Type that looks like a `commander` Command instance, but doesn't require a dependency on `commander` to avoid awkward typescript errors.
|
|
1576
|
-
* If you need to use it as a `Command` instance, just cast it with `as` to `import('commander').Command`.
|
|
1577
|
-
*/
|
|
1578
|
-
interface CommanderProgramLike {
|
|
1579
|
-
name: () => string;
|
|
1580
|
-
parseAsync: (args: string[], options?: {
|
|
1581
|
-
from: "user" | "node" | "electron";
|
|
1582
|
-
}) => Promise<unknown>;
|
|
1583
|
-
helpInformation: () => string;
|
|
1584
|
-
}
|
|
1585
|
-
interface TrpcCli {
|
|
1586
|
-
/** run the CLI - gets args from `process.argv` by default */
|
|
1587
|
-
run: (params?: TrpcCliRunParams, program?: CommanderProgramLike) => Promise<void>;
|
|
1588
|
-
/**
|
|
1589
|
-
* Build a `Commander` program from the CLI - you can use this to manually customise the program before passing it to `.run(...)`.
|
|
1590
|
-
* Note that you will need to cast the return value to `import('commander').Command` to use it as a `Command` instance.
|
|
1591
|
-
*/
|
|
1592
|
-
buildProgram: (params?: TrpcCliRunParams) => CommanderProgramLike;
|
|
1593
|
-
/**
|
|
1594
|
-
* @experimental
|
|
1595
|
-
* Get a JSON representation of the CLI - useful for generating documentation etc. This function returns basic information about the CLI
|
|
1596
|
-
* and each command - to get any extra details you will need to use the `buildProgram` function and walk the tree of commands yourself.
|
|
1597
|
-
*/
|
|
1598
|
-
toJSON: (program?: CommanderProgramLike) => CommandJSON;
|
|
1599
|
-
}
|
|
1600
|
-
interface Dependencies {
|
|
1601
|
-
"@valibot/to-json-schema"?: {
|
|
1602
|
-
toJsonSchema: (input: unknown, options?: {
|
|
1603
|
-
errorMode?: "throw" | "ignore" | "warn";
|
|
1604
|
-
}) => JSONSchema7;
|
|
1605
|
-
};
|
|
1606
|
-
effect?: {
|
|
1607
|
-
Schema: {
|
|
1608
|
-
isSchema: (input: unknown) => input is "JSONSchemaMakeable";
|
|
1609
|
-
};
|
|
1610
|
-
JSONSchema: {
|
|
1611
|
-
make: (input: "JSONSchemaMakeable") => JSONSchema7;
|
|
1612
|
-
};
|
|
1613
|
-
};
|
|
1614
|
-
}
|
|
1615
|
-
interface PromptContext {
|
|
1616
|
-
input?: NodeJS.ReadableStream;
|
|
1617
|
-
output?: NodeJS.WritableStream;
|
|
1618
|
-
clearPromptOnDone?: boolean;
|
|
1619
|
-
signal?: AbortSignal;
|
|
1620
|
-
/** The command that is being prompted for. Cast this to a `commander.Command` to access the command's name, description, options etc. */
|
|
1621
|
-
command: {
|
|
1622
|
-
name: () => string;
|
|
1623
|
-
};
|
|
1624
|
-
/** The original inputs the user provided - if they passed some but not all arguments/options, this will contain the values they did pass. */
|
|
1625
|
-
inputs: {
|
|
1626
|
-
argv: string[];
|
|
1627
|
-
arguments: {
|
|
1628
|
-
name: string;
|
|
1629
|
-
specified: boolean;
|
|
1630
|
-
value: unknown;
|
|
1631
|
-
}[];
|
|
1632
|
-
options: {
|
|
1633
|
-
name: string;
|
|
1634
|
-
specified: boolean;
|
|
1635
|
-
value: unknown;
|
|
1636
|
-
}[];
|
|
1637
|
-
};
|
|
1638
|
-
/** If set, this is the argument that is being prompted for. Cast to a `commander.Argument`. */
|
|
1639
|
-
argument?: {
|
|
1640
|
-
name: () => string;
|
|
1641
|
-
};
|
|
1642
|
-
/** If set, this is the option that is being prompted for. Cast to a `commander.Option`. */
|
|
1643
|
-
option?: {
|
|
1644
|
-
name: () => string;
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
interface Prompter {
|
|
1648
|
-
setup?: (context: PromptContext) => Promise<void>;
|
|
1649
|
-
teardown?: (context: PromptContext) => Promise<void>;
|
|
1650
|
-
input: (params: {
|
|
1651
|
-
message: string;
|
|
1652
|
-
validate?: (input: string) => boolean | string;
|
|
1653
|
-
required?: boolean;
|
|
1654
|
-
default?: string;
|
|
1655
|
-
}, context: PromptContext) => Promise<string>;
|
|
1656
|
-
select: (params: {
|
|
1657
|
-
message: string;
|
|
1658
|
-
choices: string[] | {
|
|
1659
|
-
name: string;
|
|
1660
|
-
value: string;
|
|
1661
|
-
description?: string;
|
|
1662
|
-
}[];
|
|
1663
|
-
required?: boolean;
|
|
1664
|
-
default?: string;
|
|
1665
|
-
validate?: (input: string) => boolean | string;
|
|
1666
|
-
}, context: PromptContext) => Promise<string>;
|
|
1667
|
-
confirm: (params: {
|
|
1668
|
-
message: string;
|
|
1669
|
-
default?: boolean;
|
|
1670
|
-
validate?: (input: string) => boolean | string;
|
|
1671
|
-
}, context: PromptContext) => Promise<boolean>;
|
|
1672
|
-
checkbox: (params: {
|
|
1673
|
-
message: string;
|
|
1674
|
-
choices: {
|
|
1675
|
-
name: string;
|
|
1676
|
-
value: string;
|
|
1677
|
-
checked?: boolean;
|
|
1678
|
-
}[];
|
|
1679
|
-
required?: boolean;
|
|
1680
|
-
default?: string[];
|
|
1681
|
-
}, context: PromptContext) => Promise<string[]>;
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
1286
|
/**
|
|
1685
1287
|
* Defines a command with metadata, argument definitions,
|
|
1686
1288
|
* an execution function, and (optional) subCommands.
|
|
@@ -1709,7 +1311,6 @@ declare function showUsage<A extends ArgDefinitions>(command: Command<A>, parser
|
|
|
1709
1311
|
* - File-based Commands: scanning for commands within a given commands root.
|
|
1710
1312
|
* - Commands defined within the command object.
|
|
1711
1313
|
* - Standard flags like --help, --version, and --debug.
|
|
1712
|
-
* - RPC functionality: tRPC/oRPC router integration with automatic CLI generation.
|
|
1713
1314
|
*
|
|
1714
1315
|
* This function passes along remaining arguments to command runners to ensure
|
|
1715
1316
|
* consistent parsing.
|
|
@@ -1732,41 +1333,6 @@ declare function createCli<A extends ArgDefinitions = EmptyArgs>(options: Comman
|
|
|
1732
1333
|
onCmdExit?: Command<A>["onCmdExit"];
|
|
1733
1334
|
onLauncherInit?: Command<A>["onLauncherInit"];
|
|
1734
1335
|
onLauncherExit?: Command<A>["onLauncherExit"];
|
|
1735
|
-
rpc?: {
|
|
1736
|
-
/** A tRPC router. Procedures will become CLI commands. */
|
|
1737
|
-
router: AnyRouter;
|
|
1738
|
-
/** Context to be supplied when invoking the router. */
|
|
1739
|
-
context?: any;
|
|
1740
|
-
/** The `@trpc/server` module to use for calling procedures. Required when using trpc v10. */
|
|
1741
|
-
trpcServer?: any | Promise<any>;
|
|
1742
|
-
/** Usage code examples to display in `--help` output. */
|
|
1743
|
-
usage?: string | string[];
|
|
1744
|
-
/** Dependencies for schema validation libraries */
|
|
1745
|
-
"@valibot/to-json-schema"?: {
|
|
1746
|
-
toJsonSchema: (input: unknown, options?: {
|
|
1747
|
-
errorMode?: "throw" | "ignore" | "warn";
|
|
1748
|
-
}) => any;
|
|
1749
|
-
};
|
|
1750
|
-
effect?: {
|
|
1751
|
-
Schema: {
|
|
1752
|
-
isSchema: (input: unknown) => input is "JSONSchemaMakeable";
|
|
1753
|
-
};
|
|
1754
|
-
JSONSchema: {
|
|
1755
|
-
make: (input: "JSONSchemaMakeable") => any;
|
|
1756
|
-
};
|
|
1757
|
-
};
|
|
1758
|
-
};
|
|
1759
|
-
rpcRunParams?: {
|
|
1760
|
-
argv?: string[];
|
|
1761
|
-
logger?: Logger;
|
|
1762
|
-
completion?: OmeletteInstanceLike | (() => Promise<OmeletteInstanceLike>);
|
|
1763
|
-
prompts?: Promptable;
|
|
1764
|
-
/** Format an error thrown by the root procedure before logging to `logger.error` */
|
|
1765
|
-
formatError?: (error: unknown) => string;
|
|
1766
|
-
process?: {
|
|
1767
|
-
exit: (code: number) => never;
|
|
1768
|
-
};
|
|
1769
|
-
};
|
|
1770
1336
|
}, legacyParserOptions?: ReliArgParserOptions & {
|
|
1771
1337
|
fileBased?: FileBasedOptions;
|
|
1772
1338
|
autoExit?: boolean;
|
|
@@ -1784,117 +1350,6 @@ declare function defineArgs<A extends ArgDefinitions>(args: A): A;
|
|
|
1784
1350
|
|
|
1785
1351
|
declare const runMain: typeof createCli;
|
|
1786
1352
|
|
|
1787
|
-
/** uses omelette to add completions to a commander program */
|
|
1788
|
-
declare function addCompletions(program: Command$1, completion: OmeletteInstanceLike): void;
|
|
1789
|
-
|
|
1790
|
-
/** An error thrown when the trpc procedure results in a bad request */
|
|
1791
|
-
declare class CliValidationError extends Error {
|
|
1792
|
-
}
|
|
1793
|
-
/** An error which is only thrown when a custom \`process\` parameter is used. Under normal circumstances, this should not be used, even internally. */
|
|
1794
|
-
declare class FailedToExitError extends Error {
|
|
1795
|
-
readonly exitCode: number;
|
|
1796
|
-
constructor(message: string, { exitCode, cause }: {
|
|
1797
|
-
exitCode: number;
|
|
1798
|
-
cause: unknown;
|
|
1799
|
-
});
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
declare class TrpcCommand extends Command$1 {
|
|
1803
|
-
/** @internal track the commands that have been run, so that we can find the `__result` of the last command */
|
|
1804
|
-
__ran: TrpcCommand[];
|
|
1805
|
-
__input?: unknown;
|
|
1806
|
-
/** @internal stash the return value of the underlying procedure on the command so to pass to `FailedToExitError` for use in a pinch */
|
|
1807
|
-
__result?: unknown;
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* @internal takes a trpc router and returns an object that you **could** use to build a CLI, or UI, or a bunch of other things with.
|
|
1811
|
-
* Officially, just internal for building a CLI. GLHF.
|
|
1812
|
-
*/
|
|
1813
|
-
declare const parseRouter: <R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>) => [string, ProcedureInfo][];
|
|
1814
|
-
interface ProcedureInfo {
|
|
1815
|
-
meta: TrpcCliMeta;
|
|
1816
|
-
parsedProcedure: ParsedProcedure;
|
|
1817
|
-
incompatiblePairs: [string, string][];
|
|
1818
|
-
procedure: {};
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Run a trpc router as a CLI.
|
|
1822
|
-
*
|
|
1823
|
-
* @param router A trpc router
|
|
1824
|
-
* @param context The context to use when calling the procedures - needed if your router requires a context
|
|
1825
|
-
* @param trpcServer The trpc server module to use. Only needed if using trpc v10.
|
|
1826
|
-
* @returns A CLI object with a `run` method that can be called to run the CLI. The `run` method will parse the command line arguments, call the appropriate trpc procedure, log the result and exit the process. On error, it will log the error and exit with a non-zero exit code.
|
|
1827
|
-
*/
|
|
1828
|
-
declare function createRpcCli<R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>): TrpcCli;
|
|
1829
|
-
|
|
1830
|
-
declare const flattenedProperties: (sch: JsonSchema7Type) => JsonSchema7ObjectType["properties"];
|
|
1831
|
-
/** For a union type, returns a list of pairs of properties which *shouldn't* be used together (because they don't appear in the same type variant) */
|
|
1832
|
-
declare const incompatiblePropertyPairs: (sch: JsonSchema7Type) => [string, string][];
|
|
1833
|
-
/**
|
|
1834
|
-
* Tries fairly hard to build a roughly human-readable description of a json-schema type.
|
|
1835
|
-
* A few common properties are given special treatment, most others are just stringified and output in `key: value` format.
|
|
1836
|
-
*/
|
|
1837
|
-
declare const getDescription: (v: JsonSchema7Type, depth?: number) => string;
|
|
1838
|
-
declare const getSchemaTypes: (propertyValue: JsonSchema7Type) => ("string" | "boolean" | "number" | (string & {}))[];
|
|
1839
|
-
declare const getEnumChoices: (propertyValue: JsonSchema7Type) => {
|
|
1840
|
-
readonly type: "string_enum";
|
|
1841
|
-
readonly choices: string[];
|
|
1842
|
-
} | {
|
|
1843
|
-
readonly type: "number_enum";
|
|
1844
|
-
readonly choices: number[];
|
|
1845
|
-
} | null;
|
|
1846
|
-
|
|
1847
|
-
declare const lineByLineLogger: (logger: Logger) => Logger;
|
|
1848
|
-
/**
|
|
1849
|
-
* A logger which uses `console.log` and `console.error` to log in the following way:
|
|
1850
|
-
* - Primitives are logged directly
|
|
1851
|
-
* - Arrays are logged item-by-item
|
|
1852
|
-
* - Objects are logged as JSON
|
|
1853
|
-
*
|
|
1854
|
-
* This is useful for logging structured data in a human-readable way, and for piping logs to other tools.
|
|
1855
|
-
*/
|
|
1856
|
-
declare const lineByLineConsoleLogger: Logger;
|
|
1857
|
-
|
|
1858
|
-
declare function parseProcedureInputs(inputs: unknown[], dependencies: Dependencies): Result<ParsedProcedure>;
|
|
1859
|
-
|
|
1860
|
-
interface Shadowed<T> {
|
|
1861
|
-
original: T;
|
|
1862
|
-
shadow: T;
|
|
1863
|
-
}
|
|
1864
|
-
type WithValue<T> = Shadowed<T> & {
|
|
1865
|
-
value: string | undefined;
|
|
1866
|
-
specified: boolean;
|
|
1867
|
-
};
|
|
1868
|
-
interface Analysis {
|
|
1869
|
-
command: Shadowed<Command$1>;
|
|
1870
|
-
arguments: WithValue<Argument>[];
|
|
1871
|
-
options: WithValue<Option>[];
|
|
1872
|
-
}
|
|
1873
|
-
declare const createShadowCommand: (command: Command$1, onAnalyze: (params: Analysis) => void | Promise<void>) => Command$1;
|
|
1874
|
-
declare const promptify: (program: CommanderProgramLike, prompts: Promptable) => CommanderProgramLike;
|
|
1875
|
-
|
|
1876
|
-
declare const prettifyStandardSchemaError: (error: unknown) => string | null;
|
|
1877
|
-
declare function toDotPath(path: (string | number | symbol)[]): string;
|
|
1878
|
-
declare class StandardSchemaV1Error extends Error implements StandardSchemaV1FailureResult {
|
|
1879
|
-
issues: StandardSchemaV1FailureResult["issues"];
|
|
1880
|
-
constructor(failure: StandardSchemaV1FailureResult, options?: {
|
|
1881
|
-
cause?: Error;
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
declare const looksLikeStandardSchemaFailure: (error: unknown) => error is StandardSchemaV1FailureResult;
|
|
1886
|
-
declare const looksLikeStandardSchema: (thing: unknown) => thing is StandardSchemaV1;
|
|
1887
|
-
|
|
1888
|
-
/**
|
|
1889
|
-
* Pretty much like the `instanceof` operator, but should work across different realms. Necessary for zod because some installations
|
|
1890
|
-
* might result in this library using the commonjs zod export, while the user's code uses the esm export.
|
|
1891
|
-
* https://github.com/mmkal/trpc-cli/issues/7
|
|
1892
|
-
*
|
|
1893
|
-
* Tradeoff: It's possible that this function will return false positives if the target class has the same name as an unrelated class in the current realm.
|
|
1894
|
-
* So, only use it for classes that are unlikely to have name conflicts like `ZodAbc` or `TRPCDef`.
|
|
1895
|
-
*/
|
|
1896
|
-
declare const looksLikeInstanceof: <T>(value: unknown, target: string | (new (...args: any[]) => T)) => value is T;
|
|
1897
|
-
|
|
1898
1353
|
declare const log: _reliverse_relinka.RelinkaFunction;
|
|
1899
1354
|
|
|
1900
1355
|
/**
|
|
@@ -2294,5 +1749,5 @@ declare function createAsciiArt({ message, font, clearConsole, }: {
|
|
|
2294
1749
|
clearConsole?: boolean;
|
|
2295
1750
|
}): Promise<void>;
|
|
2296
1751
|
|
|
2297
|
-
export { CANCEL,
|
|
2298
|
-
export type { AllKinds,
|
|
1752
|
+
export { CANCEL, animateText, animationMap, anykeyPrompt, applyVariant, bar, block, breakLines, callCmd, cancel, colorMap, colorize, completePrompt, confirm, confirmPrompt, countLines, createAsciiArt, createCancel, createCli, createMultiStep, createStep, datePrompt, defineArgs, defineCommand, deleteLastLine, deleteLastLines, endPrompt, errorHandler, fallbackSymbols, figures, fmt, getColumns, getExactTerminalWidth, getTerminalHeight, getTerminalWidth, group, input, inputPrompt, intro, introPrompt, isCancel, isTerminalInteractive, isValidName, isValidVariant, isWindows, log, mainSymbols, msg, msgUndo, msgUndoAll, multiselect, multiselectPrompt, nextStepsPrompt, normalizeName, numMultiSelectPrompt, numSelectPrompt, numberPrompt, outro, outroPrompt, password, pm, preventUnsupportedTTY, preventWindowsHomeDirRoot, preventWrongTerminalSize, printLineBar, relinkaAsyncByRemptsDeprecated, relinkaByRemptsDeprecated, reliversePrompts, removeCursor, renderEndLine, renderEndLineInput, restoreCursor, resultPrompt, runMain, select, selectPrompt, selectSimple, setRawMode, showUsage, spinner, startEditor, startPrompt, streamText, streamTextBox, streamTextWithSpinner, symbols, taskProgressPrompt, taskSpinPrompt, text, throwError, toBaseColor, toSolidColor, togglePrompt, typographyMap, useSpinner, variantMap };
|
|
1753
|
+
export type { AllKinds, ArgDefinition, ArgDefinitions, ArrayArgDefinition, BaseArgDefinition, BaseArgProps, BooleanArgDefinition, BorderColorName, CallCmdOptions, CancelValue, ChoiceOptions, ColorName, Command, CommandContext, CommandHook, CommandMeta, CommandRun, CommandSpec, CommandsMap, ConfirmPromptOptions, DatePromptOptions, DefineCommandOptions, EditorExitResult, EmptyArgs, FileBasedOptions, FmtMsgOptions, GroupContext, GroupOptions, GroupStep, GroupSteps, InferArgTypes, InputPromptOptions, MessageConfig, MessageKind, MsgConfig, MsgType, MultiselectPromptParams, NumberArgDefinition, OutputColor, PositionalArgDefinition, PreventWrongTerminalSizeOptions, ProgressBar, ProgressBarOptions, PromptOptions, PromptType, RenderParams, ResultsType, SelectOption, SelectPromptParams, SeparatorOption, StandardColor, StreamOptions, StreamTextOptions, StringArgDefinition, SymbolName, Symbols, TogglePromptParams, TypographyName, VariantName$1 as VariantName };
|