@pristine-ts/cli 1.0.440 → 2.0.2

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 (220) hide show
  1. package/dist/bin/pristine.cjs +7 -0
  2. package/dist/lib/cjs/bin.js +15 -1
  3. package/dist/lib/cjs/bin.js.map +1 -1
  4. package/dist/lib/cjs/bootstrap/app-module-loader.js +321 -0
  5. package/dist/lib/cjs/bootstrap/app-module-loader.js.map +1 -0
  6. package/dist/lib/cjs/bootstrap/bootstrap.js +31 -0
  7. package/dist/lib/cjs/bootstrap/bootstrap.js.map +1 -0
  8. package/dist/lib/cjs/bootstrap/build-manifest-checker.js +67 -0
  9. package/dist/lib/cjs/bootstrap/build-manifest-checker.js.map +1 -0
  10. package/dist/lib/cjs/bootstrap/build-manifest-reader.js +44 -0
  11. package/dist/lib/cjs/bootstrap/build-manifest-reader.js.map +1 -0
  12. package/dist/lib/cjs/bootstrap/build-manifest-staleness.enum.js +23 -0
  13. package/dist/lib/cjs/bootstrap/build-manifest-staleness.enum.js.map +1 -0
  14. package/dist/lib/cjs/bootstrap/build-manifest-writer.js +55 -0
  15. package/dist/lib/cjs/bootstrap/build-manifest-writer.js.map +1 -0
  16. package/dist/lib/cjs/bootstrap/build-manifest.js +31 -0
  17. package/dist/lib/cjs/bootstrap/build-manifest.js.map +1 -0
  18. package/dist/lib/cjs/bootstrap/build-runner.js +44 -0
  19. package/dist/lib/cjs/bootstrap/build-runner.js.map +1 -0
  20. package/dist/lib/cjs/bootstrap/build-staleness-prompt.js +90 -0
  21. package/dist/lib/cjs/bootstrap/build-staleness-prompt.js.map +1 -0
  22. package/dist/lib/cjs/bootstrap/dynamic-importer.js +43 -0
  23. package/dist/lib/cjs/bootstrap/dynamic-importer.js.map +1 -0
  24. package/dist/lib/cjs/bootstrap/init-prompt.js +127 -0
  25. package/dist/lib/cjs/bootstrap/init-prompt.js.map +1 -0
  26. package/dist/lib/cjs/bootstrap/loaded-app-module.js +29 -0
  27. package/dist/lib/cjs/bootstrap/loaded-app-module.js.map +1 -0
  28. package/dist/lib/cjs/bootstrap/loaded-plugin.js +22 -0
  29. package/dist/lib/cjs/bootstrap/loaded-plugin.js.map +1 -0
  30. package/dist/lib/cjs/bootstrap/plugin-loader.js +149 -0
  31. package/dist/lib/cjs/bootstrap/plugin-loader.js.map +1 -0
  32. package/dist/lib/cjs/bootstrap/source-hasher.js +41 -0
  33. package/dist/lib/cjs/bootstrap/source-hasher.js.map +1 -0
  34. package/dist/lib/cjs/cli.js +94 -111
  35. package/dist/lib/cjs/cli.js.map +1 -1
  36. package/dist/lib/cjs/cli.module.js +9 -1
  37. package/dist/lib/cjs/cli.module.js.map +1 -1
  38. package/dist/lib/cjs/commands/build-alias.command.js +50 -0
  39. package/dist/lib/cjs/commands/build-alias.command.js.map +1 -0
  40. package/dist/lib/cjs/commands/build.command.js +173 -0
  41. package/dist/lib/cjs/commands/build.command.js.map +1 -0
  42. package/dist/lib/cjs/commands/commands.js +15 -0
  43. package/dist/lib/cjs/commands/commands.js.map +1 -1
  44. package/dist/lib/cjs/commands/config-print.command.js +75 -0
  45. package/dist/lib/cjs/commands/config-print.command.js.map +1 -0
  46. package/dist/lib/cjs/commands/help-alias.command.js +52 -0
  47. package/dist/lib/cjs/commands/help-alias.command.js.map +1 -0
  48. package/dist/lib/cjs/commands/help.command.js +44 -10
  49. package/dist/lib/cjs/commands/help.command.js.map +1 -1
  50. package/dist/lib/cjs/commands/info-alias.command.js +50 -0
  51. package/dist/lib/cjs/commands/info-alias.command.js.map +1 -0
  52. package/dist/lib/cjs/commands/info.command.js +162 -0
  53. package/dist/lib/cjs/commands/info.command.js.map +1 -0
  54. package/dist/lib/cjs/commands/init-alias.command.js +51 -0
  55. package/dist/lib/cjs/commands/init-alias.command.js.map +1 -0
  56. package/dist/lib/cjs/commands/init.command-options.js +53 -0
  57. package/dist/lib/cjs/commands/init.command-options.js.map +1 -0
  58. package/dist/lib/cjs/commands/init.command.js +249 -0
  59. package/dist/lib/cjs/commands/init.command.js.map +1 -0
  60. package/dist/lib/cjs/commands/list-alias.command.js +50 -0
  61. package/dist/lib/cjs/commands/list-alias.command.js.map +1 -0
  62. package/dist/lib/cjs/commands/list.command.js +7 -1
  63. package/dist/lib/cjs/commands/list.command.js.map +1 -1
  64. package/dist/lib/cjs/commands/start-alias.command.js +51 -0
  65. package/dist/lib/cjs/commands/start-alias.command.js.map +1 -0
  66. package/dist/lib/cjs/commands/start.command-options.js +34 -0
  67. package/dist/lib/cjs/commands/start.command-options.js.map +1 -0
  68. package/dist/lib/cjs/commands/start.command.js +169 -0
  69. package/dist/lib/cjs/commands/start.command.js.map +1 -0
  70. package/dist/lib/cjs/commands/verify-alias.command.js +50 -0
  71. package/dist/lib/cjs/commands/verify-alias.command.js.map +1 -0
  72. package/dist/lib/cjs/commands/verify.command.js +71 -0
  73. package/dist/lib/cjs/commands/verify.command.js.map +1 -0
  74. package/dist/lib/cjs/config/config-loader.js +136 -0
  75. package/dist/lib/cjs/config/config-loader.js.map +1 -0
  76. package/dist/lib/cjs/config/config-provenance.enum.js +15 -0
  77. package/dist/lib/cjs/config/config-provenance.enum.js.map +1 -0
  78. package/dist/lib/cjs/config/config.js +22 -0
  79. package/dist/lib/cjs/config/config.js.map +1 -0
  80. package/dist/lib/cjs/config/define-config.js +18 -0
  81. package/dist/lib/cjs/config/define-config.js.map +1 -0
  82. package/dist/lib/cjs/config/pristine-config.interface.js +3 -0
  83. package/dist/lib/cjs/config/pristine-config.interface.js.map +1 -0
  84. package/dist/lib/cjs/config/resolved-pristine-config.js +25 -0
  85. package/dist/lib/cjs/config/resolved-pristine-config.js.map +1 -0
  86. package/dist/lib/cjs/event-handlers/cli.event-handler.js +69 -48
  87. package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
  88. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  89. package/dist/lib/esm/bin.js +15 -1
  90. package/dist/lib/esm/bin.js.map +1 -1
  91. package/dist/lib/esm/bootstrap/app-module-loader.js +315 -0
  92. package/dist/lib/esm/bootstrap/app-module-loader.js.map +1 -0
  93. package/dist/lib/esm/bootstrap/bootstrap.js +15 -0
  94. package/dist/lib/esm/bootstrap/bootstrap.js.map +1 -0
  95. package/dist/lib/esm/bootstrap/build-manifest-checker.js +61 -0
  96. package/dist/lib/esm/bootstrap/build-manifest-checker.js.map +1 -0
  97. package/dist/lib/esm/bootstrap/build-manifest-reader.js +38 -0
  98. package/dist/lib/esm/bootstrap/build-manifest-reader.js.map +1 -0
  99. package/dist/lib/esm/bootstrap/build-manifest-staleness.enum.js +20 -0
  100. package/dist/lib/esm/bootstrap/build-manifest-staleness.enum.js.map +1 -0
  101. package/dist/lib/esm/bootstrap/build-manifest-writer.js +49 -0
  102. package/dist/lib/esm/bootstrap/build-manifest-writer.js.map +1 -0
  103. package/dist/lib/esm/bootstrap/build-manifest.js +27 -0
  104. package/dist/lib/esm/bootstrap/build-manifest.js.map +1 -0
  105. package/dist/lib/esm/bootstrap/build-runner.js +41 -0
  106. package/dist/lib/esm/bootstrap/build-runner.js.map +1 -0
  107. package/dist/lib/esm/bootstrap/build-staleness-prompt.js +87 -0
  108. package/dist/lib/esm/bootstrap/build-staleness-prompt.js.map +1 -0
  109. package/dist/lib/esm/bootstrap/dynamic-importer.js +40 -0
  110. package/dist/lib/esm/bootstrap/dynamic-importer.js.map +1 -0
  111. package/dist/lib/esm/bootstrap/init-prompt.js +124 -0
  112. package/dist/lib/esm/bootstrap/init-prompt.js.map +1 -0
  113. package/dist/lib/esm/bootstrap/loaded-app-module.js +25 -0
  114. package/dist/lib/esm/bootstrap/loaded-app-module.js.map +1 -0
  115. package/dist/lib/esm/bootstrap/loaded-plugin.js +18 -0
  116. package/dist/lib/esm/bootstrap/loaded-plugin.js.map +1 -0
  117. package/dist/lib/esm/bootstrap/plugin-loader.js +143 -0
  118. package/dist/lib/esm/bootstrap/plugin-loader.js.map +1 -0
  119. package/dist/lib/esm/bootstrap/source-hasher.js +35 -0
  120. package/dist/lib/esm/bootstrap/source-hasher.js.map +1 -0
  121. package/dist/lib/esm/cli.js +109 -0
  122. package/dist/lib/esm/cli.js.map +1 -0
  123. package/dist/lib/esm/cli.module.js +7 -0
  124. package/dist/lib/esm/cli.module.js.map +1 -1
  125. package/dist/lib/esm/commands/build-alias.command.js +47 -0
  126. package/dist/lib/esm/commands/build-alias.command.js.map +1 -0
  127. package/dist/lib/esm/commands/build.command.js +167 -0
  128. package/dist/lib/esm/commands/build.command.js.map +1 -0
  129. package/dist/lib/esm/commands/commands.js +15 -0
  130. package/dist/lib/esm/commands/commands.js.map +1 -1
  131. package/dist/lib/esm/commands/config-print.command.js +69 -0
  132. package/dist/lib/esm/commands/config-print.command.js.map +1 -0
  133. package/dist/lib/esm/commands/help-alias.command.js +49 -0
  134. package/dist/lib/esm/commands/help-alias.command.js.map +1 -0
  135. package/dist/lib/esm/commands/help.command.js +44 -10
  136. package/dist/lib/esm/commands/help.command.js.map +1 -1
  137. package/dist/lib/esm/commands/info-alias.command.js +47 -0
  138. package/dist/lib/esm/commands/info-alias.command.js.map +1 -0
  139. package/dist/lib/esm/commands/info.command.js +156 -0
  140. package/dist/lib/esm/commands/info.command.js.map +1 -0
  141. package/dist/lib/esm/commands/init-alias.command.js +48 -0
  142. package/dist/lib/esm/commands/init-alias.command.js.map +1 -0
  143. package/dist/lib/esm/commands/init.command-options.js +49 -0
  144. package/dist/lib/esm/commands/init.command-options.js.map +1 -0
  145. package/dist/lib/esm/commands/init.command.js +243 -0
  146. package/dist/lib/esm/commands/init.command.js.map +1 -0
  147. package/dist/lib/esm/commands/list-alias.command.js +47 -0
  148. package/dist/lib/esm/commands/list-alias.command.js.map +1 -0
  149. package/dist/lib/esm/commands/list.command.js +8 -2
  150. package/dist/lib/esm/commands/list.command.js.map +1 -1
  151. package/dist/lib/esm/commands/start-alias.command.js +48 -0
  152. package/dist/lib/esm/commands/start-alias.command.js.map +1 -0
  153. package/dist/lib/esm/commands/start.command-options.js +30 -0
  154. package/dist/lib/esm/commands/start.command-options.js.map +1 -0
  155. package/dist/lib/esm/commands/start.command.js +166 -0
  156. package/dist/lib/esm/commands/start.command.js.map +1 -0
  157. package/dist/lib/esm/commands/verify-alias.command.js +47 -0
  158. package/dist/lib/esm/commands/verify-alias.command.js.map +1 -0
  159. package/dist/lib/esm/commands/verify.command.js +68 -0
  160. package/dist/lib/esm/commands/verify.command.js.map +1 -0
  161. package/dist/lib/esm/config/config-loader.js +130 -0
  162. package/dist/lib/esm/config/config-loader.js.map +1 -0
  163. package/dist/lib/esm/config/config-provenance.enum.js +12 -0
  164. package/dist/lib/esm/config/config-provenance.enum.js.map +1 -0
  165. package/dist/lib/esm/config/config.js +6 -0
  166. package/dist/lib/esm/config/config.js.map +1 -0
  167. package/dist/lib/esm/config/define-config.js +14 -0
  168. package/dist/lib/esm/config/define-config.js.map +1 -0
  169. package/dist/lib/esm/config/pristine-config.interface.js +2 -0
  170. package/dist/lib/esm/config/pristine-config.interface.js.map +1 -0
  171. package/dist/lib/esm/config/resolved-pristine-config.js +21 -0
  172. package/dist/lib/esm/config/resolved-pristine-config.js.map +1 -0
  173. package/dist/lib/esm/event-handlers/cli.event-handler.js +69 -48
  174. package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
  175. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -0
  176. package/dist/types/bootstrap/app-module-loader.d.ts +83 -0
  177. package/dist/types/bootstrap/bootstrap.d.ts +14 -0
  178. package/dist/types/bootstrap/build-manifest-checker.d.ts +19 -0
  179. package/dist/types/bootstrap/build-manifest-reader.d.ts +14 -0
  180. package/dist/types/bootstrap/build-manifest-staleness.enum.d.ts +18 -0
  181. package/dist/types/bootstrap/build-manifest-writer.d.ts +19 -0
  182. package/dist/types/bootstrap/build-manifest.d.ts +29 -0
  183. package/dist/types/bootstrap/build-runner.d.ts +16 -0
  184. package/dist/types/bootstrap/build-staleness-prompt.d.ts +27 -0
  185. package/dist/types/bootstrap/dynamic-importer.d.ts +13 -0
  186. package/dist/types/bootstrap/init-prompt.d.ts +38 -0
  187. package/dist/types/bootstrap/loaded-app-module.d.ts +40 -0
  188. package/dist/types/bootstrap/loaded-plugin.d.ts +20 -0
  189. package/dist/types/bootstrap/plugin-loader.d.ts +35 -0
  190. package/dist/types/bootstrap/source-hasher.d.ts +15 -0
  191. package/dist/types/cli.d.ts +12 -0
  192. package/dist/types/cli.module.d.ts +3 -0
  193. package/dist/types/commands/build-alias.command.d.ts +15 -0
  194. package/dist/types/commands/build.command.d.ts +47 -0
  195. package/dist/types/commands/commands.d.ts +15 -0
  196. package/dist/types/commands/config-print.command.d.ts +18 -0
  197. package/dist/types/commands/help-alias.command.d.ts +17 -0
  198. package/dist/types/commands/help.command.d.ts +19 -1
  199. package/dist/types/commands/info-alias.command.d.ts +15 -0
  200. package/dist/types/commands/info.command.d.ts +41 -0
  201. package/dist/types/commands/init-alias.command.d.ts +16 -0
  202. package/dist/types/commands/init.command-options.d.ts +22 -0
  203. package/dist/types/commands/init.command.d.ts +60 -0
  204. package/dist/types/commands/list-alias.command.d.ts +15 -0
  205. package/dist/types/commands/list.command.d.ts +6 -0
  206. package/dist/types/commands/start-alias.command.d.ts +16 -0
  207. package/dist/types/commands/start.command-options.d.ts +11 -0
  208. package/dist/types/commands/start.command.d.ts +47 -0
  209. package/dist/types/commands/verify-alias.command.d.ts +15 -0
  210. package/dist/types/commands/verify.command.d.ts +24 -0
  211. package/dist/types/config/config-loader.d.ts +40 -0
  212. package/dist/types/config/config-provenance.enum.d.ts +10 -0
  213. package/dist/types/config/config.d.ts +5 -0
  214. package/dist/types/config/define-config.d.ts +14 -0
  215. package/dist/types/config/pristine-config.interface.d.ts +67 -0
  216. package/dist/types/config/resolved-pristine-config.d.ts +28 -0
  217. package/dist/types/event-handlers/cli.event-handler.d.ts +30 -3
  218. package/dist/types/interfaces/command.interface.d.ts +31 -3
  219. package/package.json +16 -13
  220. package/readme.md +1023 -17
