@c9up/ream 0.1.25 → 0.1.27
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 +65 -0
- package/dist/ConfigLoader.d.ts +46 -5
- package/dist/ConfigLoader.d.ts.map +1 -1
- package/dist/ConfigLoader.js +60 -9
- package/dist/ConfigLoader.js.map +1 -1
- package/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +46 -6
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts +115 -7
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +254 -40
- package/dist/Ignitor.js.map +1 -1
- package/dist/console/BaseCommand.d.ts +217 -0
- package/dist/console/BaseCommand.d.ts.map +1 -0
- package/dist/console/BaseCommand.js +340 -0
- package/dist/console/BaseCommand.js.map +1 -0
- package/dist/console/Console.d.ts +86 -0
- package/dist/console/Console.d.ts.map +1 -0
- package/dist/console/Console.js +134 -0
- package/dist/console/Console.js.map +1 -0
- package/dist/console/ExceptionHandler.d.ts +28 -0
- package/dist/console/ExceptionHandler.d.ts.map +1 -0
- package/dist/console/ExceptionHandler.js +76 -0
- package/dist/console/ExceptionHandler.js.map +1 -0
- package/dist/console/HelpCommand.d.ts +16 -0
- package/dist/console/HelpCommand.d.ts.map +1 -0
- package/dist/console/HelpCommand.js +40 -0
- package/dist/console/HelpCommand.js.map +1 -0
- package/dist/console/IndexGenerator.d.ts +24 -0
- package/dist/console/IndexGenerator.d.ts.map +1 -0
- package/dist/console/IndexGenerator.js +65 -0
- package/dist/console/IndexGenerator.js.map +1 -0
- package/dist/console/Kernel.d.ts +298 -0
- package/dist/console/Kernel.d.ts.map +1 -0
- package/dist/console/Kernel.js +1120 -0
- package/dist/console/Kernel.js.map +1 -0
- package/dist/console/ListCommand.d.ts +18 -0
- package/dist/console/ListCommand.d.ts.map +1 -0
- package/dist/console/ListCommand.js +60 -0
- package/dist/console/ListCommand.js.map +1 -0
- package/dist/console/assertions.d.ts +20 -0
- package/dist/console/assertions.d.ts.map +1 -0
- package/dist/console/assertions.js +84 -0
- package/dist/console/assertions.js.map +1 -0
- package/dist/console/cliui.d.ts +248 -0
- package/dist/console/cliui.d.ts.map +1 -0
- package/dist/console/cliui.js +587 -0
- package/dist/console/cliui.js.map +1 -0
- package/dist/console/decorators.d.ts +90 -0
- package/dist/console/decorators.d.ts.map +1 -0
- package/dist/console/decorators.js +142 -0
- package/dist/console/decorators.js.map +1 -0
- package/dist/console/index.d.ts +32 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/console/index.js +24 -0
- package/dist/console/index.js.map +1 -0
- package/dist/console/loaders.d.ts +52 -0
- package/dist/console/loaders.d.ts.map +1 -0
- package/dist/console/loaders.js +131 -0
- package/dist/console/loaders.js.map +1 -0
- package/dist/console/parser.d.ts +86 -0
- package/dist/console/parser.d.ts.map +1 -0
- package/dist/console/parser.js +440 -0
- package/dist/console/parser.js.map +1 -0
- package/dist/console/prompts.d.ts +124 -0
- package/dist/console/prompts.d.ts.map +1 -0
- package/dist/console/prompts.js +356 -0
- package/dist/console/prompts.js.map +1 -0
- package/dist/console/tracing.d.ts +17 -0
- package/dist/console/tracing.d.ts.map +1 -0
- package/dist/console/tracing.js +11 -0
- package/dist/console/tracing.js.map +1 -0
- package/dist/console/types.d.ts +255 -0
- package/dist/console/types.d.ts.map +1 -0
- package/dist/console/types.js +25 -0
- package/dist/console/types.js.map +1 -0
- package/dist/console/ui.d.ts +20 -0
- package/dist/console/ui.d.ts.map +1 -0
- package/dist/console/ui.js +31 -0
- package/dist/console/ui.js.map +1 -0
- package/dist/console/utils.d.ts +27 -0
- package/dist/console/utils.d.ts.map +1 -0
- package/dist/console/utils.js +56 -0
- package/dist/console/utils.js.map +1 -0
- package/dist/container/Container.d.ts +23 -3
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +177 -70
- package/dist/container/Container.js.map +1 -1
- package/dist/container/types.d.ts +14 -2
- package/dist/container/types.d.ts.map +1 -1
- package/dist/decorators/Service.d.ts +7 -0
- package/dist/decorators/Service.d.ts.map +1 -1
- package/dist/decorators/Service.js +23 -3
- package/dist/decorators/Service.js.map +1 -1
- package/dist/env/Env.d.ts +29 -4
- package/dist/env/Env.d.ts.map +1 -1
- package/dist/env/Env.js +27 -4
- package/dist/env/Env.js.map +1 -1
- package/dist/env/Secret.d.ts +11 -0
- package/dist/env/Secret.d.ts.map +1 -0
- package/dist/env/Secret.js +36 -0
- package/dist/env/Secret.js.map +1 -0
- package/dist/env/interpolate.d.ts +26 -0
- package/dist/env/interpolate.d.ts.map +1 -0
- package/dist/env/interpolate.js +48 -0
- package/dist/env/interpolate.js.map +1 -0
- package/dist/env/loadEnvFiles.d.ts.map +1 -1
- package/dist/env/loadEnvFiles.js +14 -4
- package/dist/env/loadEnvFiles.js.map +1 -1
- package/dist/env/schema.d.ts +23 -6
- package/dist/env/schema.d.ts.map +1 -1
- package/dist/env/schema.js +67 -33
- package/dist/env/schema.js.map +1 -1
- package/dist/errors/ReamError.d.ts +25 -0
- package/dist/errors/ReamError.d.ts.map +1 -1
- package/dist/errors/ReamError.js +5 -0
- package/dist/errors/ReamError.js.map +1 -1
- package/dist/errors/prettyPrintError.d.ts +9 -0
- package/dist/errors/prettyPrintError.d.ts.map +1 -0
- package/dist/errors/prettyPrintError.js +22 -0
- package/dist/errors/prettyPrintError.js.map +1 -0
- package/dist/events/Emitter.d.ts +1 -1
- package/dist/events/Emitter.d.ts.map +1 -1
- package/dist/events/Emitter.js +1 -1
- package/dist/events/Emitter.js.map +1 -1
- package/dist/events/EventsProvider.d.ts +2 -2
- package/dist/events/EventsProvider.d.ts.map +1 -1
- package/dist/events/EventsProvider.js +3 -3
- package/dist/events/EventsProvider.js.map +1 -1
- package/dist/graphql/GraphQLEngine.d.ts +1 -1
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
- package/dist/graphql/GraphQLEngine.js +2 -2
- package/dist/graphql/GraphQLEngine.js.map +1 -1
- package/dist/graphql/GraphQLProvider.d.ts.map +1 -1
- package/dist/graphql/GraphQLProvider.js +7 -3
- package/dist/graphql/GraphQLProvider.js.map +1 -1
- package/dist/http/Exception.d.ts +63 -1
- package/dist/http/Exception.d.ts.map +1 -1
- package/dist/http/Exception.js +185 -48
- package/dist/http/Exception.js.map +1 -1
- package/dist/http/HttpContext.d.ts +53 -7
- package/dist/http/HttpContext.d.ts.map +1 -1
- package/dist/http/HttpContext.js +56 -15
- package/dist/http/HttpContext.js.map +1 -1
- package/dist/http/RedirectBuilder.d.ts.map +1 -1
- package/dist/http/RedirectBuilder.js +4 -1
- package/dist/http/RedirectBuilder.js.map +1 -1
- package/dist/http/Request.d.ts +141 -10
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +244 -34
- package/dist/http/Request.js.map +1 -1
- package/dist/http/Response.d.ts +176 -9
- package/dist/http/Response.d.ts.map +1 -1
- package/dist/http/Response.js +404 -16
- package/dist/http/Response.js.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware/Pipeline.d.ts +29 -8
- package/dist/middleware/Pipeline.d.ts.map +1 -1
- package/dist/middleware/Pipeline.js +40 -2
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/openapi/OpenApiProvider.js +4 -4
- package/dist/openapi/OpenApiProvider.js.map +1 -1
- package/dist/router/Router.d.ts +223 -31
- package/dist/router/Router.d.ts.map +1 -1
- package/dist/router/Router.js +520 -102
- package/dist/router/Router.js.map +1 -1
- package/dist/rpc/RpcProvider.d.ts +1 -0
- package/dist/rpc/RpcProvider.d.ts.map +1 -1
- package/dist/rpc/RpcProvider.js +7 -3
- package/dist/rpc/RpcProvider.js.map +1 -1
- package/dist/rpc/RpcRouter.d.ts +2 -2
- package/dist/rpc/RpcRouter.d.ts.map +1 -1
- package/dist/rpc/RpcRouter.js +17 -5
- package/dist/rpc/RpcRouter.js.map +1 -1
- package/dist/scheduler/ScheduleProvider.d.ts.map +1 -1
- package/dist/scheduler/ScheduleProvider.js +7 -15
- package/dist/scheduler/ScheduleProvider.js.map +1 -1
- package/dist/server/Server.d.ts +17 -4
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js +41 -7
- package/dist/server/Server.js.map +1 -1
- package/dist/services/app.d.ts +1 -1
- package/dist/services/app.js +1 -1
- package/dist/services/console.d.ts +21 -0
- package/dist/services/console.d.ts.map +1 -0
- package/dist/services/console.js +35 -0
- package/dist/services/console.js.map +1 -0
- package/dist/session/SessionMiddleware.js +3 -3
- package/dist/session/SessionMiddleware.js.map +1 -1
- package/dist/storage/StaticProvider.js +1 -1
- package/dist/storage/StaticProvider.js.map +1 -1
- package/dist/testing/ApiResponse.d.ts +218 -0
- package/dist/testing/ApiResponse.d.ts.map +1 -0
- package/dist/testing/ApiResponse.js +576 -0
- package/dist/testing/ApiResponse.js.map +1 -0
- package/dist/testing/RequestBuilder.d.ts +155 -35
- package/dist/testing/RequestBuilder.d.ts.map +1 -1
- package/dist/testing/RequestBuilder.js +455 -109
- package/dist/testing/RequestBuilder.js.map +1 -1
- package/dist/testing/TestClient.d.ts +53 -37
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +84 -52
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/utils/Macroable.d.ts +30 -0
- package/dist/utils/Macroable.d.ts.map +1 -0
- package/dist/utils/Macroable.js +43 -0
- package/dist/utils/Macroable.js.map +1 -0
- package/dist/utils/inflect.d.ts +17 -0
- package/dist/utils/inflect.d.ts.map +1 -0
- package/dist/utils/inflect.js +32 -0
- package/dist/utils/inflect.js.map +1 -0
- package/dist/utils/objectPath.d.ts +57 -0
- package/dist/utils/objectPath.d.ts.map +1 -0
- package/dist/utils/objectPath.js +141 -0
- package/dist/utils/objectPath.js.map +1 -0
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +20 -2
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/ConfigLoader.ts +72 -9
- package/src/HttpKernel.ts +53 -15
- package/src/Ignitor.ts +364 -45
- package/src/console/BaseCommand.ts +467 -0
- package/src/console/Console.ts +174 -0
- package/src/console/ExceptionHandler.ts +91 -0
- package/src/console/HelpCommand.ts +37 -0
- package/src/console/IndexGenerator.ts +79 -0
- package/src/console/Kernel.ts +1382 -0
- package/src/console/ListCommand.ts +55 -0
- package/src/console/assertions.ts +114 -0
- package/src/console/cliui.ts +756 -0
- package/src/console/decorators.ts +199 -0
- package/src/console/index.ts +67 -0
- package/src/console/loaders.ts +145 -0
- package/src/console/parser.ts +598 -0
- package/src/console/prompts.ts +548 -0
- package/src/console/tracing.ts +22 -0
- package/src/console/types.ts +280 -0
- package/src/console/ui.ts +37 -0
- package/src/console/utils.ts +69 -0
- package/src/container/Container.ts +198 -72
- package/src/container/types.ts +15 -2
- package/src/decorators/Service.ts +28 -3
- package/src/env/Env.ts +49 -5
- package/src/env/Secret.ts +41 -0
- package/src/env/interpolate.ts +54 -0
- package/src/env/loadEnvFiles.ts +12 -4
- package/src/env/schema.ts +109 -35
- package/src/errors/ReamError.ts +31 -0
- package/src/errors/prettyPrintError.ts +20 -0
- package/src/events/Emitter.ts +2 -2
- package/src/events/EventsProvider.ts +5 -5
- package/src/graphql/GraphQLEngine.ts +4 -4
- package/src/graphql/GraphQLProvider.ts +7 -3
- package/src/http/Exception.ts +214 -37
- package/src/http/HttpContext.ts +87 -18
- package/src/http/RedirectBuilder.ts +4 -1
- package/src/http/Request.ts +264 -34
- package/src/http/Response.ts +478 -27
- package/src/index.ts +41 -6
- package/src/middleware/Pipeline.ts +77 -6
- package/src/openapi/OpenApiProvider.ts +4 -4
- package/src/router/Router.ts +631 -113
- package/src/rpc/RpcProvider.ts +6 -2
- package/src/rpc/RpcRouter.ts +22 -7
- package/src/scheduler/ScheduleProvider.ts +7 -15
- package/src/server/Server.ts +49 -10
- package/src/services/app.ts +1 -1
- package/src/services/console.ts +42 -0
- package/src/session/SessionMiddleware.ts +4 -4
- package/src/storage/StaticProvider.ts +1 -1
- package/src/testing/ApiResponse.ts +691 -0
- package/src/testing/RequestBuilder.ts +577 -137
- package/src/testing/TestClient.ts +110 -77
- package/src/utils/Macroable.ts +54 -0
- package/src/utils/inflect.ts +29 -0
- package/src/utils/objectPath.ts +142 -0
- package/dist/console/CommandRunner.d.ts +0 -18
- package/dist/console/CommandRunner.d.ts.map +0 -1
- package/dist/console/CommandRunner.js +0 -65
- package/dist/console/CommandRunner.js.map +0 -1
- package/dist/decorators/Lazy.d.ts +0 -19
- package/dist/decorators/Lazy.d.ts.map +0 -1
- package/dist/decorators/Lazy.js +0 -53
- package/dist/decorators/Lazy.js.map +0 -1
- package/src/console/CommandRunner.ts +0 -82
- package/src/decorators/Lazy.ts +0 -57
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console kernel — registers commands and dispatches argv against them.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the previous `CommandRunner`, which parsed argv without knowing the
|
|
5
|
+
* commands' declared inputs and therefore could not support `--flag value`,
|
|
6
|
+
* aliases, negation, typed flags, per-command help or required-input checks.
|
|
7
|
+
*
|
|
8
|
+
* The kernel accepts any class exposing the static contract in `types.ts` —
|
|
9
|
+
* extending `BaseCommand` is optional, which is what keeps agnostic packages
|
|
10
|
+
* free of a `@c9up/ream` dependency.
|
|
11
|
+
*/
|
|
12
|
+
import type { Application } from '../Application.js';
|
|
13
|
+
import { type Logger, Ui } from './cliui.js';
|
|
14
|
+
import { Prompt } from './prompts.js';
|
|
15
|
+
import { type CommandClass, type CommandInstance, type ExecutedCommand, type FlagMetaData, type ParsedInput, type SerializedCommand } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Called when a global flag was passed to the command invoked from the command
|
|
18
|
+
* line. Returning `true` stops the dispatch before the command runs.
|
|
19
|
+
*/
|
|
20
|
+
/** The kernel's lifecycle stage — Console `getState()`. */
|
|
21
|
+
export type KernelState = 'idle' | 'booted' | 'running' | 'completed';
|
|
22
|
+
/**
|
|
23
|
+
* A source of commands (Console `LoadersContract`).
|
|
24
|
+
*
|
|
25
|
+
* Two steps, as in Console: the metadata of everything it offers, then the class
|
|
26
|
+
* for one of them — a loader that reads a directory can answer the first from
|
|
27
|
+
* a manifest without importing anything.
|
|
28
|
+
*/
|
|
29
|
+
export interface CommandLoader {
|
|
30
|
+
getMetaData(): Promise<SerializedCommand[]>;
|
|
31
|
+
getCommand(metadata: SerializedCommand): Promise<CommandClass | null>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* How a command is built and run (Console `ExecutorContract`).
|
|
35
|
+
*
|
|
36
|
+
* `create` returns the instance, ready but untouched; `run` drives its
|
|
37
|
+
* lifecycle and returns what `run()` produced.
|
|
38
|
+
*/
|
|
39
|
+
export interface CommandExecutor {
|
|
40
|
+
/**
|
|
41
|
+
* The fourth argument is Ream's: which UI the command writes through, and
|
|
42
|
+
* whether it is the one the command line invoked. An executor ported from
|
|
43
|
+
* Console simply ignores it.
|
|
44
|
+
*/
|
|
45
|
+
create(Command: CommandClass, parsed: ParsedInput, kernel: Kernel, context: {
|
|
46
|
+
isMain: boolean;
|
|
47
|
+
ui: Ui;
|
|
48
|
+
}): CommandInstance | Promise<CommandInstance>;
|
|
49
|
+
/** Runs `prepare`, `interact` and `run`, and throws what they throw. */
|
|
50
|
+
run(command: CommandInstance, kernel: Kernel): unknown;
|
|
51
|
+
}
|
|
52
|
+
/** Renders the failure of the command line (Console `ExceptionHandler`). */
|
|
53
|
+
export interface ErrorRenderer {
|
|
54
|
+
render(error: unknown, kernel: Kernel): void | Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
export type GlobalFlagListener = (command: CommandClass, kernel: Kernel, parsed: ParsedInput) => boolean | void | Promise<boolean | void>;
|
|
57
|
+
export interface KernelOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Boots the application. Called only for commands declaring
|
|
60
|
+
* `options.startApp` — a scaffolding command must not open a DB connection.
|
|
61
|
+
*/
|
|
62
|
+
startApp?: () => Promise<Application>;
|
|
63
|
+
/** Shown in usage lines. */
|
|
64
|
+
binaryName?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Shuts the application down. Handed to the command as `this.terminate()`,
|
|
67
|
+
* the only way a `staysAlive` command can end itself.
|
|
68
|
+
*/
|
|
69
|
+
onTerminate?: () => void | Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* The prompt handed to every command as `this.prompt`.
|
|
72
|
+
*
|
|
73
|
+
* Supply one to script its answers with `trap()`: without this the kernel
|
|
74
|
+
* builds its own, and a command that asks anything is untestable through
|
|
75
|
+
* `exec()` — it would reach a terminal that is not there.
|
|
76
|
+
*/
|
|
77
|
+
prompt?: Prompt;
|
|
78
|
+
}
|
|
79
|
+
export interface HandleResult {
|
|
80
|
+
/** The command asked to keep the process alive (worker, watcher…). */
|
|
81
|
+
staysAlive: boolean;
|
|
82
|
+
}
|
|
83
|
+
export declare class Kernel {
|
|
84
|
+
#private;
|
|
85
|
+
/** Shared by the kernel and every command it runs. */
|
|
86
|
+
readonly ui: Ui;
|
|
87
|
+
readonly logger: Logger;
|
|
88
|
+
/**
|
|
89
|
+
* The command a kernel runs when none is named. Replace it to ship a
|
|
90
|
+
* different landing command (Console `Kernel.defaultCommand`).
|
|
91
|
+
*/
|
|
92
|
+
static defaultCommand: CommandClass;
|
|
93
|
+
/**
|
|
94
|
+
* How a command is built and run (Console `Kernel.commandExecutor`).
|
|
95
|
+
*
|
|
96
|
+
* The seam AdonisJS itself uses to add dependency injection; Ream's default
|
|
97
|
+
* already does it — the container builds the command and invokes its hooks,
|
|
98
|
+
* so `@inject()` works on both. Replace it on a subclass to drive commands
|
|
99
|
+
* some other way.
|
|
100
|
+
*/
|
|
101
|
+
static commandExecutor: CommandExecutor;
|
|
102
|
+
/**
|
|
103
|
+
* What the CLI says about itself — binary name, versions. Printed above the
|
|
104
|
+
* command listing when it holds anything (Console `kernel.info`).
|
|
105
|
+
*/
|
|
106
|
+
readonly info: Map<string, string | number | boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Renders the failure of the command line (Console `kernel.errorHandler`).
|
|
109
|
+
*
|
|
110
|
+
* Replaceable: an application that wants its own reporting sets it here
|
|
111
|
+
* rather than wrapping `handle()`, which is what owns the process.
|
|
112
|
+
*/
|
|
113
|
+
errorHandler: ErrorRenderer;
|
|
114
|
+
/**
|
|
115
|
+
* The exit code the command line ended on (Console `kernel.exitCode`). Set once
|
|
116
|
+
* the dispatch is over: 1 for a failure, otherwise the command's own.
|
|
117
|
+
*/
|
|
118
|
+
exitCode: number | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Console's factory — `Kernel.create()` reads better than `new Kernel()`.
|
|
121
|
+
*
|
|
122
|
+
* Built through `this`, so a subclass overriding `defaultCommand` or
|
|
123
|
+
* `commandExecutor` gets its own from the factory as well as from `new`.
|
|
124
|
+
*/
|
|
125
|
+
static create<T extends typeof Kernel>(this: T, options?: KernelOptions): InstanceType<T>;
|
|
126
|
+
constructor(options?: KernelOptions);
|
|
127
|
+
/** Shown in usage lines — commands read it to print their own. */
|
|
128
|
+
get binaryName(): string;
|
|
129
|
+
/**
|
|
130
|
+
* Declare a flag every command accepts (Console `kernel.defineFlag`).
|
|
131
|
+
*
|
|
132
|
+
* Global flags steer the CLI, not the command: they are merged into the
|
|
133
|
+
* parser so no command has to redeclare them, and they are NOT assigned to
|
|
134
|
+
* the command's properties — a command reads them through `this.parsed.flags`
|
|
135
|
+
* or, more usually, does not read them at all.
|
|
136
|
+
*/
|
|
137
|
+
defineFlag(name: string, options?: Partial<FlagMetaData>): this;
|
|
138
|
+
/** The global flags — Console `kernel.flags`. */
|
|
139
|
+
get flags(): readonly FlagMetaData[];
|
|
140
|
+
/**
|
|
141
|
+
* React to a global flag (Console `kernel.on`). One listener per flag, the last
|
|
142
|
+
* one registered winning, and only for the command invoked from the command
|
|
143
|
+
* line. Returning `true` stops there, without running the command — that is
|
|
144
|
+
* how `--help` short-circuits.
|
|
145
|
+
*/
|
|
146
|
+
on(flagName: string, listener: GlobalFlagListener): this;
|
|
147
|
+
register(command: CommandClass): this;
|
|
148
|
+
registerMany(commands: Iterable<CommandClass>): this;
|
|
149
|
+
/**
|
|
150
|
+
* Register the default export of a loaded module when it is a command.
|
|
151
|
+
* Returns whether anything was registered, so the caller can report a module
|
|
152
|
+
* that exports the wrong shape instead of ignoring it.
|
|
153
|
+
*/
|
|
154
|
+
registerModule(mod: unknown): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Register a shorthand expanding to a command and, optionally, its flags —
|
|
157
|
+
* Console's `commandsAliases`. `resource` → `make:controller --resource` means
|
|
158
|
+
* `ream resource users` runs `ream make:controller --resource users`.
|
|
159
|
+
*/
|
|
160
|
+
addAlias(alias: string, expansion: string): this;
|
|
161
|
+
/**
|
|
162
|
+
* Resolve a command by name or alias — Console's `find()`.
|
|
163
|
+
*
|
|
164
|
+
* Async and throwing, as in Console: a name that resolves to nothing is a call
|
|
165
|
+
* error, and returning `undefined` pushes every caller into a check it
|
|
166
|
+
* usually forgets. `await` works even though Ream's registry answers
|
|
167
|
+
* immediately.
|
|
168
|
+
*/
|
|
169
|
+
find(name: string): Promise<CommandClass>;
|
|
170
|
+
/**
|
|
171
|
+
* Register a source of commands (Console `kernel.addLoader`).
|
|
172
|
+
*
|
|
173
|
+
* Consumed by {@link boot}, once. Unlike Console, the classes are resolved there
|
|
174
|
+
* and then rather than on first use: Ream's registry holds classes, which is
|
|
175
|
+
* what lets `find()` and `hasCommand()` answer without waiting on a loader.
|
|
176
|
+
*/
|
|
177
|
+
addLoader(loader: CommandLoader | (() => Promise<CommandLoader>)): this;
|
|
178
|
+
/**
|
|
179
|
+
* Load every registered loader's commands. Idempotent, and called by
|
|
180
|
+
* `handle()` — an application driving its own dispatch calls it itself.
|
|
181
|
+
*/
|
|
182
|
+
boot(): Promise<void>;
|
|
183
|
+
/** The kernel's lifecycle stage — Console `getState()`. */
|
|
184
|
+
getState(): KernelState;
|
|
185
|
+
/**
|
|
186
|
+
* The command run when none is named — the one this kernel was built with,
|
|
187
|
+
* or the application's replacement when it registered one under that name.
|
|
188
|
+
*/
|
|
189
|
+
getDefaultCommand(): CommandClass;
|
|
190
|
+
/** The command invoked from the command line, once it has been built. */
|
|
191
|
+
getMainCommand(): CommandInstance | undefined;
|
|
192
|
+
/** Before a command name is resolved (Console hook). */
|
|
193
|
+
finding(callback: (commandName: string) => void | Promise<void>): this;
|
|
194
|
+
/** Before a command class is read from its loader (Console hook). */
|
|
195
|
+
loading(callback: (metadata: SerializedCommand) => void | Promise<void>): this;
|
|
196
|
+
/** After a command class has been loaded (Console hook). */
|
|
197
|
+
loaded(callback: (command: CommandClass) => void | Promise<void>): this;
|
|
198
|
+
/** Before a command runs. `isMain` distinguishes the CLI dispatch. */
|
|
199
|
+
executing(callback: (command: CommandInstance, isMain: boolean) => void | Promise<void>): this;
|
|
200
|
+
/** After a command has run — not when it failed, as in Console. */
|
|
201
|
+
executed(callback: (command: CommandInstance, isMain: boolean) => void | Promise<void>): this;
|
|
202
|
+
/**
|
|
203
|
+
* The metadata of every registered command, as Console exposes it.
|
|
204
|
+
*
|
|
205
|
+
* Metadata rather than the classes themselves: this is the introspection
|
|
206
|
+
* surface (help, completions, a command palette), and handing out the
|
|
207
|
+
* constructors invites callers to instantiate a command outside the kernel,
|
|
208
|
+
* where nothing injects its dependencies or runs its lifecycle. The class is
|
|
209
|
+
* still reachable through {@link find} when a caller genuinely needs it.
|
|
210
|
+
*/
|
|
211
|
+
getCommands(): SerializedCommand[];
|
|
212
|
+
/** One command's metadata, or null — Console's `getCommand()`. */
|
|
213
|
+
getCommand(commandName: string): SerializedCommand | null;
|
|
214
|
+
/**
|
|
215
|
+
* The commands of one namespace. Called without one — or with an empty
|
|
216
|
+
* string — it answers with the commands that have no namespace at all, which
|
|
217
|
+
* is the group Console's own listing prints first.
|
|
218
|
+
*/
|
|
219
|
+
getNamespaceCommands(namespace?: string): SerializedCommand[];
|
|
220
|
+
/** Every namespace in use, sorted. */
|
|
221
|
+
getNamespaces(): string[];
|
|
222
|
+
/** Every registered alias — `static aliases` and the rc file's alike. */
|
|
223
|
+
getAliases(): string[];
|
|
224
|
+
/** The command an alias stands for, or null when the alias is unknown. */
|
|
225
|
+
getAliasCommand(alias: string): SerializedCommand | null;
|
|
226
|
+
/** Every alias pointing at this command. */
|
|
227
|
+
getCommandAliases(commandName: string): string[];
|
|
228
|
+
/**
|
|
229
|
+
* Names close enough to this one to be what the user meant — Console's
|
|
230
|
+
* suggestions. Aliases are included: they are names one can legitimately
|
|
231
|
+
* type, so a typo on one deserves the same help.
|
|
232
|
+
*/
|
|
233
|
+
getCommandSuggestions(name: string): string[];
|
|
234
|
+
getNamespaceSuggestions(name: string): string[];
|
|
235
|
+
handle(rawArgv: readonly string[], nodeArgs?: readonly string[]): Promise<HandleResult>;
|
|
236
|
+
/**
|
|
237
|
+
* Build a command, ready to run — the default executor's `create`.
|
|
238
|
+
*
|
|
239
|
+
* @internal Public only because {@link commandExecutor} is a static object
|
|
240
|
+
* and cannot reach the kernel's privates.
|
|
241
|
+
*/
|
|
242
|
+
buildCommand(Command: CommandClass, parsed: ParsedInput, context?: {
|
|
243
|
+
isMain: boolean;
|
|
244
|
+
ui: Ui;
|
|
245
|
+
}): Promise<CommandInstance>;
|
|
246
|
+
/**
|
|
247
|
+
* Run `prepare`, `interact` and `run` — the default executor's `run`.
|
|
248
|
+
*
|
|
249
|
+
* `completed` is deliberately NOT here: it must run even when this throws,
|
|
250
|
+
* which is the kernel's business, not the executor's.
|
|
251
|
+
*
|
|
252
|
+
* @internal See {@link buildCommand}.
|
|
253
|
+
*/
|
|
254
|
+
runLifecycle(command: CommandInstance): Promise<unknown>;
|
|
255
|
+
/**
|
|
256
|
+
* Run a command programmatically — Console's `consoleApp.exec()`.
|
|
257
|
+
*
|
|
258
|
+
* It REJECTS when the command fails, as Console does: the error is recorded on
|
|
259
|
+
* the command (`error`, `exitCode` 1) and then rethrown, so a caller cannot
|
|
260
|
+
* mistake a failure for a success by forgetting to look. `process.exitCode`
|
|
261
|
+
* is left alone — only the command line owns that.
|
|
262
|
+
*
|
|
263
|
+
* To inspect a failing command instead of catching, build it with
|
|
264
|
+
* {@link create} and drive it yourself, or run it through `handle()` and read
|
|
265
|
+
* {@link getMainCommand}.
|
|
266
|
+
*/
|
|
267
|
+
exec(commandName: string, argv?: readonly string[], options?: {
|
|
268
|
+
ui?: Ui;
|
|
269
|
+
}): Promise<ExecutedCommand>;
|
|
270
|
+
/**
|
|
271
|
+
* Build a command instance without running it (Console `kernel.create`).
|
|
272
|
+
*
|
|
273
|
+
* Parsed, injected and hydrated — everything `exec()` does up to the
|
|
274
|
+
* lifecycle. The escape hatch for driving a command by hand: run it with
|
|
275
|
+
* `command.exec()` and inspect it whatever it does.
|
|
276
|
+
*/
|
|
277
|
+
create<T extends CommandClass>(Command: T, argv?: readonly string[]): Promise<InstanceType<T>>;
|
|
278
|
+
/** Is this name — or alias — dispatchable? Console's `consoleApp.hasCommand()`. */
|
|
279
|
+
hasCommand(name: string): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* `list` — commands grouped by namespace, as Console does.
|
|
282
|
+
*
|
|
283
|
+
* `namespaces` narrows the output to those groups; an empty list shows
|
|
284
|
+
* everything. `make` selects `make:*`, and the empty string the commands that
|
|
285
|
+
* have no namespace at all.
|
|
286
|
+
*/
|
|
287
|
+
printList(asJson?: boolean, namespaces?: readonly string[]): void;
|
|
288
|
+
/** `<command> --help` — usage, arguments and flags for one command. */
|
|
289
|
+
printCommandHelp(command: CommandClass | SerializedCommand): void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A command's metadata, whether or not it extends `BaseCommand`.
|
|
293
|
+
*
|
|
294
|
+
* A class declared structurally by an agnostic package has no `serialize()`, so
|
|
295
|
+
* the fields are read off the statics it does carry.
|
|
296
|
+
*/
|
|
297
|
+
export declare function serializeCommand(command: CommandClass): SerializedCommand;
|
|
298
|
+
//# sourceMappingURL=Kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../src/console/Kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,KAAK,MAAM,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA;AAM5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AAGnB;;;GAGG;AACH,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAA;IAC3C,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;CACtE;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,CACJ,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAA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