@warlock.js/core 5.3.1 → 5.4.0

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 (84) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/esm/cli/cli-commands.manager.mjs +2 -0
  3. package/esm/cli/cli-commands.manager.mjs.map +1 -1
  4. package/esm/cli/cli-commands.utils.mjs +27 -9
  5. package/esm/cli/cli-commands.utils.mjs.map +1 -1
  6. package/esm/connectors/http-connector.d.mts.map +1 -1
  7. package/esm/connectors/http-connector.mjs +26 -4
  8. package/esm/connectors/http-connector.mjs.map +1 -1
  9. package/esm/database/create-database-action.mjs.map +1 -1
  10. package/esm/database/drop-tables-action.mjs.map +1 -1
  11. package/esm/database/migrate-action.mjs.map +1 -1
  12. package/esm/database/seed-command-action.mjs.map +1 -1
  13. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  14. package/esm/dev-server/boot-precondition-error.mjs +35 -0
  15. package/esm/dev-server/boot-precondition-error.mjs.map +1 -0
  16. package/esm/dev-server/development-server.mjs +6 -1
  17. package/esm/dev-server/development-server.mjs.map +1 -1
  18. package/esm/dev-server/files-orchestrator.mjs.map +1 -1
  19. package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs.map +1 -1
  20. package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs.map +1 -1
  21. package/esm/dev-server/shortcuts.mjs +27 -6
  22. package/esm/dev-server/shortcuts.mjs.map +1 -1
  23. package/esm/dev-server/start-development-server.mjs +3 -1
  24. package/esm/dev-server/start-development-server.mjs.map +1 -1
  25. package/esm/dev-server/supervisor.mjs +15 -0
  26. package/esm/dev-server/supervisor.mjs.map +1 -1
  27. package/esm/generations/add-command.action.mjs.map +1 -1
  28. package/esm/generations/features/access.feature.mjs.map +1 -1
  29. package/esm/generations/features/ai-anthropic.feature.mjs.map +1 -1
  30. package/esm/generations/features/ai-bedrock.feature.mjs.map +1 -1
  31. package/esm/generations/features/ai-google.feature.mjs.map +1 -1
  32. package/esm/generations/features/ai-ollama.feature.mjs.map +1 -1
  33. package/esm/generations/features/ai-openai.feature.mjs.map +1 -1
  34. package/esm/generations/features/ai-panoptic.feature.mjs.map +1 -1
  35. package/esm/generations/features/ai-tools.feature.mjs.map +1 -1
  36. package/esm/generations/features/ai-workspace.feature.mjs.map +1 -1
  37. package/esm/generations/features/ai.feature.mjs.map +1 -1
  38. package/esm/generations/features/herald.feature.mjs.map +1 -1
  39. package/esm/generations/features/image.feature.mjs.map +1 -1
  40. package/esm/generations/features/index.mjs.map +1 -1
  41. package/esm/generations/features/mail.feature.mjs.map +1 -1
  42. package/esm/generations/features/mongodb.feature.mjs.map +1 -1
  43. package/esm/generations/features/mysql.feature.mjs.map +1 -1
  44. package/esm/generations/features/notifications.feature.mjs.map +1 -1
  45. package/esm/generations/features/postgres.feature.mjs.map +1 -1
  46. package/esm/generations/features/react-email.feature.mjs +3 -9
  47. package/esm/generations/features/react-email.feature.mjs.map +1 -1
  48. package/esm/generations/features/react.feature.mjs.map +1 -1
  49. package/esm/generations/features/redis.feature.mjs.map +1 -1
  50. package/esm/generations/features/s3.feature.mjs.map +1 -1
  51. package/esm/generations/features/scheduler.feature.mjs.map +1 -1
  52. package/esm/generations/features/ses.feature.mjs.map +1 -1
  53. package/esm/generations/features/shadcn.feature.mjs.map +1 -1
  54. package/esm/generations/features/shared/patch-tsconfig-include.mjs +85 -0
  55. package/esm/generations/features/shared/patch-tsconfig-include.mjs.map +1 -0
  56. package/esm/generations/features/shared/relocate-conflicting-home-route.mjs +153 -0
  57. package/esm/generations/features/shared/relocate-conflicting-home-route.mjs.map +1 -0
  58. package/esm/generations/features/socket.feature.mjs.map +1 -1
  59. package/esm/generations/features/tailwind.feature.mjs.map +1 -1
  60. package/esm/generations/features/test.feature.mjs.map +1 -1
  61. package/esm/generations/features/types.mjs.map +1 -1
  62. package/esm/generations/features/web.feature.mjs +4 -89
  63. package/esm/generations/features/web.feature.mjs.map +1 -1
  64. package/esm/generations/stubs.mjs +59 -19
  65. package/esm/generations/stubs.mjs.map +1 -1
  66. package/esm/http/boot-port-preflight.d.mts.map +1 -1
  67. package/esm/http/boot-port-preflight.mjs +17 -3
  68. package/esm/http/boot-port-preflight.mjs.map +1 -1
  69. package/esm/http/resolve-bind-port.mjs +51 -0
  70. package/esm/http/resolve-bind-port.mjs.map +1 -0
  71. package/esm/tests/test-helpers.d.mts.map +1 -1
  72. package/esm/tests/test-helpers.mjs +4 -1
  73. package/esm/tests/test-helpers.mjs.map +1 -1
  74. package/esm/utils/detect-environment-overrides.mjs +67 -0
  75. package/esm/utils/detect-environment-overrides.mjs.map +1 -0
  76. package/esm/utils/load-environment.mjs +24 -0
  77. package/esm/utils/load-environment.mjs.map +1 -1
  78. package/esm/utils/report-environment-overrides.mjs +30 -0
  79. package/esm/utils/report-environment-overrides.mjs.map +1 -0
  80. package/esm/validation/types.d.mts +4 -1
  81. package/esm/validation/types.d.mts.map +1 -1
  82. package/llms-full.txt +10 -2
  83. package/package.json +12 -12
  84. package/skills/run-app/SKILL.md +10 -2
@@ -15,19 +15,40 @@ import readline from "node:readline";
15
15
  */
