@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.
Files changed (302) hide show
  1. package/README.md +65 -0
  2. package/dist/ConfigLoader.d.ts +46 -5
  3. package/dist/ConfigLoader.d.ts.map +1 -1
  4. package/dist/ConfigLoader.js +60 -9
  5. package/dist/ConfigLoader.js.map +1 -1
  6. package/dist/HttpKernel.d.ts.map +1 -1
  7. package/dist/HttpKernel.js +46 -6
  8. package/dist/HttpKernel.js.map +1 -1
  9. package/dist/Ignitor.d.ts +115 -7
  10. package/dist/Ignitor.d.ts.map +1 -1
  11. package/dist/Ignitor.js +254 -40
  12. package/dist/Ignitor.js.map +1 -1
  13. package/dist/console/BaseCommand.d.ts +217 -0
  14. package/dist/console/BaseCommand.d.ts.map +1 -0
  15. package/dist/console/BaseCommand.js +340 -0
  16. package/dist/console/BaseCommand.js.map +1 -0
  17. package/dist/console/Console.d.ts +86 -0
  18. package/dist/console/Console.d.ts.map +1 -0
  19. package/dist/console/Console.js +134 -0
  20. package/dist/console/Console.js.map +1 -0
  21. package/dist/console/ExceptionHandler.d.ts +28 -0
  22. package/dist/console/ExceptionHandler.d.ts.map +1 -0
  23. package/dist/console/ExceptionHandler.js +76 -0
  24. package/dist/console/ExceptionHandler.js.map +1 -0
  25. package/dist/console/HelpCommand.d.ts +16 -0
  26. package/dist/console/HelpCommand.d.ts.map +1 -0
  27. package/dist/console/HelpCommand.js +40 -0
  28. package/dist/console/HelpCommand.js.map +1 -0
  29. package/dist/console/IndexGenerator.d.ts +24 -0
  30. package/dist/console/IndexGenerator.d.ts.map +1 -0
  31. package/dist/console/IndexGenerator.js +65 -0
  32. package/dist/console/IndexGenerator.js.map +1 -0
  33. package/dist/console/Kernel.d.ts +298 -0
  34. package/dist/console/Kernel.d.ts.map +1 -0
  35. package/dist/console/Kernel.js +1120 -0
  36. package/dist/console/Kernel.js.map +1 -0
  37. package/dist/console/ListCommand.d.ts +18 -0
  38. package/dist/console/ListCommand.d.ts.map +1 -0
  39. package/dist/console/ListCommand.js +60 -0
  40. package/dist/console/ListCommand.js.map +1 -0
  41. package/dist/console/assertions.d.ts +20 -0
  42. package/dist/console/assertions.d.ts.map +1 -0
  43. package/dist/console/assertions.js +84 -0
  44. package/dist/console/assertions.js.map +1 -0
  45. package/dist/console/cliui.d.ts +248 -0
  46. package/dist/console/cliui.d.ts.map +1 -0
  47. package/dist/console/cliui.js +587 -0
  48. package/dist/console/cliui.js.map +1 -0
  49. package/dist/console/decorators.d.ts +90 -0
  50. package/dist/console/decorators.d.ts.map +1 -0
  51. package/dist/console/decorators.js +142 -0
  52. package/dist/console/decorators.js.map +1 -0
  53. package/dist/console/index.d.ts +32 -0
  54. package/dist/console/index.d.ts.map +1 -0
  55. package/dist/console/index.js +24 -0
  56. package/dist/console/index.js.map +1 -0
  57. package/dist/console/loaders.d.ts +52 -0
  58. package/dist/console/loaders.d.ts.map +1 -0
  59. package/dist/console/loaders.js +131 -0
  60. package/dist/console/loaders.js.map +1 -0
  61. package/dist/console/parser.d.ts +86 -0
  62. package/dist/console/parser.d.ts.map +1 -0
  63. package/dist/console/parser.js +440 -0
  64. package/dist/console/parser.js.map +1 -0
  65. package/dist/console/prompts.d.ts +124 -0
  66. package/dist/console/prompts.d.ts.map +1 -0
  67. package/dist/console/prompts.js +356 -0
  68. package/dist/console/prompts.js.map +1 -0
  69. package/dist/console/tracing.d.ts +17 -0
  70. package/dist/console/tracing.d.ts.map +1 -0
  71. package/dist/console/tracing.js +11 -0
  72. package/dist/console/tracing.js.map +1 -0
  73. package/dist/console/types.d.ts +255 -0
  74. package/dist/console/types.d.ts.map +1 -0
  75. package/dist/console/types.js +25 -0
  76. package/dist/console/types.js.map +1 -0
  77. package/dist/console/ui.d.ts +20 -0
  78. package/dist/console/ui.d.ts.map +1 -0
  79. package/dist/console/ui.js +31 -0
  80. package/dist/console/ui.js.map +1 -0
  81. package/dist/console/utils.d.ts +27 -0
  82. package/dist/console/utils.d.ts.map +1 -0
  83. package/dist/console/utils.js +56 -0
  84. package/dist/console/utils.js.map +1 -0
  85. package/dist/container/Container.d.ts +23 -3
  86. package/dist/container/Container.d.ts.map +1 -1
  87. package/dist/container/Container.js +177 -70
  88. package/dist/container/Container.js.map +1 -1
  89. package/dist/container/types.d.ts +14 -2
  90. package/dist/container/types.d.ts.map +1 -1
  91. package/dist/decorators/Service.d.ts +7 -0
  92. package/dist/decorators/Service.d.ts.map +1 -1
  93. package/dist/decorators/Service.js +23 -3
  94. package/dist/decorators/Service.js.map +1 -1
  95. package/dist/env/Env.d.ts +29 -4
  96. package/dist/env/Env.d.ts.map +1 -1
  97. package/dist/env/Env.js +27 -4
  98. package/dist/env/Env.js.map +1 -1
  99. package/dist/env/Secret.d.ts +11 -0
  100. package/dist/env/Secret.d.ts.map +1 -0
  101. package/dist/env/Secret.js +36 -0
  102. package/dist/env/Secret.js.map +1 -0
  103. package/dist/env/interpolate.d.ts +26 -0
  104. package/dist/env/interpolate.d.ts.map +1 -0
  105. package/dist/env/interpolate.js +48 -0
  106. package/dist/env/interpolate.js.map +1 -0
  107. package/dist/env/loadEnvFiles.d.ts.map +1 -1
  108. package/dist/env/loadEnvFiles.js +14 -4
  109. package/dist/env/loadEnvFiles.js.map +1 -1
  110. package/dist/env/schema.d.ts +23 -6
  111. package/dist/env/schema.d.ts.map +1 -1
  112. package/dist/env/schema.js +67 -33
  113. package/dist/env/schema.js.map +1 -1
  114. package/dist/errors/ReamError.d.ts +25 -0
  115. package/dist/errors/ReamError.d.ts.map +1 -1
  116. package/dist/errors/ReamError.js +5 -0
  117. package/dist/errors/ReamError.js.map +1 -1
  118. package/dist/errors/prettyPrintError.d.ts +9 -0
  119. package/dist/errors/prettyPrintError.d.ts.map +1 -0
  120. package/dist/errors/prettyPrintError.js +22 -0
  121. package/dist/errors/prettyPrintError.js.map +1 -0
  122. package/dist/events/Emitter.d.ts +1 -1
  123. package/dist/events/Emitter.d.ts.map +1 -1
  124. package/dist/events/Emitter.js +1 -1
  125. package/dist/events/Emitter.js.map +1 -1
  126. package/dist/events/EventsProvider.d.ts +2 -2
  127. package/dist/events/EventsProvider.d.ts.map +1 -1
  128. package/dist/events/EventsProvider.js +3 -3
  129. package/dist/events/EventsProvider.js.map +1 -1
  130. package/dist/graphql/GraphQLEngine.d.ts +1 -1
  131. package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
  132. package/dist/graphql/GraphQLEngine.js +2 -2
  133. package/dist/graphql/GraphQLEngine.js.map +1 -1
  134. package/dist/graphql/GraphQLProvider.d.ts.map +1 -1
  135. package/dist/graphql/GraphQLProvider.js +7 -3
  136. package/dist/graphql/GraphQLProvider.js.map +1 -1
  137. package/dist/http/Exception.d.ts +63 -1
  138. package/dist/http/Exception.d.ts.map +1 -1
  139. package/dist/http/Exception.js +185 -48
  140. package/dist/http/Exception.js.map +1 -1
  141. package/dist/http/HttpContext.d.ts +53 -7
  142. package/dist/http/HttpContext.d.ts.map +1 -1
  143. package/dist/http/HttpContext.js +56 -15
  144. package/dist/http/HttpContext.js.map +1 -1
  145. package/dist/http/RedirectBuilder.d.ts.map +1 -1
  146. package/dist/http/RedirectBuilder.js +4 -1
  147. package/dist/http/RedirectBuilder.js.map +1 -1
  148. package/dist/http/Request.d.ts +141 -10
  149. package/dist/http/Request.d.ts.map +1 -1
  150. package/dist/http/Request.js +244 -34
  151. package/dist/http/Request.js.map +1 -1
  152. package/dist/http/Response.d.ts +176 -9
  153. package/dist/http/Response.d.ts.map +1 -1
  154. package/dist/http/Response.js +404 -16
  155. package/dist/http/Response.js.map +1 -1
  156. package/dist/index.d.ts +19 -8
  157. package/dist/index.d.ts.map +1 -1
  158. package/dist/index.js +20 -5
  159. package/dist/index.js.map +1 -1
  160. package/dist/middleware/Pipeline.d.ts +29 -8
  161. package/dist/middleware/Pipeline.d.ts.map +1 -1
  162. package/dist/middleware/Pipeline.js +40 -2
  163. package/dist/middleware/Pipeline.js.map +1 -1
  164. package/dist/openapi/OpenApiProvider.js +4 -4
  165. package/dist/openapi/OpenApiProvider.js.map +1 -1
  166. package/dist/router/Router.d.ts +223 -31
  167. package/dist/router/Router.d.ts.map +1 -1
  168. package/dist/router/Router.js +520 -102
  169. package/dist/router/Router.js.map +1 -1
  170. package/dist/rpc/RpcProvider.d.ts +1 -0
  171. package/dist/rpc/RpcProvider.d.ts.map +1 -1
  172. package/dist/rpc/RpcProvider.js +7 -3
  173. package/dist/rpc/RpcProvider.js.map +1 -1
  174. package/dist/rpc/RpcRouter.d.ts +2 -2
  175. package/dist/rpc/RpcRouter.d.ts.map +1 -1
  176. package/dist/rpc/RpcRouter.js +17 -5
  177. package/dist/rpc/RpcRouter.js.map +1 -1
  178. package/dist/scheduler/ScheduleProvider.d.ts.map +1 -1
  179. package/dist/scheduler/ScheduleProvider.js +7 -15
  180. package/dist/scheduler/ScheduleProvider.js.map +1 -1
  181. package/dist/server/Server.d.ts +17 -4
  182. package/dist/server/Server.d.ts.map +1 -1
  183. package/dist/server/Server.js +41 -7
  184. package/dist/server/Server.js.map +1 -1
  185. package/dist/services/app.d.ts +1 -1
  186. package/dist/services/app.js +1 -1
  187. package/dist/services/console.d.ts +21 -0
  188. package/dist/services/console.d.ts.map +1 -0
  189. package/dist/services/console.js +35 -0
  190. package/dist/services/console.js.map +1 -0
  191. package/dist/session/SessionMiddleware.js +3 -3
  192. package/dist/session/SessionMiddleware.js.map +1 -1
  193. package/dist/storage/StaticProvider.js +1 -1
  194. package/dist/storage/StaticProvider.js.map +1 -1
  195. package/dist/testing/ApiResponse.d.ts +218 -0
  196. package/dist/testing/ApiResponse.d.ts.map +1 -0
  197. package/dist/testing/ApiResponse.js +576 -0
  198. package/dist/testing/ApiResponse.js.map +1 -0
  199. package/dist/testing/RequestBuilder.d.ts +155 -35
  200. package/dist/testing/RequestBuilder.d.ts.map +1 -1
  201. package/dist/testing/RequestBuilder.js +455 -109
  202. package/dist/testing/RequestBuilder.js.map +1 -1
  203. package/dist/testing/TestClient.d.ts +53 -37
  204. package/dist/testing/TestClient.d.ts.map +1 -1
  205. package/dist/testing/TestClient.js +84 -52
  206. package/dist/testing/TestClient.js.map +1 -1
  207. package/dist/utils/Macroable.d.ts +30 -0
  208. package/dist/utils/Macroable.d.ts.map +1 -0
  209. package/dist/utils/Macroable.js +43 -0
  210. package/dist/utils/Macroable.js.map +1 -0
  211. package/dist/utils/inflect.d.ts +17 -0
  212. package/dist/utils/inflect.d.ts.map +1 -0
  213. package/dist/utils/inflect.js +32 -0
  214. package/dist/utils/inflect.js.map +1 -0
  215. package/dist/utils/objectPath.d.ts +57 -0
  216. package/dist/utils/objectPath.d.ts.map +1 -0
  217. package/dist/utils/objectPath.js +141 -0
  218. package/dist/utils/objectPath.js.map +1 -0
  219. package/events.darwin-arm64.node +0 -0
  220. package/events.darwin-x64.node +0 -0
  221. package/events.linux-arm64-gnu.node +0 -0
  222. package/events.linux-x64-gnu.node +0 -0
  223. package/events.win32-x64-msvc.node +0 -0
  224. package/index.darwin-arm64.node +0 -0
  225. package/index.darwin-x64.node +0 -0
  226. package/index.linux-arm64-gnu.node +0 -0
  227. package/index.linux-x64-gnu.node +0 -0
  228. package/index.win32-x64-msvc.node +0 -0
  229. package/package.json +20 -2
  230. package/scheduler.darwin-arm64.node +0 -0
  231. package/scheduler.darwin-x64.node +0 -0
  232. package/scheduler.linux-arm64-gnu.node +0 -0
  233. package/scheduler.linux-x64-gnu.node +0 -0
  234. package/scheduler.win32-x64-msvc.node +0 -0
  235. package/src/ConfigLoader.ts +72 -9
  236. package/src/HttpKernel.ts +53 -15
  237. package/src/Ignitor.ts +364 -45
  238. package/src/console/BaseCommand.ts +467 -0
  239. package/src/console/Console.ts +174 -0
  240. package/src/console/ExceptionHandler.ts +91 -0
  241. package/src/console/HelpCommand.ts +37 -0
  242. package/src/console/IndexGenerator.ts +79 -0
  243. package/src/console/Kernel.ts +1382 -0
  244. package/src/console/ListCommand.ts +55 -0
  245. package/src/console/assertions.ts +114 -0
  246. package/src/console/cliui.ts +756 -0
  247. package/src/console/decorators.ts +199 -0
  248. package/src/console/index.ts +67 -0
  249. package/src/console/loaders.ts +145 -0
  250. package/src/console/parser.ts +598 -0
  251. package/src/console/prompts.ts +548 -0
  252. package/src/console/tracing.ts +22 -0
  253. package/src/console/types.ts +280 -0
  254. package/src/console/ui.ts +37 -0
  255. package/src/console/utils.ts +69 -0
  256. package/src/container/Container.ts +198 -72
  257. package/src/container/types.ts +15 -2
  258. package/src/decorators/Service.ts +28 -3
  259. package/src/env/Env.ts +49 -5
  260. package/src/env/Secret.ts +41 -0
  261. package/src/env/interpolate.ts +54 -0
  262. package/src/env/loadEnvFiles.ts +12 -4
  263. package/src/env/schema.ts +109 -35
  264. package/src/errors/ReamError.ts +31 -0
  265. package/src/errors/prettyPrintError.ts +20 -0
  266. package/src/events/Emitter.ts +2 -2
  267. package/src/events/EventsProvider.ts +5 -5
  268. package/src/graphql/GraphQLEngine.ts +4 -4
  269. package/src/graphql/GraphQLProvider.ts +7 -3
  270. package/src/http/Exception.ts +214 -37
  271. package/src/http/HttpContext.ts +87 -18
  272. package/src/http/RedirectBuilder.ts +4 -1
  273. package/src/http/Request.ts +264 -34
  274. package/src/http/Response.ts +478 -27
  275. package/src/index.ts +41 -6
  276. package/src/middleware/Pipeline.ts +77 -6
  277. package/src/openapi/OpenApiProvider.ts +4 -4
  278. package/src/router/Router.ts +631 -113
  279. package/src/rpc/RpcProvider.ts +6 -2
  280. package/src/rpc/RpcRouter.ts +22 -7
  281. package/src/scheduler/ScheduleProvider.ts +7 -15
  282. package/src/server/Server.ts +49 -10
  283. package/src/services/app.ts +1 -1
  284. package/src/services/console.ts +42 -0
  285. package/src/session/SessionMiddleware.ts +4 -4
  286. package/src/storage/StaticProvider.ts +1 -1
  287. package/src/testing/ApiResponse.ts +691 -0
  288. package/src/testing/RequestBuilder.ts +577 -137
  289. package/src/testing/TestClient.ts +110 -77
  290. package/src/utils/Macroable.ts +54 -0
  291. package/src/utils/inflect.ts +29 -0
  292. package/src/utils/objectPath.ts +142 -0
  293. package/dist/console/CommandRunner.d.ts +0 -18
  294. package/dist/console/CommandRunner.d.ts.map +0 -1
  295. package/dist/console/CommandRunner.js +0 -65
  296. package/dist/console/CommandRunner.js.map +0 -1
  297. package/dist/decorators/Lazy.d.ts +0 -19
  298. package/dist/decorators/Lazy.d.ts.map +0 -1
  299. package/dist/decorators/Lazy.js +0 -53
  300. package/dist/decorators/Lazy.js.map +0 -1
  301. package/src/console/CommandRunner.ts +0 -82
  302. 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,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,EAAE,CAAA;KAAE,GACnC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,wEAAwE;IACxE,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GA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