@@ -0,0 +1,60 @@
1
+ import { CommandInterface } from "../interfaces/command.interface";
2
+ import { ConsoleManager } from "../managers/console.manager";
3
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
4
+ import { InitCommandOptions } from "./init.command-options";
5
+ import { InitPrompt } from "../bootstrap/init-prompt";
6
+ /**
7
+ * Scaffolds a new Pristine project setup. In a TTY, prompts the user for source path,
8
+ * output path, tsconfig, build format, and a couple of yes/no decisions; in non-TTY (CI),
9
+ * accepts every value via `--source-path`, `--output-path`, etc. flags or refuses to run.
10
+ *
11
+ * What it produces:
12
+ * - `pristine.config.ts` at the project root with the answers populated.
13
+ * - Optionally, a starter AppModule at the configured `sourcePath` (only when the file
14
+ * doesn't already exist — never overwrites).
15
+ * - Optionally, `npm` scripts in `package.json`: `build`, `start`, `verify` (only ones
16
+ * that don't already exist — never overwrites).
17
+ * - `.pristine/` added to `.gitignore` if a `.gitignore` exists at the project root.
18
+ *
19
+ * Refuses to overwrite an existing `pristine.config.ts` so re-running init is safe.
20
+ */
21
+ export declare class InitCommand implements CommandInterface<InitCommandOptions> {
22
+ private readonly consoleManager;
23
+ private readonly initPrompt;
24
+ optionsType: typeof InitCommandOptions;
25
+ name: string;
26
+ description: string;
27
+ private readonly configFileName;
28
+ private readonly gitignoreEntry;
29
+ constructor(consoleManager: ConsoleManager, initPrompt: InitPrompt);
30
+ run(args: InitCommandOptions): Promise<ExitCodeEnum | number>;
31
+ /**
32
+ * Fills in answers from CLI flags first, then prompts (in TTY) for whatever's missing.
33
+ * Returns undefined when running non-TTY with insufficient flags so the caller can exit
34
+ * with the right error code (already rendered).
35
+ * @private
36
+ */
37
+ private gatherAnswers;
38
+ /**
39
+ * Writes a starter AppModule at the configured source path if and only if the file
40
+ * doesn't already exist. Never overwrites — re-running init on an established project
41
+ * shouldn't risk clobbering real code.
42
+ * @private
43
+ */
44
+ private scaffoldSource;
45
+ /**
46
+ * Adds `build`, `start`, `verify` to package.json's scripts. Only adds scripts that
47
+ * don't already exist — never overwrites a user-defined script.
48
+ * @private
49
+ */
50
+ private addPackageScripts;
51
+ /**
52
+ * Adds `.pristine/` to `.gitignore` if `.gitignore` exists and the entry isn't already
53
+ * there. Doesn't create `.gitignore` from scratch — that would be presumptuous in a
54
+ * project that hasn't initialized git.
55
+ * @private
56
+ */
57
+ private addToGitignore;
58
+ private renderConfigTemplate;
59
+ private renderAppModuleTemplate;
60
+ }
@@ -0,0 +1,15 @@
1
+ import { CommandInterface } from "../interfaces/command.interface";
2
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
3
+ import { ListCommand } from "./list.command";
4
+ /**
5
+ * Top-level alias for the framework-reserved `p:list` command. Injects the delegate
6
+ * directly via standard DI.
7
+ */
8
+ export declare class ListAliasCommand implements CommandInterface<null> {
9
+ private readonly delegate;
10
+ optionsType: null;
11
+ name: string;
12
+ description: string;
13
+ constructor(delegate: ListCommand);
14
+ run(args: any): Promise<ExitCodeEnum | number>;
15
+ }
@@ -2,11 +2,17 @@ import { DependencyContainer } from "tsyringe";
2
2
  import { CommandInterface } from "../interfaces/command.interface";
