@reliverse/rempts 1.7.49 → 1.7.51
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 +117 -697
- package/dist-npm/bin/mod.mjs +767 -2453
- package/package.json +7 -45
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,169 +1014,110 @@ 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 {
|
|
1153
1082
|
description?: string;
|
|
1154
1083
|
required?: boolean;
|
|
1155
|
-
allowed?: string[];
|
|
1084
|
+
allowed?: readonly string[];
|
|
1156
1085
|
}
|
|
1157
1086
|
interface BaseArgDefinition {
|
|
1158
1087
|
type: string;
|
|
1159
1088
|
description?: string;
|
|
1160
1089
|
required?: boolean;
|
|
1161
1090
|
default?: any;
|
|
1162
|
-
allowed?: any[];
|
|
1091
|
+
allowed?: readonly any[];
|
|
1163
1092
|
dependencies?: string[];
|
|
1164
1093
|
}
|
|
1165
1094
|
type PositionalArgDefinition = BaseArgDefinition & {
|
|
1166
1095
|
type: "positional";
|
|
1167
1096
|
default?: string;
|
|
1097
|
+
allowed?: readonly string[];
|
|
1168
1098
|
};
|
|
1169
1099
|
type BooleanArgDefinition = BaseArgDefinition & {
|
|
1170
1100
|
type: "boolean";
|
|
1171
1101
|
default?: boolean;
|
|
1172
|
-
allowed?: boolean[];
|
|
1102
|
+
allowed?: readonly boolean[];
|
|
1173
1103
|
alias?: string;
|
|
1174
1104
|
};
|
|
1175
1105
|
type StringArgDefinition = BaseArgDefinition & {
|
|
1176
1106
|
type: "string";
|
|
1177
1107
|
default?: string;
|
|
1108
|
+
allowed?: readonly string[];
|
|
1178
1109
|
alias?: string;
|
|
1179
1110
|
};
|
|
1180
1111
|
type NumberArgDefinition = BaseArgDefinition & {
|
|
1181
1112
|
type: "number";
|
|
1182
1113
|
default?: number;
|
|
1183
|
-
allowed?: number[];
|
|
1114
|
+
allowed?: readonly number[];
|
|
1184
1115
|
alias?: string;
|
|
1185
1116
|
};
|
|
1186
1117
|
type ArrayArgDefinition = BaseArgDefinition & {
|
|
1187
1118
|
type: "array";
|
|
1188
1119
|
default?: string | readonly string[];
|
|
1120
|
+
allowed?: readonly string[];
|
|
1189
1121
|
alias?: string;
|
|
1190
1122
|
};
|
|
1191
1123
|
type ArgDefinition = PositionalArgDefinition | BooleanArgDefinition | StringArgDefinition | NumberArgDefinition | ArrayArgDefinition;
|
|
@@ -1249,11 +1181,6 @@ interface DefineCommandOptions<A extends ArgDefinitions = EmptyArgs> {
|
|
|
1249
1181
|
* Called once per CLI process, after all command/run() logic is finished
|
|
1250
1182
|
*/
|
|
1251
1183
|
onLauncherExit?: () => void | Promise<void>;
|
|
1252
|
-
/**
|
|
1253
|
-
* tRPC/oRPC router for RPC mode. When provided, the command will automatically
|
|
1254
|
-
* switch to RPC mode and use the router's procedures as CLI commands.
|
|
1255
|
-
*/
|
|
1256
|
-
router?: AnyRouter;
|
|
1257
1184
|
}
|
|
1258
1185
|
interface Command<A extends ArgDefinitions = EmptyArgs> {
|
|
1259
1186
|
meta?: CommandMeta;
|
|
@@ -1291,372 +1218,70 @@ interface Command<A extends ArgDefinitions = EmptyArgs> {
|
|
|
1291
1218
|
* Called once per CLI process, after all command/run() logic is finished
|
|
1292
1219
|
*/
|
|
1293
1220
|
onLauncherExit?: () => void | Promise<void>;
|
|
1294
|
-
/**
|
|
1295
|
-
* tRPC/oRPC router for RPC mode. When provided, the command will automatically
|
|
1296
|
-
* switch to RPC mode and use the router's procedures as CLI commands.
|
|
1297
|
-
*/
|
|
1298
|
-
router?: AnyRouter;
|
|
1299
1221
|
}
|
|
1222
|
+
type ExtractAllowed<T extends ArgDefinition> = T extends {
|
|
1223
|
+
type: "positional";
|
|
1224
|
+
allowed: readonly (infer U)[];
|
|
1225
|
+
} ? U : T extends {
|
|
1226
|
+
type: "positional";
|
|
1227
|
+
} ? string : T extends {
|
|
1228
|
+
type: "boolean";
|
|
1229
|
+
allowed: readonly (infer U)[];
|
|
1230
|
+
} ? U : T extends {
|
|
1231
|
+
type: "boolean";
|
|
1232
|
+
} ? boolean : T extends {
|
|
1233
|
+
type: "string";
|
|
1234
|
+
allowed: readonly (infer U)[];
|
|
1235
|
+
} ? U : T extends {
|
|
1236
|
+
type: "string";
|
|
1237
|
+
} ? string : T extends {
|
|
1238
|
+
type: "number";
|
|
1239
|
+
allowed: readonly (infer U)[];
|
|
1240
|
+
} ? U : T extends {
|
|
1241
|
+
type: "number";
|
|
1242
|
+
} ? number : T extends {
|
|
1243
|
+
type: "array";
|
|
1244
|
+
allowed: readonly (infer U)[];
|
|
1245
|
+
} ? U[] : T extends {
|
|
1246
|
+
type: "array";
|
|
1247
|
+
} ? string[] : never;
|
|
1300
1248
|
type InferArgTypes<A extends ArgDefinitions> = {
|
|
1301
|
-
[K in keyof A]: A[K]
|
|
1302
|
-
type: "array";
|
|
1303
|
-
} ? string[] : never;
|
|
1249
|
+
[K in keyof A]: ExtractAllowed<A[K]>;
|
|
1304
1250
|
};
|
|
1305
1251
|
interface FileBasedOptions {
|
|
1306
1252
|
enable: boolean;
|
|
1307
1253
|
cmdsRootPath: string;
|
|
1308
1254
|
}
|
|
1309
1255
|
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
* const cmd = await loadCommand("./web/cmd");
|
|
1320
|
-
*
|
|
1321
|
-
* // Use with runCmd - pass args as separate array elements
|
|
1322
|
-
* await runCmd(cmd, ["--dev", "true"]); // ✅ Correct
|
|
1323
|
-
* await runCmd(cmd, [`--dev ${isDev}`]); // ❌ Wrong - creates single string
|
|
1324
|
-
* ```
|
|
1325
|
-
*/
|
|
1326
|
-
declare function loadCommand(cmdPath: string): Promise<Command>;
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* Static implementation functions for the typed command system.
|
|
1330
|
-
* These functions are imported by the generated cmds.ts file.
|
|
1331
|
-
*/
|
|
1332
|
-
declare function argsToStringArray(args: Record<string, unknown>): string[];
|
|
1333
|
-
declare function createCallCmd<TCommandArgsMap>(): Promise<(<T extends keyof TCommandArgsMap>(cmdName: T, args?: TCommandArgsMap[T]) => Promise<void>)>;
|
|
1334
|
-
declare function createGetTypedCmd<TCommandArgsMap>(): Promise<(<T extends keyof TCommandArgsMap>(cmdName: T) => Promise<{
|
|
1335
|
-
command: Command;
|
|
1336
|
-
run: (args?: TCommandArgsMap[T]) => Promise<void>;
|
|
1337
|
-
}>)>;
|
|
1338
|
-
declare function callCmdImpl<TCommandArgsMap>(cmdName: keyof TCommandArgsMap, args?: TCommandArgsMap[keyof TCommandArgsMap]): Promise<void>;
|
|
1339
|
-
declare function getTypedCmdImpl<TCommandArgsMap>(cmdName: keyof TCommandArgsMap): Promise<{
|
|
1340
|
-
command: Command;
|
|
1341
|
-
run: (args?: TCommandArgsMap[keyof TCommandArgsMap]) => Promise<void>;
|
|
1342
|
-
}>;
|
|
1343
|
-
|
|
1344
|
-
/**
|
|
1345
|
-
* JSON representation of a commander `Command` instance
|
|
1346
|
-
* 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.
|
|
1347
|
-
*/
|
|
1348
|
-
interface CommandJSON {
|
|
1349
|
-
name?: string;
|
|
1350
|
-
version?: string;
|
|
1351
|
-
description?: string;
|
|
1352
|
-
usage?: string;
|
|
1353
|
-
commands?: CommandJSON[];
|
|
1354
|
-
arguments?: {
|
|
1355
|
-
name: string;
|
|
1356
|
-
description?: string;
|
|
1357
|
-
required: boolean;
|
|
1358
|
-
defaultValue?: {};
|
|
1359
|
-
defaultValueDescription?: string;
|
|
1360
|
-
variadic: boolean;
|
|
1361
|
-
choices?: string[];
|
|
1362
|
-
}[];
|
|
1363
|
-
options?: {
|
|
1364
|
-
name: string;
|
|
1365
|
-
description?: string;
|
|
1366
|
-
required: boolean;
|
|
1367
|
-
defaultValue?: {};
|
|
1368
|
-
defaultValueDescription?: string;
|
|
1369
|
-
variadic: boolean;
|
|
1370
|
-
attributeName?: string;
|
|
1371
|
-
flags?: string;
|
|
1372
|
-
short?: string;
|
|
1373
|
-
negate: boolean;
|
|
1374
|
-
optional: boolean;
|
|
1375
|
-
choices?: string[];
|
|
1376
|
-
}[];
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Convert a commander `Command` instance to a JSON object.
|
|
1380
|
-
*
|
|
1381
|
-
* Note: in theory you could use this with any `Command` instance, it doesn't have
|
|
1382
|
-
* 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.
|
|
1383
|
-
*
|
|
1384
|
-
* 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.
|
|
1385
|
-
*/
|
|
1386
|
-
declare const commandToJSON: (command: Command$1) => CommandJSON;
|
|
1387
|
-
|
|
1388
|
-
interface TrpcCliParams<R extends AnyRouter> extends Dependencies {
|
|
1389
|
-
/** A tRPC router. Procedures will become CLI commands. */
|
|
1390
|
-
router: R;
|
|
1391
|
-
name?: string;
|
|
1392
|
-
version?: string;
|
|
1393
|
-
description?: string;
|
|
1394
|
-
usage?: string | string[];
|
|
1395
|
-
/** Context to be supplied when invoking the router. */
|
|
1396
|
-
context?: inferRouterContext<R>;
|
|
1397
|
-
/** @deprecated this is actually **removed** not deprecated; use `aliases` on each procedure `meta` instead */
|
|
1398
|
-
alias?: never;
|
|
1399
|
-
/** @deprecated this is actually **removed** not deprecated; set `default: true` on the procedure `meta` instead */
|
|
1400
|
-
_default?: never;
|
|
1401
|
-
/** The `@trpc/server` module to use for calling procedures. Required when using trpc v10. */
|
|
1402
|
-
trpcServer?: TrpcServerModuleLike | Promise<TrpcServerModuleLike>;
|
|
1403
|
-
}
|
|
1404
|
-
/** Rough shape of the `@trpc/server` (v10) module. Needed to pass in to `createRpcCli` when using trpc v10. */
|
|
1405
|
-
interface TrpcServerModuleLike {
|
|
1406
|
-
initTRPC: {
|
|
1407
|
-
create: () => {
|
|
1408
|
-
createCallerFactory: CreateCallerFactoryLike<{}>;
|
|
1409
|
-
};
|
|
1410
|
-
};
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Optional interface for describing procedures via meta - if your router conforms to this meta shape, it will contribute to the CLI help text.
|
|
1414
|
-
*/
|
|
1415
|
-
interface TrpcCliMeta {
|
|
1416
|
-
/** Version of the script displayed in `--help` output. Use to avoid enabling `--version` option. */
|
|
1417
|
-
version?: string;
|
|
1418
|
-
/** Description of the script or command to display in `--help` output. */
|
|
1419
|
-
description?: string;
|
|
1420
|
-
/** Usage code examples to display in `--help` output. */
|
|
1421
|
-
usage?: false | string | string[];
|
|
1422
|
-
/** Example code snippets to display in `--help` output. */
|
|
1423
|
-
examples?: string | string[];
|
|
1424
|
-
/** If true, this command will be run if no command is specified. */
|
|
1425
|
-
default?: boolean;
|
|
1426
|
-
aliases?: {
|
|
1427
|
-
/** Aliases for the command. Note: take care to avoid conflicts with other commands. */
|
|
1428
|
-
command?: string[];
|
|
1429
|
-
/** 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. */
|
|
1430
|
-
options?: Record<string, string>;
|
|
1431
|
-
};
|
|
1432
|
-
/** 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. */
|
|
1433
|
-
jsonInput?: boolean;
|
|
1434
|
-
/** Sub-property for the CLI meta. If present, will take precedence over the top-level meta, to avoid conflicts with other tools. */
|
|
1435
|
-
cliMeta?: TrpcCliMeta;
|
|
1436
|
-
}
|
|
1437
|
-
interface ParsedProcedure {
|
|
1438
|
-
positionalParameters: {
|
|
1439
|
-
name: string;
|
|
1440
|
-
description: string;
|
|
1441
|
-
type: "string" | "number" | "boolean" | (string & {});
|
|
1442
|
-
required: boolean;
|
|
1443
|
-
array: boolean;
|
|
1444
|
-
}[];
|
|
1445
|
-
/** JSON Schema type describing the flags for the procedure */
|
|
1446
|
-
optionsJsonSchema: JsonSchema7Type;
|
|
1447
|
-
/**
|
|
1448
|
-
* Function for taking parsed argv output and transforming it so it can be passed into the procedure.
|
|
1449
|
-
* Needed because this function is where inspect the input schema(s) and determine how to map the argv to the input
|
|
1450
|
-
*/
|
|
1451
|
-
getPojoInput: (argv: {
|
|
1452
|
-
positionalValues: (string | string[])[];
|
|
1453
|
-
options: Record<string, unknown>;
|
|
1454
|
-
}) => unknown;
|
|
1455
|
-
}
|
|
1456
|
-
type Result<T> = {
|
|
1457
|
-
success: true;
|
|
1458
|
-
value: T;
|
|
1459
|
-
} | {
|
|
1460
|
-
success: false;
|
|
1461
|
-
error: string;
|
|
1462
|
-
};
|
|
1463
|
-
/** A function that logs any inputs. e.g. `console.info` */
|
|
1464
|
-
type Log = (...args: unknown[]) => void;
|
|
1465
|
-
/**
|
|
1466
|
-
* A struct which has `info` and `error` functions for logging. Easiest example: `console`
|
|
1467
|
-
* But most loggers like pino, winston etc. have a similar interface.
|
|
1468
|
-
*/
|
|
1469
|
-
interface Logger {
|
|
1470
|
-
info?: Log;
|
|
1471
|
-
error?: Log;
|
|
1256
|
+
interface CallCmdOptions {
|
|
1257
|
+
/** Whether to automatically exit process on errors (default: false for programmatic usage) */
|
|
1258
|
+
autoExit?: boolean;
|
|
1259
|
+
/** Whether to show debug output */
|
|
1260
|
+
debug?: boolean;
|
|
1261
|
+
/** Whether to call lifecycle hooks (onCmdInit/onCmdExit) */
|
|
1262
|
+
useLifecycleHooks?: boolean;
|
|
1263
|
+
/** Custom parser options for argv processing */
|
|
1264
|
+
parserOptions?: ReliArgParserOptions;
|
|
1472
1265
|
}
|
|
1473
1266
|
/**
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
* ```ts
|
|
1478
|
-
* import omelette from 'omelette'
|
|
1479
|
-
* import {createRpcCli} from '@reliverse/rempts'
|
|
1267
|
+
* Programmatically call a defineCommand command with arguments.
|
|
1268
|
+
* Fully compatible with launcher-mod.ts execution logic.
|
|
1480
1269
|
*
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
* ```
|
|
1486
|
-
*
|
|
1487
|
-
* Or it also accepts an async function that resolves to an `omelette` instance, so you can use dynamic import:
|
|
1270
|
+
* @param command - The command definition created with defineCommand()
|
|
1271
|
+
* @param input - Either argv array (CLI-style) or args object (programmatic style)
|
|
1272
|
+
* @param options - Optional configuration for execution
|
|
1273
|
+
* @returns Promise resolving to the command context
|
|
1488
1274
|
*
|
|
1275
|
+
* @example
|
|
1489
1276
|
* ```ts
|
|
1490
|
-
*
|
|
1277
|
+
* // CLI-style with argv array
|
|
1278
|
+
* const result = await callCmd(myCommand, ['--flag', 'value', 'positional']);
|
|
1491
1279
|
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
* completion: () => import('omelette').then(omelette => omelette.default('myprogram')),
|
|
1495
|
-
* })
|
|
1280
|
+
* // Programmatic style with object
|
|
1281
|
+
* const result = await callCmd(myCommand, { flag: true, name: 'value' });
|
|
1496
1282
|
* ```
|
|
1497
1283
|
*/
|
|
1498
|
-
|
|
1499
|
-
on: (event: "complete", callback: (fragment: string, params: {
|
|
1500
|
-
line: string;
|
|
1501
|
-
fragment: number;
|
|
1502
|
-
reply: (suggestions: string[]) => void;
|
|
1503
|
-
}) => void) => void;
|
|
1504
|
-
init: () => void;
|
|
1505
|
-
setupShellInitFile: () => void;
|
|
1506
|
-
cleanupShellInitFile: () => void;
|
|
1507
|
-
tree: (value: any) => this;
|
|
1508
|
-
}
|
|
1509
|
-
interface InquirerPromptOptions {
|
|
1510
|
-
message: string;
|
|
1511
|
-
required?: boolean;
|
|
1512
|
-
validate?: (input: string) => boolean | string;
|
|
1513
|
-
default?: any;
|
|
1514
|
-
}
|
|
1515
|
-
/** looks like the `@inquirer/prompts` package */
|
|
1516
|
-
interface InquirerPromptsLike {
|
|
1517
|
-
input: (params: InquirerPromptOptions) => Promise<string>;
|
|
1518
|
-
confirm: (params: InquirerPromptOptions) => Promise<boolean>;
|
|
1519
|
-
}
|
|
1520
|
-
/** looks like the `prompts` package */
|
|
1521
|
-
interface PromptsLike {
|
|
1522
|
-
prompt: Function;
|
|
1523
|
-
inject: Function;
|
|
1524
|
-
}
|
|
1525
|
-
/** looks like the `enquirer` package */
|
|
1526
|
-
interface EnquirerLike {
|
|
1527
|
-
prompt: <T>(params: {
|
|
1528
|
-
type: "input";
|
|
1529
|
-
name: string;
|
|
1530
|
-
message: string;
|
|
1531
|
-
validate?: (input: string) => boolean | string;
|
|
1532
|
-
initial?: unknown;
|
|
1533
|
-
}) => Promise<T>;
|
|
1534
|
-
}
|
|
1535
|
-
interface ClackPromptsLike {
|
|
1536
|
-
intro: (title: string) => void;
|
|
1537
|
-
outro: (title: string) => void;
|
|
1538
|
-
}
|
|
1539
|
-
type Promptable = InquirerPromptsLike | EnquirerLike | PromptsLike | Prompter | ClackPromptsLike | ((command: CommanderProgramLike) => Prompter);
|
|
1540
|
-
interface TrpcCliRunParams {
|
|
1541
|
-
argv?: string[];
|
|
1542
|
-
logger?: Logger;
|
|
1543
|
-
completion?: OmeletteInstanceLike | (() => Promise<OmeletteInstanceLike>);
|
|
1544
|
-
prompts?: Promptable;
|
|
1545
|
-
/** Format an error thrown by the root procedure before logging to `logger.error` */
|
|
1546
|
-
formatError?: (error: unknown) => string;
|
|
1547
|
-
process?: {
|
|
1548
|
-
exit: (code: number) => never;
|
|
1549
|
-
};
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
* Type that looks like a `commander` Command instance, but doesn't require a dependency on `commander` to avoid awkward typescript errors.
|
|
1553
|
-
* If you need to use it as a `Command` instance, just cast it with `as` to `import('commander').Command`.
|
|
1554
|
-
*/
|
|
1555
|
-
interface CommanderProgramLike {
|
|
1556
|
-
name: () => string;
|
|
1557
|
-
parseAsync: (args: string[], options?: {
|
|
1558
|
-
from: "user" | "node" | "electron";
|
|
1559
|
-
}) => Promise<unknown>;
|
|
1560
|
-
helpInformation: () => string;
|
|
1561
|
-
}
|
|
1562
|
-
interface TrpcCli {
|
|
1563
|
-
/** run the CLI - gets args from `process.argv` by default */
|
|
1564
|
-
run: (params?: TrpcCliRunParams, program?: CommanderProgramLike) => Promise<void>;
|
|
1565
|
-
/**
|
|
1566
|
-
* Build a `Commander` program from the CLI - you can use this to manually customise the program before passing it to `.run(...)`.
|
|
1567
|
-
* Note that you will need to cast the return value to `import('commander').Command` to use it as a `Command` instance.
|
|
1568
|
-
*/
|
|
1569
|
-
buildProgram: (params?: TrpcCliRunParams) => CommanderProgramLike;
|
|
1570
|
-
/**
|
|
1571
|
-
* @experimental
|
|
1572
|
-
* Get a JSON representation of the CLI - useful for generating documentation etc. This function returns basic information about the CLI
|
|
1573
|
-
* and each command - to get any extra details you will need to use the `buildProgram` function and walk the tree of commands yourself.
|
|
1574
|
-
*/
|
|
1575
|
-
toJSON: (program?: CommanderProgramLike) => CommandJSON;
|
|
1576
|
-
}
|
|
1577
|
-
interface Dependencies {
|
|
1578
|
-
"@valibot/to-json-schema"?: {
|
|
1579
|
-
toJsonSchema: (input: unknown, options?: {
|
|
1580
|
-
errorMode?: "throw" | "ignore" | "warn";
|
|
1581
|
-
}) => JSONSchema7;
|
|
1582
|
-
};
|
|
1583
|
-
effect?: {
|
|
1584
|
-
Schema: {
|
|
1585
|
-
isSchema: (input: unknown) => input is "JSONSchemaMakeable";
|
|
1586
|
-
};
|
|
1587
|
-
JSONSchema: {
|
|
1588
|
-
make: (input: "JSONSchemaMakeable") => JSONSchema7;
|
|
1589
|
-
};
|
|
1590
|
-
};
|
|
1591
|
-
}
|
|
1592
|
-
interface PromptContext {
|
|
1593
|
-
input?: NodeJS.ReadableStream;
|
|
1594
|
-
output?: NodeJS.WritableStream;
|
|
1595
|
-
clearPromptOnDone?: boolean;
|
|
1596
|
-
signal?: AbortSignal;
|
|
1597
|
-
/** The command that is being prompted for. Cast this to a `commander.Command` to access the command's name, description, options etc. */
|
|
1598
|
-
command: {
|
|
1599
|
-
name: () => string;
|
|
1600
|
-
};
|
|
1601
|
-
/** The original inputs the user provided - if they passed some but not all arguments/options, this will contain the values they did pass. */
|
|
1602
|
-
inputs: {
|
|
1603
|
-
argv: string[];
|
|
1604
|
-
arguments: {
|
|
1605
|
-
name: string;
|
|
1606
|
-
specified: boolean;
|
|
1607
|
-
value: unknown;
|
|
1608
|
-
}[];
|
|
1609
|
-
options: {
|
|
1610
|
-
name: string;
|
|
1611
|
-
specified: boolean;
|
|
1612
|
-
value: unknown;
|
|
1613
|
-
}[];
|
|
1614
|
-
};
|
|
1615
|
-
/** If set, this is the argument that is being prompted for. Cast to a `commander.Argument`. */
|
|
1616
|
-
argument?: {
|
|
1617
|
-
name: () => string;
|
|
1618
|
-
};
|
|
1619
|
-
/** If set, this is the option that is being prompted for. Cast to a `commander.Option`. */
|
|
1620
|
-
option?: {
|
|
1621
|
-
name: () => string;
|
|
1622
|
-
};
|
|
1623
|
-
}
|
|
1624
|
-
interface Prompter {
|
|
1625
|
-
setup?: (context: PromptContext) => Promise<void>;
|
|
1626
|
-
teardown?: (context: PromptContext) => Promise<void>;
|
|
1627
|
-
input: (params: {
|
|
1628
|
-
message: string;
|
|
1629
|
-
validate?: (input: string) => boolean | string;
|
|
1630
|
-
required?: boolean;
|
|
1631
|
-
default?: string;
|
|
1632
|
-
}, context: PromptContext) => Promise<string>;
|
|
1633
|
-
select: (params: {
|
|
1634
|
-
message: string;
|
|
1635
|
-
choices: string[] | {
|
|
1636
|
-
name: string;
|
|
1637
|
-
value: string;
|
|
1638
|
-
description?: string;
|
|
1639
|
-
}[];
|
|
1640
|
-
required?: boolean;
|
|
1641
|
-
default?: string;
|
|
1642
|
-
validate?: (input: string) => boolean | string;
|
|
1643
|
-
}, context: PromptContext) => Promise<string>;
|
|
1644
|
-
confirm: (params: {
|
|
1645
|
-
message: string;
|
|
1646
|
-
default?: boolean;
|
|
1647
|
-
validate?: (input: string) => boolean | string;
|
|
1648
|
-
}, context: PromptContext) => Promise<boolean>;
|
|
1649
|
-
checkbox: (params: {
|
|
1650
|
-
message: string;
|
|
1651
|
-
choices: {
|
|
1652
|
-
name: string;
|
|
1653
|
-
value: string;
|
|
1654
|
-
checked?: boolean;
|
|
1655
|
-
}[];
|
|
1656
|
-
required?: boolean;
|
|
1657
|
-
default?: string[];
|
|
1658
|
-
}, context: PromptContext) => Promise<string[]>;
|
|
1659
|
-
}
|
|
1284
|
+
declare function callCmd<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, input: string[] | Partial<InferArgTypes<A>>, options?: CallCmdOptions): Promise<CommandContext<InferArgTypes<A>>>;
|
|
1660
1285
|
|
|
1661
1286
|
/**
|
|
1662
1287
|
* Defines a command with metadata, argument definitions,
|
|
@@ -1686,7 +1311,6 @@ declare function showUsage<A extends ArgDefinitions>(command: Command<A>, parser
|
|
|
1686
1311
|
* - File-based Commands: scanning for commands within a given commands root.
|
|
1687
1312
|
* - Commands defined within the command object.
|
|
1688
1313
|
* - Standard flags like --help, --version, and --debug.
|
|
1689
|
-
* - RPC functionality: tRPC/oRPC router integration with automatic CLI generation.
|
|
1690
1314
|
*
|
|
1691
1315
|
* This function passes along remaining arguments to command runners to ensure
|
|
1692
1316
|
* consistent parsing.
|
|
@@ -1709,41 +1333,6 @@ declare function createCli<A extends ArgDefinitions = EmptyArgs>(options: Comman
|
|
|
1709
1333
|
onCmdExit?: Command<A>["onCmdExit"];
|
|
1710
1334
|
onLauncherInit?: Command<A>["onLauncherInit"];
|
|
1711
1335
|
onLauncherExit?: Command<A>["onLauncherExit"];
|
|
1712
|
-
rpc?: {
|
|
1713
|
-
/** A tRPC router. Procedures will become CLI commands. */
|
|
1714
|
-
router: AnyRouter;
|
|
1715
|
-
/** Context to be supplied when invoking the router. */
|
|
1716
|
-
context?: any;
|
|
1717
|
-
/** The `@trpc/server` module to use for calling procedures. Required when using trpc v10. */
|
|
1718
|
-
trpcServer?: any | Promise<any>;
|
|
1719
|
-
/** Usage code examples to display in `--help` output. */
|
|
1720
|
-
usage?: string | string[];
|
|
1721
|
-
/** Dependencies for schema validation libraries */
|
|
1722
|
-
"@valibot/to-json-schema"?: {
|
|
1723
|
-
toJsonSchema: (input: unknown, options?: {
|
|
1724
|
-
errorMode?: "throw" | "ignore" | "warn";
|
|
1725
|
-
}) => any;
|
|
1726
|
-
};
|
|
1727
|
-
effect?: {
|
|
1728
|
-
Schema: {
|
|
1729
|
-
isSchema: (input: unknown) => input is "JSONSchemaMakeable";
|
|
1730
|
-
};
|
|
1731
|
-
JSONSchema: {
|
|
1732
|
-
make: (input: "JSONSchemaMakeable") => any;
|
|
1733
|
-
};
|
|
1734
|
-
};
|
|
1735
|
-
};
|
|
1736
|
-
rpcRunParams?: {
|
|
1737
|
-
argv?: string[];
|
|
1738
|
-
logger?: Logger;
|
|
1739
|
-
completion?: OmeletteInstanceLike | (() => Promise<OmeletteInstanceLike>);
|
|
1740
|
-
prompts?: Promptable;
|
|
1741
|
-
/** Format an error thrown by the root procedure before logging to `logger.error` */
|
|
1742
|
-
formatError?: (error: unknown) => string;
|
|
1743
|
-
process?: {
|
|
1744
|
-
exit: (code: number) => never;
|
|
1745
|
-
};
|
|
1746
|
-
};
|
|
1747
1336
|
}, legacyParserOptions?: ReliArgParserOptions & {
|
|
1748
1337
|
fileBased?: FileBasedOptions;
|
|
1749
1338
|
autoExit?: boolean;
|
|
@@ -1758,178 +1347,9 @@ declare function createCli<A extends ArgDefinitions = EmptyArgs>(options: Comman
|
|
|
1758
1347
|
* for IntelliSense and validation for array defaults against options.
|
|
1759
1348
|
*/
|
|
1760
1349
|
declare function defineArgs<A extends ArgDefinitions>(args: A): A;
|
|
1761
|
-
/**
|
|
1762
|
-
* Programmatically run a command with subcommand support and flexible argument handling.
|
|
1763
|
-
* This function can handle subcommands (including nested), positional arguments, and automatically normalizes
|
|
1764
|
-
* template literals and space-separated strings.
|
|
1765
|
-
*
|
|
1766
|
-
* @param command The command definition (from defineCommand)
|
|
1767
|
-
* @param argv The argv array to parse (default: []). Supports template literals and subcommands.
|
|
1768
|
-
* @param parserOptions Optional reliArgParser options
|
|
1769
|
-
*
|
|
1770
|
-
* @example
|
|
1771
|
-
* ```ts
|
|
1772
|
-
* // ✅ Single command with template literals
|
|
1773
|
-
* await runCmdWithSubcommands(cmd, [`--dev ${isDev}`]);
|
|
1774
|
-
*
|
|
1775
|
-
* // ✅ Subcommand with arguments
|
|
1776
|
-
* await runCmdWithSubcommands(cmd, [`build --input src/mod.ts --someBoolean`]);
|
|
1777
|
-
*
|
|
1778
|
-
* // ✅ Subcommand with positional arguments
|
|
1779
|
-
* await runCmdWithSubcommands(cmd, [`build src/mod.ts --someBoolean`]);
|
|
1780
|
-
*
|
|
1781
|
-
* // ✅ Nested subcommands
|
|
1782
|
-
* await runCmdWithSubcommands(cmd, [`build someSubCmd src/mod.ts --no-cjs`]);
|
|
1783
|
-
* await runCmdWithSubcommands(cmd, [`build sub1 sub2 sub3 file.ts --flag`]);
|
|
1784
|
-
*
|
|
1785
|
-
* // ✅ Mixed array with subcommands
|
|
1786
|
-
* await runCmdWithSubcommands(cmd, [
|
|
1787
|
-
* `build someSubCmd src/mod.ts`,
|
|
1788
|
-
* "--no-cjs",
|
|
1789
|
-
* "--verbose"
|
|
1790
|
-
* ]);
|
|
1791
|
-
* ```
|
|
1792
|
-
*/
|
|
1793
|
-
declare function runCmdWithSubcommands<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, argv?: string[], parserOptions?: ReliArgParserOptions & {
|
|
1794
|
-
fileBased?: FileBasedOptions;
|
|
1795
|
-
autoExit?: boolean;
|
|
1796
|
-
}): Promise<any>;
|
|
1797
|
-
/**
|
|
1798
|
-
* Programmatically run a command's run() handler with parsed arguments.
|
|
1799
|
-
* Does not handle subcommands, file-based commands, or global hooks.
|
|
1800
|
-
* Suitable for use in demos, tests, or programmatic invocation.
|
|
1801
|
-
*
|
|
1802
|
-
* @param command The command definition (from defineCommand)
|
|
1803
|
-
* @param argv The argv array to parse (default: []). Each argument should be a separate array element.
|
|
1804
|
-
* @param parserOptions Optional reliArgParser options
|
|
1805
|
-
*
|
|
1806
|
-
* @example
|
|
1807
|
-
* **each argument as separate array element**:
|
|
1808
|
-
* ```ts
|
|
1809
|
-
* await runCmd(cmd, ["--dev", "true"]);
|
|
1810
|
-
* await runCmd(cmd, ["--name", "John", "--verbose"]);
|
|
1811
|
-
* ```
|
|
1812
|
-
* **automatic normalization of template literals**:
|
|
1813
|
-
* ```ts
|
|
1814
|
-
* await runCmd(cmd, [`--dev ${isDev}`]); // Automatically converted to ["--dev", "true"]
|
|
1815
|
-
* await runCmd(cmd, [`--dev ${isDev} --build mod.ts`]); // ["--dev", "true", "--build", "mod.ts"]
|
|
1816
|
-
* ```
|
|
1817
|
-
*/
|
|
1818
|
-
declare function runCmd<A extends ArgDefinitions = EmptyArgs>(command: Command<A>, argv?: string[], parserOptions?: ReliArgParserOptions): Promise<void>;
|
|
1819
1350
|
|
|
1820
1351
|
declare const runMain: typeof createCli;
|
|
1821
1352
|
|
|
1822
|
-
/** uses omelette to add completions to a commander program */
|
|
1823
|
-
declare function addCompletions(program: Command$1, completion: OmeletteInstanceLike): void;
|
|
1824
|
-
|
|
1825
|
-
/** An error thrown when the trpc procedure results in a bad request */
|
|
1826
|
-
declare class CliValidationError extends Error {
|
|
1827
|
-
}
|
|
1828
|
-
/** An error which is only thrown when a custom \`process\` parameter is used. Under normal circumstances, this should not be used, even internally. */
|
|
1829
|
-
declare class FailedToExitError extends Error {
|
|
1830
|
-
readonly exitCode: number;
|
|
1831
|
-
constructor(message: string, { exitCode, cause }: {
|
|
1832
|
-
exitCode: number;
|
|
1833
|
-
cause: unknown;
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
declare class TrpcCommand extends Command$1 {
|
|
1838
|
-
/** @internal track the commands that have been run, so that we can find the `__result` of the last command */
|
|
1839
|
-
__ran: TrpcCommand[];
|
|
1840
|
-
__input?: unknown;
|
|
1841
|
-
/** @internal stash the return value of the underlying procedure on the command so to pass to `FailedToExitError` for use in a pinch */
|
|
1842
|
-
__result?: unknown;
|
|
1843
|
-
}
|
|
1844
|
-
/**
|
|
1845
|
-
* @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.
|
|
1846
|
-
* Officially, just internal for building a CLI. GLHF.
|
|
1847
|
-
*/
|
|
1848
|
-
declare const parseRouter: <R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>) => [string, ProcedureInfo][];
|
|
1849
|
-
interface ProcedureInfo {
|
|
1850
|
-
meta: TrpcCliMeta;
|
|
1851
|
-
parsedProcedure: ParsedProcedure;
|
|
1852
|
-
incompatiblePairs: [string, string][];
|
|
1853
|
-
procedure: {};
|
|
1854
|
-
}
|
|
1855
|
-
/**
|
|
1856
|
-
* Run a trpc router as a CLI.
|
|
1857
|
-
*
|
|
1858
|
-
* @param router A trpc router
|
|
1859
|
-
* @param context The context to use when calling the procedures - needed if your router requires a context
|
|
1860
|
-
* @param trpcServer The trpc server module to use. Only needed if using trpc v10.
|
|
1861
|
-
* @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.
|
|
1862
|
-
*/
|
|
1863
|
-
declare function createRpcCli<R extends AnyRouter>({ router, ...params }: TrpcCliParams<R>): TrpcCli;
|
|
1864
|
-
|
|
1865
|
-
declare const flattenedProperties: (sch: JsonSchema7Type) => JsonSchema7ObjectType["properties"];
|
|
1866
|
-
/** 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) */
|
|
1867
|
-
declare const incompatiblePropertyPairs: (sch: JsonSchema7Type) => [string, string][];
|
|
1868
|
-
/**
|
|
1869
|
-
* Tries fairly hard to build a roughly human-readable description of a json-schema type.
|
|
1870
|
-
* A few common properties are given special treatment, most others are just stringified and output in `key: value` format.
|
|
1871
|
-
*/
|
|
1872
|
-
declare const getDescription: (v: JsonSchema7Type, depth?: number) => string;
|
|
1873
|
-
declare const getSchemaTypes: (propertyValue: JsonSchema7Type) => ("string" | "boolean" | "number" | (string & {}))[];
|
|
1874
|
-
declare const getEnumChoices: (propertyValue: JsonSchema7Type) => {
|
|
1875
|
-
readonly type: "string_enum";
|
|
1876
|
-
readonly choices: string[];
|
|
1877
|
-
} | {
|
|
1878
|
-
readonly type: "number_enum";
|
|
1879
|
-
readonly choices: number[];
|
|
1880
|
-
} | null;
|
|
1881
|
-
|
|
1882
|
-
declare const lineByLineLogger: (logger: Logger) => Logger;
|
|
1883
|
-
/**
|
|
1884
|
-
* A logger which uses `console.log` and `console.error` to log in the following way:
|
|
1885
|
-
* - Primitives are logged directly
|
|
1886
|
-
* - Arrays are logged item-by-item
|
|
1887
|
-
* - Objects are logged as JSON
|
|
1888
|
-
*
|
|
1889
|
-
* This is useful for logging structured data in a human-readable way, and for piping logs to other tools.
|
|
1890
|
-
*/
|
|
1891
|
-
declare const lineByLineConsoleLogger: Logger;
|
|
1892
|
-
|
|
1893
|
-
declare function parseProcedureInputs(inputs: unknown[], dependencies: Dependencies): Result<ParsedProcedure>;
|
|
1894
|
-
|
|
1895
|
-
interface Shadowed<T> {
|
|
1896
|
-
original: T;
|
|
1897
|
-
shadow: T;
|
|
1898
|
-
}
|
|
1899
|
-
type WithValue<T> = Shadowed<T> & {
|
|
1900
|
-
value: string | undefined;
|
|
1901
|
-
specified: boolean;
|
|
1902
|
-
};
|
|
1903
|
-
interface Analysis {
|
|
1904
|
-
command: Shadowed<Command$1>;
|
|
1905
|
-
arguments: WithValue<Argument>[];
|
|
1906
|
-
options: WithValue<Option>[];
|
|
1907
|
-
}
|
|
1908
|
-
declare const createShadowCommand: (command: Command$1, onAnalyze: (params: Analysis) => void | Promise<void>) => Command$1;
|
|
1909
|
-
declare const promptify: (program: CommanderProgramLike, prompts: Promptable) => CommanderProgramLike;
|
|
1910
|
-
|
|
1911
|
-
declare const prettifyStandardSchemaError: (error: unknown) => string | null;
|
|
1912
|
-
declare function toDotPath(path: (string | number | symbol)[]): string;
|
|
1913
|
-
declare class StandardSchemaV1Error extends Error implements StandardSchemaV1FailureResult {
|
|
1914
|
-
issues: StandardSchemaV1FailureResult["issues"];
|
|
1915
|
-
constructor(failure: StandardSchemaV1FailureResult, options?: {
|
|
1916
|
-
cause?: Error;
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
declare const looksLikeStandardSchemaFailure: (error: unknown) => error is StandardSchemaV1FailureResult;
|
|
1921
|
-
declare const looksLikeStandardSchema: (thing: unknown) => thing is StandardSchemaV1;
|
|
1922
|
-
|
|
1923
|
-
/**
|
|
1924
|
-
* Pretty much like the `instanceof` operator, but should work across different realms. Necessary for zod because some installations
|
|
1925
|
-
* might result in this library using the commonjs zod export, while the user's code uses the esm export.
|
|
1926
|
-
* https://github.com/mmkal/trpc-cli/issues/7
|
|
1927
|
-
*
|
|
1928
|
-
* 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.
|
|
1929
|
-
* So, only use it for classes that are unlikely to have name conflicts like `ZodAbc` or `TRPCDef`.
|
|
1930
|
-
*/
|
|
1931
|
-
declare const looksLikeInstanceof: <T>(value: unknown, target: string | (new (...args: any[]) => T)) => value is T;
|
|
1932
|
-
|
|
1933
1353
|
declare const log: _reliverse_relinka.RelinkaFunction;
|
|
1934
1354
|
|
|
1935
1355
|
/**
|
|
@@ -2329,5 +1749,5 @@ declare function createAsciiArt({ message, font, clearConsole, }: {
|
|
|
2329
1749
|
clearConsole?: boolean;
|
|
2330
1750
|
}): Promise<void>;
|
|
2331
1751
|
|
|
2332
|
-
export { CANCEL,
|
|
2333
|
-
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 };
|