@reliverse/rempts 1.7.30 → 1.7.31
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/README.md +49 -0
- package/bin/libs/launcher/launcher-mod.d.ts +39 -9
- package/bin/libs/launcher/launcher-mod.js +208 -165
- package/bin/mod.d.ts +1 -1
- package/bin/mod.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
- 🏞️ no more hacking together `inquirer`/`citty`/`commander`/`chalk`
|
|
29
29
|
- 🆕 automatic command creation (`bun dler rempts --init cmd1 cmd2`)
|
|
30
30
|
- 🐦🔥 automatic creation of `src/app/cmds.ts` file (`bun dler rempts`)
|
|
31
|
+
- 🔌 tRPC/ORPC router integration - automatically generate CLI commands from your RPC procedures
|
|
31
32
|
|
|
32
33
|
## Installation
|
|
33
34
|
|
|
@@ -364,6 +365,48 @@ See [example/launcher/app/nested](./example/launcher/app/nested/) and [example/l
|
|
|
364
365
|
|
|
365
366
|
When playing with the example, you can run e.g. `bun dev:modern nested foo bar baz` to see the result in action.
|
|
366
367
|
|
|
368
|
+
## RPC Integration
|
|
369
|
+
|
|
370
|
+
Rempts now supports seamless integration with tRPC and ORPC routers, allowing you to automatically generate CLI commands from your RPC procedures. This provides a powerful way to expose your API endpoints as command-line tools.
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import { z } from "zod";
|
|
374
|
+
import { initTRPC } from "@trpc/server";
|
|
375
|
+
import { createCli } from "@reliverse/rempts";
|
|
376
|
+
|
|
377
|
+
const t = initTRPC.create();
|
|
378
|
+
|
|
379
|
+
const appRouter = t.router({
|
|
380
|
+
hello: t.procedure
|
|
381
|
+
.input(z.object({ name: z.string().optional() }))
|
|
382
|
+
.query(({ input }) => `Hello ${input.name ?? "World"}!`),
|
|
383
|
+
|
|
384
|
+
add: t.procedure
|
|
385
|
+
.input(z.object({ a: z.number(), b: z.number() }))
|
|
386
|
+
.mutation(({ input }) => input.a + input.b)
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// Automatically generates CLI commands from your tRPC procedures
|
|
390
|
+
await createCli({
|
|
391
|
+
name: "my-cli",
|
|
392
|
+
rpc: { router: appRouter }
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**Features:**
|
|
397
|
+
|
|
398
|
+
- 🚀 Automatic CLI generation from tRPC procedures
|
|
399
|
+
- 🔄 Support for both tRPC v10 and v11
|
|
400
|
+
- 🏗️ Nested command structures from sub-routers
|
|
401
|
+
- ✅ Input validation from Zod schemas
|
|
402
|
+
- 📖 Automatic help generation from procedure metadata
|
|
403
|
+
- 🎯 Full TypeScript support with type inference
|
|
404
|
+
- 🎨 Interactive prompts for missing arguments
|
|
405
|
+
- ⌨️ Shell completion support
|
|
406
|
+
- 🔧 Customizable logging and error handling
|
|
407
|
+
|
|
408
|
+
See [RPC Integration Guide](./docs/launcher-rpc.md) for detailed documentation and examples.
|
|
409
|
+
|
|
367
410
|
### Playground
|
|
368
411
|
|
|
369
412
|
```bash
|
|
@@ -377,6 +420,12 @@ bun dev
|
|
|
377
420
|
- `bun dev:modern`: This example will show you a modern CLI launcher usage with file-based commands.
|
|
378
421
|
- `bun dev:classic`: This example will show you a classic CLI launcher usage with programmatic commands.
|
|
379
422
|
|
|
423
|
+
### tRPC/oRPC Integration Example Commands
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
bun example/trpc-orpc/rempts/effect-primary.ts create-profile --name 'Jane Smith' --age 28 --bio 'Software Engineer' --tags 'developer,typescript'
|
|
427
|
+
```
|
|
428
|
+
|
|
380
429
|
### Launcher Usage Examples
|
|
381
430
|
|
|
382
431
|
#### Minimal Usage Example
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReliArgParserOptions } from "@reliverse/reliarg";
|
|
2
2
|
import type { ArgDefinitions, Command, DefineCommandOptions, EmptyArgs, FileBasedOptions } from "./launcher-types.js";
|
|
3
|
+
import type { AnyRouter } from "./trpc-orpc-support/trpc-compat.js";
|
|
4
|
+
import type { Logger, OmeletteInstanceLike, Promptable } from "./trpc-orpc-support/types.js";
|
|
3
5
|
/**
|
|
4
6
|
* Defines a command with metadata, argument definitions,
|
|
5
7
|
* an execution function, and (optional) subCommands.
|
|
@@ -28,6 +30,7 @@ export declare function showUsage<A extends ArgDefinitions>(command: Command<A>,
|
|
|
28
30
|
* - File-based Commands: scanning for commands within a given commands root.
|
|
29
31
|
* - Commands defined within the command object.
|
|
30
32
|
* - Standard flags like --help, --version, and --debug.
|
|
33
|
+
* - RPC functionality: tRPC/oRPC router integration with automatic CLI generation.
|
|
31
34
|
*
|
|
32
35
|
* This function passes along remaining arguments to command runners to ensure
|
|
33
36
|
* consistent parsing.
|
|
@@ -50,21 +53,48 @@ export declare function createCli<A extends ArgDefinitions = EmptyArgs>(options:
|
|
|
50
53
|
onCmdExit?: Command<A>["onCmdExit"];
|
|
51
54
|
onLauncherInit?: Command<A>["onLauncherInit"];
|
|
52
55
|
onLauncherExit?: Command<A>["onLauncherExit"];
|
|
56
|
+
rpc?: {
|
|
57
|
+
/** A tRPC router. Procedures will become CLI commands. */
|
|
58
|
+
router: AnyRouter;
|
|
59
|
+
/** Context to be supplied when invoking the router. */
|
|
60
|
+
context?: any;
|
|
61
|
+
/** The `@trpc/server` module to use for calling procedures. Required when using trpc v10. */
|
|
62
|
+
trpcServer?: any | Promise<any>;
|
|
63
|
+
/** Usage code examples to display in `--help` output. */
|
|
64
|
+
usage?: string | string[];
|
|
65
|
+
/** Dependencies for schema validation libraries */
|
|
66
|
+
"@valibot/to-json-schema"?: {
|
|
67
|
+
toJsonSchema: (input: unknown, options?: {
|
|
68
|
+
errorMode?: "throw" | "ignore" | "warn";
|
|
69
|
+
}) => any;
|
|
70
|
+
};
|
|
71
|
+
effect?: {
|
|
72
|
+
Schema: {
|
|
73
|
+
isSchema: (input: unknown) => input is "JSONSchemaMakeable";
|
|
74
|
+
};
|
|
75
|
+
JSONSchema: {
|
|
76
|
+
make: (input: "JSONSchemaMakeable") => any;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
rpcRunParams?: {
|
|
81
|
+
argv?: string[];
|
|
82
|
+
logger?: Logger;
|
|
83
|
+
completion?: OmeletteInstanceLike | (() => Promise<OmeletteInstanceLike>);
|
|
84
|
+
prompts?: Promptable;
|
|
85
|
+
/** Format an error thrown by the root procedure before logging to `logger.error` */
|
|
86
|
+
formatError?: (error: unknown) => string;
|
|
87
|
+
process?: {
|
|
88
|
+
exit: (code: number) => never;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
53
91
|
}, legacyParserOptions?: ReliArgParserOptions & {
|
|
54
92
|
fileBased?: FileBasedOptions;
|
|
55
93
|
autoExit?: boolean;
|
|
56
94
|
metaSettings?: {
|
|
57
95
|
showDescriptionOnMain?: boolean;
|
|
58
96
|
};
|
|
59
|
-
}): {
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated Use createCli() directly instead. This method will be removed in a future version.
|
|
62
|
-
* @example
|
|
63
|
-
* // Instead of:
|
|
64
|
-
* createCli({...}).run()
|
|
65
|
-
* // Use:
|
|
66
|
-
* await createCli({...})
|
|
67
|
-
*/
|
|
97
|
+
}): Promise<void> & {
|
|
68
98
|
run(_ctx?: any): Promise<void>;
|
|
69
99
|
};
|
|
70
100
|
/**
|
|
@@ -5,6 +5,7 @@ import fs from "@reliverse/relifso";
|
|
|
5
5
|
import { relinka, relinkaConfig, relinkaShutdown } from "@reliverse/relinka";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { readPackageJSON } from "pkg-types";
|
|
8
|
+
import { createRpcCli } from "./trpc-orpc-support/index.js";
|
|
8
9
|
function buildExampleArgs(args) {
|
|
9
10
|
const parts = [];
|
|
10
11
|
const positionalKeys = Object.keys(args || {}).filter(
|
|
@@ -379,95 +380,180 @@ export function createCli(options, legacyParserOptions) {
|
|
|
379
380
|
meta: mergedMeta
|
|
380
381
|
};
|
|
381
382
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
383
|
+
const execute = async (_ctx) => {
|
|
384
|
+
if (options && typeof options === "object" && "rpc" in options && options.rpc) {
|
|
385
|
+
const rpcOptions = options.rpc;
|
|
386
|
+
const rpcRunParams = options.rpcRunParams || {};
|
|
387
|
+
debugLog("RPC integration detected, creating RPC CLI...");
|
|
388
|
+
try {
|
|
389
|
+
require("tsx/cjs");
|
|
390
|
+
await import("tsx/esm");
|
|
391
|
+
debugLog("tsx loaded successfully for TypeScript support");
|
|
392
|
+
} catch {
|
|
393
|
+
debugLog("tsx not available, continuing without TypeScript support");
|
|
394
|
+
}
|
|
395
|
+
const getRouterMeta = (router) => {
|
|
396
|
+
if ("_def" in router && router._def && "meta" in router._def) {
|
|
397
|
+
return router._def.meta;
|
|
398
|
+
}
|
|
399
|
+
return void 0;
|
|
400
|
+
};
|
|
401
|
+
const routerMeta = getRouterMeta(rpcOptions.router);
|
|
402
|
+
const rpcCli = createRpcCli({
|
|
403
|
+
router: rpcOptions.router,
|
|
404
|
+
name: globalCliMeta.name || routerMeta?.name,
|
|
405
|
+
version: globalCliMeta.version || routerMeta?.version,
|
|
406
|
+
description: globalCliMeta.description || routerMeta?.description,
|
|
407
|
+
usage: rpcOptions.usage,
|
|
408
|
+
context: rpcOptions.context,
|
|
409
|
+
trpcServer: rpcOptions.trpcServer,
|
|
410
|
+
"@valibot/to-json-schema": rpcOptions["@valibot/to-json-schema"],
|
|
411
|
+
effect: rpcOptions.effect
|
|
412
|
+
});
|
|
413
|
+
debugLog(
|
|
414
|
+
"RPC CLI created, running with argv:",
|
|
415
|
+
rpcRunParams.argv || process.argv.slice(2)
|
|
395
416
|
);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
417
|
+
await rpcCli.run({
|
|
418
|
+
argv: rpcRunParams.argv || process.argv.slice(2),
|
|
419
|
+
logger: rpcRunParams.logger || {
|
|
420
|
+
info: console.log,
|
|
421
|
+
error: console.error
|
|
422
|
+
},
|
|
423
|
+
completion: rpcRunParams.completion,
|
|
424
|
+
prompts: rpcRunParams.prompts,
|
|
425
|
+
formatError: rpcRunParams.formatError,
|
|
426
|
+
process: rpcRunParams.process
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (typeof command.onLauncherInit === "function") {
|
|
431
|
+
try {
|
|
432
|
+
await command.onLauncherInit();
|
|
433
|
+
} catch (err) {
|
|
434
|
+
relinka("error", "Error in onLauncherInit:", err);
|
|
435
|
+
if (parserOptions.autoExit !== false) process.exit(1);
|
|
436
|
+
throw err;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
try {
|
|
440
|
+
if (!parserOptions.fileBased && !command.commands) {
|
|
441
|
+
const mainEntry = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : process.cwd();
|
|
442
|
+
const defaultCmdsRoot = path.join(mainEntry, "src", "app");
|
|
443
|
+
const exists = await fs.pathExists(defaultCmdsRoot);
|
|
444
|
+
const finalCmdsRoot = exists ? defaultCmdsRoot : path.join(mainEntry, "app");
|
|
445
|
+
parserOptions.fileBased = {
|
|
446
|
+
enable: true,
|
|
447
|
+
cmdsRootPath: finalCmdsRoot
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const rawArgv = process.argv.slice(2);
|
|
451
|
+
const autoExit = parserOptions.autoExit !== false;
|
|
452
|
+
if (!(parserOptions.fileBased?.enable || command.commands && Object.keys(command.commands).length > 0 || command.run)) {
|
|
453
|
+
relinka(
|
|
454
|
+
"error",
|
|
455
|
+
"Invalid CLI configuration: No file-based commands, subCommands, or run() handler are defined. This CLI will not do anything.\n\u2502 To fix: add file-based commands (./app), or provide at least one subCommand or a run() handler."
|
|
456
|
+
);
|
|
457
|
+
process.exit(1);
|
|
458
|
+
}
|
|
459
|
+
if (parserOptions.fileBased?.enable && rawArgv.length > 0) {
|
|
460
|
+
const commandsDir = path.resolve(parserOptions.fileBased.cmdsRootPath);
|
|
461
|
+
const resolved = await resolveFileBasedCommandPath(
|
|
462
|
+
commandsDir,
|
|
463
|
+
rawArgv
|
|
464
|
+
);
|
|
465
|
+
if (resolved) {
|
|
466
|
+
const {
|
|
467
|
+
def: subCommand,
|
|
468
|
+
leftoverArgv,
|
|
469
|
+
path: pathSegments
|
|
470
|
+
} = resolved;
|
|
471
|
+
const helpIdx = leftoverArgv.findIndex(
|
|
472
|
+
(arg) => arg === "help" || arg === "--help" || arg === "-h"
|
|
473
|
+
);
|
|
474
|
+
if (helpIdx !== -1) {
|
|
475
|
+
await showUsage(
|
|
476
|
+
subCommand,
|
|
477
|
+
{
|
|
478
|
+
...parserOptions,
|
|
479
|
+
_fileBasedCurrentDir: pathSegments.length ? path.join(commandsDir, ...pathSegments) : commandsDir,
|
|
480
|
+
_fileBasedPathSegments: pathSegments
|
|
481
|
+
},
|
|
482
|
+
globalCliMeta
|
|
483
|
+
);
|
|
484
|
+
if (autoExit) process.exit(0);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const fileBasedEnabled = parserOptions.fileBased?.enable;
|
|
490
|
+
if (fileBasedEnabled && rawArgv.length > 0 && rawArgv[0] && !isFlag(rawArgv[0])) {
|
|
491
|
+
const [subName, ...subCmdArgv] = rawArgv;
|
|
399
492
|
try {
|
|
400
|
-
|
|
493
|
+
const ctx = getParsedContext(command, rawArgv, parserOptions);
|
|
494
|
+
if (typeof command.onCmdInit === "function")
|
|
495
|
+
await command.onCmdInit(ctx);
|
|
496
|
+
await runFileBasedSubCmd(
|
|
497
|
+
subName,
|
|
498
|
+
subCmdArgv,
|
|
499
|
+
parserOptions.fileBased,
|
|
500
|
+
parserOptions,
|
|
501
|
+
command.onCmdExit ? async (_subCtx) => {
|
|
502
|
+
await command.onCmdExit?.(ctx);
|
|
503
|
+
} : void 0,
|
|
504
|
+
globalCliMeta
|
|
505
|
+
);
|
|
506
|
+
if (autoExit) process.exit(0);
|
|
507
|
+
return;
|
|
401
508
|
} catch (err) {
|
|
402
|
-
relinka("error", "Error
|
|
403
|
-
if (
|
|
509
|
+
relinka("error", "Error loading file-based subcommand:", err.message);
|
|
510
|
+
if (autoExit) process.exit(1);
|
|
404
511
|
throw err;
|
|
405
512
|
}
|
|
406
513
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
);
|
|
425
|
-
process.exit(1);
|
|
514
|
+
if (!fileBasedEnabled && command.commands && rawArgv.length > 0 && rawArgv[0] && !isFlag(rawArgv[0])) {
|
|
515
|
+
const [maybeSub, ...subCmdArgv] = rawArgv;
|
|
516
|
+
let subSpec;
|
|
517
|
+
for (const [key, spec] of Object.entries(command.commands)) {
|
|
518
|
+
if (key === maybeSub) {
|
|
519
|
+
subSpec = spec;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
const cmd = await loadSubCommand(spec);
|
|
524
|
+
if (cmd.meta?.aliases?.includes(maybeSub)) {
|
|
525
|
+
subSpec = spec;
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
} catch (err) {
|
|
529
|
+
debugLog(`Error checking alias for command ${key}:`, err);
|
|
530
|
+
}
|
|
426
531
|
}
|
|
427
|
-
if (
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
);
|
|
431
|
-
const resolved = await resolveFileBasedCommandPath(
|
|
432
|
-
commandsDir,
|
|
433
|
-
rawArgv
|
|
532
|
+
if (subSpec) {
|
|
533
|
+
const helpIdx = subCmdArgv.findIndex(
|
|
534
|
+
(arg) => arg === "help" || arg === "--help" || arg === "-h"
|
|
434
535
|
);
|
|
435
|
-
if (
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
536
|
+
if (helpIdx !== -1) {
|
|
537
|
+
const subCommandDef = await loadSubCommand(subSpec);
|
|
538
|
+
await showUsage(
|
|
539
|
+
subCommandDef,
|
|
540
|
+
{
|
|
541
|
+
...parserOptions,
|
|
542
|
+
_isSubcommand: true
|
|
543
|
+
},
|
|
544
|
+
globalCliMeta
|
|
443
545
|
);
|
|
444
|
-
if (
|
|
445
|
-
|
|
446
|
-
subCommand,
|
|
447
|
-
{
|
|
448
|
-
...parserOptions,
|
|
449
|
-
_fileBasedCurrentDir: pathSegments.length ? path.join(commandsDir, ...pathSegments) : commandsDir,
|
|
450
|
-
_fileBasedPathSegments: pathSegments
|
|
451
|
-
},
|
|
452
|
-
globalCliMeta
|
|
453
|
-
);
|
|
454
|
-
if (autoExit) process.exit(0);
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
546
|
+
if (autoExit) process.exit(0);
|
|
547
|
+
return;
|
|
457
548
|
}
|
|
458
|
-
}
|
|
459
|
-
const fileBasedEnabled = parserOptions.fileBased?.enable;
|
|
460
|
-
if (fileBasedEnabled && rawArgv.length > 0 && rawArgv[0] && !isFlag(rawArgv[0])) {
|
|
461
|
-
const [subName, ...subCmdArgv] = rawArgv;
|
|
462
549
|
try {
|
|
463
550
|
const ctx = getParsedContext(command, rawArgv, parserOptions);
|
|
464
551
|
if (typeof command.onCmdInit === "function")
|
|
465
552
|
await command.onCmdInit(ctx);
|
|
466
|
-
await
|
|
467
|
-
|
|
553
|
+
await runSubCommand(
|
|
554
|
+
subSpec,
|
|
468
555
|
subCmdArgv,
|
|
469
|
-
parserOptions
|
|
470
|
-
parserOptions,
|
|
556
|
+
{ ...parserOptions, _isSubcommand: true },
|
|
471
557
|
command.onCmdExit ? async (_subCtx) => {
|
|
472
558
|
await command.onCmdExit?.(ctx);
|
|
473
559
|
} : void 0,
|
|
@@ -476,107 +562,64 @@ export function createCli(options, legacyParserOptions) {
|
|
|
476
562
|
if (autoExit) process.exit(0);
|
|
477
563
|
return;
|
|
478
564
|
} catch (err) {
|
|
479
|
-
relinka(
|
|
480
|
-
"error",
|
|
481
|
-
"Error loading file-based subcommand:",
|
|
482
|
-
err.message
|
|
483
|
-
);
|
|
565
|
+
relinka("error", "Error running subcommand:", err.message);
|
|
484
566
|
if (autoExit) process.exit(1);
|
|
485
567
|
throw err;
|
|
486
568
|
}
|
|
487
569
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
} catch (err) {
|
|
503
|
-
debugLog(`Error checking alias for command ${key}:`, err);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
if (subSpec) {
|
|
507
|
-
const helpIdx = subCmdArgv.findIndex(
|
|
508
|
-
(arg) => arg === "help" || arg === "--help" || arg === "-h"
|
|
509
|
-
);
|
|
510
|
-
if (helpIdx !== -1) {
|
|
511
|
-
const subCommandDef = await loadSubCommand(subSpec);
|
|
512
|
-
await showUsage(
|
|
513
|
-
subCommandDef,
|
|
514
|
-
{
|
|
515
|
-
...parserOptions,
|
|
516
|
-
_isSubcommand: true
|
|
517
|
-
},
|
|
518
|
-
globalCliMeta
|
|
519
|
-
);
|
|
520
|
-
if (autoExit) process.exit(0);
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
try {
|
|
524
|
-
const ctx = getParsedContext(command, rawArgv, parserOptions);
|
|
525
|
-
if (typeof command.onCmdInit === "function")
|
|
526
|
-
await command.onCmdInit(ctx);
|
|
527
|
-
await runSubCommand(
|
|
528
|
-
subSpec,
|
|
529
|
-
subCmdArgv,
|
|
530
|
-
{ ...parserOptions, _isSubcommand: true },
|
|
531
|
-
command.onCmdExit ? async (_subCtx) => {
|
|
532
|
-
await command.onCmdExit?.(ctx);
|
|
533
|
-
} : void 0,
|
|
534
|
-
globalCliMeta
|
|
535
|
-
);
|
|
536
|
-
if (autoExit) process.exit(0);
|
|
537
|
-
return;
|
|
538
|
-
} catch (err) {
|
|
539
|
-
relinka("error", "Error running subcommand:", err.message);
|
|
540
|
-
if (autoExit) process.exit(1);
|
|
541
|
-
throw err;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
await relinkaConfig;
|
|
546
|
-
if (rawArgv[0] === "help" || checkHelp(rawArgv)) {
|
|
547
|
-
await showUsage(command, parserOptions, globalCliMeta);
|
|
548
|
-
if (autoExit) process.exit(0);
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
if (checkVersion(rawArgv)) {
|
|
552
|
-
if (command.meta?.name) {
|
|
553
|
-
relinka(
|
|
554
|
-
"info",
|
|
555
|
-
`${command.meta?.name} ${command.meta?.version ? `v${command.meta?.version}` : ""}`
|
|
556
|
-
);
|
|
557
|
-
}
|
|
558
|
-
if (autoExit) process.exit(0);
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
try {
|
|
562
|
-
await runCommandWithArgs(
|
|
563
|
-
command,
|
|
564
|
-
rawArgv,
|
|
565
|
-
parserOptions,
|
|
566
|
-
globalCliMeta
|
|
570
|
+
}
|
|
571
|
+
await relinkaConfig;
|
|
572
|
+
if (rawArgv[0] === "help" || checkHelp(rawArgv)) {
|
|
573
|
+
await showUsage(command, parserOptions, globalCliMeta);
|
|
574
|
+
if (autoExit) process.exit(0);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (checkVersion(rawArgv)) {
|
|
578
|
+
if (command.meta?.name) {
|
|
579
|
+
relinka(
|
|
580
|
+
"info",
|
|
581
|
+
`${command.meta?.name} ${command.meta?.version ? `v${command.meta?.version}` : ""}`
|
|
567
582
|
);
|
|
568
|
-
} finally {
|
|
569
583
|
}
|
|
570
|
-
|
|
584
|
+
if (autoExit) process.exit(0);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
await runCommandWithArgs(
|
|
589
|
+
command,
|
|
590
|
+
rawArgv,
|
|
591
|
+
parserOptions,
|
|
592
|
+
globalCliMeta
|
|
593
|
+
);
|
|
571
594
|
} finally {
|
|
572
|
-
if (typeof command.onLauncherExit === "function")
|
|
573
|
-
await command.onLauncherExit();
|
|
574
595
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
)
|
|
596
|
+
await relinkaShutdown();
|
|
597
|
+
} finally {
|
|
598
|
+
if (typeof command.onLauncherExit === "function")
|
|
599
|
+
await command.onLauncherExit();
|
|
578
600
|
}
|
|
579
601
|
};
|
|
602
|
+
const promise = execute();
|
|
603
|
+
const cli = Object.assign(promise, {
|
|
604
|
+
/**
|
|
605
|
+
* @deprecated Use createCli() directly instead. This method will be removed in a future version.
|
|
606
|
+
* @example
|
|
607
|
+
* // Instead of:
|
|
608
|
+
* createCli({...}).run()
|
|
609
|
+
* // Use:
|
|
610
|
+
* await createCli({...})
|
|
611
|
+
*/
|
|
612
|
+
async run(_ctx) {
|
|
613
|
+
relinka(
|
|
614
|
+
"warn",
|
|
615
|
+
"\u26A0\uFE0F Deprecated: .run() method is deprecated. Use createCli() directly instead."
|
|
616
|
+
);
|
|
617
|
+
relinka("warn", " Instead of: createCli({...}).run()");
|
|
618
|
+
relinka("warn", " Use: await createCli({...})");
|
|
619
|
+
return execute(_ctx);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
return cli;
|
|
580
623
|
}
|
|
581
624
|
function checkHelp(argv) {
|
|
582
625
|
return argv.includes("--help") || argv.includes("-h");
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { animationMap, animateText } from "./libs/animate/animate-mod.js";
|
|
2
2
|
export { anykeyPrompt } from "./libs/anykey/anykey-mod.js";
|
|
3
|
-
export { createAsciiArt } from "./libs/visual/visual-mod.js";
|
|
4
3
|
export type { CancelValue } from "./libs/cancel/cancel.js";
|
|
5
4
|
export { CANCEL, isWindows, setRawMode, getColumns, block, isCancel, cancel, createCancel, } from "./libs/cancel/cancel.js";
|
|
6
5
|
export { confirm } from "./libs/confirm/confirm-alias.js";
|
|
@@ -63,4 +62,5 @@ export { completePrompt, renderEndLine, renderEndLineInput, } from "./libs/utils
|
|
|
63
62
|
export { streamText, streamTextBox, streamTextWithSpinner, } from "./libs/utils/stream-text.js";
|
|
64
63
|
export { pm, reliversePrompts } from "./libs/utils/system.js";
|
|
65
64
|
export { isTerminalInteractive, isValidName, normalizeName, } from "./libs/utils/validate.js";
|
|
65
|
+
export { createAsciiArt } from "./libs/visual/visual-mod.js";
|
|
66
66
|
export type { MsgType, TypographyName, BorderColorName, ColorName, VariantName, MsgConfig, PromptOptions, ChoiceOptions, SelectOption, StandardColor, OutputColor, EditorExitResult, MessageKind, AllKinds, MessageConfig, StreamOptions, ProgressBarOptions, ProgressBar, PromptType, ConfirmPromptOptions, StreamTextOptions, PreventWrongTerminalSizeOptions, InputPromptOptions, RenderParams, SymbolName, Symbols, FmtMsgOptions, TogglePromptParams, SeparatorOption, MultiselectPromptParams, DatePromptOptions, } from "./types.js";
|
package/bin/mod.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { animationMap, animateText } from "./libs/animate/animate-mod.js";
|
|
2
2
|
export { anykeyPrompt } from "./libs/anykey/anykey-mod.js";
|
|
3
|
-
export { createAsciiArt } from "./libs/visual/visual-mod.js";
|
|
4
3
|
export {
|
|
5
4
|
CANCEL,
|
|
6
5
|
isWindows,
|
|
@@ -148,3 +147,4 @@ export {
|
|
|
148
147
|
isValidName,
|
|
149
148
|
normalizeName
|
|
150
149
|
} from "./libs/utils/validate.js";
|
|
150
|
+
export { createAsciiArt } from "./libs/visual/visual-mod.js";
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"cli-spinners": "^3.2.0",
|
|
18
18
|
"commander": "^14.0.0",
|
|
19
19
|
"detect-package-manager": "^3.0.2",
|
|
20
|
+
"effect": "^3.16.8",
|
|
20
21
|
"enquirer": "^2.4.1",
|
|
21
22
|
"figlet": "^1.8.1",
|
|
22
23
|
"gradient-string": "^3.0.0",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"license": "MIT",
|
|
44
45
|
"name": "@reliverse/rempts",
|
|
45
46
|
"type": "module",
|
|
46
|
-
"version": "1.7.
|
|
47
|
+
"version": "1.7.31",
|
|
47
48
|
"author": "reliverse",
|
|
48
49
|
"bugs": {
|
|
49
50
|
"email": "blefnk@gmail.com",
|