3
3
  import { ConsoleManager } from "../managers/console.manager";
4
4
  import { ExitCodeEnum } from "../enums/exit-code.enum";
5
+ /**
6
+ * Lists every registered command's name. Like `HelpCommand`, this resolves the command set
7
+ * lazily inside `run()` via the injected child container to avoid the self-referential cycle
8
+ * that constructor-time `@injectAll(Command)` would create — see `HelpCommand` for details.
9
+ */
5
10
  export declare class ListCommand implements CommandInterface<null> {
6
11
  private readonly consoleManager;
7
12
  private readonly container;
8
13
  optionsType: null;
9
14
  name: string;
15
+ description: string;
10
16
  constructor(consoleManager: ConsoleManager, container: DependencyContainer);
11
17
  run(args: any): Promise<ExitCodeEnum | number>;
12
18
  }
@@ -0,0 +1,16 @@
1
+ import { CommandInterface } from "../interfaces/command.interface";
2
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
3
+ import { StartCommand } from "./start.command";
4
+ import { StartCommandOptions } from "./start.command-options";
5
+ /**
6
+ * Top-level alias for the framework-reserved `p:start` command. Injects the delegate
7
+ * directly via standard DI.
8
+ */
9
+ export declare class StartAliasCommand implements CommandInterface<StartCommandOptions> {
10
+ private readonly delegate;
11
+ optionsType: typeof StartCommandOptions;
12
+ name: string;
13
+ description: string;
14
+ constructor(delegate: StartCommand);
15
+ run(args: StartCommandOptions): Promise<ExitCodeEnum | number>;
16
+ }
@@ -0,0 +1,11 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * Runtime overrides for `pristine start`. These are applied to every `RuntimeServerInterface`
4
+ * the kernel resolves — implementations are free to ignore them. The flags exist mainly for
5
+ * one-off cases ("I just need to test on a different port right now"); the canonical place
6
+ * to set defaults is the matching module's configurationDefinitions or `pristine.config.ts`.
7
+ */
8
+ export declare class StartCommandOptions {
9
+ port?: number;
10
+ address?: string;
11
+ }
@@ -0,0 +1,47 @@
1
+ import { Kernel, RuntimeServerInterface } from "@pristine-ts/core";
2
+ import { CommandInterface } from "../interfaces/command.interface";
3
+ import { ConsoleManager } from "../managers/console.manager";
4
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
5
+ import { StartCommandOptions } from "./start.command-options";
6
+ /**
7
+ * Boots the AppModule, starts every registered `RuntimeServerInterface` (HTTP server, gRPC
8
+ * server, etc.), and keeps the process alive until SIGTERM or SIGINT. On signal, runs the
9
+ * registered `onShutdown` hooks via `Kernel.stop()` and exits.
10
+ *
11
+ * This is the production-grade entry point. Use `pristine start` (or its `pristine p:start`
12
+ * canonical name) instead of `node dist/main.js` if you want Pristine to manage the lifecycle,
13
+ * signal handling, and graceful shutdown — including listening on every server module the
14
+ * AppModule imports.
15
+ *
16
+ * Notes:
17
+ * - The kernel is **already started** by `bootstrap()` before this command runs (the CLI
18
+ * boots once for every command). This command does not call `kernel.start()` again — it
19
+ * just starts the registered servers and keeps the process alive.
20
+ * - `RuntimeServer`-tagged services are constructor-injected via `@injectAll`. This works
21
+ * because `RuntimeServer` is a different tag than `Command`, so there's no self-reference
22
+ * cycle (StartCommand is `@tag(Command)`, not `@tag(RuntimeServer)`). When no servers
23
+ * are registered, the array is empty and the start path skips the loop.
24
+ * - The `Kernel` is injected only for `kernel.stop()` — the legitimate use of the Kernel
25
+ * as a service. Other resolution (commands, runtime servers, etc.) goes through
26
+ * standard DI rather than reaching through `kernel.container`.
27
+ * - The shutdown timeout (per `onShutdown` hook) defaults to 10 seconds. The whole-process
28
+ * hard exit timeout defaults to 30 seconds — if the orderly shutdown doesn't finish in
29
+ * that window, the process is force-exited so Kubernetes / ECS don't get stuck waiting.
30
+ * - `--port` / `--address` flags are propagated to every RuntimeServer's `start()`. In
31
+ * multi-server scenarios where servers should listen on different ports, use the per-module
32
+ * configuration values (e.g. `pristine.http.kernel-server.port`) instead of CLI flags.
33
+ * - Watch mode (`--watch`) is not yet implemented. For a dev loop, wrap `pristine start` in
34
+ * `nodemon` or `tsx --watch`.
35
+ */
36
+ export declare class StartCommand implements CommandInterface<StartCommandOptions> {
37
+ private readonly consoleManager;
38
+ private readonly kernel;
39
+ private readonly servers;
40
+ optionsType: typeof StartCommandOptions;
41
+ name: string;
42
+ description: string;
43
+ private static readonly HARD_EXIT_TIMEOUT_MS;
44
+ private readonly defaultRuntimeServerName;
45
+ constructor(consoleManager: ConsoleManager, kernel: Kernel, servers: RuntimeServerInterface[]);
46
+ run(args: StartCommandOptions): Promise<ExitCodeEnum | number>;
47
+ }
@@ -0,0 +1,15 @@
1
+ import { CommandInterface } from "../interfaces/command.interface";
2
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
3
+ import { VerifyCommand } from "./verify.command";
4
+ /**
5
+ * Top-level alias for the framework-reserved `p:verify` command. Injects the delegate
6
+ * directly via standard DI.
7
+ */
8
+ export declare class VerifyAliasCommand implements CommandInterface<null> {
9
+ private readonly delegate;
10
+ optionsType: null;
11
+ name: string;
12
+ description: string;
13
+ constructor(delegate: VerifyCommand);
14
+ run(args: any): Promise<ExitCodeEnum | number>;
15
+ }
@@ -0,0 +1,24 @@
1
+ import { LogHandlerInterface } from "@pristine-ts/logging";
2
+ import { CommandInterface } from "../interfaces/command.interface";
3
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
4
+ import { AppModuleLoader } from "../bootstrap/app-module-loader";
5
+ /**
6
+ * Verifies that the consumer's AppModule can be instantiated against its configuration.
7
+ * Builds a fresh throw-away kernel, runs every boot phase capturing per-phase outcomes,
8
+ * executes every embedder-registered `InstantiationTestInterface`, and routes the resulting
9
+ * report through the project's `LogHandlerInterface`.
10
+ *
11
+ * Note: this command runs after the CLI's own `kernel.start()` has succeeded, so it cannot
12
+ * be used to debug a configuration that is so broken the CLI can't start. For that case,
13
+ * call `kernel.verifyInstantiation(...)` directly from a small script that imports your
14
+ * AppModule.
15
+ */
16
+ export declare class VerifyCommand implements CommandInterface<null> {
17
+ private readonly logHandler;
18
+ private readonly appModuleLoader;
19
+ optionsType: null;
20
+ name: string;
21
+ description: string;
22
+ constructor(logHandler: LogHandlerInterface, appModuleLoader: AppModuleLoader);
23
+ run(args: any): Promise<ExitCodeEnum | number>;
24
+ }
@@ -0,0 +1,40 @@
1
+ import { ResolvedPristineConfig } from "./resolved-pristine-config";
2
+ import { DynamicImporter } from "../bootstrap/dynamic-importer";
3
+ /**
4
+ * Loads `pristine.config.ts` (preferred) or `pristine.config.js` (escape hatch for
5
+ * pure-JS projects). Walks up from `process.cwd()` looking for the file, then loads it
6
+ * through `jiti` (for `.ts`) or Node's dynamic `import()` (for `.js`).
7
+ *
8
+ * Returns a `ResolvedPristineConfig` carrying the file path (when found) and per-field
9
+ * provenance, which `pristine p:config:print` uses to render an annotated dump.
10
+ */
11
+ export declare class ConfigLoader {
12
+ private readonly dynamicImporter;
13
+ /**
14
+ * File names searched for, in order. `.ts` is the canonical form — `defineConfig()`
15
+ * gives full IDE autocomplete and every Pristine project ships a TS toolchain anyway.
16
+ * `.js` is the escape hatch for the rare pure-JS project that cannot have a `.ts`
17
+ * file at the root.
18
+ */
19
+ private readonly configFileNames;
20
+ constructor(dynamicImporter: DynamicImporter);
21
+ load(options?: {
22
+ explicitPath?: string;
23
+ startDir?: string;
24
+ }): Promise<ResolvedPristineConfig>;
25
+ /**
26
+ * Walks up from `startDir` looking for a config file with any of the supported names.
27
+ * Stops at the first match, returning the absolute path. Stops at the filesystem root
28
+ * without finding anything → returns undefined. Walking up matters in monorepos: a CLI
29
+ * invoked in `packages/foo/` should still find a `pristine.config.ts` at the repo root.
30
+ * @private
31
+ */
32
+ private findConfigFile;
33
+ /**
34
+ * Loads a config file from `absolutePath`. `.ts` goes through `jiti`; `.js` uses Node's
35
+ * native dynamic `import()`. Extracts the default export, falling back to a named
36
+ * `pristineConfig` export for users who prefer not to use `export default`.
37
+ * @private
38
+ */
39
+ private importConfigFile;
40
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Where a resolved configuration value originated. Used by `pristine p:config:print` to
3
+ * annotate output so users can tell whether a value comes from their config file, a
4
+ * deprecated `package.json` field, or the CLI's built-in defaults.
5
+ */
6
+ export declare enum ConfigProvenanceEnum {
7
+ ConfigFile = "config-file",
8
+ PackageJsonDeprecated = "package-json-deprecated",
9
+ Default = "default"
10
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./config-loader";
2
+ export * from "./config-provenance.enum";
3
+ export * from "./define-config";
4
+ export * from "./pristine-config.interface";
5
+ export * from "./resolved-pristine-config";
@@ -0,0 +1,14 @@
1
+ import { PristineConfig } from "./pristine-config.interface";
2
+ /**
3
+ * Identity helper that gives an authored `pristine.config.ts` full type checking and
4
+ * autocomplete. Implementation is intentionally trivial — the types do all the work.
5
+ *
6
+ * ```ts
7
+ * import {defineConfig} from "@pristine-ts/cli";
8
+ *
9
+ * export default defineConfig({
10
+ * appModule: { path: "dist/app.module.js" },
11
+ * });
12
+ * ```
13
+ */
14
+ export declare const defineConfig: (config: PristineConfig) => PristineConfig;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The shape of `pristine.config.ts` (or `pristine.config.js`). The `appModule` block is
3
+ * the canonical (and only) way to tell the CLI where your AppModule lives. When that
4
+ * block is present, both `sourcePath` and `outputPath` must be provided so the build
5
+ * manifest can keep them in sync.
6
+ *
7
+ * Authored as a `.ts` file by default; use `defineConfig()` (re-exported from
8
+ * `@pristine-ts/cli`) for full IDE autocomplete:
9
+ *
10
+ * ```ts
11
+ * import {defineConfig} from "@pristine-ts/cli";
12
+ *
13
+ * export default defineConfig({
14
+ * appModule: {
15
+ * sourcePath: "src/app.module.ts",
16
+ * outputPath: "dist/app.module.js",
17
+ * },
18
+ * });
19
+ * ```
20
+ *
21
+ * Run `pristine init` to generate this file interactively.
22
+ */
23
+ export interface PristineConfig {
24
+ /**
25
+ * Where the AppModule lives. Both `sourcePath` and `outputPath` are required when
26
+ * `appModule` is set. Paths are resolved relative to the directory containing the
27
+ * config file.
28
+ */
29
+ appModule?: {
30
+ /** Source TypeScript file the build compiles. */
31
+ sourcePath: string;
32
+ /** Compiled JavaScript file the runtime loads. */
33
+ outputPath: string;
34
+ /** Name of the export holding the AppModule definition. Default: `AppModule`. */
35
+ export?: string;
36
+ };
37
+ /** Build pipeline configuration. Used by `pristine build`. */
38
+ build?: {
39
+ outDir?: string;
40
+ tsconfig?: string;
41
+ format?: "esm" | "cjs" | "both";
42
+ clean?: boolean;
43
+ };
44
+ /** Reserved for future `pristine start` features (entry path, watch mode, node args). */
45
+ start?: {
46
+ entry?: string;
47
+ watch?: boolean | {
48
+ paths: string[];
49
+ ignore?: string[];
50
+ };
51
+ nodeArgs?: string[];
52
+ };
53
+ /**
54
+ * Extra packages whose `*Module` exports should be merged into the runtime AppModule when
55
+ * the CLI boots. Lets tooling-only modules (e.g. a generator package) contribute commands
56
+ * without forcing the consumer to import them into their production runtime AppModule.
57
+ */
58
+ plugins?: Array<string | {
59
+ name: string;
60
+ options?: unknown;
61
+ }>;
62
+ /**
63
+ * Default `kernel.start()` configuration values, merged on top of the CLI's defaults. Lets
64
+ * you keep CLI-only runtime overrides out of your AppModule.
65
+ */
66
+ kernelConfiguration?: Record<string, unknown>;
67
+ }
@@ -0,0 +1,28 @@
1
+ import { ConfigProvenanceEnum } from "./config-provenance.enum";
2
+ import { PristineConfig } from "./pristine-config.interface";
3
+ /**
4
+ * A loaded `PristineConfig` augmented with discovery metadata. `ConfigLoader` returns this
5
+ * shape; the raw `PristineConfig` is what users author.
6
+ */
7
+ export declare class ResolvedPristineConfig {
8
+ readonly config: PristineConfig;
9
+ /** Absolute path to the config file that was loaded, if any. */
10
+ readonly configFilePath: string | undefined;
11
+ /**
12
+ * Per-top-level-field provenance markers, mainly for `pristine p:config:print`. Keys are
13
+ * top-level fields of `PristineConfig` (`appModule`, `build`, `start`, `plugins`,
14
+ * `kernelConfiguration`); values are the `ConfigProvenanceEnum` describing where each
15
+ * came from.
16
+ */
17
+ readonly provenance: Record<string, ConfigProvenanceEnum>;
18
+ constructor(config: PristineConfig,
19
+ /** Absolute path to the config file that was loaded, if any. */
20
+ configFilePath: string | undefined,
21
+ /**
22
+ * Per-top-level-field provenance markers, mainly for `pristine p:config:print`. Keys are
23
+ * top-level fields of `PristineConfig` (`appModule`, `build`, `start`, `plugins`,
24
+ * `kernelConfiguration`); values are the `ConfigProvenanceEnum` describing where each
25
+ * came from.
26
+ */
27
+ provenance: Record<string, ConfigProvenanceEnum>);
28
+ }
@@ -5,14 +5,41 @@ import { CommandInterface } from "../interfaces/command.interface";
5
5
  import { LogHandlerInterface } from "@pristine-ts/logging";
6
6
  import { Validator } from "@pristine-ts/class-validator";
7
7
  import { ConsoleManager } from "../managers/console.manager";
8
- import { DataMapper } from "@pristine-ts/data-mapping-common";
8
+ import { ExitCodeEnum } from "../enums/exit-code.enum";
9
+ /**
10
+ * Resolution of a command's argv input. Either we successfully produced an instance of the
11
+ * command's `optionsType` (or the raw args for null-optionsType commands) and `args` is set,
12
+ * OR mapping/validation failed and `exitCode` carries the failure status. Mutually exclusive
13
+ * by construction — `args` is undefined iff `exitCode` is set.
14
+ *
15
+ * Used as the return value of `CliEventHandler.resolveArgs` so the call site can branch on
16
+ * the success/failure case without a thrown exception in the hot path.
17
+ */
18
+ interface ResolvedCommandArgs {
19
+ args?: any;
20
+ exitCode?: ExitCodeEnum;
21
+ }
9
22
  export declare class CliEventHandler implements EventHandlerInterface<any, any> {
10
23
  private readonly logHandler;
11
24
  private readonly validator;
12
25
  private readonly consoleManager;
13
- private readonly dataMapper;
14
26
  private readonly commands;
15
- constructor(logHandler: LogHandlerInterface, validator: Validator, consoleManager: ConsoleManager, dataMapper: DataMapper, commands: CommandInterface<any>[]);
27
+ constructor(logHandler: LogHandlerInterface, validator: Validator, consoleManager: ConsoleManager, commands: CommandInterface<any>[]);
16
28
  handle(event: CommandEvent): Promise<CommandEventResponse>;
29
+ /**
30
+ * Maps `rawArgs` (the parsed argv shape produced by `CommandEventMapper`) into a typed
31
+ * instance of `command.optionsType`, then runs `class-validator` against the instance.
32
+ *
33
+ * For commands that opt out of typed options (`optionsType === null`), passes the raw
34
+ * args through unchanged — the legacy escape hatch for commands that want to handle
35
+ * argv parsing themselves.
36
+ *
37
+ * Mapping or validation failures print the underlying error to the console and return an
38
+ * `exitCode` so the caller can exit non-zero. Success returns the typed instance under
39
+ * `args`. The two are mutually exclusive — see `ResolvedCommandArgs`.
40
+ */
41
+ resolveArgs(command: CommandInterface<any>, rawArgs: any): Promise<ResolvedCommandArgs>;
17
42
  supports(event: Event<any>): boolean;
43
+ private logExitStatus;
18
44
  }
45
+ export {};
@@ -1,6 +1,34 @@
1
+ import { ClassConstructor } from "class-transformer";
1
2
  import { ExitCodeEnum } from "../enums/exit-code.enum";
2
- export interface CommandInterface<ArgumentsOptionsType> {
3
+ /**
4
+ * The contract every CLI command implements. The CliEventHandler reads `optionsType` to
5
+ * map raw `process.argv` flags onto a typed instance of the declared options class, runs
6
+ * `class-validator` against the instance, and then calls `run(args)` with the validated
7
+ * instance.
8
+ *
9
+ * `optionsType` MUST be a class constructor (the class itself, e.g. `optionsType = MyOptions`)
10
+ * — not an instance. Set it to `null` for commands that don't accept any options. Returning
11
+ * an instance from a property declared as a constructor was a long-standing footgun: the
12
+ * data mapper silently failed and the validator never ran, so `run(args)`'s typed signature
13
+ * lied. The class-constructor contract makes the mapping/validation pipeline work as designed.
14
+ *
15
+ * Type parameter `T` is the options class. Commands without options use `null`.
16
+ */
17
+ export interface CommandInterface<T> {
3
18
  name: string;
4
- optionsType: ArgumentsOptionsType;
5
- run(args: ArgumentsOptionsType): Promise<ExitCodeEnum | number>;
19
+ /**
20
+ * Optional one-line summary shown by `pristine help`. Keep it short — multi-line
21
+ * descriptions belong in the command's own documentation, not in the help output.
22
+ */
23
+ description?: string;
24
+ /**
25
+ * Constructor of the class that describes this command's CLI flags, decorated with
26
+ * `class-validator` rules. Use `null` for commands that take no flags.
27
+ */
28
+ optionsType: ClassConstructor<T> | null;
29
+ /**
30
+ * Invoked with a validated instance of `optionsType` (when `optionsType` is non-null) or
31
+ * the raw parsed argv shape (when `optionsType` is null). Return an exit code.
32
+ */
33
+ run(args: T): Promise<ExitCodeEnum | number>;
6
34
  }
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@pristine-ts/cli",
3
- "version": "1.0.440",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/cli.module.js",
6
6
  "main": "dist/lib/cjs/cli.module.js",
7
7
  "types": "dist/types/cli.module.d.ts",
8
8
  "bin": {
9
- "pristine": "dist/lib/cjs/bin.js"
9
+ "pristine": "dist/bin/pristine.cjs"
10
10
  },
11
11
  "scripts": {
12
- "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
13
- "postbuild": "chmod +x dist/lib/cjs/bin.js",
12
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/build-bin.mjs",
14
13
  "prepublish": "npm run build",
15
14
  "test": "jest",
16
15
  "test:cov": "jest --coverage",
@@ -25,16 +24,20 @@
25
24
  "access": "public"
26
25
  },
27
26
  "dependencies": {
28
- "@pristine-ts/common": "^1.0.440",
29
- "@pristine-ts/core": "^1.0.440",
30
- "@pristine-ts/data-mapping": "^1.0.440",
31
- "@pristine-ts/data-mapping-common": "^1.0.440",
32
- "@pristine-ts/file": "^1.0.440",
33
- "@pristine-ts/logging": "^1.0.440",
34
- "@pristine-ts/validation": "^1.0.440",
35
- "class-transformer": "^0.5.1",
27
+ "@inquirer/prompts": "^7.2.0",
28
+ "@pristine-ts/common": "^2.0.2",
29
+ "@pristine-ts/core": "^2.0.2",
30
+ "@pristine-ts/data-mapping": "^2.0.2",
31
+ "@pristine-ts/data-mapping-common": "^2.0.2",
32
+ "@pristine-ts/file": "^2.0.2",
33
+ "@pristine-ts/logging": "^2.0.2",
34
+ "@pristine-ts/validation": "^2.0.2",
35
+ "jiti": "^2.4.0",
36
36
  "uuid": "^9.0.1"
37
37
  },
38
+ "devDependencies": {
39
+ "esbuild": "^0.24.0"
40
+ },
38
41
  "jest": {
39
42
  "transform": {
40
43
  ".(ts|tsx)": "ts-jest"
@@ -69,7 +72,7 @@
69
72
  "src/*.{js,ts}"
70
73
  ]
71
74
  },
72
- "gitHead": "2828491bc8cc720476584f3cf60791a4a705a77e",
75
+ "gitHead": "b0899c7eb6b34a99c6df0739507b1458549a0009",
73
76
  "repository": {
74
77
  "type": "git",
75
78
  "url": "https://github.com/magieno/pristine-ts.git",