16
16
  var DevServerShortcuts = class {
17
17
  /**
18
- * @param input The stream to read keys from. Defaults to the process's
19
- * own stdin; tests pass a fake TTY instead.
20
- * @param onInterrupt What `Ctrl+C` does once raw mode has taken it away from
21
- * the terminal driver. Defaults to re-raising `SIGINT`.
18
+ * @param explicitInput The stream to read keys from. Tests pass a fake TTY;
19
+ * production code omits it and gets `process.stdin`,
20
+ * resolved lazily see {@link input}.
21
+ * @param onInterrupt What `Ctrl+C` does once raw mode has taken it away
22
+ * from the terminal driver. Defaults to re-raising
23
+ * `SIGINT`.
22
24
  */
23
- constructor(input = process.stdin, onInterrupt = raiseInterrupt) {
24
- this.input = input;
25
+ constructor(explicitInput, onInterrupt = raiseInterrupt) {
26
+ this.explicitInput = explicitInput;
25
27
  this.onInterrupt = onInterrupt;
26
28
  this.shortcuts = /* @__PURE__ */ new Map();
27
29
  this.listening = false;
28
30
  this.busy = false;
29
31
  }
30
32
  /**
33
+ * The stream to read keys from, resolved on first USE rather than at
34
+ * construction.
35
+ *
36
+ * `devServerShortcuts` below is a process-wide singleton, and every CLI
37
+ * command loads it merely by importing `dev-server.command.ts` —
38
+ * `framework-cli-commands.ts` statically imports every command module up
39
+ * front, for `warlock add`/`migrate`/`routes`/etc. just as much as for
40
+ * `warlock dev`. A constructor-default of `process.stdin` used to run at
41
+ * THAT import, not at `register()`, so simply running any command touched
42
+ * `process.stdin` and made Node construct a real stdin handle nobody asked
43
+ * for — including one-shot commands that never call `register()` and have
44
+ * no terminal to manage. A getter defers the touch to the methods that
45
+ * actually need a stream (`isSupported`/`register`/`listen`/`release`),
46
+ * none of which run for a command that never offers a shortcut.
47
+ */
48
+ get input() {
49
+ return this.explicitInput ?? process.stdin;
50
+ }
51
+ /**
31
52
  * Whether the current terminal can deliver individual keypresses. False in
32
53
  * CI, when stdin is a pipe, and in any non-interactive shell.
33
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"shortcuts.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/shortcuts.ts"],"sourcesContent":["import readline from \"node:readline\";\n\n/**\n * A single-keypress shortcut offered by the dev server while it runs.\n */\nexport type DevServerShortcut = {\n /** The key that triggers it, e.g. `\"u\"`. Matched case-insensitively. */\n key: string;\n /** Short human label, used when we print the available shortcuts. */\n description: string;\n /** What to run when the key is pressed. Rejections are swallowed. */\n handler: () => void | Promise<void>;\n};\n\n/**\n * Single-keypress shortcuts for the dev server (`press u to update`, …).\n *\n * Reading one key at a time requires putting stdin into raw mode, which\n * means this process — not the terminal driver — becomes responsible for\n * `Ctrl+C`. The manager therefore re-raises `SIGINT` itself so the existing\n * graceful-shutdown handlers keep working exactly as before.\n *\n * Everything is opt-in and self-guarding: with no TTY (piped output, CI,\n * a supervisor) `register()` reports `false` and stdin is never touched, so\n * callers can fall back to printing a plain \"run `npx warlock update`\" hint.\n */\nexport class DevServerShortcuts {\n private readonly shortcuts = new Map<string, DevServerShortcut>();\n\n /** Whether we currently hold stdin in raw mode. */\n private listening = false;\n\n /** Set while a handler runs, so a second keypress can't re-enter it. */\n private busy = false;\n\n private keypressListener?: (character: string, key: KeypressEvent) => void;\n\n /**\n * @param input The stream to read keys from. Defaults to the process's\n * own stdin; tests pass a fake TTY instead.\n * @param onInterrupt What `Ctrl+C` does once raw mode has taken it away from\n * the terminal driver. Defaults to re-raising `SIGINT`.\n */\n public constructor(\n private readonly input: NodeJS.ReadStream = process.stdin,\n private readonly onInterrupt: () => void = raiseInterrupt,\n ) {}\n\n /**\n * Whether the current terminal can deliver individual keypresses. False in\n * CI, when stdin is a pipe, and in any non-interactive shell.\n */\n public isSupported(): boolean {\n return Boolean(this.input.isTTY && typeof this.input.setRawMode === \"function\");\n }\n\n /**\n * Offer a shortcut. Returns whether it was actually registered — `false`\n * means the terminal can't support keypresses and the caller should print\n * a copy-and-paste command instead.\n */\n public register(shortcut: DevServerShortcut): boolean {\n if (!this.isSupported()) {\n return false;\n }\n\n this.shortcuts.set(shortcut.key.toLowerCase(), shortcut);\n this.listen();\n\n return true;\n }\n\n /** Every armed shortcut, in the order it was registered. */\n public list(): DevServerShortcut[] {\n return [...this.shortcuts.values()];\n }\n\n /** Drop a shortcut, releasing the terminal once none are left. */\n public unregister(key: string): void {\n this.shortcuts.delete(key.toLowerCase());\n\n if (this.shortcuts.size === 0) {\n this.release();\n }\n }\n\n /**\n * Hand the terminal back: leave raw mode and stop listening. Call this\n * before spawning a child process that needs stdin (the package manager\n * install), and on shutdown. Registered shortcuts are kept, so `register()`\n * (or `resume()`) can take the terminal again afterwards.\n */\n public release(): void {\n if (!this.listening) {\n return;\n }\n\n this.listening = false;\n\n if (this.keypressListener) {\n this.input.off(\"keypress\", this.keypressListener);\n this.keypressListener = undefined;\n }\n\n if (this.input.isTTY) {\n this.input.setRawMode(false);\n }\n\n this.input.pause();\n }\n\n /** Re-take the terminal after a {@link release}, if shortcuts remain. */\n public resume(): void {\n if (this.shortcuts.size > 0) {\n this.listen();\n }\n }\n\n /** Start (or keep) listening for keypresses. */\n private listen(): void {\n if (this.listening || !this.isSupported()) {\n return;\n }\n\n this.listening = true;\n\n readline.emitKeypressEvents(this.input);\n this.input.setRawMode(true);\n this.input.resume();\n\n this.keypressListener = (_character, key) => {\n void this.handleKeypress(key);\n };\n\n this.input.on(\"keypress\", this.keypressListener);\n }\n\n /**\n * Route a keypress to its shortcut. In raw mode the terminal no longer\n * turns `Ctrl+C` into a signal for us, so we translate it back into a\n * `SIGINT` and let the dev server's shutdown handlers take it from there.\n */\n private async handleKeypress(key: KeypressEvent | undefined): Promise<void> {\n if (!key) {\n return;\n }\n\n if (key.ctrl && (key.name === \"c\" || key.name === \"d\")) {\n this.release();\n this.onInterrupt();\n return;\n }\n\n if (this.busy) {\n return;\n }\n\n const shortcut = key.name ? this.shortcuts.get(key.name.toLowerCase()) : undefined;\n\n if (!shortcut) {\n return;\n }\n\n this.busy = true;\n\n try {\n await shortcut.handler();\n } catch {\n // A shortcut is a convenience — never let it take the dev server down.\n } finally {\n this.busy = false;\n }\n }\n}\n\n/** Re-raise the interrupt the terminal would have sent outside raw mode. */\nfunction raiseInterrupt(): void {\n process.kill(process.pid, \"SIGINT\");\n}\n\n/** The keypress shape emitted by `readline.emitKeypressEvents`. */\ntype KeypressEvent = {\n name?: string;\n ctrl?: boolean;\n meta?: boolean;\n shift?: boolean;\n};\n\n/** Process-wide shortcuts for the running dev server. */\nexport const devServerShortcuts = new DevServerShortcuts();\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,MAAgC;;;;;;;CAiB9B,AAAO,YACL,AAAiB,QAA2B,QAAQ,OACpD,AAAiB,cAA0B,gBAC3C;EAFiB;EACA;mCAlBU,IAAI,IAA+B;mBAG5C;cAGL;CAaZ;;;;;CAMH,AAAO,cAAuB;EAC5B,OAAO,QAAQ,KAAK,MAAM,SAAS,OAAO,KAAK,MAAM,eAAe,UAAU;CAChF;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AAI,KAAK,YAAY,CAAC,IAAI;EAEzE,IAAI,CAAC,UACH;EAGF,KAAK,OAAO;EAEZ,IAAI;GACF,MAAM,SAAS,QAAQ;EACzB,QAAQ,CAER,UAAU;GACR,KAAK,OAAO;EACd;CACF;AACF;;AAGA,SAAS,iBAAuB;CAC9B,QAAQ,KAAK,QAAQ,KAAK,QAAQ;AACpC;;AAWA,MAAa,qBAAqB,IAAI,mBAAmB"}
1
+ {"version":3,"file":"shortcuts.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/shortcuts.ts"],"sourcesContent":["import readline from \"node:readline\";\n\n/**\n * A single-keypress shortcut offered by the dev server while it runs.\n */\nexport type DevServerShortcut = {\n /** The key that triggers it, e.g. `\"u\"`. Matched case-insensitively. */\n key: string;\n /** Short human label, used when we print the available shortcuts. */\n description: string;\n /** What to run when the key is pressed. Rejections are swallowed. */\n handler: () => void | Promise<void>;\n};\n\n/**\n * Single-keypress shortcuts for the dev server (`press u to update`, …).\n *\n * Reading one key at a time requires putting stdin into raw mode, which\n * means this process — not the terminal driver — becomes responsible for\n * `Ctrl+C`. The manager therefore re-raises `SIGINT` itself so the existing\n * graceful-shutdown handlers keep working exactly as before.\n *\n * Everything is opt-in and self-guarding: with no TTY (piped output, CI,\n * a supervisor) `register()` reports `false` and stdin is never touched, so\n * callers can fall back to printing a plain \"run `npx warlock update`\" hint.\n */\nexport class DevServerShortcuts {\n private readonly shortcuts = new Map<string, DevServerShortcut>();\n\n /** Whether we currently hold stdin in raw mode. */\n private listening = false;\n\n /** Set while a handler runs, so a second keypress can't re-enter it. */\n private busy = false;\n\n private keypressListener?: (character: string, key: KeypressEvent) => void;\n\n /**\n * @param explicitInput The stream to read keys from. Tests pass a fake TTY;\n * production code omits it and gets `process.stdin`,\n * resolved lazily see {@link input}.\n * @param onInterrupt What `Ctrl+C` does once raw mode has taken it away\n * from the terminal driver. Defaults to re-raising\n * `SIGINT`.\n */\n public constructor(\n private readonly explicitInput?: NodeJS.ReadStream,\n private readonly onInterrupt: () => void = raiseInterrupt,\n ) {}\n\n /**\n * The stream to read keys from, resolved on first USE rather than at\n * construction.\n *\n * `devServerShortcuts` below is a process-wide singleton, and every CLI\n * command loads it merely by importing `dev-server.command.ts` —\n * `framework-cli-commands.ts` statically imports every command module up\n * front, for `warlock add`/`migrate`/`routes`/etc. just as much as for\n * `warlock dev`. A constructor-default of `process.stdin` used to run at\n * THAT import, not at `register()`, so simply running any command touched\n * `process.stdin` and made Node construct a real stdin handle nobody asked\n * for — including one-shot commands that never call `register()` and have\n * no terminal to manage. A getter defers the touch to the methods that\n * actually need a stream (`isSupported`/`register`/`listen`/`release`),\n * none of which run for a command that never offers a shortcut.\n */\n private get input(): NodeJS.ReadStream {\n return this.explicitInput ?? process.stdin;\n }\n\n /**\n * Whether the current terminal can deliver individual keypresses. False in\n * CI, when stdin is a pipe, and in any non-interactive shell.\n */\n public isSupported(): boolean {\n return Boolean(this.input.isTTY && typeof this.input.setRawMode === \"function\");\n }\n\n /**\n * Offer a shortcut. Returns whether it was actually registered — `false`\n * means the terminal can't support keypresses and the caller should print\n * a copy-and-paste command instead.\n */\n public register(shortcut: DevServerShortcut): boolean {\n if (!this.isSupported()) {\n return false;\n }\n\n this.shortcuts.set(shortcut.key.toLowerCase(), shortcut);\n this.listen();\n\n return true;\n }\n\n /** Every armed shortcut, in the order it was registered. */\n public list(): DevServerShortcut[] {\n return [...this.shortcuts.values()];\n }\n\n /** Drop a shortcut, releasing the terminal once none are left. */\n public unregister(key: string): void {\n this.shortcuts.delete(key.toLowerCase());\n\n if (this.shortcuts.size === 0) {\n this.release();\n }\n }\n\n /**\n * Hand the terminal back: leave raw mode and stop listening. Call this\n * before spawning a child process that needs stdin (the package manager\n * install), and on shutdown. Registered shortcuts are kept, so `register()`\n * (or `resume()`) can take the terminal again afterwards.\n */\n public release(): void {\n if (!this.listening) {\n return;\n }\n\n this.listening = false;\n\n if (this.keypressListener) {\n this.input.off(\"keypress\", this.keypressListener);\n this.keypressListener = undefined;\n }\n\n if (this.input.isTTY) {\n this.input.setRawMode(false);\n }\n\n this.input.pause();\n }\n\n /** Re-take the terminal after a {@link release}, if shortcuts remain. */\n public resume(): void {\n if (this.shortcuts.size > 0) {\n this.listen();\n }\n }\n\n /** Start (or keep) listening for keypresses. */\n private listen(): void {\n if (this.listening || !this.isSupported()) {\n return;\n }\n\n this.listening = true;\n\n readline.emitKeypressEvents(this.input);\n this.input.setRawMode(true);\n this.input.resume();\n\n this.keypressListener = (_character, key) => {\n void this.handleKeypress(key);\n };\n\n this.input.on(\"keypress\", this.keypressListener);\n }\n\n /**\n * Route a keypress to its shortcut. In raw mode the terminal no longer\n * turns `Ctrl+C` into a signal for us, so we translate it back into a\n * `SIGINT` and let the dev server's shutdown handlers take it from there.\n */\n private async handleKeypress(key: KeypressEvent | undefined): Promise<void> {\n if (!key) {\n return;\n }\n\n if (key.ctrl && (key.name === \"c\" || key.name === \"d\")) {\n this.release();\n this.onInterrupt();\n return;\n }\n\n if (this.busy) {\n return;\n }\n\n const shortcut = key.name ? this.shortcuts.get(key.name.toLowerCase()) : undefined;\n\n if (!shortcut) {\n return;\n }\n\n this.busy = true;\n\n try {\n await shortcut.handler();\n } catch {\n // A shortcut is a convenience — never let it take the dev server down.\n } finally {\n this.busy = false;\n }\n }\n}\n\n/** Re-raise the interrupt the terminal would have sent outside raw mode. */\nfunction raiseInterrupt(): void {\n process.kill(process.pid, \"SIGINT\");\n}\n\n/** The keypress shape emitted by `readline.emitKeypressEvents`. */\ntype KeypressEvent = {\n name?: string;\n ctrl?: boolean;\n meta?: boolean;\n shift?: boolean;\n};\n\n/** Process-wide shortcuts for the running dev server. */\nexport const devServerShortcuts = new DevServerShortcuts();\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,qBAAb,MAAgC;;;;;;;;;CAmB9B,AAAO,YACL,AAAiB,eACjB,AAAiB,cAA0B,gBAC3C;EAFiB;EACA;mCApBU,IAAI,IAA+B;mBAG5C;cAGL;CAeZ;;;;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,IAAI,IAAI,SAAS,IAAI,SAAS,OAAO,IAAI,SAAS,MAAM;GACtD,KAAK,QAAQ;GACb,KAAK,YAAY;GACjB;EACF;EAEA,IAAI,KAAK,MACP;EAGF,MAAM,WAAW,IAAI,OAAO,KAAK,UAAU,IAAI,IAAI,KAAK,YAAY,CAAC,IAAI;EAEzE,IAAI,CAAC,UACH;EAGF,KAAK,OAAO;EAEZ,IAAI;GACF,MAAM,SAAS,QAAQ;EACzB,QAAQ,CAER,UAAU;GACR,KAAK,OAAO;EACd;CACF;AACF;;AAGA,SAAS,iBAAuB;CAC9B,QAAQ,KAAK,QAAQ,KAAK,QAAQ;AACpC;;AAWA,MAAa,qBAAqB,IAAI,mBAAmB"}
@@ -1,4 +1,6 @@
1
1
  import { devLogError, devServeLog } from "./dev-logger.mjs";
2
+ import "./supervisor.mjs";
3
+ import { isBootPreconditionError } from "./boot-precondition-error.mjs";
2
4
  import { DevelopmentServer } from "./development-server.mjs";
3
5
  import { registerDevShortcuts } from "./register-dev-shortcuts.mjs";
4
6
  import { colors } from "@mongez/copper";
@@ -24,7 +26,7 @@ async function startDevelopmentServer(options = {}) {
24
26
  } catch (error) {
25
27
  devLogError(`Failed to start Development Server: ${error.message}`);
26
28
  await safeShutdown(devServer);
27
- process.exit(1);
29
+ process.exit(isBootPreconditionError(error) ? 78 : 1);
28
30
  }
29
31
  registerDevShortcuts(devServer);
30
32
  return devServer;
@@ -1 +1 @@
1
- {"version":3,"file":"start-development-server.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/start-development-server.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { devLogError, devServeLog } from \"./dev-logger\";\nimport { DevelopmentServer } from \"./development-server\";\nimport { registerDevShortcuts } from \"./register-dev-shortcuts\";\n\nlet handlersRegistered = false;\n\n/**\n * Options accepted by `startDevelopmentServer`. CLI flags translate to\n * these; programmatic callers (tests, scripts) can pass them directly.\n *\n * `undefined` for any field means \"fall through to `warlock.config.ts >\n * devServer.*` defaults.\" Pass an explicit value only to override.\n */\nexport type StartDevServerOptions = {\n /**\n * Delete `.warlock/manifest.json` before starting — forces every file\n * to be re-parsed from disk instead of restored from the cached graph.\n */\n fresh?: boolean;\n /** Run background type generation. Default from devServer config (true). */\n generateTypings?: boolean;\n /** Run file health checkers. Default from devServer config (true). */\n healthCheckers?: boolean;\n};\n\n/**\n * Start the development server.\n *\n * Boots the file orchestrator, loads app modules, starts late-phase\n * connectors, then wires graceful shutdown for SIGINT/SIGTERM (plus\n * SIGHUP on Windows where Ctrl+C in spawned children lands as SIGHUP).\n *\n * If startup throws, shuts down cleanly and exits 1 — dev should die\n * loudly rather than hang with a half-initialized state.\n */\nexport async function startDevelopmentServer(\n options: StartDevServerOptions = {},\n): Promise<DevelopmentServer> {\n // V8 honours inline source maps embedded by the transpile cache (and\n // tsx's own maps in passthrough mode), so thrown-error stack frames point\n // at the original `src/**.ts` line/column instead of transpiled output.\n process.setSourceMapsEnabled(true);\n\n const devServer = new DevelopmentServer(options);\n\n registerShutdownHandlers(devServer);\n\n try {\n await devServer.start();\n } catch (error) {\n devLogError(`Failed to start Development Server: ${(error as Error).message}`);\n await safeShutdown(devServer);\n process.exit(1);\n }\n\n // Only once the server is actually up — a half-started process has nothing\n // worth restarting, and taking raw mode before then would swallow the\n // Ctrl+C of a developer trying to escape a slow boot.\n registerDevShortcuts(devServer);\n\n return devServer;\n}\n\n/**\n * Register signal handlers once per process. Guards against handler\n * accumulation if `startDevelopmentServer` is invoked more than once\n * (tests, programmatic restart).\n */\nfunction registerShutdownHandlers(devServer: DevelopmentServer): void {\n if (handlersRegistered) return;\n handlersRegistered = true;\n\n const onSignal = (signal: NodeJS.Signals) => async () => {\n devServeLog(colors.yellow(`📡 Received ${signal}`));\n const ok = await safeShutdown(devServer);\n process.exit(ok ? 0 : 1);\n };\n\n process.on(\"SIGINT\", onSignal(\"SIGINT\"));\n process.on(\"SIGTERM\", onSignal(\"SIGTERM\"));\n // Ctrl+C in spawned Windows children lands as SIGHUP, not SIGINT.\n if (process.platform === \"win32\") {\n process.on(\"SIGHUP\", onSignal(\"SIGHUP\"));\n }\n}\n\n/**\n * Shut down the dev server without swallowing async errors. Returns\n * whether shutdown completed cleanly so the caller picks the exit code.\n */\nasync function safeShutdown(devServer: DevelopmentServer): Promise<boolean> {\n try {\n await devServer.shutdown();\n return true;\n } catch (error) {\n devLogError(`Shutdown failed: ${(error as Error).message}`);\n return false;\n }\n}\n"],"mappings":";;;;;;AAKA,IAAI,qBAAqB;;;;;;;;;;;AA+BzB,eAAsB,uBACpB,UAAiC,CAAC,GACN;CAI5B,QAAQ,qBAAqB,IAAI;CAEjC,MAAM,YAAY,IAAI,kBAAkB,OAAO;CAE/C,yBAAyB,SAAS;CAElC,IAAI;EACF,MAAM,UAAU,MAAM;CACxB,SAAS,OAAO;EACd,YAAY,uCAAwC,MAAgB,SAAS;EAC7E,MAAM,aAAa,SAAS;EAC5B,QAAQ,KAAK,CAAC;CAChB;CAKA,qBAAqB,SAAS;CAE9B,OAAO;AACT;;;;;;AAOA,SAAS,yBAAyB,WAAoC;CACpE,IAAI,oBAAoB;CACxB,qBAAqB;CAErB,MAAM,YAAY,WAA2B,YAAY;EACvD,YAAY,OAAO,OAAO,eAAe,QAAQ,CAAC;EAClD,MAAM,KAAK,MAAM,aAAa,SAAS;EACvC,QAAQ,KAAK,KAAK,IAAI,CAAC;CACzB;CAEA,QAAQ,GAAG,UAAU,SAAS,QAAQ,CAAC;CACvC,QAAQ,GAAG,WAAW,SAAS,SAAS,CAAC;CAEzC,IAAI,QAAQ,aAAa,SACvB,QAAQ,GAAG,UAAU,SAAS,QAAQ,CAAC;AAE3C;;;;;AAMA,eAAe,aAAa,WAAgD;CAC1E,IAAI;EACF,MAAM,UAAU,SAAS;EACzB,OAAO;CACT,SAAS,OAAO;EACd,YAAY,oBAAqB,MAAgB,SAAS;EAC1D,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"start-development-server.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/start-development-server.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { isBootPreconditionError } from \"./boot-precondition-error\";\nimport { devLogError, devServeLog } from \"./dev-logger\";\nimport { DevelopmentServer } from \"./development-server\";\nimport { registerDevShortcuts } from \"./register-dev-shortcuts\";\nimport { BOOT_PRECONDITION_EXIT_CODE } from \"./supervisor\";\n\nlet handlersRegistered = false;\n\n/**\n * Options accepted by `startDevelopmentServer`. CLI flags translate to\n * these; programmatic callers (tests, scripts) can pass them directly.\n *\n * `undefined` for any field means \"fall through to `warlock.config.ts >\n * devServer.*` defaults.\" Pass an explicit value only to override.\n */\nexport type StartDevServerOptions = {\n /**\n * Delete `.warlock/manifest.json` before starting — forces every file\n * to be re-parsed from disk instead of restored from the cached graph.\n */\n fresh?: boolean;\n /** Run background type generation. Default from devServer config (true). */\n generateTypings?: boolean;\n /** Run file health checkers. Default from devServer config (true). */\n healthCheckers?: boolean;\n};\n\n/**\n * Start the development server.\n *\n * Boots the file orchestrator, loads app modules, starts late-phase\n * connectors, then wires graceful shutdown for SIGINT/SIGTERM (plus\n * SIGHUP on Windows where Ctrl+C in spawned children lands as SIGHUP).\n *\n * If startup throws, shuts down cleanly and exits 1 — dev should die\n * loudly rather than hang with a half-initialized state.\n */\nexport async function startDevelopmentServer(\n options: StartDevServerOptions = {},\n): Promise<DevelopmentServer> {\n // V8 honours inline source maps embedded by the transpile cache (and\n // tsx's own maps in passthrough mode), so thrown-error stack frames point\n // at the original `src/**.ts` line/column instead of transpiled output.\n process.setSourceMapsEnabled(true);\n\n const devServer = new DevelopmentServer(options);\n\n registerShutdownHandlers(devServer);\n\n try {\n await devServer.start();\n } catch (error) {\n devLogError(`Failed to start Development Server: ${(error as Error).message}`);\n await safeShutdown(devServer);\n\n // A boot-precondition failure (busy port, rejected validator, ...) has\n // already printed a good message above — exit with the dedicated code so\n // the supervisor treats it as terminal instead of restart-looping into\n // the same failure. Every other error keeps exit 1, the ordinary\n // restart-worthy path.\n process.exit(isBootPreconditionError(error) ? BOOT_PRECONDITION_EXIT_CODE : 1);\n }\n\n // Only once the server is actually up — a half-started process has nothing\n // worth restarting, and taking raw mode before then would swallow the\n // Ctrl+C of a developer trying to escape a slow boot.\n registerDevShortcuts(devServer);\n\n return devServer;\n}\n\n/**\n * Register signal handlers once per process. Guards against handler\n * accumulation if `startDevelopmentServer` is invoked more than once\n * (tests, programmatic restart).\n */\nfunction registerShutdownHandlers(devServer: DevelopmentServer): void {\n if (handlersRegistered) return;\n handlersRegistered = true;\n\n const onSignal = (signal: NodeJS.Signals) => async () => {\n devServeLog(colors.yellow(`📡 Received ${signal}`));\n const ok = await safeShutdown(devServer);\n process.exit(ok ? 0 : 1);\n };\n\n process.on(\"SIGINT\", onSignal(\"SIGINT\"));\n process.on(\"SIGTERM\", onSignal(\"SIGTERM\"));\n // Ctrl+C in spawned Windows children lands as SIGHUP, not SIGINT.\n if (process.platform === \"win32\") {\n process.on(\"SIGHUP\", onSignal(\"SIGHUP\"));\n }\n}\n\n/**\n * Shut down the dev server without swallowing async errors. Returns\n * whether shutdown completed cleanly so the caller picks the exit code.\n */\nasync function safeShutdown(devServer: DevelopmentServer): Promise<boolean> {\n try {\n await devServer.shutdown();\n return true;\n } catch (error) {\n devLogError(`Shutdown failed: ${(error as Error).message}`);\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAI,qBAAqB;;;;;;;;;;;AA+BzB,eAAsB,uBACpB,UAAiC,CAAC,GACN;CAI5B,QAAQ,qBAAqB,IAAI;CAEjC,MAAM,YAAY,IAAI,kBAAkB,OAAO;CAE/C,yBAAyB,SAAS;CAElC,IAAI;EACF,MAAM,UAAU,MAAM;CACxB,SAAS,OAAO;EACd,YAAY,uCAAwC,MAAgB,SAAS;EAC7E,MAAM,aAAa,SAAS;EAO5B,QAAQ,KAAK,wBAAwB,KAAK,SAAkC,CAAC;CAC/E;CAKA,qBAAqB,SAAS;CAE9B,OAAO;AACT;;;;;;AAOA,SAAS,yBAAyB,WAAoC;CACpE,IAAI,oBAAoB;CACxB,qBAAqB;CAErB,MAAM,YAAY,WAA2B,YAAY;EACvD,YAAY,OAAO,OAAO,eAAe,QAAQ,CAAC;EAClD,MAAM,KAAK,MAAM,aAAa,SAAS;EACvC,QAAQ,KAAK,KAAK,IAAI,CAAC;CACzB;CAEA,QAAQ,GAAG,UAAU,SAAS,QAAQ,CAAC;CACvC,QAAQ,GAAG,WAAW,SAAS,SAAS,CAAC;CAEzC,IAAI,QAAQ,aAAa,SACvB,QAAQ,GAAG,UAAU,SAAS,QAAQ,CAAC;AAE3C;;;;;AAMA,eAAe,aAAa,WAAgD;CAC1E,IAAI;EACF,MAAM,UAAU,SAAS;EACzB,OAAO;CACT,SAAS,OAAO;EACd,YAAY,oBAAqB,MAAgB,SAAS;EAC1D,OAAO;CACT;AACF"}
@@ -14,6 +14,17 @@ const WORKER_ENV_FLAG = "WARLOCK_DEV_WORKER";
14
14
  * a stray supervisor-less exit reads sensibly in a shell.
15
15
  */
16
16
  const RESTART_EXIT_CODE = 75;
17
+ /**
18
+ * Exit code a worker uses when it hit a startup precondition whose cause
19
+ * cannot change by trying again — a busy port, a rejected boot validator, an
20
+ * unusable configured value. Chosen as EX_CONFIG, whose conventional meaning
21
+ * ("configuration error") matches the class. The supervisor treats this as
22
+ * terminal: no restart, no crash-budget spend, and no extra banner — the
23
+ * worker has already printed a good message, and the whole point of this
24
+ * exit code is that the supervisor does not scroll it away with a
25
+ * "restarting" line and then reprint the same failure a moment later.
26
+ */
27
+ const BOOT_PRECONDITION_EXIT_CODE = 78;
17
28
  /** Signals the supervisor must hand to the worker rather than act on itself. */
18
29
  const FORWARDED_SIGNALS = ["SIGTERM", "SIGHUP"];
19
30
  /**
@@ -83,6 +94,10 @@ function superviseDevServer(now = Date.now) {
83
94
  spawnWorker();
84
95
  return;
85
96
  }
97
+ if (code === 78) {
98
+ process.exit(code);
99
+ return;
100
+ }
86
101
  if ((signal !== null || (code ?? 0) !== 0) && shouldRecoverFromCrash(now() - spawnedAt)) {
87
102
  devLogWarn(`Development server ${signal ? `was killed by ${signal}` : `exited with code ${code}`} — restarting.`);
88
103
  spawnWorker();
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/supervisor.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { devLogError, devLogWarn } from \"./dev-logger\";\n\n/**\n * Set on the worker process so it knows it was launched by a supervisor —\n * and so `warlock dev` inside the worker runs the server instead of\n * supervising a third process.\n */\nexport const WORKER_ENV_FLAG = \"WARLOCK_DEV_WORKER\";\n\n/**\n * Exit code a worker uses to ask for a fresh process. Chosen as EX_TEMPFAIL,\n * whose conventional meaning (\"temporary failure, retry\") is close enough that\n * a stray supervisor-less exit reads sensibly in a shell.\n */\nexport const RESTART_EXIT_CODE = 75;\n\n/** Signals the supervisor must hand to the worker rather than act on itself. */\nconst FORWARDED_SIGNALS: NodeJS.Signals[] = [\"SIGTERM\", \"SIGHUP\"];\n\n/**\n * How long a worker must survive before an abnormal exit counts as a crash\n * worth recovering from rather than a failed boot worth reporting once.\n */\nconst HEALTHY_UPTIME_MS = 5_000;\n\n/** Crashes allowed inside {@link CRASH_WINDOW_MS} before we stop restarting. */\nconst CRASH_RESTART_LIMIT = 3;\n\n/** The rolling window flapping is measured over. */\nconst CRASH_WINDOW_MS = 60_000;\n\n/** Whether this process is the worker (i.e. a supervisor already exists). */\nexport function isDevWorker(): boolean {\n return process.env[WORKER_ENV_FLAG] === \"1\";\n}\n\n/**\n * Run `warlock dev` as a supervised pair: a thin parent that owns the terminal\n * and a disposable child that is the actual dev server.\n *\n * The child asks to be replaced by exiting {@link RESTART_EXIT_CODE}; the\n * supervisor spawns a fresh one in its place. Because the parent is never\n * itself replaced, the process tree stays exactly two deep no matter how many\n * restarts happen — the previous design re-exec'd itself and left one idle\n * waiter behind per restart.\n *\n * The supervisor deliberately loads no config, no connectors, and no\n * application code, so a worker that wedges or dies can always be replaced by\n * a process that is known-good.\n *\n * Never resolves: the returned promise is a deliberate dead end so callers can\n * `return` it to stop everything downstream (notably the command's preloaders,\n * which must only ever run in the worker). The process ends with the last\n * worker, not with this promise.\n */\nexport function superviseDevServer(now: () => number = Date.now): Promise<never> {\n let worker: ChildProcess | undefined;\n let shuttingDown = false;\n\n /** Timestamps of recent crash-restarts, used to detect flapping. */\n let crashes: number[] = [];\n\n const spawnWorker = (): void => {\n const spawnedAt = now();\n\n const spawnedWorker = spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {\n cwd: process.cwd(),\n env: { ...process.env, [WORKER_ENV_FLAG]: \"1\" },\n stdio: \"inherit\",\n windowsHide: false,\n });\n worker = spawnedWorker;\n\n spawnedWorker.on(\"error\", (error) => {\n if (worker !== spawnedWorker) return;\n\n shuttingDown = true;\n devLogError(`Could not start the development server: ${error.message}`);\n process.exit(1);\n });\n\n spawnedWorker.on(\"exit\", (code, signal) => {\n // A replaced worker can finish emitting lifecycle events after its\n // successor is already healthy. It must not spend that successor's crash\n // budget, spawn another worker, or print a terminal flapping diagnosis.\n if (worker !== spawnedWorker) return;\n\n worker = undefined;\n releaseTerminal();\n\n // `return` after every exit deliberately: `process.exit` is typed\n // `never`, but treating it as control flow means anything that stubs it\n // out turns \"we are shutting down\" into \"spawn another worker\".\n if (shuttingDown) {\n process.exit(signal ? 1 : (code ?? 0));\n return;\n }\n\n if (code === RESTART_EXIT_CODE) {\n spawnWorker();\n return;\n }\n\n const crashed = signal !== null || (code ?? 0) !== 0;\n\n if (crashed && shouldRecoverFromCrash(now() - spawnedAt)) {\n devLogWarn(\n `Development server ${signal ? `was killed by ${signal}` : `exited with code ${code}`} — restarting.`,\n );\n spawnWorker();\n return;\n }\n\n // The worker owns its own error reporting; the supervisor only mirrors\n // the outcome so `npm run dev` and CI see the code they expect.\n process.exit(signal ? 1 : (code ?? 0));\n });\n };\n\n /**\n * Whether a worker that died on its own should be replaced.\n *\n * The rule is minimum healthy uptime, not a bare retry count. A worker that\n * dies almost immediately failed to *boot* — a broken config, a port already\n * taken — and it has already printed why; respawning would just reprint the\n * same error and bury it. A worker that ran fine for a while and then died\n * (OOM, a native crash, a dead loader thread) is the case worth recovering,\n * because the state that killed it is usually not reproduced on a fresh boot.\n *\n * Flapping is still capped: enough crashes inside one window and we stop and\n * say so, rather than restarting forever behind the developer's back.\n */\n function shouldRecoverFromCrash(uptimeMs: number): boolean {\n if (uptimeMs < HEALTHY_UPTIME_MS) {\n return false;\n }\n\n const at = now();\n\n crashes = [...crashes.filter((time) => at - time < CRASH_WINDOW_MS), at];\n\n if (crashes.length > CRASH_RESTART_LIMIT) {\n devLogError(\n `Development server crashed ${crashes.length} times in ` +\n `${Math.round(CRASH_WINDOW_MS / 1000)}s — not restarting again. ` +\n `Fix the cause and run \\`warlock dev\\` when you're ready.`,\n );\n return false;\n }\n\n return true;\n }\n\n // SIGINT reaches the worker directly from the terminal (same process group),\n // so the supervisor must NOT act on it — exiting here would orphan a server\n // that is still draining. It only notes that the next exit is final.\n process.on(\"SIGINT\", () => {\n shuttingDown = true;\n });\n\n for (const signal of FORWARDED_SIGNALS) {\n process.on(signal, () => {\n shuttingDown = true;\n worker?.kill(signal);\n });\n }\n\n spawnWorker();\n\n return new Promise<never>(() => {\n // Intentionally never settles — see the doc comment.\n });\n}\n\n/**\n * Put the shared TTY back into a sane state after a worker exits.\n *\n * The worker takes stdin into raw mode for its keyboard shortcuts and releases\n * it on shutdown — but a worker that was killed outright never got the chance,\n * and the mode belongs to the terminal, not the process that set it. Without\n * this, the next worker (or the user's shell) inherits a stdin with no line\n * editing and no Ctrl+C.\n */\nfunction releaseTerminal(): void {\n try {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // Nothing to recover if the terminal is already gone.\n }\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBAAkB;;;;;;AAO/B,MAAa,oBAAoB;;AAGjC,MAAM,oBAAsC,CAAC,WAAW,QAAQ;;;;;AAMhE,MAA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K,OAAO,eAAe,GAAG,EAAE;EAEvE,IAAI,QAAQ,SAAS,qBAAqB;GACxC,YACE,8BAA8B,QAAQ,OAAO,YACxC,KAAK,MAAM,kBAAkB,GAAI,EAAE,mFAE1C;GACA,OAAO;EACT;EAEA,OAAO;CACT;CAKA,QAAQ,GAAG,gBAAgB;EACzB,eAAe;CACjB,CAAC;CAED,KAAK,MAAM,UAAU,mBACnB,QAAQ,GAAG,cAAc;EACvB,eAAe;EACf,QAAQ,KAAK,MAAM;CACrB,CAAC;CAGH,YAAY;CAEZ,OAAO,IAAI,cAAqB,CAEhC,CAAC;AACH;;;;;;;;;;AAWA,SAAS,kBAAwB;CAC/B,IAAI;EACF,IAAI,QAAQ,MAAM,OAChB,QAAQ,MAAM,WAAW,KAAK;CAElC,QAAQ,CAER;AACF"}
1
+ {"version":3,"file":"supervisor.mjs","names":[],"sources":["../../../../../../../core/src/dev-server/supervisor.ts"],"sourcesContent":["import { spawn, type ChildProcess } from \"node:child_process\";\nimport { devLogError, devLogWarn } from \"./dev-logger\";\n\n/**\n * Set on the worker process so it knows it was launched by a supervisor —\n * and so `warlock dev` inside the worker runs the server instead of\n * supervising a third process.\n */\nexport const WORKER_ENV_FLAG = \"WARLOCK_DEV_WORKER\";\n\n/**\n * Exit code a worker uses to ask for a fresh process. Chosen as EX_TEMPFAIL,\n * whose conventional meaning (\"temporary failure, retry\") is close enough that\n * a stray supervisor-less exit reads sensibly in a shell.\n */\nexport const RESTART_EXIT_CODE = 75;\n\n/**\n * Exit code a worker uses when it hit a startup precondition whose cause\n * cannot change by trying again — a busy port, a rejected boot validator, an\n * unusable configured value. Chosen as EX_CONFIG, whose conventional meaning\n * (\"configuration error\") matches the class. The supervisor treats this as\n * terminal: no restart, no crash-budget spend, and no extra banner — the\n * worker has already printed a good message, and the whole point of this\n * exit code is that the supervisor does not scroll it away with a\n * \"restarting\" line and then reprint the same failure a moment later.\n */\nexport const BOOT_PRECONDITION_EXIT_CODE = 78;\n\n/** Signals the supervisor must hand to the worker rather than act on itself. */\nconst FORWARDED_SIGNALS: NodeJS.Signals[] = [\"SIGTERM\", \"SIGHUP\"];\n\n/**\n * How long a worker must survive before an abnormal exit counts as a crash\n * worth recovering from rather than a failed boot worth reporting once.\n */\nconst HEALTHY_UPTIME_MS = 5_000;\n\n/** Crashes allowed inside {@link CRASH_WINDOW_MS} before we stop restarting. */\nconst CRASH_RESTART_LIMIT = 3;\n\n/** The rolling window flapping is measured over. */\nconst CRASH_WINDOW_MS = 60_000;\n\n/** Whether this process is the worker (i.e. a supervisor already exists). */\nexport function isDevWorker(): boolean {\n return process.env[WORKER_ENV_FLAG] === \"1\";\n}\n\n/**\n * Run `warlock dev` as a supervised pair: a thin parent that owns the terminal\n * and a disposable child that is the actual dev server.\n *\n * The child asks to be replaced by exiting {@link RESTART_EXIT_CODE}; the\n * supervisor spawns a fresh one in its place. Because the parent is never\n * itself replaced, the process tree stays exactly two deep no matter how many\n * restarts happen — the previous design re-exec'd itself and left one idle\n * waiter behind per restart.\n *\n * The supervisor deliberately loads no config, no connectors, and no\n * application code, so a worker that wedges or dies can always be replaced by\n * a process that is known-good.\n *\n * Never resolves: the returned promise is a deliberate dead end so callers can\n * `return` it to stop everything downstream (notably the command's preloaders,\n * which must only ever run in the worker). The process ends with the last\n * worker, not with this promise.\n */\nexport function superviseDevServer(now: () => number = Date.now): Promise<never> {\n let worker: ChildProcess | undefined;\n let shuttingDown = false;\n\n /** Timestamps of recent crash-restarts, used to detect flapping. */\n let crashes: number[] = [];\n\n const spawnWorker = (): void => {\n const spawnedAt = now();\n\n const spawnedWorker = spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {\n cwd: process.cwd(),\n env: { ...process.env, [WORKER_ENV_FLAG]: \"1\" },\n stdio: \"inherit\",\n windowsHide: false,\n });\n worker = spawnedWorker;\n\n spawnedWorker.on(\"error\", (error) => {\n if (worker !== spawnedWorker) return;\n\n shuttingDown = true;\n devLogError(`Could not start the development server: ${error.message}`);\n process.exit(1);\n });\n\n spawnedWorker.on(\"exit\", (code, signal) => {\n // A replaced worker can finish emitting lifecycle events after its\n // successor is already healthy. It must not spend that successor's crash\n // budget, spawn another worker, or print a terminal flapping diagnosis.\n if (worker !== spawnedWorker) return;\n\n worker = undefined;\n releaseTerminal();\n\n // `return` after every exit deliberately: `process.exit` is typed\n // `never`, but treating it as control flow means anything that stubs it\n // out turns \"we are shutting down\" into \"spawn another worker\".\n if (shuttingDown) {\n process.exit(signal ? 1 : (code ?? 0));\n return;\n }\n\n if (code === RESTART_EXIT_CODE) {\n spawnWorker();\n return;\n }\n\n // A boot precondition failure cannot be fixed by trying again — skip\n // the crash-recovery path entirely (no uptime check, no crash-budget\n // spend, no \"restarting\" banner) and mirror the exit code exactly, the\n // same way a deliberate shutdown does just below.\n if (code === BOOT_PRECONDITION_EXIT_CODE) {\n process.exit(code);\n return;\n }\n\n const crashed = signal !== null || (code ?? 0) !== 0;\n\n if (crashed && shouldRecoverFromCrash(now() - spawnedAt)) {\n devLogWarn(\n `Development server ${signal ? `was killed by ${signal}` : `exited with code ${code}`} — restarting.`,\n );\n spawnWorker();\n return;\n }\n\n // The worker owns its own error reporting; the supervisor only mirrors\n // the outcome so `npm run dev` and CI see the code they expect.\n process.exit(signal ? 1 : (code ?? 0));\n });\n };\n\n /**\n * Whether a worker that died on its own should be replaced.\n *\n * The rule is minimum healthy uptime, not a bare retry count. A worker that\n * dies almost immediately failed to *boot* — a broken config, a port already\n * taken — and it has already printed why; respawning would just reprint the\n * same error and bury it. A worker that ran fine for a while and then died\n * (OOM, a native crash, a dead loader thread) is the case worth recovering,\n * because the state that killed it is usually not reproduced on a fresh boot.\n *\n * Flapping is still capped: enough crashes inside one window and we stop and\n * say so, rather than restarting forever behind the developer's back.\n */\n function shouldRecoverFromCrash(uptimeMs: number): boolean {\n if (uptimeMs < HEALTHY_UPTIME_MS) {\n return false;\n }\n\n const at = now();\n\n crashes = [...crashes.filter((time) => at - time < CRASH_WINDOW_MS), at];\n\n if (crashes.length > CRASH_RESTART_LIMIT) {\n devLogError(\n `Development server crashed ${crashes.length} times in ` +\n `${Math.round(CRASH_WINDOW_MS / 1000)}s — not restarting again. ` +\n `Fix the cause and run \\`warlock dev\\` when you're ready.`,\n );\n return false;\n }\n\n return true;\n }\n\n // SIGINT reaches the worker directly from the terminal (same process group),\n // so the supervisor must NOT act on it — exiting here would orphan a server\n // that is still draining. It only notes that the next exit is final.\n process.on(\"SIGINT\", () => {\n shuttingDown = true;\n });\n\n for (const signal of FORWARDED_SIGNALS) {\n process.on(signal, () => {\n shuttingDown = true;\n worker?.kill(signal);\n });\n }\n\n spawnWorker();\n\n return new Promise<never>(() => {\n // Intentionally never settles — see the doc comment.\n });\n}\n\n/**\n * Put the shared TTY back into a sane state after a worker exits.\n *\n * The worker takes stdin into raw mode for its keyboard shortcuts and releases\n * it on shutdown — but a worker that was killed outright never got the chance,\n * and the mode belongs to the terminal, not the process that set it. Without\n * this, the next worker (or the user's shell) inherits a stdin with no line\n * editing and no Ctrl+C.\n */\nfunction releaseTerminal(): void {\n try {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false);\n }\n } catch {\n // Nothing to recover if the terminal is already gone.\n }\n}\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBAAkB;;;;;;AAO/B,MAAa,oBAAoB;;;;;;;;;;;AAYjC,MAAa,8BAA8B;;AAG3C,MAAM,oBAAsC,CAAC,WAAW,QAAQ;;;;;AAMhE,MAAM,oBAAoB;;AAG1B,MAAM,sBAAsB;;AAG5B,MAAM,kBAAkB;;AAGxB,SAAgB,cAAuB;CACrC,OAAO,QAAQ,IAAI,qBAAqB;AAC1C;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,mBAAmB,MAAoB,KAAK,KAAqB;CAC/E,IAAI;CACJ,IAAI,eAAe;;CAGnB,IAAI,UAAoB,CAAC;CAEzB,MAAM,oBAA0B;EAC9B,MAAM,YAAY,IAAI;EAEtB,MAAM,gBAAgB,MAAM,QAAQ,UAAU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vB,eAAe;EACf,QAAQ,KAAK,MAAM;CACrB,CAAC;CAGH,YAAY;CAEZ,OAAO,IAAI,cAAqB,CAEhC,CAAC;AACH;;;;;;;;;;AAWA,SAAS,kBAAwB;CAC/B,IAAI;EACF,IAAI,QAAQ,MAAM,OAChB,QAAQ,MAAM,WAAW,KAAK;CAElC,QAAQ,CAER;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"add-command.action.mjs","names":[],"sources":["../../../../../../../core/src/generations/add-command.action.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n fileExistsAsync,\r\n getJsonFileAsync,\r\n putFileAsync,\r\n putJsonFileAsync,\r\n} from \"@warlock.js/fs\";\r\nimport { execSync } from \"node:child_process\";\r\nimport { CommandActionData } from \"../commands/types\";\r\nimport {\r\n detectPackageManager,\n getAddCommand,\n getExactAddCommand,\n type PackageManager,\n} from \"../updater/package-manager\";\nimport { rootPath, srcPath } from \"../utils\";\r\nimport { getWarlockVersion } from \"../utils/framework-vesion\";\r\nimport { featuresMap } from \"./features\";\r\n\r\nexport { featuresMap };\r\nexport type { FeatureDefinition } from \"./features\";\r\n\r\n/**\r\n * The parts of a project `package.json` this action reads or writes. Deliberately\r\n * partial — it describes what we touch, not the whole manifest.\r\n */\r\ntype ProjectPackageJson = {\r\n dependencies?: Record<string, string>;\r\n devDependencies?: Record<string, string>;\r\n scripts?: Record<string, string>;\r\n};\r\n\r\nexport const allowedFeatures = Object.keys(featuresMap);\n\nfunction isWarlockPackage(packageName: string): boolean {\n return packageName.startsWith(\"@warlock.js/\");\n}\n\n/**\n * Resolve the internal feature-map placeholder to the version of Core that is\n * actually executing the command. Every @warlock.js package is lockstep, so\n * Core is the single source of truth; non-Warlock dependencies are untouched.\n */\nexport function resolveWarlockDependencyVersions(\n dependencies: Record<string, string>,\n frameworkVersion: string,\n): void {\n for (const dependency of Object.keys(dependencies)) {\n if (isWarlockPackage(dependency)) {\n dependencies[dependency] = frameworkVersion;\n }\n }\n}\n\nfunction resolveFeatures(features: string[], visited = new Set<string>()): string[] {\n const resolved: string[] = [];\r\n\r\n for (const feature of features) {\r\n if (visited.has(feature)) continue;\r\n visited.add(feature);\r\n\r\n const def = featuresMap[feature];\r\n\r\n if (def.requires?.length) {\r\n resolved.push(...resolveFeatures(def.requires, visited));\r\n }\r\n\r\n resolved.push(feature);\r\n }\r\n\r\n return resolved;\r\n}\r\n\r\nexport async function addCommandAction(options: CommandActionData) {\r\n const features = options.args;\r\n const { packageManager, list, noInstall } = options.options;\r\n\r\n if (list) {\r\n console.log(\"Available Features:\");\r\n\r\n for (const feature of allowedFeatures) {\r\n console.log(\r\n `- ${colors.yellowBright(feature)}: ${colors.green(featuresMap[feature].description)}`,\r\n );\r\n }\r\n\r\n process.exit(0);\r\n }\r\n\r\n validateFeatures(features);\r\n\r\n const resolvedFeatures = resolveFeatures(features);\r\n\r\n const dependencies: Record<string, string> = {};\r\n const devDependencies: Record<string, string> = {};\r\n const ejectConfigs: Record<string, { content: string; name: string }> = {};\r\n const scripts: Record<string, string> = {};\r\n\r\n for (const feature of resolvedFeatures) {\r\n const featurePackages = featuresMap[feature as keyof typeof featuresMap];\r\n Object.assign(dependencies, featurePackages.dependencies);\r\n if (featurePackages.devDependencies) {\r\n Object.assign(devDependencies, featurePackages.devDependencies);\r\n }\r\n\r\n if (featurePackages.ejectConfig) {\r\n ejectConfigs[featurePackages.ejectConfig.name] = featurePackages.ejectConfig;\r\n }\r\n\r\n if (featurePackages.script) {\r\n Object.assign(scripts, featurePackages.script);\r\n }\r\n }\r\n\r\n // Pin every @warlock.js/* feature package to the INSTALLED framework version so\r\n // a scaffolded project's features match its core version instead of drifting to\n // the feature map's static range.\n const frameworkVersion = await getWarlockVersion();\n resolveWarlockDependencyVersions(dependencies, frameworkVersion);\n\r\n const currentPackageJson = await getJsonFileAsync<ProjectPackageJson>(rootPath(\"package.json\"));\r\n\r\n // Fresh templates may omit one of the maps — guard before reading.\r\n currentPackageJson.dependencies = currentPackageJson.dependencies ?? {};\r\n currentPackageJson.devDependencies = currentPackageJson.devDependencies ?? {};\r\n\r\n // Skip anything already present so we never downgrade an existing pin.\r\n for (const dependency of Object.keys(dependencies)) {\r\n if (currentPackageJson.dependencies[dependency]) {\r\n console.log(`${colors.yellowBright(dependency)} is already installed, skipping...`);\r\n delete dependencies[dependency];\r\n }\r\n }\r\n\r\n for (const devDependency of Object.keys(devDependencies)) {\r\n if (currentPackageJson.devDependencies[devDependency]) {\r\n console.log(`${colors.yellowBright(devDependency)} is already installed, skipping...`);\r\n delete devDependencies[devDependency];\r\n }\r\n }\r\n\r\n if (noInstall) {\r\n await recordDependencies(dependencies, devDependencies);\r\n } else {\r\n await installDependencies(packageManager as PackageManager | undefined, dependencies, devDependencies);\r\n }\r\n\r\n for (const [name, config] of Object.entries(ejectConfigs)) {\r\n if (await fileExistsAsync(srcPath(`config/${name}.ts`))) {\r\n console.log(`${colors.yellowBright(name)} config already exists, skipping...`);\r\n continue;\r\n }\r\n\r\n console.log(`Creating ${colors.magenta(name)} config...`);\r\n\r\n await putFileAsync(srcPath(`config/${name}.ts`), config.content);\r\n\r\n console.log(`${colors.green(name)} config created successfully`);\r\n }\r\n\r\n // now loop again over features to execute onExecuting\r\n for (const feature of resolvedFeatures) {\r\n const featurePackages = featuresMap[feature as keyof typeof featuresMap];\r\n if (featurePackages.onExecuting) {\r\n await featurePackages.onExecuting(options);\r\n }\r\n }\r\n\r\n if (Object.keys(scripts).length > 0) {\r\n console.log(`Adding scripts ${colors.magenta(Object.keys(scripts).join(\", \"))}`);\r\n const packageJsonPath = rootPath(\"package.json\");\r\n const packageJson = await getJsonFileAsync<ProjectPackageJson>(packageJsonPath);\r\n packageJson.scripts = { ...(packageJson.scripts ?? {}), ...scripts };\r\n await putJsonFileAsync(packageJsonPath, packageJson);\r\n\r\n console.log(`Scripts added successfully ${colors.green(Object.keys(scripts).join(\", \"))}`);\r\n }\r\n}\r\n\r\n/**\r\n * Install the resolved dependency sets through the project's package manager.\r\n * Runs two passes (prod then dev) so each lands in the correct section.\r\n */\r\nexport async function installDependencies(\n packageManager: PackageManager | undefined,\r\n dependencies: Record<string, string>,\r\n devDependencies: Record<string, string>,\r\n) {\r\n // `--package-manager` is optional; without it, fall back to the lockfile.\r\n const resolvedPackageManager = packageManager ?? (await detectPackageManager());\n const packageManagerCommand = getAddCommand(resolvedPackageManager);\n const exactPackageManagerCommand = getExactAddCommand(resolvedPackageManager);\n\n const installDependencySet = (\n dependencySet: Record<string, string>,\n development: boolean,\n ) => {\n const regularSpecs: string[] = [];\n const exactWarlockSpecs: string[] = [];\n\n for (const [name, version] of Object.entries(dependencySet)) {\n const spec = `${name}@${version}`;\n (isWarlockPackage(name) ? exactWarlockSpecs : regularSpecs).push(spec);\n }\n\n const developmentFlag = development ? \" -D\" : \"\";\n const runInstall = (command: string, specs: string[]) => {\n if (specs.length === 0) return;\n\n execSync(`${command} ${specs.join(\" \")}${developmentFlag}`, {\n cwd: process.cwd(),\n stdio: \"inherit\",\n });\n };\n\n runInstall(packageManagerCommand, regularSpecs);\n runInstall(exactPackageManagerCommand, exactWarlockSpecs);\n };\n\r\n if (Object.keys(dependencies).length > 0) {\r\n console.log(`Installing dependencies ${colors.magenta(Object.keys(dependencies).join(\", \"))}`);\r\n\r\n installDependencySet(dependencies, false);\n\r\n console.log(\r\n `Dependencies installed successfully ${colors.green(Object.keys(dependencies).join(\", \"))}`,\r\n );\r\n }\r\n\r\n if (Object.keys(devDependencies).length > 0) {\r\n console.log(\r\n `Installing dev dependencies ${colors.magenta(Object.keys(devDependencies).join(\", \"))}`,\r\n );\r\n\r\n installDependencySet(devDependencies, true);\n\r\n console.log(\r\n `Dev dependencies installed successfully ${colors.green(Object.keys(devDependencies).join(\", \"))}`,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Write the resolved dependency sets into package.json without installing.\r\n * Used by `--no-install` so a scaffolder can batch every feature into one\r\n * install pass after the command returns. Versions come from the feature map.\r\n */\r\nasync function recordDependencies(\r\n dependencies: Record<string, string>,\r\n devDependencies: Record<string, string>,\r\n) {\r\n if (Object.keys(dependencies).length === 0 && Object.keys(devDependencies).length === 0) {\r\n return;\r\n }\r\n\r\n const packageJsonPath = rootPath(\"package.json\");\r\n const packageJson = await getJsonFileAsync<ProjectPackageJson>(packageJsonPath);\r\n\r\n packageJson.dependencies = packageJson.dependencies ?? {};\r\n packageJson.devDependencies = packageJson.devDependencies ?? {};\r\n\r\n Object.assign(packageJson.dependencies, dependencies);\r\n Object.assign(packageJson.devDependencies, devDependencies);\r\n\r\n await putJsonFileAsync(packageJsonPath, packageJson);\r\n\r\n const recorded = [...Object.keys(dependencies), ...Object.keys(devDependencies)];\r\n\r\n console.log(\r\n `Recorded ${colors.green(recorded.join(\", \"))} in package.json (install skipped via --no-install)`,\r\n );\r\n}\r\n\r\nfunction validateFeatures(features: string[]) {\n for (const feature of features) {\r\n if (!allowedFeatures.includes(feature)) {\r\n console.log(\r\n `Feature ${colors.redBright(feature)} is not allowed, allowed features are: ${colors.green(allowedFeatures.join(\", \"))}`,\r\n );\r\n process.exit(1);\r\n }\r\n }\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAa,kBAAkB,OAAO,KAAK,WAAW;AAEtD,SAAS,iBAAiB,aAA8B;CACtD,OAAO,YAAY,WAAW,cAAc;AAC9C;;;;;;AAOA,SAAgB,iCACd,cACA,kBACM;CACN,KAAK,MAAM,cAAc,OAAO,KAAK,YAAY,GAC/C,IAAI,iBAAiB,UAAU,GAC7B,aAAa,cAAc;AAGjC;AAEA,SAAS,gBAAgB,UAAoB,0BAAU,IAAI,IAAY,GAAa;CAClF,MAAM,WAAqB,CAAC;CAE5B,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,IAAI,OAAO,GAAG;EAC1B,QAAQ,IAAI,OAAO;EAEnB,MAAM,MAAM,YAAY;EAExB,IAAI,IAAI,UAAU,QAChB,SAAS,KAAK,GAAG,gBAAgB,IAAI,UAAU,OAAO,CAAC;EAGzD,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ACpF;CAGF,MAAM,kBAAkB,SAAS,cAAc;CAC/C,MAAM,cAAc,MAAM,iBAAqC,eAAe;CAE9E,YAAY,eAAe,YAAY,gBAAgB,CAAC;CACxD,YAAY,kBAAkB,YAAY,mBAAmB,CAAC;CAE9D,OAAO,OAAO,YAAY,cAAc,YAAY;CACpD,OAAO,OAAO,YAAY,iBAAiB,eAAe;CAE1D,MAAM,iBAAiB,iBAAiB,WAAW;CAEnD,MAAM,WAAW,CAAC,GAAG,OAAO,KAAK,YAAY,GAAG,GAAG,OAAO,KAAK,eAAe,CAAC;CAE/E,QAAQ,IACN,YAAY,OAAO,MAAM,SAAS,KAAK,IAAI,CAAC,EAAE,oDAChD;AACF;AAEA,SAAS,iBAAiB,UAAoB;CAC5C,KAAK,MAAM,WAAW,UACpB,IAAI,CAAC,gBAAgB,SAAS,OAAO,GAAG;EACtC,QAAQ,IACN,WAAW,OAAO,UAAU,OAAO,EAAE,yCAAyC,OAAO,MAAM,gBAAgB,KAAK,IAAI,CAAC,GACvH;EACA,QAAQ,KAAK,CAAC;CAChB;AAEJ"}
1
+ {"version":3,"file":"add-command.action.mjs","names":[],"sources":["../../../../../../../core/src/generations/add-command.action.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n fileExistsAsync,\r\n getJsonFileAsync,\r\n putFileAsync,\r\n putJsonFileAsync,\r\n} from \"@warlock.js/fs\";\r\nimport { execSync } from \"node:child_process\";\r\nimport type { CommandActionData } from \"../commands/types\";\r\nimport {\r\n detectPackageManager,\n getAddCommand,\n getExactAddCommand,\n type PackageManager,\n} from \"../updater/package-manager\";\nimport { rootPath, srcPath } from \"../utils\";\r\nimport { getWarlockVersion } from \"../utils/framework-vesion\";\r\nimport { featuresMap } from \"./features\";\r\n\r\nexport { featuresMap };\r\nexport type { FeatureDefinition } from \"./features\";\r\n\r\n/**\r\n * The parts of a project `package.json` this action reads or writes. Deliberately\r\n * partial — it describes what we touch, not the whole manifest.\r\n */\r\ntype ProjectPackageJson = {\r\n dependencies?: Record<string, string>;\r\n devDependencies?: Record<string, string>;\r\n scripts?: Record<string, string>;\r\n};\r\n\r\nexport const allowedFeatures = Object.keys(featuresMap);\n\nfunction isWarlockPackage(packageName: string): boolean {\n return packageName.startsWith(\"@warlock.js/\");\n}\n\n/**\n * Resolve the internal feature-map placeholder to the version of Core that is\n * actually executing the command. Every @warlock.js package is lockstep, so\n * Core is the single source of truth; non-Warlock dependencies are untouched.\n */\nexport function resolveWarlockDependencyVersions(\n dependencies: Record<string, string>,\n frameworkVersion: string,\n): void {\n for (const dependency of Object.keys(dependencies)) {\n if (isWarlockPackage(dependency)) {\n dependencies[dependency] = frameworkVersion;\n }\n }\n}\n\nfunction resolveFeatures(features: string[], visited = new Set<string>()): string[] {\n const resolved: string[] = [];\r\n\r\n for (const feature of features) {\r\n if (visited.has(feature)) continue;\r\n visited.add(feature);\r\n\r\n const def = featuresMap[feature];\r\n\r\n if (def.requires?.length) {\r\n resolved.push(...resolveFeatures(def.requires, visited));\r\n }\r\n\r\n resolved.push(feature);\r\n }\r\n\r\n return resolved;\r\n}\r\n\r\nexport async function addCommandAction(options: CommandActionData) {\r\n const features = options.args;\r\n const { packageManager, list, noInstall } = options.options;\r\n\r\n if (list) {\r\n console.log(\"Available Features:\");\r\n\r\n for (const feature of allowedFeatures) {\r\n console.log(\r\n `- ${colors.yellowBright(feature)}: ${colors.green(featuresMap[feature].description)}`,\r\n );\r\n }\r\n\r\n process.exit(0);\r\n }\r\n\r\n validateFeatures(features);\r\n\r\n const resolvedFeatures = resolveFeatures(features);\r\n\r\n const dependencies: Record<string, string> = {};\r\n const devDependencies: Record<string, string> = {};\r\n const ejectConfigs: Record<string, { content: string; name: string }> = {};\r\n const scripts: Record<string, string> = {};\r\n\r\n for (const feature of resolvedFeatures) {\r\n const featurePackages = featuresMap[feature as keyof typeof featuresMap];\r\n Object.assign(dependencies, featurePackages.dependencies);\r\n if (featurePackages.devDependencies) {\r\n Object.assign(devDependencies, featurePackages.devDependencies);\r\n }\r\n\r\n if (featurePackages.ejectConfig) {\r\n ejectConfigs[featurePackages.ejectConfig.name] = featurePackages.ejectConfig;\r\n }\r\n\r\n if (featurePackages.script) {\r\n Object.assign(scripts, featurePackages.script);\r\n }\r\n }\r\n\r\n // Pin every @warlock.js/* feature package to the INSTALLED framework version so\r\n // a scaffolded project's features match its core version instead of drifting to\n // the feature map's static range.\n const frameworkVersion = await getWarlockVersion();\n resolveWarlockDependencyVersions(dependencies, frameworkVersion);\n\r\n const currentPackageJson = await getJsonFileAsync<ProjectPackageJson>(rootPath(\"package.json\"));\r\n\r\n // Fresh templates may omit one of the maps — guard before reading.\r\n currentPackageJson.dependencies = currentPackageJson.dependencies ?? {};\r\n currentPackageJson.devDependencies = currentPackageJson.devDependencies ?? {};\r\n\r\n // Skip anything already present so we never downgrade an existing pin.\r\n for (const dependency of Object.keys(dependencies)) {\r\n if (currentPackageJson.dependencies[dependency]) {\r\n console.log(`${colors.yellowBright(dependency)} is already installed, skipping...`);\r\n delete dependencies[dependency];\r\n }\r\n }\r\n\r\n for (const devDependency of Object.keys(devDependencies)) {\r\n if (currentPackageJson.devDependencies[devDependency]) {\r\n console.log(`${colors.yellowBright(devDependency)} is already installed, skipping...`);\r\n delete devDependencies[devDependency];\r\n }\r\n }\r\n\r\n if (noInstall) {\r\n await recordDependencies(dependencies, devDependencies);\r\n } else {\r\n await installDependencies(packageManager as PackageManager | undefined, dependencies, devDependencies);\r\n }\r\n\r\n for (const [name, config] of Object.entries(ejectConfigs)) {\r\n if (await fileExistsAsync(srcPath(`config/${name}.ts`))) {\r\n console.log(`${colors.yellowBright(name)} config already exists, skipping...`);\r\n continue;\r\n }\r\n\r\n console.log(`Creating ${colors.magenta(name)} config...`);\r\n\r\n await putFileAsync(srcPath(`config/${name}.ts`), config.content);\r\n\r\n console.log(`${colors.green(name)} config created successfully`);\r\n }\r\n\r\n // now loop again over features to execute onExecuting\r\n for (const feature of resolvedFeatures) {\r\n const featurePackages = featuresMap[feature as keyof typeof featuresMap];\r\n if (featurePackages.onExecuting) {\r\n await featurePackages.onExecuting(options);\r\n }\r\n }\r\n\r\n if (Object.keys(scripts).length > 0) {\r\n console.log(`Adding scripts ${colors.magenta(Object.keys(scripts).join(\", \"))}`);\r\n const packageJsonPath = rootPath(\"package.json\");\r\n const packageJson = await getJsonFileAsync<ProjectPackageJson>(packageJsonPath);\r\n packageJson.scripts = { ...(packageJson.scripts ?? {}), ...scripts };\r\n await putJsonFileAsync(packageJsonPath, packageJson);\r\n\r\n console.log(`Scripts added successfully ${colors.green(Object.keys(scripts).join(\", \"))}`);\r\n }\r\n}\r\n\r\n/**\r\n * Install the resolved dependency sets through the project's package manager.\r\n * Runs two passes (prod then dev) so each lands in the correct section.\r\n */\r\nexport async function installDependencies(\n packageManager: PackageManager | undefined,\r\n dependencies: Record<string, string>,\r\n devDependencies: Record<string, string>,\r\n) {\r\n // `--package-manager` is optional; without it, fall back to the lockfile.\r\n const resolvedPackageManager = packageManager ?? (await detectPackageManager());\n const packageManagerCommand = getAddCommand(resolvedPackageManager);\n const exactPackageManagerCommand = getExactAddCommand(resolvedPackageManager);\n\n const installDependencySet = (\n dependencySet: Record<string, string>,\n development: boolean,\n ) => {\n const regularSpecs: string[] = [];\n const exactWarlockSpecs: string[] = [];\n\n for (const [name, version] of Object.entries(dependencySet)) {\n const spec = `${name}@${version}`;\n (isWarlockPackage(name) ? exactWarlockSpecs : regularSpecs).push(spec);\n }\n\n const developmentFlag = development ? \" -D\" : \"\";\n const runInstall = (command: string, specs: string[]) => {\n if (specs.length === 0) return;\n\n execSync(`${command} ${specs.join(\" \")}${developmentFlag}`, {\n cwd: process.cwd(),\n stdio: \"inherit\",\n });\n };\n\n runInstall(packageManagerCommand, regularSpecs);\n runInstall(exactPackageManagerCommand, exactWarlockSpecs);\n };\n\r\n if (Object.keys(dependencies).length > 0) {\r\n console.log(`Installing dependencies ${colors.magenta(Object.keys(dependencies).join(\", \"))}`);\r\n\r\n installDependencySet(dependencies, false);\n\r\n console.log(\r\n `Dependencies installed successfully ${colors.green(Object.keys(dependencies).join(\", \"))}`,\r\n );\r\n }\r\n\r\n if (Object.keys(devDependencies).length > 0) {\r\n console.log(\r\n `Installing dev dependencies ${colors.magenta(Object.keys(devDependencies).join(\", \"))}`,\r\n );\r\n\r\n installDependencySet(devDependencies, true);\n\r\n console.log(\r\n `Dev dependencies installed successfully ${colors.green(Object.keys(devDependencies).join(\", \"))}`,\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Write the resolved dependency sets into package.json without installing.\r\n * Used by `--no-install` so a scaffolder can batch every feature into one\r\n * install pass after the command returns. Versions come from the feature map.\r\n */\r\nasync function recordDependencies(\r\n dependencies: Record<string, string>,\r\n devDependencies: Record<string, string>,\r\n) {\r\n if (Object.keys(dependencies).length === 0 && Object.keys(devDependencies).length === 0) {\r\n return;\r\n }\r\n\r\n const packageJsonPath = rootPath(\"package.json\");\r\n const packageJson = await getJsonFileAsync<ProjectPackageJson>(packageJsonPath);\r\n\r\n packageJson.dependencies = packageJson.dependencies ?? {};\r\n packageJson.devDependencies = packageJson.devDependencies ?? {};\r\n\r\n Object.assign(packageJson.dependencies, dependencies);\r\n Object.assign(packageJson.devDependencies, devDependencies);\r\n\r\n await putJsonFileAsync(packageJsonPath, packageJson);\r\n\r\n const recorded = [...Object.keys(dependencies), ...Object.keys(devDependencies)];\r\n\r\n console.log(\r\n `Recorded ${colors.green(recorded.join(\", \"))} in package.json (install skipped via --no-install)`,\r\n );\r\n}\r\n\r\nfunction validateFeatures(features: string[]) {\n for (const feature of features) {\r\n if (!allowedFeatures.includes(feature)) {\r\n console.log(\r\n `Feature ${colors.redBright(feature)} is not allowed, allowed features are: ${colors.green(allowedFeatures.join(\", \"))}`,\r\n );\r\n process.exit(1);\r\n }\r\n }\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAa,kBAAkB,OAAO,KAAK,WAAW;AAEtD,SAAS,iBAAiB,aAA8B;CACtD,OAAO,YAAY,WAAW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K,IAAI,CAAC,GAC1F;CACF;CAEA,IAAI,OAAO,KAAK,eAAe,CAAC,CAAC,SAAS,GAAG;EAC3C,QAAQ,IACN,+BAA+B,OAAO,QAAQ,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI,CAAC,GACvF;EAEA,qBAAqB,iBAAiB,IAAI;EAE1C,QAAQ,IACN,2CAA2C,OAAO,MAAM,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI,CAAC,GACjG;CACF;AACF;;;;;;AAOA,eAAe,mBACb,cACA,iBACA;CACA,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,WAAW,KAAK,OAAO,KAAK,eAAe,CAAC,CAAC,WAAW,GACpF;CAGF,MAAM,kBAAkB,SAAS,cAAc;CAC/C,MAAM,cAAc,MAAM,iBAAqC,eAAe;CAE9E,YAAY,eAAe,YAAY,gBAAgB,CAAC;CACxD,YAAY,kBAAkB,YAAY,mBAAmB,CAAC;CAE9D,OAAO,OAAO,YAAY,cAAc,YAAY;CACpD,OAAO,OAAO,YAAY,iBAAiB,eAAe;CAE1D,MAAM,iBAAiB,iBAAiB,WAAW;CAEnD,MAAM,WAAW,CAAC,GAAG,OAAO,KAAK,YAAY,GAAG,GAAG,OAAO,KAAK,eAAe,CAAC;CAE/E,QAAQ,IACN,YAAY,OAAO,MAAM,SAAS,KAAK,IAAI,CAAC,EAAE,oDAChD;AACF;AAEA,SAAS,iBAAiB,UAAoB;CAC5C,KAAK,MAAM,WAAW,UACpB,IAAI,CAAC,gBAAgB,SAAS,OAAO,GAAG;EACtC,QAAQ,IACN,WAAW,OAAO,UAAU,OAAO,EAAE,yCAAyC,OAAO,MAAM,gBAAgB,KAAK,IAAI,CAAC,GACvH;EACA,QAAQ,KAAK,CAAC;CAChB;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"access.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/access.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n ensureDirectoryAsync,\r\n fileExistsAsync,\r\n getFileAsync,\r\n putFileAsync,\r\n} from \"@warlock.js/fs\";\r\nimport { CommandActionData } from \"../../commands/types\";\r\nimport { srcPath } from \"../../utils\";\r\nimport {\r\n accessConfigStub,\r\n accessResolverStub,\r\n accessRoleMigrationStub,\r\n accessRoleModelIndexStub,\r\n accessRoleModelStub,\r\n accessUserRoleMigrationStub,\r\n accessUserRoleModelIndexStub,\r\n accessUserRoleModelStub,\r\n} from \"../stubs\";\r\nimport { migrationTimestamp } from \"./shared/migration-timestamp\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nasync function registerAccessLocale() {\r\n // Register the access locale in the project's shared translations file so a\r\n // denied check returns a real sentence, not the raw \"access.errors.forbidden\"\r\n // key. Append when the file exists, create it otherwise; skip if already there.\r\n const localesPath = srcPath(\"app/shared/utils/locales.ts\");\r\n\r\n const accessLocale = `groupedTranslations(\"access\", {\r\n errors: {\r\n forbidden: {\r\n en: \"You do not have permission to perform this action.\",\r\n ar: \"ليس لديك صلاحية لتنفيذ هذا الإجراء.\",\r\n },\r\n },\r\n});\r\n`;\r\n\r\n if (await fileExistsAsync(localesPath)) {\r\n const current = await getFileAsync(localesPath);\r\n\r\n if (current.includes(`groupedTranslations(\"access\"`)) {\r\n console.log(`${colors.yellowBright(\"access\")} locale already registered, skipping...`);\r\n\r\n return;\r\n }\r\n\r\n // The file uses groupedTranslations already iff it calls it — only inject the\r\n // import when no call is present yet.\r\n const importLine = `import { groupedTranslations } from \"@warlock.js/core\";`;\r\n const prefix = current.includes(\"groupedTranslations(\") ? \"\" : `${importLine}\\n\\n`;\r\n\r\n await putFileAsync(localesPath, `${prefix}${current.trimEnd()}\\n\\n${accessLocale}`);\r\n\r\n console.log(\r\n `${colors.green(\"✓\")} Registered the access locale in src/app/shared/utils/locales.ts`,\r\n );\r\n\r\n return;\r\n }\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/shared/utils\"));\r\n\r\n await putFileAsync(\r\n localesPath,\r\n `import { groupedTranslations } from \"@warlock.js/core\";\\n\\n${accessLocale}`,\r\n );\r\n\r\n console.log(`${colors.green(\"✓\")} Created src/app/shared/utils/locales.ts with the access locale`);\r\n}\r\n\r\nasync function scaffoldAccessFiles() {\r\n // The resolver file is the sentinel for \"access already scaffolded\" — its\r\n // presence means the role/user-role model folders and their timestamped\r\n // migrations were created too, so we must not re-emit duplicate migrations on\r\n // a second run.\r\n const resolverPath = srcPath(\"app/access/services/access-resolver.ts\");\r\n\r\n if (await fileExistsAsync(resolverPath)) {\r\n console.log(\r\n `${colors.yellowBright(\"src/app/access\")} already scaffolded, skipping resolver + role tables...`,\r\n );\r\n\r\n return;\r\n }\r\n\r\n // 1. Role catalog model folder (model + barrel + migration). The catalog row\r\n // is role name → granted permissions; managed at runtime in the DB.\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/role\"));\r\n await putFileAsync(srcPath(\"app/access/models/role/role.model.ts\"), accessRoleModelStub);\r\n await putFileAsync(srcPath(\"app/access/models/role/index.ts\"), accessRoleModelIndexStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/models/role`);\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/role/migrations\"));\r\n\r\n // Migration filenames carry a MM-DD-YYYY_HH-MM-SS prefix so cascade infers\r\n // their createdAt and orders them deterministically (the migrate action\r\n // discovers src/app/*/models/*/migrations/*). The two tables are independent\r\n // (no FK between them), but the user-role migration is stamped a second later\r\n // so the relative order is stable.\r\n const roleMigrationFile = `${migrationTimestamp()}-role.migration.ts`;\r\n await putFileAsync(\r\n srcPath(\"app/access/models/role/migrations\", roleMigrationFile),\r\n accessRoleMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/access/models/role/migrations/${roleMigrationFile}`,\r\n );\r\n\r\n // 2. UserRole assignment model folder (model + barrel + migration). The model\r\n // statics scope an unresolved tenant to GLOBAL rows only (security\r\n // invariant) — see the stub for the reasoning.\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/user-role\"));\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/user-role.model.ts\"),\r\n accessUserRoleModelStub,\r\n );\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/index.ts\"),\r\n accessUserRoleModelIndexStub,\r\n );\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/models/user-role`);\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/user-role/migrations\"));\r\n\r\n const userRoleMigrationFile = `${migrationTimestamp(1)}-user-role.migration.ts`;\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/migrations\", userRoleMigrationFile),\r\n accessUserRoleMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/access/models/user-role/migrations/${userRoleMigrationFile}`,\r\n );\r\n\r\n // 3. The DatabaseAccessResolver — the one required config seam, wired into\r\n // config/access.ts by the ejected stub.\r\n await ensureDirectoryAsync(srcPath(\"app/access/services\"));\r\n await putFileAsync(resolverPath, accessResolverStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/services/access-resolver.ts`);\r\n}\r\n\r\nasync function completeAccessInstallation(_options: CommandActionData) {\r\n await registerAccessLocale();\r\n await scaffoldAccessFiles();\r\n}\r\n\r\nexport const accessFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/access — authorization (RBAC + ABAC): permission checks, ABAC policies, and roles. Ejects config/access.ts, the DatabaseAccessResolver + Role/UserRole models and migrations into src/app/access, and registers the access locale in src/app/shared/utils/locales.ts\",\r\n dependencies: {\r\n \"@warlock.js/access\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: accessConfigStub,\r\n name: \"access\",\r\n },\r\n onExecuting: completeAccessInstallation,\r\n};\r\n"],"mappings":";;;;;;;;;AAsBA,eAAe,uBAAuB;CAIpC,MAAM,cAAc,QAAQ,6BAA6B;CAEzD,MAAM,eAAe;;;;;;;;;CAUrB,IAAI,MAAM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AAyC;CAE1E,MAAM,qBAAqB,QAAQ,wCAAwC,CAAC;CAE5E,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,EAAE;CACvD,MAAM,aACJ,QAAQ,0CAA0C,qBAAqB,GACvE,2BACF;CACA,QAAQ,IACN,GAAG,OAAO,MAAM,GAAG,EAAE,sDAAsD,uBAC7E;CAIA,MAAM,qBAAqB,QAAQ,qBAAqB,CAAC;CACzD,MAAM,aAAa,cAAc,kBAAkB;CACnD,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,oDAAoD;AACvF;AAEA,eAAe,2BAA2B,UAA6B;CACrE,MAAM,qBAAqB;CAC3B,MAAM,oBAAoB;AAC5B;AAEA,MAAa,gBAAmC;CAC9C,aACE;CACF,cAAc,EACZ,sBAAsB,0BACxB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;CACA,aAAa;AACf"}
1
+ {"version":3,"file":"access.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/access.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n ensureDirectoryAsync,\r\n fileExistsAsync,\r\n getFileAsync,\r\n putFileAsync,\r\n} from \"@warlock.js/fs\";\r\nimport type { CommandActionData } from \"../../commands/types\";\r\nimport { srcPath } from \"../../utils\";\r\nimport {\r\n accessConfigStub,\r\n accessResolverStub,\r\n accessRoleMigrationStub,\r\n accessRoleModelIndexStub,\r\n accessRoleModelStub,\r\n accessUserRoleMigrationStub,\r\n accessUserRoleModelIndexStub,\r\n accessUserRoleModelStub,\r\n} from \"../stubs\";\r\nimport { migrationTimestamp } from \"./shared/migration-timestamp\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nasync function registerAccessLocale() {\r\n // Register the access locale in the project's shared translations file so a\r\n // denied check returns a real sentence, not the raw \"access.errors.forbidden\"\r\n // key. Append when the file exists, create it otherwise; skip if already there.\r\n const localesPath = srcPath(\"app/shared/utils/locales.ts\");\r\n\r\n const accessLocale = `groupedTranslations(\"access\", {\r\n errors: {\r\n forbidden: {\r\n en: \"You do not have permission to perform this action.\",\r\n ar: \"ليس لديك صلاحية لتنفيذ هذا الإجراء.\",\r\n },\r\n },\r\n});\r\n`;\r\n\r\n if (await fileExistsAsync(localesPath)) {\r\n const current = await getFileAsync(localesPath);\r\n\r\n if (current.includes(`groupedTranslations(\"access\"`)) {\r\n console.log(`${colors.yellowBright(\"access\")} locale already registered, skipping...`);\r\n\r\n return;\r\n }\r\n\r\n // The file uses groupedTranslations already iff it calls it — only inject the\r\n // import when no call is present yet.\r\n const importLine = `import { groupedTranslations } from \"@warlock.js/core\";`;\r\n const prefix = current.includes(\"groupedTranslations(\") ? \"\" : `${importLine}\\n\\n`;\r\n\r\n await putFileAsync(localesPath, `${prefix}${current.trimEnd()}\\n\\n${accessLocale}`);\r\n\r\n console.log(\r\n `${colors.green(\"✓\")} Registered the access locale in src/app/shared/utils/locales.ts`,\r\n );\r\n\r\n return;\r\n }\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/shared/utils\"));\r\n\r\n await putFileAsync(\r\n localesPath,\r\n `import { groupedTranslations } from \"@warlock.js/core\";\\n\\n${accessLocale}`,\r\n );\r\n\r\n console.log(`${colors.green(\"✓\")} Created src/app/shared/utils/locales.ts with the access locale`);\r\n}\r\n\r\nasync function scaffoldAccessFiles() {\r\n // The resolver file is the sentinel for \"access already scaffolded\" — its\r\n // presence means the role/user-role model folders and their timestamped\r\n // migrations were created too, so we must not re-emit duplicate migrations on\r\n // a second run.\r\n const resolverPath = srcPath(\"app/access/services/access-resolver.ts\");\r\n\r\n if (await fileExistsAsync(resolverPath)) {\r\n console.log(\r\n `${colors.yellowBright(\"src/app/access\")} already scaffolded, skipping resolver + role tables...`,\r\n );\r\n\r\n return;\r\n }\r\n\r\n // 1. Role catalog model folder (model + barrel + migration). The catalog row\r\n // is role name → granted permissions; managed at runtime in the DB.\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/role\"));\r\n await putFileAsync(srcPath(\"app/access/models/role/role.model.ts\"), accessRoleModelStub);\r\n await putFileAsync(srcPath(\"app/access/models/role/index.ts\"), accessRoleModelIndexStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/models/role`);\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/role/migrations\"));\r\n\r\n // Migration filenames carry a MM-DD-YYYY_HH-MM-SS prefix so cascade infers\r\n // their createdAt and orders them deterministically (the migrate action\r\n // discovers src/app/*/models/*/migrations/*). The two tables are independent\r\n // (no FK between them), but the user-role migration is stamped a second later\r\n // so the relative order is stable.\r\n const roleMigrationFile = `${migrationTimestamp()}-role.migration.ts`;\r\n await putFileAsync(\r\n srcPath(\"app/access/models/role/migrations\", roleMigrationFile),\r\n accessRoleMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/access/models/role/migrations/${roleMigrationFile}`,\r\n );\r\n\r\n // 2. UserRole assignment model folder (model + barrel + migration). The model\r\n // statics scope an unresolved tenant to GLOBAL rows only (security\r\n // invariant) — see the stub for the reasoning.\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/user-role\"));\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/user-role.model.ts\"),\r\n accessUserRoleModelStub,\r\n );\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/index.ts\"),\r\n accessUserRoleModelIndexStub,\r\n );\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/models/user-role`);\r\n\r\n await ensureDirectoryAsync(srcPath(\"app/access/models/user-role/migrations\"));\r\n\r\n const userRoleMigrationFile = `${migrationTimestamp(1)}-user-role.migration.ts`;\r\n await putFileAsync(\r\n srcPath(\"app/access/models/user-role/migrations\", userRoleMigrationFile),\r\n accessUserRoleMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/access/models/user-role/migrations/${userRoleMigrationFile}`,\r\n );\r\n\r\n // 3. The DatabaseAccessResolver — the one required config seam, wired into\r\n // config/access.ts by the ejected stub.\r\n await ensureDirectoryAsync(srcPath(\"app/access/services\"));\r\n await putFileAsync(resolverPath, accessResolverStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/access/services/access-resolver.ts`);\r\n}\r\n\r\nasync function completeAccessInstallation(_options: CommandActionData) {\r\n await registerAccessLocale();\r\n await scaffoldAccessFiles();\r\n}\r\n\r\nexport const accessFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/access — authorization (RBAC + ABAC): permission checks, ABAC policies, and roles. Ejects config/access.ts, the DatabaseAccessResolver + Role/UserRole models and migrations into src/app/access, and registers the access locale in src/app/shared/utils/locales.ts\",\r\n dependencies: {\r\n \"@warlock.js/access\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: accessConfigStub,\r\n name: \"access\",\r\n },\r\n onExecuting: completeAccessInstallation,\r\n};\r\n"],"mappings":";;;;;;;;;AAsBA,eAAe,uBAAuB;CAIpC,MAAM,cAAc,QAAQ,6BAA6B;CAEzD,MAAM,eAAe;;;;;;;;;CAUrB,IAAI,MAAM,gBAAgB,WAAW,GAAG;EACtC,MAAM,UAAU,MAAM,aAAa,WAAW;EAE9C,IAAI,QAAQ,SAAS,8BAA8B,GAAG;GACpD,QAAQ,IAAI,GAAG,OAAO,aAAa,QAAQ,EAAE,wCAAwC;GAErF;EACF;EAOA,MAAM,aAAa,aAAa,GAFjB,QAAQ,SAAS,sBAAsB,IAAI,KAAK,gEAEnB,QAAQ,QAAQ,EAAE,MAAM,cAAc;EAElF,QAAQ,IACN,GAAG,OAAO,MAAM,GAAG,EAAE,iEACvB;EAEA;CACF;CAEA,MAAM,qBAAqB,QAAQ,kBAAkB,CAAC;CAEtD,MAAM,aACJ,aACA,8DAA8D,cAChE;CAEA,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,gEAAgE;AACnG;AAEA,eAAe,sBAAsB;CAKnC,MAAM,eAAe,QAAQ,wCAAwC;CAErE,IAAI,MAAM,gBAAgB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1
- {"version":3,"file":"ai-anthropic.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-anthropic.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiAnthropicFeature: FeatureDefinition = {\r\n description: \"Anthropic (Claude) provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-anthropic\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,qBAAwC;CACnD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,4BAA4B,0BAC9B;AACF"}
1
+ {"version":3,"file":"ai-anthropic.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-anthropic.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiAnthropicFeature: FeatureDefinition = {\r\n description: \"Anthropic (Claude) provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-anthropic\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,qBAAwC;CACnD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,4BAA4B,0BAC9B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-bedrock.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-bedrock.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiBedrockFeature: FeatureDefinition = {\r\n description: \"AWS Bedrock provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-bedrock\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,mBAAsC;CACjD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,0BAA0B,0BAC5B;AACF"}
1
+ {"version":3,"file":"ai-bedrock.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-bedrock.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiBedrockFeature: FeatureDefinition = {\r\n description: \"AWS Bedrock provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-bedrock\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,mBAAsC;CACjD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,0BAA0B,0BAC5B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-google.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-google.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiGoogleFeature: FeatureDefinition = {\r\n description: \"Google (Gemini) provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-google\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
1
+ {"version":3,"file":"ai-google.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-google.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiGoogleFeature: FeatureDefinition = {\r\n description: \"Google (Gemini) provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-google\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-ollama.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-ollama.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiOllamaFeature: FeatureDefinition = {\r\n description: \"Ollama provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-ollama\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
1
+ {"version":3,"file":"ai-ollama.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-ollama.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiOllamaFeature: FeatureDefinition = {\r\n description: \"Ollama provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-ollama\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-openai.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-openai.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiOpenaiFeature: FeatureDefinition = {\r\n description: \"OpenAI provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-openai\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
1
+ {"version":3,"file":"ai-openai.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-openai.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiOpenaiFeature: FeatureDefinition = {\r\n description: \"OpenAI provider for @warlock.js/ai (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-openai\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-panoptic.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-panoptic.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiPanopticFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-panoptic — observability for @warlock.js/ai (collector, exporters, zero-setup local dashboard) via ai.config({ panoptic }) (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-panoptic\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-panoptic\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,oBAAuC;CAClD,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,2BAA2B,0BAC7B;CACA,mBAAmB,oBAAoB,yBAAyB;AAClE"}
1
+ {"version":3,"file":"ai-panoptic.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-panoptic.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiPanopticFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-panoptic — observability for @warlock.js/ai (collector, exporters, zero-setup local dashboard) via ai.config({ panoptic }) (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-panoptic\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-panoptic\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,oBAAuC;CAClD,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,2BAA2B,0BAC7B;CACA,mBAAmB,oBAAoB,yBAAyB;AAClE"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-tools.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-tools.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiToolsFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-tools — ready-made agent tools (web search, fetch, HTTP, calculator, date-time) + an MCP client/server, under ai.tools.* / ai.mcp (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-tools\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-tools\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,iBAAoC;CAC/C,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,wBAAwB,0BAC1B;CACA,mBAAmB,oBAAoB,sBAAsB;AAC/D"}
1
+ {"version":3,"file":"ai-tools.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-tools.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiToolsFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-tools — ready-made agent tools (web search, fetch, HTTP, calculator, date-time) + an MCP client/server, under ai.tools.* / ai.mcp (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-tools\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-tools\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,iBAAoC;CAC/C,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,wBAAwB,0BAC1B;CACA,mBAAmB,oBAAoB,sBAAsB;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-workspace.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-workspace.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiWorkspaceFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-workspace — a policy-jailed filesystem + shell workspace for coding agents, as ai.workspace (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-workspace\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-workspace\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,qBAAwC;CACnD,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,4BAA4B,0BAC9B;CACA,mBAAmB,oBAAoB,0BAA0B;AACnE"}
1
+ {"version":3,"file":"ai-workspace.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai-workspace.feature.ts"],"sourcesContent":["import { linkAiPackageImport } from \"./shared/link-ai-package-import\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiWorkspaceFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/ai-workspace — a policy-jailed filesystem + shell workspace for coding agents, as ai.workspace (pulls the core ai package)\",\r\n requires: [\"ai\"],\r\n dependencies: {\r\n \"@warlock.js/ai-workspace\": INSTALLED_WARLOCK_VERSION,\n },\r\n onExecuting: () => linkAiPackageImport(\"@warlock.js/ai-workspace\"),\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,qBAAwC;CACnD,aACE;CACF,UAAU,CAAC,IAAI;CACf,cAAc,EACZ,4BAA4B,0BAC9B;CACA,mBAAmB,oBAAoB,0BAA0B;AACnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai.feature.ts"],"sourcesContent":["import { aiConfigStub } from \"../stubs\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiFeature: FeatureDefinition = {\r\n description: \"Installs @warlock.js/ai — the core AI toolkit (agents, tools, workflows)\",\r\n dependencies: {\r\n \"@warlock.js/ai\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: aiConfigStub,\r\n name: \"ai\",\r\n },\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,YAA+B;CAC1C,aAAa;CACb,cAAc,EACZ,kBAAkB,0BACpB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"ai.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/ai.feature.ts"],"sourcesContent":["import { aiConfigStub } from \"../stubs\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const aiFeature: FeatureDefinition = {\r\n description: \"Installs @warlock.js/ai — the core AI toolkit (agents, tools, workflows)\",\r\n dependencies: {\r\n \"@warlock.js/ai\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: aiConfigStub,\r\n name: \"ai\",\r\n },\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,YAA+B;CAC1C,aAAa;CACb,cAAc,EACZ,kBAAkB,0BACpB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"herald.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/herald.feature.ts"],"sourcesContent":["import { communicatorsConfigStub } from \"../stubs\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const heraldFeature: FeatureDefinition = {\r\n description: \"Installs herald for message broker (Herald Package)\",\r\n dependencies: {\r\n \"@warlock.js/herald\": INSTALLED_WARLOCK_VERSION,\n amqplib: \"^0.10.0\",\r\n },\r\n devDependencies: {\r\n \"@types/amqplib\": \"^0.10.0\",\r\n },\r\n ejectConfig: {\r\n content: communicatorsConfigStub,\r\n name: \"herald\",\r\n },\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,gBAAmC;CAC9C,aAAa;CACb,cAAc;EACZ,sBAAsB;EACtB,SAAS;CACX;CACA,iBAAiB,EACf,kBAAkB,UACpB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"herald.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/herald.feature.ts"],"sourcesContent":["import { communicatorsConfigStub } from \"../stubs\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const heraldFeature: FeatureDefinition = {\r\n description: \"Installs herald for message broker (Herald Package)\",\r\n dependencies: {\r\n \"@warlock.js/herald\": INSTALLED_WARLOCK_VERSION,\n amqplib: \"^0.10.0\",\r\n },\r\n devDependencies: {\r\n \"@types/amqplib\": \"^0.10.0\",\r\n },\r\n ejectConfig: {\r\n content: communicatorsConfigStub,\r\n name: \"herald\",\r\n },\r\n};\r\n"],"mappings":";;;;AAGA,MAAa,gBAAmC;CAC9C,aAAa;CACb,cAAc;EACZ,sBAAsB;EACtB,SAAS;CACX;CACA,iBAAiB,EACf,kBAAkB,UACpB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"image.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/image.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const imageFeature: FeatureDefinition = {\r\n description: \"Installs sharp for image processing\",\r\n dependencies: {\r\n sharp: \"^0.34.5\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,OAAO,UACT;AACF"}
1
+ {"version":3,"file":"image.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/image.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const imageFeature: FeatureDefinition = {\r\n description: \"Installs sharp for image processing\",\r\n dependencies: {\r\n sharp: \"^0.34.5\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,OAAO,UACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/index.ts"],"sourcesContent":["import { accessFeature } from \"./access.feature\";\r\nimport { aiAnthropicFeature } from \"./ai-anthropic.feature\";\r\nimport { aiBedrockFeature } from \"./ai-bedrock.feature\";\r\nimport { aiGoogleFeature } from \"./ai-google.feature\";\r\nimport { aiOllamaFeature } from \"./ai-ollama.feature\";\r\nimport { aiOpenaiFeature } from \"./ai-openai.feature\";\r\nimport { aiPanopticFeature } from \"./ai-panoptic.feature\";\r\nimport { aiToolsFeature } from \"./ai-tools.feature\";\r\nimport { aiWorkspaceFeature } from \"./ai-workspace.feature\";\r\nimport { aiFeature } from \"./ai.feature\";\r\nimport { heraldFeature } from \"./herald.feature\";\r\nimport { imageFeature } from \"./image.feature\";\r\nimport { mailFeature } from \"./mail.feature\";\r\nimport { mongodbFeature } from \"./mongodb.feature\";\r\nimport { mysqlFeature } from \"./mysql.feature\";\r\nimport { notificationsFeature } from \"./notifications.feature\";\r\nimport { postgresFeature } from \"./postgres.feature\";\r\nimport { reactEmailFeature } from \"./react-email.feature\";\r\nimport { reactFeature } from \"./react.feature\";\r\nimport { redisFeature } from \"./redis.feature\";\r\nimport { s3Feature } from \"./s3.feature\";\r\nimport { schedulerFeature } from \"./scheduler.feature\";\r\nimport { sesFeature } from \"./ses.feature\";\r\nimport { shadcnFeature } from \"./shadcn.feature\";\r\nimport { socketFeature } from \"./socket.feature\";\r\nimport { tailwindFeature } from \"./tailwind.feature\";\r\nimport { testFeature } from \"./test.feature\";\r\nimport { FeatureDefinition } from \"./types\";\r\nimport { webFeature } from \"./web.feature\";\r\n\r\nexport type { FeatureDefinition } from \"./types\";\r\n\r\n/**\r\n * The feature registry `warlock add` dispatches against.\r\n *\r\n * This file is an INDEX, nothing more: every entry lives in its own module\r\n * alongside the `onExecuting` body it runs. Key order is load-bearing — it is\r\n * the order `--list` prints and the order the \"not allowed\" error lists — so\r\n * add new features in the place they should appear, not alphabetically.\r\n */\r\nexport const featuresMap: Record<string, FeatureDefinition> = {\r\n \"react-email\": reactEmailFeature,\r\n react: reactFeature,\r\n image: imageFeature,\r\n mail: mailFeature,\r\n ses: sesFeature,\r\n mongodb: mongodbFeature,\r\n scheduler: schedulerFeature,\r\n // swagger / postman intentionally omitted — those packages do not exist yet;\r\n // they will ship together in the unified @warlock.js/api-docs package.\r\n postgres: postgresFeature,\r\n mysql: mysqlFeature,\r\n redis: redisFeature,\r\n s3: s3Feature,\r\n test: testFeature,\r\n web: webFeature,\r\n // Directly after `web`, and only there: it `requires` it, it is useless\r\n // without it, and a reader scanning `--list` for the page stack should meet\r\n // the two together rather than find styling filed between queues and sockets.\r\n tailwind: tailwindFeature,\r\n // Immediately after `tailwind`, for the same reason `tailwind` follows `web`:\r\n // it `requires` it, it appends to the stylesheet that feature creates, and the\r\n // three of them are one stack a reader should meet in build order.\r\n shadcn: shadcnFeature,\r\n herald: heraldFeature,\r\n socket: socketFeature,\r\n notifications: notificationsFeature,\r\n access: accessFeature,\r\n ai: aiFeature,\r\n \"ai-openai\": aiOpenaiFeature,\r\n \"ai-google\": aiGoogleFeature,\r\n \"ai-anthropic\": aiAnthropicFeature,\r\n \"ai-bedrock\": aiBedrockFeature,\r\n \"ai-ollama\": aiOllamaFeature,\r\n \"ai-tools\": aiToolsFeature,\r\n \"ai-panoptic\": aiPanopticFeature,\r\n \"ai-workspace\": aiWorkspaceFeature,\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,cAAiD;CAC5D,eAAe;CACf,OAAO;CACP,OAAO;CACP,MAAM;CACN,KAAK;CACL,SAAS;CACT,WAAW;CAGX,UAAU;CACV,OAAO;CACP,OAAO;CACP,IAAI;CACJ,MAAM;CACN,KAAK;CAIL,UAAU;CAIV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,QAAQ;CACR,IAAI;CACJ,aAAa;CACb,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,aAAa;CACb,YAAY;CACZ,eAAe;CACf,gBAAgB;AAClB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/index.ts"],"sourcesContent":["import { accessFeature } from \"./access.feature\";\r\nimport { aiAnthropicFeature } from \"./ai-anthropic.feature\";\r\nimport { aiBedrockFeature } from \"./ai-bedrock.feature\";\r\nimport { aiGoogleFeature } from \"./ai-google.feature\";\r\nimport { aiOllamaFeature } from \"./ai-ollama.feature\";\r\nimport { aiOpenaiFeature } from \"./ai-openai.feature\";\r\nimport { aiPanopticFeature } from \"./ai-panoptic.feature\";\r\nimport { aiToolsFeature } from \"./ai-tools.feature\";\r\nimport { aiWorkspaceFeature } from \"./ai-workspace.feature\";\r\nimport { aiFeature } from \"./ai.feature\";\r\nimport { heraldFeature } from \"./herald.feature\";\r\nimport { imageFeature } from \"./image.feature\";\r\nimport { mailFeature } from \"./mail.feature\";\r\nimport { mongodbFeature } from \"./mongodb.feature\";\r\nimport { mysqlFeature } from \"./mysql.feature\";\r\nimport { notificationsFeature } from \"./notifications.feature\";\r\nimport { postgresFeature } from \"./postgres.feature\";\r\nimport { reactEmailFeature } from \"./react-email.feature\";\r\nimport { reactFeature } from \"./react.feature\";\r\nimport { redisFeature } from \"./redis.feature\";\r\nimport { s3Feature } from \"./s3.feature\";\r\nimport { schedulerFeature } from \"./scheduler.feature\";\r\nimport { sesFeature } from \"./ses.feature\";\r\nimport { shadcnFeature } from \"./shadcn.feature\";\r\nimport { socketFeature } from \"./socket.feature\";\r\nimport { tailwindFeature } from \"./tailwind.feature\";\r\nimport { testFeature } from \"./test.feature\";\r\nimport type { FeatureDefinition } from \"./types\";\r\nimport { webFeature } from \"./web.feature\";\r\n\r\nexport type { FeatureDefinition } from \"./types\";\r\n\r\n/**\r\n * The feature registry `warlock add` dispatches against.\r\n *\r\n * This file is an INDEX, nothing more: every entry lives in its own module\r\n * alongside the `onExecuting` body it runs. Key order is load-bearing — it is\r\n * the order `--list` prints and the order the \"not allowed\" error lists — so\r\n * add new features in the place they should appear, not alphabetically.\r\n */\r\nexport const featuresMap: Record<string, FeatureDefinition> = {\r\n \"react-email\": reactEmailFeature,\r\n react: reactFeature,\r\n image: imageFeature,\r\n mail: mailFeature,\r\n ses: sesFeature,\r\n mongodb: mongodbFeature,\r\n scheduler: schedulerFeature,\r\n // swagger / postman intentionally omitted — those packages do not exist yet;\r\n // they will ship together in the unified @warlock.js/api-docs package.\r\n postgres: postgresFeature,\r\n mysql: mysqlFeature,\r\n redis: redisFeature,\r\n s3: s3Feature,\r\n test: testFeature,\r\n web: webFeature,\r\n // Directly after `web`, and only there: it `requires` it, it is useless\r\n // without it, and a reader scanning `--list` for the page stack should meet\r\n // the two together rather than find styling filed between queues and sockets.\r\n tailwind: tailwindFeature,\r\n // Immediately after `tailwind`, for the same reason `tailwind` follows `web`:\r\n // it `requires` it, it appends to the stylesheet that feature creates, and the\r\n // three of them are one stack a reader should meet in build order.\r\n shadcn: shadcnFeature,\r\n herald: heraldFeature,\r\n socket: socketFeature,\r\n notifications: notificationsFeature,\r\n access: accessFeature,\r\n ai: aiFeature,\r\n \"ai-openai\": aiOpenaiFeature,\r\n \"ai-google\": aiGoogleFeature,\r\n \"ai-anthropic\": aiAnthropicFeature,\r\n \"ai-bedrock\": aiBedrockFeature,\r\n \"ai-ollama\": aiOllamaFeature,\r\n \"ai-tools\": aiToolsFeature,\r\n \"ai-panoptic\": aiPanopticFeature,\r\n \"ai-workspace\": aiWorkspaceFeature,\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,cAAiD;CAC5D,eAAe;CACf,OAAO;CACP,OAAO;CACP,MAAM;CACN,KAAK;CACL,SAAS;CACT,WAAW;CAGX,UAAU;CACV,OAAO;CACP,OAAO;CACP,IAAI;CACJ,MAAM;CACN,KAAK;CAIL,UAAU;CAIV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,QAAQ;CACR,IAAI;CACJ,aAAa;CACb,aAAa;CACb,gBAAgB;CAChB,cAAc;CACd,aAAa;CACb,YAAY;CACZ,eAAe;CACf,gBAAgB;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"mail.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mail.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const mailFeature: FeatureDefinition = {\r\n description: \"Installs nodemailer for sending emails\",\r\n dependencies: {\r\n nodemailer: \"^8.0.5\",\r\n },\r\n devDependencies: {\r\n \"@types/nodemailer\": \"^8.0.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,cAAiC;CAC5C,aAAa;CACb,cAAc,EACZ,YAAY,SACd;CACA,iBAAiB,EACf,qBAAqB,SACvB;AACF"}
1
+ {"version":3,"file":"mail.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mail.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const mailFeature: FeatureDefinition = {\r\n description: \"Installs nodemailer for sending emails\",\r\n dependencies: {\r\n nodemailer: \"^8.0.5\",\r\n },\r\n devDependencies: {\r\n \"@types/nodemailer\": \"^8.0.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,cAAiC;CAC5C,aAAa;CACb,cAAc,EACZ,YAAY,SACd;CACA,iBAAiB,EACf,qBAAqB,SACvB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"mongodb.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mongodb.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const mongodbFeature: FeatureDefinition = {\r\n description: \"Installs mongodb driver for database driver (Cascade Package)\",\r\n dependencies: {\r\n mongodb: \"^7.0.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,iBAAoC;CAC/C,aAAa;CACb,cAAc,EACZ,SAAS,SACX;AACF"}
1
+ {"version":3,"file":"mongodb.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mongodb.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const mongodbFeature: FeatureDefinition = {\r\n description: \"Installs mongodb driver for database driver (Cascade Package)\",\r\n dependencies: {\r\n mongodb: \"^7.0.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,iBAAoC;CAC/C,aAAa;CACb,cAAc,EACZ,SAAS,SACX;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"mysql.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mysql.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const mysqlFeature: FeatureDefinition = {\r\n description: \"Installs mysql2 for MySQL database driver (Cascade Package)\",\r\n dependencies: {\r\n mysql2: \"^3.5.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,QAAQ,SACV;AACF"}
1
+ {"version":3,"file":"mysql.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/mysql.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const mysqlFeature: FeatureDefinition = {\r\n description: \"Installs mysql2 for MySQL database driver (Cascade Package)\",\r\n dependencies: {\r\n mysql2: \"^3.5.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,QAAQ,SACV;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/notifications.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { ensureDirectoryAsync, fileExistsAsync, putFileAsync } from \"@warlock.js/fs\";\r\nimport { CommandActionData } from \"../../commands/types\";\r\nimport { srcPath } from \"../../utils\";\r\nimport {\r\n notificationControllersStub,\r\n notificationMigrationStub,\r\n notificationModelStub,\r\n notificationRoutesStub,\r\n notificationsConfigStub,\r\n} from \"../stubs\";\r\nimport { migrationTimestamp } from \"./shared/migration-timestamp\";\r\nimport { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nasync function completeNotificationsInstallation(_options: CommandActionData) {\r\n const modelPath = srcPath(\"app/notifications/notification.model.ts\");\r\n\r\n // The model file is the sentinel for \"notifications already scaffolded\" —\r\n // its presence means the migration was created too (timestamped, so we must\r\n // not re-emit a duplicate on a second run).\r\n if (await fileExistsAsync(modelPath)) {\r\n console.log(\r\n `${colors.yellowBright(\"src/app/notifications\")} already scaffolded, skipping model + migration...`,\r\n );\r\n return;\r\n }\r\n\r\n // 1. Notification model — extends the package's DatabaseNotification base.\r\n await ensureDirectoryAsync(srcPath(\"app/notifications\"));\r\n await putFileAsync(modelPath, notificationModelStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/notifications/notification.model.ts`);\r\n\r\n // 2. Migration — timestamped MM-DD-YYYY_HH-MM-SS prefix so cascade infers its\r\n // createdAt and orders it deterministically (migrate-action discovers\r\n // src/app/*/migrations/*).\r\n await ensureDirectoryAsync(srcPath(\"app/notifications/migrations\"));\r\n\r\n const migrationFile = `${migrationTimestamp()}-notification.migration.ts`;\r\n\r\n await putFileAsync(\r\n srcPath(\"app/notifications/migrations\", migrationFile),\r\n notificationMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/notifications/migrations/${migrationFile}`,\r\n );\r\n\r\n // 3. HTTP surface — the in-app read/dismiss endpoints (routes + controllers),\r\n // gated by authMiddleware. Delete if the app exposes notifications another way.\r\n await ensureDirectoryAsync(srcPath(\"app/notifications/controllers\"));\r\n await putFileAsync(\r\n srcPath(\"app/notifications/controllers/notifications.controller.ts\"),\r\n notificationControllersStub,\r\n );\r\n await putFileAsync(srcPath(\"app/notifications/routes.ts\"), notificationRoutesStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/notifications/routes.ts + controllers`);\r\n}\r\n\r\nexport const notificationsFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/notifications — multi-channel notifications (mail + in-app database). Pulls the mail feature, ejects config/notifications.ts, and scaffolds the Notification model + migration plus the recipient-scoped read/dismiss routes + controllers into src/app/notifications\",\r\n // The ejected config wires a `mail` channel by default (needs nodemailer,\r\n // via the `mail` feature); the scaffolded routes are gated by\r\n // `authMiddleware`, so `@warlock.js/auth` is pulled in too.\r\n requires: [\"mail\"],\r\n dependencies: {\r\n \"@warlock.js/notifications\": INSTALLED_WARLOCK_VERSION,\n \"@warlock.js/auth\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: notificationsConfigStub,\r\n name: \"notifications\",\r\n },\r\n onExecuting: completeNotificationsInstallation,\r\n};\r\n"],"mappings":";;;;;;;;;AAcA,eAAe,kCAAkC,UAA6B;CAC5E,MAAM,YAAY,QAAQ,yCAAyC;CAKnE,IAAI,MAAM,gBAAgB,SAAS,GAAG;EACpC,QAAQ,IACN,GAAG,OAAO,aAAa,uBAAuB,EAAE,mDAClD;EACA;CACF;CAGA,MAAM,qBAAqB,QAAQ,mBAAmB,CAAC;CACvD,MAAM,aAAa,WAAW,qBAAqB;CACnD,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,qDAAqD;CAKtF,MAAM,qBAAqB,QAAQ,8BAA8B,CAAC;CAElE,MAAM,gBAAgB,GAAG,mBAAmB,EAAE;CAE9C,MAAM,aACJ,QAAQ,gCAAgC,aAAa,GACrD,yBACF;CACA,QAAQ,IACN,GAAG,OAAO,MAAM,GAAG,EAAE,4CAA4C,eACnE;CAIA,MAAM,qBAAqB,QAAQ,+BAA+B,CAAC;CACnE,MAAM,aACJ,QAAQ,2DAA2D,GACnE,2BACF;CACA,MAAM,aAAa,QAAQ,6BAA6B,GAAG,sBAAsB;CACjF,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,uDAAuD;AAC1F;AAEA,MAAa,uBAA0C;CACrD,aACE;CAIF,UAAU,CAAC,MAAM;CACjB,cAAc;EACZ,6BAA6B;EAC7B,oBAAoB;CACtB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;CACA,aAAa;AACf"}
1
+ {"version":3,"file":"notifications.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/notifications.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { ensureDirectoryAsync, fileExistsAsync, putFileAsync } from \"@warlock.js/fs\";\r\nimport type { CommandActionData } from \"../../commands/types\";\r\nimport { srcPath } from \"../../utils\";\r\nimport {\r\n notificationControllersStub,\r\n notificationMigrationStub,\r\n notificationModelStub,\r\n notificationRoutesStub,\r\n notificationsConfigStub,\r\n} from \"../stubs\";\r\nimport { migrationTimestamp } from \"./shared/migration-timestamp\";\r\nimport { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nasync function completeNotificationsInstallation(_options: CommandActionData) {\r\n const modelPath = srcPath(\"app/notifications/notification.model.ts\");\r\n\r\n // The model file is the sentinel for \"notifications already scaffolded\" —\r\n // its presence means the migration was created too (timestamped, so we must\r\n // not re-emit a duplicate on a second run).\r\n if (await fileExistsAsync(modelPath)) {\r\n console.log(\r\n `${colors.yellowBright(\"src/app/notifications\")} already scaffolded, skipping model + migration...`,\r\n );\r\n return;\r\n }\r\n\r\n // 1. Notification model — extends the package's DatabaseNotification base.\r\n await ensureDirectoryAsync(srcPath(\"app/notifications\"));\r\n await putFileAsync(modelPath, notificationModelStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/notifications/notification.model.ts`);\r\n\r\n // 2. Migration — timestamped MM-DD-YYYY_HH-MM-SS prefix so cascade infers its\r\n // createdAt and orders it deterministically (migrate-action discovers\r\n // src/app/*/migrations/*).\r\n await ensureDirectoryAsync(srcPath(\"app/notifications/migrations\"));\r\n\r\n const migrationFile = `${migrationTimestamp()}-notification.migration.ts`;\r\n\r\n await putFileAsync(\r\n srcPath(\"app/notifications/migrations\", migrationFile),\r\n notificationMigrationStub,\r\n );\r\n console.log(\r\n `${colors.green(\"✓\")} Created src/app/notifications/migrations/${migrationFile}`,\r\n );\r\n\r\n // 3. HTTP surface — the in-app read/dismiss endpoints (routes + controllers),\r\n // gated by authMiddleware. Delete if the app exposes notifications another way.\r\n await ensureDirectoryAsync(srcPath(\"app/notifications/controllers\"));\r\n await putFileAsync(\r\n srcPath(\"app/notifications/controllers/notifications.controller.ts\"),\r\n notificationControllersStub,\r\n );\r\n await putFileAsync(srcPath(\"app/notifications/routes.ts\"), notificationRoutesStub);\r\n console.log(`${colors.green(\"✓\")} Created src/app/notifications/routes.ts + controllers`);\r\n}\r\n\r\nexport const notificationsFeature: FeatureDefinition = {\r\n description:\r\n \"Installs @warlock.js/notifications — multi-channel notifications (mail + in-app database). Pulls the mail feature, ejects config/notifications.ts, and scaffolds the Notification model + migration plus the recipient-scoped read/dismiss routes + controllers into src/app/notifications\",\r\n // The ejected config wires a `mail` channel by default (needs nodemailer,\r\n // via the `mail` feature); the scaffolded routes are gated by\r\n // `authMiddleware`, so `@warlock.js/auth` is pulled in too.\r\n requires: [\"mail\"],\r\n dependencies: {\r\n \"@warlock.js/notifications\": INSTALLED_WARLOCK_VERSION,\n \"@warlock.js/auth\": INSTALLED_WARLOCK_VERSION,\n },\r\n ejectConfig: {\r\n content: notificationsConfigStub,\r\n name: \"notifications\",\r\n },\r\n onExecuting: completeNotificationsInstallation,\r\n};\r\n"],"mappings":";;;;;;;;;AAcA,eAAe,kCAAkC,UAA6B;CAC5E,MAAM,YAAY,QAAQ,yCAAyC;CAKnE,IAAI,MAAM,gBAAgB,SAAS,GAAG;EACpC,QAAQ,IACN,GAAG,OAAO,aAAa,uBAAuB,EAAE,mDAClD;EACA;CACF;CAGA,MAAM,qBAAqB,QAAQ,mBAAmB,CAAC;CACvD,MAAM,aAAa,WAAW,qBAAqB;CACnD,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,qDAAqD;CAKtF,MAAM,qBAAqB,QAAQ,8BAA8B,CAAC;CAElE,MAAM,gBAAgB,GAAG,mBAAmB,EAAE;CAE9C,MAAM,aACJ,QAAQ,gCAAgC,aAAa,GACrD,yBACF;CACA,QAAQ,IACN,GAAG,OAAO,MAAM,GAAG,EAAE,4CAA4C,eACnE;CAIA,MAAM,qBAAqB,QAAQ,+BAA+B,CAAC;CACnE,MAAM,aACJ,QAAQ,2DAA2D,GACnE,2BACF;CACA,MAAM,aAAa,QAAQ,6BAA6B,GAAG,sBAAsB;CACjF,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,uDAAuD;AAC1F;AAEA,MAAa,uBAA0C;CACrD,aACE;CAIF,UAAU,CAAC,MAAM;CACjB,cAAc;EACZ,6BAA6B;EAC7B,oBAAoB;CACtB;CACA,aAAa;EACX,SAAS;EACT,MAAM;CACR;CACA,aAAa;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/postgres.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const postgresFeature: FeatureDefinition = {\r\n description: \"Installs pg for Postgres database (Cascade Package)\",\r\n dependencies: {\r\n pg: \"^8.11.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,cAAc,EACZ,IAAI,UACN;AACF"}
1
+ {"version":3,"file":"postgres.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/postgres.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const postgresFeature: FeatureDefinition = {\r\n description: \"Installs pg for Postgres database (Cascade Package)\",\r\n dependencies: {\r\n pg: \"^8.11.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,kBAAqC;CAChD,aAAa;CACb,cAAc,EACZ,IAAI,UACN;AACF"}
@@ -1,7 +1,8 @@
1
1
  import { rootPath } from "../../utils/paths.mjs";
2
2
  import "../../utils/index.mjs";
3
+ import { patchTsconfigInclude } from "./shared/patch-tsconfig-include.mjs";
3
4
  import { colors } from "@mongez/copper";
4
- import { ensureDirectoryAsync, fileExistsAsync, getJsonFileAsync, putFileAsync, putJsonFileAsync } from "@warlock.js/fs";
5
+ import { ensureDirectoryAsync, fileExistsAsync, putFileAsync } from "@warlock.js/fs";
5
6
 
6
7
  //#region ../core/src/generations/features/react-email.feature.ts
7
8
  async function completeReactEmailInstallation(_options) {
@@ -42,14 +43,7 @@ export default function WelcomeEmail({ name }: WelcomeEmailProps) {
42
43
  `);
43
44
  console.log(`${colors.green("✓")} Created emails/welcome-email.tsx`);
44
45
  }
45
- const tsconfigPath = rootPath("tsconfig.json");
46
- const tsconfig = await getJsonFileAsync(tsconfigPath);
47
- if (!tsconfig.include) tsconfig.include = [];
48
- if (!tsconfig.include.includes("emails")) {
49
- tsconfig.include.push("emails");
50
- await putJsonFileAsync(tsconfigPath, tsconfig);
51
- console.log(`${colors.green("✓")} Added "emails" to tsconfig.json include`);
52
- }
46
+ await patchTsconfigInclude("emails", "Without it, the email components under emails/ are outside the project and do not typecheck.");
53
47
  }
54
48
  const reactEmailFeature = {
55
49
  description: "Installs react-email for building email templates with React and Tailwind",
@@ -1 +1 @@
1
- {"version":3,"file":"react-email.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/react-email.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport {\r\n ensureDirectoryAsync,\r\n fileExistsAsync,\r\n getJsonFileAsync,\r\n putFileAsync,\r\n putJsonFileAsync,\r\n} from \"@warlock.js/fs\";\r\nimport { CommandActionData } from \"../../commands/types\";\r\nimport { rootPath } from \"../../utils\";\r\nimport { FeatureDefinition } from \"./types\";\r\n\r\n/**\r\n * The part of a project `tsconfig.json` this action patches.\r\n */\r\ntype ProjectTsConfig = {\r\n include?: string[];\r\n};\r\n\r\nasync function completeReactEmailInstallation(_options: CommandActionData) {\r\n // 1. Create emails/ folder with a sample component\r\n const emailsFolderPath = rootPath(\"emails\");\r\n const sampleEmailPath = rootPath(\"emails/welcome-email.tsx\");\r\n\r\n if (!(await fileExistsAsync(sampleEmailPath))) {\r\n await ensureDirectoryAsync(emailsFolderPath);\r\n await putFileAsync(\r\n sampleEmailPath,\r\n `import { Body, Container, Head, Html, Text } from \"@react-email/components\";\r\nimport { Tailwind } from \"@react-email/tailwind\";\r\n\r\ninterface WelcomeEmailProps {\r\n name: string;\r\n}\r\n\r\n/**\r\n * Sample welcome email component.\r\n * Preview with: yarn email:preview\r\n */\r\nexport default function WelcomeEmail({ name }: WelcomeEmailProps) {\r\n return (\r\n <Html>\r\n <Head />\r\n <Tailwind>\r\n <Body className=\"bg-gray-100 font-sans\">\r\n <Container className=\"mx-auto max-w-xl py-8 px-4\">\r\n <Text className=\"text-2xl font-bold text-gray-900\">\r\n Welcome, {name}!\r\n </Text>\r\n <Text className=\"text-gray-600 mt-2\">\r\n You're all set. We're glad to have you on board.\r\n </Text>\r\n </Container>\r\n </Body>\r\n </Tailwind>\r\n </Html>\r\n );\r\n}\r\n`,\r\n );\r\n console.log(`${colors.green(\"✓\")} Created emails/welcome-email.tsx`);\r\n }\r\n\r\n // 2. Patch tsconfig.json — add \"emails\" to include if missing\r\n const tsconfigPath = rootPath(\"tsconfig.json\");\r\n const tsconfig = await getJsonFileAsync<ProjectTsConfig>(tsconfigPath);\r\n\r\n if (!tsconfig.include) {\r\n tsconfig.include = [];\r\n }\r\n\r\n if (!tsconfig.include.includes(\"emails\")) {\r\n tsconfig.include.push(\"emails\");\r\n await putJsonFileAsync(tsconfigPath, tsconfig);\r\n console.log(`${colors.green(\"✓\")} Added \"emails\" to tsconfig.json include`);\r\n }\r\n}\r\n\r\nexport const reactEmailFeature: FeatureDefinition = {\r\n description: \"Installs react-email for building email templates with React and Tailwind\",\r\n requires: [\"mail\", \"react\"],\r\n dependencies: {\r\n \"react-email\": \"^5.2.10\",\r\n \"@react-email/components\": \"^1.0.11\",\r\n \"@react-email/render\": \"^2.0.5\",\r\n \"@react-email/tailwind\": \"^2.0.7\",\r\n },\r\n devDependencies: {\r\n \"@react-email/preview-server\": \"5.2.10\",\r\n },\r\n script: {\r\n \"email:preview\": \"npx react-email dev\",\r\n },\r\n onExecuting: completeReactEmailInstallation,\r\n};\r\n"],"mappings":";;;;;;AAmBA,eAAe,+BAA+B,UAA6B;CAEzE,MAAM,mBAAmB,SAAS,QAAQ;CAC1C,MAAM,kBAAkB,SAAS,0BAA0B;CAE3D,IAAI,CAAE,MAAM,gBAAgB,eAAe,GAAI;EAC7C,MAAM,qBAAqB,gBAAgB;EAC3C,MAAM,aACJ,iBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BF;EACA,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,kCAAkC;CACrE;CAGA,MAAM,eAAe,SAAS,eAAe;CAC7C,MAAM,WAAW,MAAM,iBAAkC,YAAY;CAErE,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,CAAC;CAGtB,IAAI,CAAC,SAAS,QAAQ,SAAS,QAAQ,GAAG;EACxC,SAAS,QAAQ,KAAK,QAAQ;EAC9B,MAAM,iBAAiB,cAAc,QAAQ;EAC7C,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,yCAAyC;CAC5E;AACF;AAEA,MAAa,oBAAuC;CAClD,aAAa;CACb,UAAU,CAAC,QAAQ,OAAO;CAC1B,cAAc;EACZ,eAAe;EACf,2BAA2B;EAC3B,uBAAuB;EACvB,yBAAyB;CAC3B;CACA,iBAAiB,EACf,+BAA+B,SACjC;CACA,QAAQ,EACN,iBAAiB,sBACnB;CACA,aAAa;AACf"}
1
+ {"version":3,"file":"react-email.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/react-email.feature.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { ensureDirectoryAsync, fileExistsAsync, putFileAsync } from \"@warlock.js/fs\";\r\nimport type { CommandActionData } from \"../../commands/types\";\r\nimport { rootPath } from \"../../utils\";\r\nimport { patchTsconfigInclude } from \"./shared/patch-tsconfig-include\";\r\nimport type { FeatureDefinition } from \"./types\";\r\n\r\nasync function completeReactEmailInstallation(_options: CommandActionData) {\r\n // 1. Create emails/ folder with a sample component\r\n const emailsFolderPath = rootPath(\"emails\");\r\n const sampleEmailPath = rootPath(\"emails/welcome-email.tsx\");\r\n\r\n if (!(await fileExistsAsync(sampleEmailPath))) {\r\n await ensureDirectoryAsync(emailsFolderPath);\r\n await putFileAsync(\r\n sampleEmailPath,\r\n `import { Body, Container, Head, Html, Text } from \"@react-email/components\";\r\nimport { Tailwind } from \"@react-email/tailwind\";\r\n\r\ninterface WelcomeEmailProps {\r\n name: string;\r\n}\r\n\r\n/**\r\n * Sample welcome email component.\r\n * Preview with: yarn email:preview\r\n */\r\nexport default function WelcomeEmail({ name }: WelcomeEmailProps) {\r\n return (\r\n <Html>\r\n <Head />\r\n <Tailwind>\r\n <Body className=\"bg-gray-100 font-sans\">\r\n <Container className=\"mx-auto max-w-xl py-8 px-4\">\r\n <Text className=\"text-2xl font-bold text-gray-900\">\r\n Welcome, {name}!\r\n </Text>\r\n <Text className=\"text-gray-600 mt-2\">\r\n You're all set. We're glad to have you on board.\r\n </Text>\r\n </Container>\r\n </Body>\r\n </Tailwind>\r\n </Html>\r\n );\r\n}\r\n`,\r\n );\r\n console.log(`${colors.green(\"✓\")} Created emails/welcome-email.tsx`);\r\n }\r\n\r\n // 2. Patch tsconfig.json add \"emails\" to include if missing.\r\n await patchTsconfigInclude(\r\n \"emails\",\r\n \"Without it, the email components under emails/ are outside the project and do not typecheck.\",\r\n );\r\n}\r\n\r\nexport const reactEmailFeature: FeatureDefinition = {\r\n description: \"Installs react-email for building email templates with React and Tailwind\",\r\n requires: [\"mail\", \"react\"],\r\n dependencies: {\r\n \"react-email\": \"^5.2.10\",\r\n \"@react-email/components\": \"^1.0.11\",\r\n \"@react-email/render\": \"^2.0.5\",\r\n \"@react-email/tailwind\": \"^2.0.7\",\r\n },\r\n devDependencies: {\r\n \"@react-email/preview-server\": \"5.2.10\",\r\n },\r\n script: {\r\n \"email:preview\": \"npx react-email dev\",\r\n },\r\n onExecuting: completeReactEmailInstallation,\r\n};\r\n"],"mappings":";;;;;;;AAOA,eAAe,+BAA+B,UAA6B;CAEzE,MAAM,mBAAmB,SAAS,QAAQ;CAC1C,MAAM,kBAAkB,SAAS,0BAA0B;CAE3D,IAAI,CAAE,MAAM,gBAAgB,eAAe,GAAI;EAC7C,MAAM,qBAAqB,gBAAgB;EAC3C,MAAM,aACJ,iBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BF;EACA,QAAQ,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,kCAAkC;CACrE;CAGA,MAAM,qBACJ,UACA,8FACF;AACF;AAEA,MAAa,oBAAuC;CAClD,aAAa;CACb,UAAU,CAAC,QAAQ,OAAO;CAC1B,cAAc;EACZ,eAAe;EACf,2BAA2B;EAC3B,uBAAuB;EACvB,yBAAyB;CAC3B;CACA,iBAAiB,EACf,+BAA+B,SACjC;CACA,QAAQ,EACN,iBAAiB,sBACnB;CACA,aAAa;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"react.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/react.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const reactFeature: FeatureDefinition = {\r\n description:\r\n \"Installs React and React dom for rendering React components (non-interactive), useful for sending mails and generating HTML\",\r\n dependencies: {\r\n react: \"^19.2.3\",\r\n \"react-dom\": \"^19.2.3\",\r\n },\r\n devDependencies: {\r\n \"@types/react\": \"^19.2.7\",\r\n \"@types/react-dom\": \"^19.2.3\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aACE;CACF,cAAc;EACZ,OAAO;EACP,aAAa;CACf;CACA,iBAAiB;EACf,gBAAgB;EAChB,oBAAoB;CACtB;AACF"}
1
+ {"version":3,"file":"react.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/react.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const reactFeature: FeatureDefinition = {\r\n description:\r\n \"Installs React and React dom for rendering React components (non-interactive), useful for sending mails and generating HTML\",\r\n dependencies: {\r\n react: \"^19.2.3\",\r\n \"react-dom\": \"^19.2.3\",\r\n },\r\n devDependencies: {\r\n \"@types/react\": \"^19.2.7\",\r\n \"@types/react-dom\": \"^19.2.3\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aACE;CACF,cAAc;EACZ,OAAO;EACP,aAAa;CACf;CACA,iBAAiB;EACf,gBAAgB;EAChB,oBAAoB;CACtB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"redis.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/redis.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const redisFeature: FeatureDefinition = {\r\n description: \"Installs redis for Redis cache driver (Cache Package)\",\r\n dependencies: {\r\n redis: \"^4.6.13\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,OAAO,UACT;AACF"}
1
+ {"version":3,"file":"redis.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/redis.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const redisFeature: FeatureDefinition = {\r\n description: \"Installs redis for Redis cache driver (Cache Package)\",\r\n dependencies: {\r\n redis: \"^4.6.13\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,eAAkC;CAC7C,aAAa;CACb,cAAc,EACZ,OAAO,UACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"s3.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/s3.feature.ts"],"sourcesContent":["import { FeatureDefinition } from \"./types\";\r\n\r\nexport const s3Feature: FeatureDefinition = {\r\n description: \"Installs AWS SDK for Cloud storage (Storage Package)\",\r\n dependencies: {\r\n \"@aws-sdk/client-s3\": \"^3.955.0\",\r\n \"@aws-sdk/lib-storage\": \"^3.955.0\",\r\n \"@aws-sdk/s3-request-presigner\": \"^3.955.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,YAA+B;CAC1C,aAAa;CACb,cAAc;EACZ,sBAAsB;EACtB,wBAAwB;EACxB,iCAAiC;CACnC;AACF"}
1
+ {"version":3,"file":"s3.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/s3.feature.ts"],"sourcesContent":["import type { FeatureDefinition } from \"./types\";\r\n\r\nexport const s3Feature: FeatureDefinition = {\r\n description: \"Installs AWS SDK for Cloud storage (Storage Package)\",\r\n dependencies: {\r\n \"@aws-sdk/client-s3\": \"^3.955.0\",\r\n \"@aws-sdk/lib-storage\": \"^3.955.0\",\r\n \"@aws-sdk/s3-request-presigner\": \"^3.955.0\",\r\n },\r\n};\r\n"],"mappings":";AAEA,MAAa,YAA+B;CAC1C,aAAa;CACb,cAAc;EACZ,sBAAsB;EACtB,wBAAwB;EACxB,iCAAiC;CACnC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/scheduler.feature.ts"],"sourcesContent":["import { FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const schedulerFeature: FeatureDefinition = {\r\n description: \"Installs warlock scheduler for scheduling tasks\",\r\n dependencies: {\r\n \"@warlock.js/scheduler\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,mBAAsC;CACjD,aAAa;CACb,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}
1
+ {"version":3,"file":"scheduler.feature.mjs","names":[],"sources":["../../../../../../../../core/src/generations/features/scheduler.feature.ts"],"sourcesContent":["import { type FeatureDefinition, INSTALLED_WARLOCK_VERSION } from \"./types\";\n\r\nexport const schedulerFeature: FeatureDefinition = {\r\n description: \"Installs warlock scheduler for scheduling tasks\",\r\n dependencies: {\r\n \"@warlock.js/scheduler\": INSTALLED_WARLOCK_VERSION,\n },\r\n};\r\n"],"mappings":";;;AAEA,MAAa,mBAAsC;CACjD,aAAa;CACb,cAAc,EACZ,yBAAyB,0BAC3B;AACF"}