@pristine-ts/cli 1.0.440 → 2.0.1

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,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuildManifest = void 0;
4
+ /**
5
+ * On-disk record of what `pristine build` produced. Written atomically at the end of a
6
+ * successful build to `.pristine/build-manifest.json`. Read by every downstream command that
7
+ * loads the AppModule (`pristine start`, `pristine verify`, etc.) so the loader can detect
8
+ * staleness — source file changed, config changed, output file missing — without scanning
9
+ * the filesystem.
10
+ *
11
+ * Plain class (no DI / no methods) because manifests serialize to/from JSON and the simpler
12
+ * the shape is, the harder it is to break the on-disk contract by accident.
13
+ */
14
+ class BuildManifest {
15
+ constructor(
16
+ /** Absolute path to the AppModule source file as it was at build time. */
17
+ appModuleSourcePath,
18
+ /** Absolute path to the compiled AppModule output file as it was at build time. */
19
+ appModuleOutputPath,
20
+ /** SHA-256 of the source file contents at build time. Drives staleness detection. */
21
+ sourceHash,
22
+ /** ISO-8601 timestamp of when the build completed. */
23
+ builtAt) {
24
+ this.appModuleSourcePath = appModuleSourcePath;
25
+ this.appModuleOutputPath = appModuleOutputPath;
26
+ this.sourceHash = sourceHash;
27
+ this.builtAt = builtAt;
28
+ }
29
+ }
30
+ exports.BuildManifest = BuildManifest;
31
+ //# sourceMappingURL=build-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-manifest.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-manifest.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,MAAa,aAAa;IACxB;IACE,0EAA0E;IAC1D,mBAA2B;IAC3C,mFAAmF;IACnE,mBAA2B;IAC3C,qFAAqF;IACrE,UAAkB;IAClC,sDAAsD;IACtC,OAAe;QANf,wBAAmB,GAAnB,mBAAmB,CAAQ;QAE3B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAE3B,eAAU,GAAV,UAAU,CAAQ;QAElB,YAAO,GAAP,OAAO,CAAQ;IAEjC,CAAC;CACF;AAZD,sCAYC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BuildRunner = void 0;
10
+ const tsyringe_1 = require("tsyringe");
11
+ const child_process_1 = require("child_process");
12
+ /**
13
+ * Runs `pristine p:build` as a subprocess of the currently-running bin. Used by
14
+ * `AppModuleLoader` when the user accepts the "rebuild now?" prompt — re-running the build
15
+ * inline avoids the awkward "exit, ask the user to type a command, re-enter" loop.
16
+ *
17
+ * Spawning rather than dispatching to `BuildCommand` directly keeps `AppModuleLoader` free
18
+ * of the build pipeline's dependency graph (ConsoleManager, ShellManager, etc.) which only
19
+ * exists in the kernel container — and the kernel hasn't booted yet at the point this is
20
+ * called. The subprocess re-bootstraps the kernel cleanly with all of those services.
21
+ *
22
+ * Returns `true` on a successful build (exit code 0), `false` on any failure or signal.
23
+ */
24
+ let BuildRunner = class BuildRunner {
25
+ constructor() {
26
+ this.buildCommandName = "p:build";
27
+ }
28
+ run() {
29
+ // process.argv[1] is the absolute path to the running bin file (set by Node when the
30
+ // bin was invoked). Re-spawning the same bin guarantees we use the exact same CLI
31
+ // version + setup the user is currently running against — no risk of resolving a
32
+ // different `pristine` from PATH that doesn't match this process's expectations.
33
+ const result = (0, child_process_1.spawnSync)(process.execPath, [process.argv[1], this.buildCommandName], {
34
+ stdio: "inherit",
35
+ cwd: process.cwd(),
36
+ });
37
+ return result.status === 0;
38
+ }
39
+ };
40
+ exports.BuildRunner = BuildRunner;
41
+ exports.BuildRunner = BuildRunner = __decorate([
42
+ (0, tsyringe_1.injectable)()
43
+ ], BuildRunner);
44
+ //# sourceMappingURL=build-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-runner.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-runner.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAoC;AACpC,iDAAwC;AAExC;;;;;;;;;;;GAWG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAAjB;QACY,qBAAgB,GAAW,SAAS,CAAC;IAcxD,CAAC;IAZC,GAAG;QACD,qFAAqF;QACrF,kFAAkF;QAClF,iFAAiF;QACjF,iFAAiF;QACjF,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE;YACnF,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;SACnB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AAfY,kCAAW;sBAAX,WAAW;IADvB,IAAA,qBAAU,GAAE;GACA,WAAW,CAevB"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.BuildStalenessPrompt = void 0;
22
+ const tsyringe_1 = require("tsyringe");
23
+ const build_manifest_staleness_enum_1 = require("./build-manifest-staleness.enum");
24
+ const dynamic_importer_1 = require("./dynamic-importer");
25
+ /**
26
+ * When the build manifest is stale (source edited, output missing, etc.), `AppModuleLoader`
27
+ * stops the load and consults this prompt. In a TTY, asks the user whether to run
28
+ * `pristine build` now; in non-TTY (CI, Docker), refuses to prompt and lets the caller exit
29
+ * non-zero with the explanation — auto-rebuilding in CI hides bugs.
30
+ *
31
+ * Just the prompt UI here. The actual rebuild dispatch is the caller's responsibility so
32
+ * this class stays small and testable.
33
+ */
34
+ let BuildStalenessPrompt = class BuildStalenessPrompt {
35
+ constructor(dynamicImporter) {
36
+ this.dynamicImporter = dynamicImporter;
37
+ this.promptMessage = "Run `pristine build` now to refresh?";
38
+ }
39
+ isInteractive() {
40
+ return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
41
+ }
42
+ /**
43
+ * Renders a one-line explanation of why the manifest is stale. Used by both the prompt
44
+ * (TTY) and the non-TTY error path so the messaging is identical regardless of channel.
45
+ */
46
+ describe(reason) {
47
+ switch (reason) {
48
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.Missing:
49
+ return "No build manifest found. Run `pristine build` before invoking this command.";
50
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.SourcePathChanged:
51
+ return "Your config's `appModule.sourcePath` no longer matches the last build. Run `pristine build` to rebuild against the new source.";
52
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.OutputPathChanged:
53
+ return "Your config's `appModule.outputPath` no longer matches the last build. Run `pristine build` to rebuild against the new output path.";
54
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.SourceContentChanged:
55
+ return "Your AppModule source has changed since the last build. Run `pristine build` to recompile.";
56
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.OutputMissing:
57
+ return "The compiled AppModule output is missing on disk. Run `pristine build` to produce it.";
58
+ case build_manifest_staleness_enum_1.BuildManifestStalenessEnum.Fresh:
59
+ // Should never be asked to describe Fresh, but a safe fallback beats a thrown error
60
+ // in a hot path.
61
+ return "Build manifest is up to date.";
62
+ }
63
+ }
64
+ /**
65
+ * Asks the user whether to rebuild. Returns `true` for yes, `false` for no, `undefined`
66
+ * for cancellation (Ctrl+C). Caller decides what to do with each outcome.
67
+ */
68
+ prompt(reason) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
71
+ const confirm = inquirer.confirm;
72
+ try {
73
+ return yield confirm({
74
+ message: `${this.describe(reason)}\n ${this.promptMessage}`,
75
+ default: true,
76
+ });
77
+ }
78
+ catch (_a) {
79
+ // @inquirer throws on Ctrl+C. Treat as a clean cancellation.
80
+ return undefined;
81
+ }
82
+ });
83
+ }
84
+ };
85
+ exports.BuildStalenessPrompt = BuildStalenessPrompt;
86
+ exports.BuildStalenessPrompt = BuildStalenessPrompt = __decorate([
87
+ (0, tsyringe_1.injectable)(),
88
+ __metadata("design:paramtypes", [dynamic_importer_1.DynamicImporter])
89
+ ], BuildStalenessPrompt);
90
+ //# sourceMappingURL=build-staleness-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-staleness-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/build-staleness-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAA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AM,CAAC;gBACP,6DAA6D;gBAC7D,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAnDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,qBAAU,GAAE;qCAImC,kCAAe;GAHlD,oBAAoB,CAmDhC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.DynamicImporter = void 0;
19
+ const tsyringe_1 = require("tsyringe");
20
+ /**
21
+ * Wraps Node's real dynamic `import()` so it survives both tsc's CJS lowering and esbuild's
22
+ * bundling. Both transformations otherwise rewrite `await import(x)` to a `require(x)` call —
23
+ * which is wrong for ESM-only packages and for `file://` URLs. The Function constructor's body
24
+ * is opaque to both, so the `import()` inside it goes through unrewritten.
25
+ *
26
+ * Centralized in one class so the same escape hatch isn't reimplemented in every consumer
27
+ * (loaders, plugin discovery, config loading, etc.).
28
+ */
29
+ let DynamicImporter = class DynamicImporter {
30
+ constructor() {
31
+ this.importFn = new Function("specifier", "return import(specifier);");
32
+ }
33
+ import(specifier) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ return this.importFn(specifier);
36
+ });
37
+ }
38
+ };
39
+ exports.DynamicImporter = DynamicImporter;
40
+ exports.DynamicImporter = DynamicImporter = __decorate([
41
+ (0, tsyringe_1.injectable)()
42
+ ], DynamicImporter);
43
+ //# sourceMappingURL=dynamic-importer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-importer.js","sourceRoot":"","sources":["../../../../src/bootstrap/dynamic-importer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AAEpC;;;;;;;;GAQG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QACY,aAAQ,GAAwC,IAAI,QAAQ,CAC3E,WAAW,EACX,2BAA2B,CACW,CAAC;IAK3C,CAAC;IAHO,MAAM,CAAC,SAAiB;;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;KAAA;CACF,CAAA;AATY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,qBAAU,GAAE;GACA,eAAe,CAS3B"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.InitPrompt = void 0;
22
+ const tsyringe_1 = require("tsyringe");
23
+ const dynamic_importer_1 = require("./dynamic-importer");
24
+ /**
25
+ * Interactive Q&A for `pristine init`. Lazy-loads `@inquirer/prompts` so the dep cost is
26
+ * only paid when actually prompting (the same pattern as `BuildStalenessPrompt` uses).
27
+ *
28
+ * Each method takes a "current value" so callers can pre-fill answers from CLI flags and
29
+ * only prompt for the gaps. Returning the same value the user passed in is intentional —
30
+ * it keeps the call sites uniform regardless of whether the value came from a flag or a
31
+ * prompt.
32
+ */
33
+ let InitPrompt = class InitPrompt {
34
+ constructor(dynamicImporter) {
35
+ this.dynamicImporter = dynamicImporter;
36
+ this.defaultSourcePath = "src/app.module.ts";
37
+ this.defaultOutputPath = "dist/app.module.js";
38
+ this.defaultTsconfig = "tsconfig.json";
39
+ this.defaultFormat = "esm";
40
+ }
41
+ isInteractive() {
42
+ return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
43
+ }
44
+ askSourcePath(current) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ if (current !== undefined)
47
+ return current;
48
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
49
+ const input = inquirer.input;
50
+ return input({
51
+ message: "Where does your AppModule source file live?",
52
+ default: this.defaultSourcePath,
53
+ });
54
+ });
55
+ }
56
+ askOutputPath(current) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ if (current !== undefined)
59
+ return current;
60
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
61
+ const input = inquirer.input;
62
+ return input({
63
+ message: "Where should the compiled AppModule output land?",
64
+ default: this.defaultOutputPath,
65
+ });
66
+ });
67
+ }
68
+ askTsconfig(current) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ if (current !== undefined)
71
+ return current;
72
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
73
+ const input = inquirer.input;
74
+ return input({
75
+ message: "Which tsconfig should `pristine build` use?",
76
+ default: this.defaultTsconfig,
77
+ });
78
+ });
79
+ }
80
+ askFormat(current) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (current !== undefined)
83
+ return current;
84
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
85
+ const select = inquirer.select;
86
+ return select({
87
+ message: "Which build format do you want?",
88
+ choices: [
89
+ { name: "esm (modern, recommended)", value: "esm" },
90
+ { name: "cjs (CommonJS)", value: "cjs" },
91
+ { name: "both (publish ESM + CJS)", value: "both" },
92
+ ],
93
+ default: this.defaultFormat,
94
+ });
95
+ });
96
+ }
97
+ askScaffoldSource(current, sourcePath) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ if (current !== undefined)
100
+ return current;
101
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
102
+ const confirm = inquirer.confirm;
103
+ return confirm({
104
+ message: `Scaffold a starter AppModule at ${sourcePath}?`,
105
+ default: true,
106
+ });
107
+ });
108
+ }
109
+ askWritePackageScripts(current) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ if (current !== undefined)
112
+ return current;
113
+ const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
114
+ const confirm = inquirer.confirm;
115
+ return confirm({
116
+ message: "Add `build`, `start`, `verify` scripts to package.json (only ones that don't already exist)?",
117
+ default: true,
118
+ });
119
+ });
120
+ }
121
+ };
122
+ exports.InitPrompt = InitPrompt;
123
+ exports.InitPrompt = InitPrompt = __decorate([
124
+ (0, tsyringe_1.injectable)(),
125
+ __metadata("design:paramtypes", [dynamic_importer_1.DynamicImporter])
126
+ ], InitPrompt);
127
+ //# sourceMappingURL=init-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/init-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,yDAAmD;AAgBnD;;;;;;;;GAQG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAU;IAMrB,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAL5C,sBAAiB,GAAW,mBAAmB,CAAC;QAChD,sBAAiB,GAAW,oBAAoB,CAAC;QACjD,oBAAe,GAAW,eAAe,CAAC;QAC1C,kBAAa,GAA2B,KAAK,CAAC;IAG/D,CAAC;IAED,aAAa;QACX,OAAO,OAAO,CAAE,OAAO,CAAC,MAAc,CAAC,KAAK,CAAC,IAAI,OAAO,CAAE,OAAO,CAAC,KAAa,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IAEK,aAAa,CAAC,OAA2B;;YAC7C,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,KAAK,GAAqC,QAAQ,CAAC,KAAK,CAAC;YAC/D,OAAO,KAAK,CAAC;gBACX,OAAO,EAAE,6CAA6C;gBACtD,OAAO,EAAE,IAAI,CAAC,iBAAiB;aAChC,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,aAAa,CAAC,OAA2B;;YAC7C,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,C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AI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,OAAO,GAAsC,QAAQ,CAAC,OAAO,CAAC;YACpE,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,mCAAmC,UAAU,GAAG;gBACzD,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,sBAAsB,CAAC,OAA4B;;YACvD,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,OAAO,CAAC;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,OAAO,GAAsC,QAAQ,CAAC,OAAO,CAAC;YACpE,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,8FAA8F;gBACvG,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAA;AA7EY,gCAAU;qBAAV,UAAU;IADtB,IAAA,qBAAU,GAAE;qCAOmC,kCAAe;GANlD,UAAU,CA6EtB"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadedAppModule = void 0;
4
+ /**
5
+ * The fully-resolved AppModule + ambient configuration that the CLI uses to boot the kernel.
6
+ * Returned by `AppModuleLoader.load()`.
7
+ */
8
+ class LoadedAppModule {
9
+ constructor(appModule, configuration,
10
+ /**
11
+ * True when `LoggingModule` is in the resolved AppModule's import graph. The CLI uses
12
+ * this to decide whether to layer in opinionated default logging configuration (Simple
13
+ * output mode, Error severity threshold) on top of the kernel configuration.
14
+ */
15
+ isLoggingModulePresent,
16
+ /**
17
+ * Plugins loaded from `pristine.config.ts`'s `plugins` array. Empty when no plugins are
18
+ * declared. Carried through so commands like `pristine info` can show what's contributing
19
+ * extra modules to the runtime.
20
+ */
21
+ plugins) {
22
+ this.appModule = appModule;
23
+ this.configuration = configuration;
24
+ this.isLoggingModulePresent = isLoggingModulePresent;
25
+ this.plugins = plugins;
26
+ }
27
+ }
28
+ exports.LoadedAppModule = LoadedAppModule;
29
+ //# sourceMappingURL=loaded-app-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaded-app-module.js","sourceRoot":"","sources":["../../../../src/bootstrap/loaded-app-module.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAa,eAAe;IAC1B,YACkB,SAA6B,EAC7B,aAA0D;IAC1E;;;;OAIG;IACa,sBAA+B;IAC/C;;;;OAIG;IACa,OAAuB;QAbvB,cAAS,GAAT,SAAS,CAAoB;QAC7B,kBAAa,GAAb,aAAa,CAA6C;QAM1D,2BAAsB,GAAtB,sBAAsB,CAAS;QAM/B,YAAO,GAAP,OAAO,CAAgB;IAEzC,CAAC;CACF;AAlBD,0CAkBC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadedPlugin = void 0;
4
+ /**
5
+ * A successfully-loaded plugin. Records the package name (for collision diagnostics), the
6
+ * absolute path it was resolved to, and every `*Module` export the plugin's entry produced.
7
+ */
8
+ class LoadedPlugin {
9
+ constructor(
10
+ /** As declared in `pristine.config.ts` plugins[] (string form or `.name` form). */
11
+ name,
12
+ /** Absolute path resolved by `createRequire` from the consumer's project. */
13
+ resolvedPath,
14
+ /** Modules harvested from the plugin's exports — one entry per `*Module` named export. */
15
+ modules) {
16
+ this.name = name;
17
+ this.resolvedPath = resolvedPath;
18
+ this.modules = modules;
19
+ }
20
+ }
21
+ exports.LoadedPlugin = LoadedPlugin;
22
+ //# sourceMappingURL=loaded-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaded-plugin.js","sourceRoot":"","sources":["../../../../src/bootstrap/loaded-plugin.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,YAAY;IACvB;IACE,mFAAmF;IACnE,IAAY;IAC5B,6EAA6E;IAC7D,YAAoB;IACpC,0FAA0F;IAC1E,OAA0B;QAJ1B,SAAI,GAAJ,IAAI,CAAQ;QAEZ,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,YAAO,GAAP,OAAO,CAAmB;IAE5C,CAAC;CACF;AAVD,oCAUC"}
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.PluginLoader = void 0;
25
+ const tsyringe_1 = require("tsyringe");
26
+ const module_1 = require("module");
27
+ const path_1 = __importDefault(require("path"));
28
+ const url_1 = require("url");
29
+ const dynamic_importer_1 = require("./dynamic-importer");
30
+ const loaded_plugin_1 = require("./loaded-plugin");
31
+ /**
32
+ * Resolves and loads every plugin declared in `config.plugins`. Plugin packages are resolved
33
+ * from the **consumer's project**, not from the CLI's install location — a plugin lives in
34
+ * the consumer's `node_modules`, not in `@pristine-ts/cli/node_modules`. Without
35
+ * `createRequire` pinned to the project location, `import("@my-org/plugin")` would walk up
36
+ * from the bin's install dir and miss it.
37
+ *
38
+ * A plugin that fails to load surfaces as a thrown error rather than being silently skipped —
39
+ * silent plugin loading is a footgun that makes "why isn't my command showing up" debuggable
40
+ * only by reading source.
41
+ */
42
+ let PluginLoader = class PluginLoader {
43
+ constructor(dynamicImporter) {
44
+ this.dynamicImporter = dynamicImporter;
45
+ }
46
+ load(config, configFilePath, projectRoot) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ var _a;
49
+ const plugins = (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
50
+ if (plugins.length === 0) {
51
+ return [];
52
+ }
53
+ // `createRequire` needs a "from" file to anchor resolution. When a config file exists,
54
+ // use it (so plugins resolve relative to where the config lives — important in monorepos).
55
+ // When no config file exists but plugins are somehow declared, anchor to the project root.
56
+ const anchor = configFilePath !== null && configFilePath !== void 0 ? configFilePath : path_1.default.join(projectRoot, "package.json");
57
+ const requireFn = (0, module_1.createRequire)((0, url_1.pathToFileURL)(anchor).href);
58
+ const loaded = [];
59
+ for (const entry of plugins) {
60
+ const name = typeof entry === "string" ? entry : entry.name;
61
+ const resolvedPath = this.resolvePluginPath(name, requireFn, anchor);
62
+ const imported = yield this.importPlugin(name, resolvedPath);
63
+ const modules = this.harvestModuleExports(imported);
64
+ if (modules.length === 0) {
65
+ throw new Error(`[pristine] Plugin '${name}' exported no '*Module' symbols. A plugin must export at least one ` +
66
+ `ModuleInterface (e.g. \`export const FooModule: ModuleInterface = { keyname: "...", ... }\`).`);
67
+ }
68
+ loaded.push(new loaded_plugin_1.LoadedPlugin(name, resolvedPath, modules));
69
+ }
70
+ return loaded;
71
+ });
72
+ }
73
+ /**
74
+ * Synthesizes an outer AppModule whose `importModules` includes the user's AppModule plus
75
+ * every plugin-contributed module, deduplicated by reference. Preserves the user's keyname
76
+ * (suffixed with `.with-plugins`) so introspection tools (`pristine info`) still surface a
77
+ * recognizable label.
78
+ */
79
+ wrap(appModule, plugins) {
80
+ var _a;
81
+ if (plugins.length === 0) {
82
+ return appModule;
83
+ }
84
+ const seen = new Set();
85
+ const importModules = [];
86
+ const add = (m) => {
87
+ if (seen.has(m))
88
+ return;
89
+ seen.add(m);
90
+ importModules.push(m);
91
+ };
92
+ add(appModule);
93
+ for (const plugin of plugins) {
94
+ for (const module of plugin.modules) {
95
+ add(module);
96
+ }
97
+ }
98
+ return {
99
+ keyname: `${appModule.keyname}.with-plugins`,
100
+ importModules,
101
+ importServices: (_a = appModule.importServices) !== null && _a !== void 0 ? _a : [],
102
+ };
103
+ }
104
+ resolvePluginPath(name, requireFn, anchor) {
105
+ try {
106
+ return requireFn.resolve(name);
107
+ }
108
+ catch (error) {
109
+ throw new Error(`[pristine] Failed to resolve plugin '${name}' from '${anchor}': ${error.message}. ` +
110
+ `Make sure the plugin package is installed in your project's node_modules.`);
111
+ }
112
+ }
113
+ importPlugin(name, resolvedPath) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ try {
116
+ return yield this.dynamicImporter.import((0, url_1.pathToFileURL)(resolvedPath).href);
117
+ }
118
+ catch (error) {
119
+ throw new Error(`[pristine] Failed to import plugin '${name}' from '${resolvedPath}': ${error.message}`);
120
+ }
121
+ });
122
+ }
123
+ /**
124
+ * Walks a plugin's exports collecting every value whose name ends in `Module` and looks
125
+ * like a `ModuleInterface` (has a `keyname` string). Accepts both ESM (default export) and
126
+ * CJS (named exports on the module namespace) plugin shapes.
127
+ */
128
+ harvestModuleExports(imported) {
129
+ const modules = [];
130
+ const candidates = [imported, imported === null || imported === void 0 ? void 0 : imported.default].filter(o => o !== undefined && o !== null);
131
+ for (const candidate of candidates) {
132
+ for (const key of Object.keys(candidate)) {
133
+ if (key.endsWith("Module") === false)
134
+ continue;
135
+ const value = candidate[key];
136
+ if (value !== null && typeof value === "object" && typeof value.keyname === "string") {
137
+ modules.push(value);
138
+ }
139
+ }
140
+ }
141
+ return modules;
142
+ }
143
+ };
144
+ exports.PluginLoader = PluginLoader;
145
+ exports.PluginLoader = PluginLoader = __decorate([
146
+ (0, tsyringe_1.injectable)(),
147
+ __metadata("design:paramtypes", [dynamic_importer_1.DynamicImporter])
148
+ ], PluginLoader);
149
+ //# sourceMappingURL=plugin-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../../../src/bootstrap/plugin-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,mCAAqC;AACrC,gDAAwB;AACxB,6BAAkC;AAGlC,yDAAmD;AACnD,mDAA6C;AAE7C;;;;;;;;;;GAUG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAC7D,CAAC;IAEK,IAAI,CAAC,MAAsB,EAAE,cAAkC,EAAE,WAAmB;;;YACxF,MAAM,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,CAAC;YACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,uFAAuF;YACvF,2FAA2F;YAC3F,2FAA2F;YAC3F,MAAM,MAAM,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YACxE,MAAM,SAAS,GAAG,IAAA,sBAAa,EAAC,IAAA,mBAAa,EAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;YAE5D,MAAM,MAAM,GAAmB,EAAE,CAAC;YAElC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,MAAM,IAAI,GAAG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AI,CAAC,SAAS,CAAC,EAAE,CAAC;gBACzC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,KAAK;oBAAE,SAAS;gBAC/C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;gBAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;oBACrF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA/GY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,qBAAU,GAAE;qCAEmC,kCAAe;GADlD,YAAY,CA+GxB"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SourceHasher = void 0;
13
+ const tsyringe_1 = require("tsyringe");
14
+ const crypto_1 = require("crypto");
15
+ const fs_1 = __importDefault(require("fs"));
16
+ /**
17
+ * Computes the content hash that goes into the build manifest. SHA-256 because it's
18
+ * collision-free for our purposes, ships with Node, and the hex digest is short enough
19
+ * to pretty-print in error messages without truncating.
20
+ *
21
+ * The hash is just a fingerprint of the source file's bytes — no AST awareness, no
22
+ * imports-aware tracing. That's intentional: a deeper hash (e.g. of the whole source tree)
23
+ * adds complexity and IO without changing the staleness story for the common case (user
24
+ * edits app.module.ts → hash changes → CLI tells them to rebuild).
25
+ */
26
+ let SourceHasher = class SourceHasher {
27
+ constructor() {
28
+ this.algorithm = "sha256";
29
+ this.digestPrefix = "sha256:";
30
+ }
31
+ hashFile(absolutePath) {
32
+ const hash = (0, crypto_1.createHash)(this.algorithm);
33
+ hash.update(fs_1.default.readFileSync(absolutePath));
34
+ return this.digestPrefix + hash.digest("hex");
35
+ }
36
+ };
37
+ exports.SourceHasher = SourceHasher;
38
+ exports.SourceHasher = SourceHasher = __decorate([
39
+ (0, tsyringe_1.injectable)()
40
+ ], SourceHasher);
41
+ //# sourceMappingURL=source-hasher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-hasher.js","sourceRoot":"","sources":["../../../../src/bootstrap/source-hasher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoC;AACpC,mCAAkC;AAClC,4CAAoB;AAEpB;;;;;;;;;GASG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACY,cAAS,GAAW,QAAQ,CAAC;QAC7B,iBAAY,GAAW,SAAS,CAAC;IAOpD,CAAC;IALC,QAAQ,CAAC,YAAoB;QAC3B,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,YAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AATY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,qBAAU,GAAE;GACA,YAAY,CASxB"}