@warlock.js/core 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/esm/application/application.d.mts.map +1 -1
  3. package/esm/application/application.mjs.map +1 -1
  4. package/esm/benchmark/benchmark-snapshots.d.mts.map +1 -1
  5. package/esm/benchmark/benchmark.d.mts.map +1 -1
  6. package/esm/benchmark/channels/console.channel.mjs.map +1 -1
  7. package/esm/benchmark/channels/noop.channel.d.mts.map +1 -1
  8. package/esm/benchmark/profiler.d.mts.map +1 -1
  9. package/esm/benchmark/profiler.mjs.map +1 -1
  10. package/esm/bootstrap/setup.d.mts.map +1 -1
  11. package/esm/bootstrap/setup.mjs.map +1 -1
  12. package/esm/bootstrap.d.mts.map +1 -1
  13. package/esm/cache/database-cache-driver.d.mts.map +1 -1
  14. package/esm/cache/database-cache-driver.mjs.map +1 -1
  15. package/esm/cli/cli-commands.manager.mjs.map +1 -1
  16. package/esm/cli/cli-commands.utils.mjs +16 -10
  17. package/esm/cli/cli-commands.utils.mjs.map +1 -1
  18. package/esm/cli/commands/doctor/boot-for-diagnostics.mjs.map +1 -1
  19. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -1
  20. package/esm/cli/commands/doctor/checks/handler-signature.check.mjs.map +1 -1
  21. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -1
  22. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -1
  23. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -1
  24. package/esm/cli/commands/generate/generate.command.mjs.map +1 -1
  25. package/esm/cli/commands/generate/generators/column-dsl-parser.mjs.map +1 -1
  26. package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -1
  27. package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -1
  28. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  29. package/esm/cli/commands/generate/utils/name-parser.mjs.map +1 -1
  30. package/esm/cli/commands/generate/utils/prompt.mjs.map +1 -1
  31. package/esm/cli/commands/routes/diff-page-routes.mjs +84 -0
  32. package/esm/cli/commands/routes/diff-page-routes.mjs.map +1 -0
  33. package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -1
  34. package/esm/cli/commands/routes/route-row.mjs.map +1 -1
  35. package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -1
  36. package/esm/cli/commands/routes/routes-diff.action.mjs +84 -0
  37. package/esm/cli/commands/routes/routes-diff.action.mjs.map +1 -0
  38. package/esm/cli/commands/routes.command.mjs +15 -1
  39. package/esm/cli/commands/routes.command.mjs.map +1 -1
  40. package/esm/cli/commands/start-production.command.mjs +8 -1
  41. package/esm/cli/commands/start-production.command.mjs.map +1 -1
  42. package/esm/cli/commands/storage-put.action.mjs.map +1 -1
  43. package/esm/cli/commands/typings-generator.command.mjs.map +1 -1
  44. package/esm/cli/commands-loader.mjs.map +1 -1
  45. package/esm/cli/framework-cli-commands.mjs +2 -1
  46. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  47. package/esm/cli/start.mjs.map +1 -1
  48. package/esm/cli/string-similarity.mjs.map +1 -1
  49. package/esm/commands/cli-command.mjs.map +1 -1
  50. package/esm/config/config-loader.d.mts +1 -1
  51. package/esm/config/config-loader.d.mts.map +1 -1
  52. package/esm/config/config-loader.mjs.map +1 -1
  53. package/esm/config/config-setter.d.mts.map +1 -1
  54. package/esm/config/config-special-handlers.d.mts +1 -1
  55. package/esm/config/config-special-handlers.mjs.map +1 -1
  56. package/esm/config/load-config-files.mjs.map +1 -1
  57. package/esm/connectors/access-connector.d.mts.map +1 -1
  58. package/esm/connectors/ai-connector.d.mts.map +1 -1
  59. package/esm/connectors/assert-no-reserved-connector-names.mjs.map +1 -1
  60. package/esm/connectors/assert-unique-connector-names.mjs.map +1 -1
  61. package/esm/connectors/base-connector.d.mts.map +1 -1
  62. package/esm/connectors/base-connector.mjs.map +1 -1
  63. package/esm/connectors/cache-connector.d.mts.map +1 -1
  64. package/esm/connectors/connectors-manager.d.mts.map +1 -1
  65. package/esm/connectors/connectors-manager.mjs.map +1 -1
  66. package/esm/connectors/database-connector.d.mts.map +1 -1
  67. package/esm/connectors/describe-server-address.mjs +20 -3
  68. package/esm/connectors/describe-server-address.mjs.map +1 -1
  69. package/esm/connectors/herald-connector.d.mts.map +1 -1
  70. package/esm/connectors/http-connector.d.mts.map +1 -1
  71. package/esm/connectors/http-connector.mjs +5 -1
  72. package/esm/connectors/http-connector.mjs.map +1 -1
  73. package/esm/connectors/logger-connector.d.mts.map +1 -1
  74. package/esm/connectors/mail-connector.d.mts.map +1 -1
  75. package/esm/connectors/notifications-connector.d.mts.map +1 -1
  76. package/esm/connectors/register-configured-connectors.mjs.map +1 -1
  77. package/esm/connectors/socket-connector.d.mts.map +1 -1
  78. package/esm/connectors/socket-connector.mjs.map +1 -1
  79. package/esm/connectors/storage.connector.d.mts.map +1 -1
  80. package/esm/container/index.d.mts.map +1 -1
  81. package/esm/database/create-database-action.mjs.map +1 -1
  82. package/esm/database/drop-tables-action.mjs.map +1 -1
  83. package/esm/database/migrate-action.mjs.map +1 -1
  84. package/esm/database/models/database-log/database-log.mjs.map +1 -1
  85. package/esm/database/seed-command-action.mjs.map +1 -1
  86. package/esm/database/seeds/seed-records-table-migration.mjs +1 -1
  87. package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -1
  88. package/esm/database/seeds/seeder.mjs.map +1 -1
  89. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  90. package/esm/database/seeds/seeds-table-migration.mjs +1 -1
  91. package/esm/database/seeds/seeds-table-migration.mjs.map +1 -1
  92. package/esm/database/utils.mjs.map +1 -1
  93. package/esm/dev-server/check-for-updates.mjs.map +1 -1
  94. package/esm/dev-server/dependency-graph.d.mts.map +1 -1
  95. package/esm/dev-server/dependency-graph.mjs.map +1 -1
  96. package/esm/dev-server/dev-logger.mjs.map +1 -1
  97. package/esm/dev-server/development-server.mjs.map +1 -1
  98. package/esm/dev-server/file-event-handler.mjs.map +1 -1
  99. package/esm/dev-server/file-manager.d.mts.map +1 -1
  100. package/esm/dev-server/file-manager.mjs.map +1 -1
  101. package/esm/dev-server/file-operations.d.mts.map +1 -1
  102. package/esm/dev-server/files-orchestrator.mjs.map +1 -1
  103. package/esm/dev-server/files-watcher.mjs.map +1 -1
  104. package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs.map +1 -1
  105. package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs.map +1 -1
  106. package/esm/dev-server/health-checker/file-health-result.d.mts.map +1 -1
  107. package/esm/dev-server/health-checker/file-health-result.mjs.map +1 -1
  108. package/esm/dev-server/health-checker/files-healthcare.manager.mjs.map +1 -1
  109. package/esm/dev-server/layer-executor.mjs +10 -3
  110. package/esm/dev-server/layer-executor.mjs.map +1 -1
  111. package/esm/dev-server/loader/hook-thread.d.mts.map +1 -1
  112. package/esm/dev-server/loader/own-resolver.mjs.map +1 -1
  113. package/esm/dev-server/loader/register-loader.mjs.map +1 -1
  114. package/esm/dev-server/loader/resolve-hook.mjs.map +1 -1
  115. package/esm/dev-server/loader/source-slug.mjs.map +1 -1
  116. package/esm/dev-server/loader/transpile-cache.mjs +12 -3
  117. package/esm/dev-server/loader/transpile-cache.mjs.map +1 -1
  118. package/esm/dev-server/loader/version-registry.mjs.map +1 -1
  119. package/esm/dev-server/manifest-manager.d.mts.map +1 -1
  120. package/esm/dev-server/manifest-manager.mjs.map +1 -1
  121. package/esm/dev-server/module-loader.mjs.map +1 -1
  122. package/esm/dev-server/package-json-manager.mjs.map +1 -1
  123. package/esm/dev-server/parse-imports.mjs.map +1 -1
  124. package/esm/dev-server/ready-block.mjs.map +1 -1
  125. package/esm/dev-server/special-files-collector.d.mts.map +1 -1
  126. package/esm/dev-server/special-files-collector.mjs.map +1 -1
  127. package/esm/dev-server/supervisor.mjs +9 -6
  128. package/esm/dev-server/supervisor.mjs.map +1 -1
  129. package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
  130. package/esm/dev-server/type-generator.mjs.map +1 -1
  131. package/esm/dev-server/utils.mjs.map +1 -1
  132. package/esm/encryption/encrypt.mjs.map +1 -1
  133. package/esm/encryption/hash.mjs.map +1 -1
  134. package/esm/encryption/password.mjs.map +1 -1
  135. package/esm/generations/add-command.action.mjs +11 -4
  136. package/esm/generations/add-command.action.mjs.map +1 -1
  137. package/esm/generations/features/access.feature.mjs +2 -1
  138. package/esm/generations/features/access.feature.mjs.map +1 -1
  139. package/esm/generations/features/ai-anthropic.feature.mjs +3 -1
  140. package/esm/generations/features/ai-anthropic.feature.mjs.map +1 -1
  141. package/esm/generations/features/ai-bedrock.feature.mjs +3 -1
  142. package/esm/generations/features/ai-bedrock.feature.mjs.map +1 -1
  143. package/esm/generations/features/ai-google.feature.mjs +3 -1
  144. package/esm/generations/features/ai-google.feature.mjs.map +1 -1
  145. package/esm/generations/features/ai-ollama.feature.mjs +3 -1
  146. package/esm/generations/features/ai-ollama.feature.mjs.map +1 -1
  147. package/esm/generations/features/ai-openai.feature.mjs +3 -1
  148. package/esm/generations/features/ai-openai.feature.mjs.map +1 -1
  149. package/esm/generations/features/ai-panoptic.feature.mjs +2 -1
  150. package/esm/generations/features/ai-panoptic.feature.mjs.map +1 -1
  151. package/esm/generations/features/ai-tools.feature.mjs +2 -1
  152. package/esm/generations/features/ai-tools.feature.mjs.map +1 -1
  153. package/esm/generations/features/ai-workspace.feature.mjs +2 -1
  154. package/esm/generations/features/ai-workspace.feature.mjs.map +1 -1
  155. package/esm/generations/features/ai.feature.mjs +2 -1
  156. package/esm/generations/features/ai.feature.mjs.map +1 -1
  157. package/esm/generations/features/herald.feature.mjs +2 -1
  158. package/esm/generations/features/herald.feature.mjs.map +1 -1
  159. package/esm/generations/features/notifications.feature.mjs +3 -2
  160. package/esm/generations/features/notifications.feature.mjs.map +1 -1
  161. package/esm/generations/features/scheduler.feature.mjs +3 -1
  162. package/esm/generations/features/scheduler.feature.mjs.map +1 -1
  163. package/esm/generations/features/shadcn.feature.mjs.map +1 -1
  164. package/esm/generations/features/shared/migration-timestamp.mjs.map +1 -1
  165. package/esm/generations/features/tailwind.feature.mjs.map +1 -1
  166. package/esm/generations/features/types.mjs +14 -0
  167. package/esm/generations/features/types.mjs.map +1 -0
  168. package/esm/generations/features/web.feature.mjs +10 -2
  169. package/esm/generations/features/web.feature.mjs.map +1 -1
  170. package/esm/generations/stubs.mjs +169 -28
  171. package/esm/generations/stubs.mjs.map +1 -1
  172. package/esm/http/boot-port-preflight.d.mts +46 -0
  173. package/esm/http/boot-port-preflight.d.mts.map +1 -0
  174. package/esm/http/boot-port-preflight.mjs +87 -0
  175. package/esm/http/boot-port-preflight.mjs.map +1 -0
  176. package/esm/http/context/request-context.d.mts.map +1 -1
  177. package/esm/http/context/request-context.mjs.map +1 -1
  178. package/esm/http/context/request-memo.d.mts.map +1 -1
  179. package/esm/http/context/request-memo.mjs.map +1 -1
  180. package/esm/http/createHttpApplication.d.mts.map +1 -1
  181. package/esm/http/createHttpApplication.mjs.map +1 -1
  182. package/esm/http/health.d.mts.map +1 -1
  183. package/esm/http/index.d.mts +1 -0
  184. package/esm/http/index.mjs +1 -0
  185. package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
  186. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  187. package/esm/http/middleware/inject-request-context.mjs.map +1 -1
  188. package/esm/http/middleware/ip-filter.middleware.d.mts +1 -1
  189. package/esm/http/middleware/ip-filter.middleware.mjs +1 -1
  190. package/esm/http/middleware/ip-filter.middleware.mjs.map +1 -1
  191. package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
  192. package/esm/http/middleware/utils/idempotency-key.mjs.map +1 -1
  193. package/esm/http/port-preflight.d.mts +8 -0
  194. package/esm/http/port-preflight.d.mts.map +1 -1
  195. package/esm/http/port-preflight.mjs +8 -1
  196. package/esm/http/port-preflight.mjs.map +1 -1
  197. package/esm/http/ready-report.d.mts.map +1 -1
  198. package/esm/http/request-controller.d.mts.map +1 -1
  199. package/esm/http/request.d.mts +14 -2
  200. package/esm/http/request.d.mts.map +1 -1
  201. package/esm/http/request.mjs +16 -2
  202. package/esm/http/request.mjs.map +1 -1
  203. package/esm/http/response.d.mts +3 -3
  204. package/esm/http/response.d.mts.map +1 -1
  205. package/esm/http/response.mjs.map +1 -1
  206. package/esm/http/server.d.mts.map +1 -1
  207. package/esm/http/server.mjs +26 -2
  208. package/esm/http/server.mjs.map +1 -1
  209. package/esm/http/types.d.mts +1 -3
  210. package/esm/http/types.d.mts.map +1 -1
  211. package/esm/http/uploaded-file.d.mts.map +1 -1
  212. package/esm/http/uploaded-file.mjs.map +1 -1
  213. package/esm/http/uploads-config.d.mts.map +1 -1
  214. package/esm/image/image.d.mts.map +1 -1
  215. package/esm/image/image.mjs.map +1 -1
  216. package/esm/index.d.mts +6 -1
  217. package/esm/index.mjs +6 -1
  218. package/esm/logger/fatal-visibility.d.mts +25 -0
  219. package/esm/logger/fatal-visibility.d.mts.map +1 -0
  220. package/esm/logger/fatal-visibility.mjs +31 -0
  221. package/esm/logger/fatal-visibility.mjs.map +1 -0
  222. package/esm/logger/index.d.mts +1 -0
  223. package/esm/logger/index.mjs +1 -0
  224. package/esm/logger/logger.mjs.map +1 -1
  225. package/esm/mail/config.d.mts.map +1 -1
  226. package/esm/mail/events.d.mts.map +1 -1
  227. package/esm/mail/mail.d.mts.map +1 -1
  228. package/esm/mail/mail.mjs.map +1 -1
  229. package/esm/mail/mailer-pool.d.mts.map +1 -1
  230. package/esm/mail/mailer-pool.mjs +2 -0
  231. package/esm/mail/mailer-pool.mjs.map +1 -1
  232. package/esm/mail/send-mail.mjs.map +1 -1
  233. package/esm/mail/test-mailbox.d.mts.map +1 -1
  234. package/esm/mail/test-mailbox.mjs.map +1 -1
  235. package/esm/production/assert-dist-ready-to-start.mjs +24 -0
  236. package/esm/production/assert-dist-ready-to-start.mjs.map +1 -0
  237. package/esm/production/assert-generated-imports.mjs.map +1 -1
  238. package/esm/production/build-app-production.mjs.map +1 -1
  239. package/esm/production/dist-build-manifest.mjs +47 -0
  240. package/esm/production/dist-build-manifest.mjs.map +1 -0
  241. package/esm/production/production-builder.mjs +68 -13
  242. package/esm/production/production-builder.mjs.map +1 -1
  243. package/esm/production/production-supervisor.mjs +21 -9
  244. package/esm/production/production-supervisor.mjs.map +1 -1
  245. package/esm/production/promote-dist.mjs +115 -0
  246. package/esm/production/promote-dist.mjs.map +1 -0
  247. package/esm/production/resolve-build-config.mjs.map +1 -1
  248. package/esm/repositories/adapters/cascade/cascade-adapter.d.mts.map +1 -1
  249. package/esm/repositories/adapters/cascade/cascade-adapter.mjs.map +1 -1
  250. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
  251. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
  252. package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
  253. package/esm/repositories/repository.manager.d.mts.map +1 -1
  254. package/esm/repositories/repository.manager.mjs.map +1 -1
  255. package/esm/resource/register-resource.d.mts.map +1 -1
  256. package/esm/resource/resource-field-builder.d.mts.map +1 -1
  257. package/esm/resource/resource-field-builder.mjs.map +1 -1
  258. package/esm/resource/resource.d.mts.map +1 -1
  259. package/esm/resource/resource.mjs.map +1 -1
  260. package/esm/restful/restful.d.mts.map +1 -1
  261. package/esm/restful/restful.mjs.map +1 -1
  262. package/esm/router/index.d.mts +3 -0
  263. package/esm/router/index.mjs +3 -0
  264. package/esm/router/log-request-lifecycle.mjs.map +1 -1
  265. package/esm/router/normalize-request-path.d.mts +14 -0
  266. package/esm/router/normalize-request-path.d.mts.map +1 -0
  267. package/esm/router/normalize-request-path.mjs +18 -0
  268. package/esm/router/normalize-request-path.mjs.map +1 -0
  269. package/esm/router/normalize-route-path.d.mts +28 -0
  270. package/esm/router/normalize-route-path.d.mts.map +1 -0
  271. package/esm/router/normalize-route-path.mjs +33 -0
  272. package/esm/router/normalize-route-path.mjs.map +1 -0
  273. package/esm/router/positional-handler-diagnostics.d.mts.map +1 -1
  274. package/esm/router/positional-handler-diagnostics.mjs.map +1 -1
  275. package/esm/router/route-name-method-suffix.d.mts +33 -0
  276. package/esm/router/route-name-method-suffix.d.mts.map +1 -0
  277. package/esm/router/route-name-method-suffix.mjs +39 -0
  278. package/esm/router/route-name-method-suffix.mjs.map +1 -0
  279. package/esm/router/route-registry.d.mts.map +1 -1
  280. package/esm/router/route-registry.mjs +3 -2
  281. package/esm/router/route-registry.mjs.map +1 -1
  282. package/esm/router/router.d.mts +14 -0
  283. package/esm/router/router.d.mts.map +1 -1
  284. package/esm/router/router.mjs +50 -11
  285. package/esm/router/router.mjs.map +1 -1
  286. package/esm/socket/utils.d.mts.map +1 -1
  287. package/esm/storage/config.d.mts.map +1 -1
  288. package/esm/storage/context/storage-driver-context.d.mts.map +1 -1
  289. package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
  290. package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
  291. package/esm/storage/drivers/do-spaces-driver.d.mts.map +1 -1
  292. package/esm/storage/drivers/local-driver.d.mts.map +1 -1
  293. package/esm/storage/drivers/local-driver.mjs.map +1 -1
  294. package/esm/storage/drivers/r2-driver.d.mts.map +1 -1
  295. package/esm/storage/scoped-storage.d.mts.map +1 -1
  296. package/esm/storage/scoped-storage.mjs.map +1 -1
  297. package/esm/storage/storage-file.d.mts.map +1 -1
  298. package/esm/storage/storage-file.mjs.map +1 -1
  299. package/esm/storage/storage.d.mts.map +1 -1
  300. package/esm/storage/types.d.mts +14 -0
  301. package/esm/storage/types.d.mts.map +1 -1
  302. package/esm/storage/utils/safe-fetch.mjs.map +1 -1
  303. package/esm/tests/start-http-development-server.d.mts.map +1 -1
  304. package/esm/tests/start-http-development-server.mjs +2 -1
  305. package/esm/tests/start-http-development-server.mjs.map +1 -1
  306. package/esm/tests/test-connectors-selection.mjs.map +1 -1
  307. package/esm/tests/test-helpers.d.mts.map +1 -1
  308. package/esm/tests/test-setup-timeout.mjs.map +1 -1
  309. package/esm/tests/vitest-setup.d.mts.map +1 -1
  310. package/esm/tests/vitest-setup.mjs.map +1 -1
  311. package/esm/updater/update-warlock-packages.mjs.map +1 -1
  312. package/esm/use-cases/use-case-broadcast.d.mts.map +1 -1
  313. package/esm/use-cases/use-case-events.d.mts.map +1 -1
  314. package/esm/use-cases/use-case-pipeline.d.mts.map +1 -1
  315. package/esm/use-cases/use-case.d.mts.map +1 -1
  316. package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
  317. package/esm/use-cases/use-cases-registry.mjs.map +1 -1
  318. package/esm/utils/database-log.d.mts.map +1 -1
  319. package/esm/utils/database-log.mjs.map +1 -1
  320. package/esm/utils/environment.d.mts.map +1 -1
  321. package/esm/utils/framework-vesion.mjs.map +1 -1
  322. package/esm/utils/get-localized.mjs.map +1 -1
  323. package/esm/utils/load-environment.mjs.map +1 -1
  324. package/esm/utils/normalized-path.d.mts.map +1 -1
  325. package/esm/utils/paths.d.mts.map +1 -1
  326. package/esm/utils/promise-all-object.d.mts.map +1 -1
  327. package/esm/utils/promise-all-object.mjs.map +1 -1
  328. package/esm/utils/sluggable.mjs.map +1 -1
  329. package/esm/utils/version-compare.mjs.map +1 -1
  330. package/esm/validation/database/exists-except-current-id.mjs.map +1 -1
  331. package/esm/validation/database/exists-except-current-user.mjs.map +1 -1
  332. package/esm/validation/database/unique-except-current-id.mjs.map +1 -1
  333. package/esm/validation/plugins/localized-plugin.mjs.map +1 -1
  334. package/esm/validation/validators/file-validator.mjs.map +1 -1
  335. package/esm/vite/lower-stage3-decorators.d.mts.map +1 -1
  336. package/esm/warlock-config/default-configurations.mjs.map +1 -1
  337. package/esm/warlock-config/warlock-config.manager.d.mts.map +1 -1
  338. package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
  339. package/llms-full.txt +205 -90
  340. package/llms.txt +5 -5
  341. package/package.json +12 -12
  342. package/skills/add-connector/SKILL.md +35 -28
  343. package/skills/create-controller/SKILL.md +1 -1
  344. package/skills/create-module/SKILL.md +12 -12
  345. package/skills/hash-password/SKILL.md +4 -4
  346. package/skills/run-app/SKILL.md +77 -16
  347. package/skills/send-mail/SKILL.md +2 -2
  348. package/skills/use-middleware/SKILL.md +13 -4
  349. package/skills/use-model-transformers/SKILL.md +2 -2
  350. package/skills/use-repository/SKILL.md +1 -1
  351. package/skills/validate-input/SKILL.md +1 -1
  352. package/skills/warlock-conventions/SKILL.md +1 -1
  353. package/skills/warlock-doctor/SKILL.md +3 -3
  354. package/skills/warlock-routes/SKILL.md +47 -9
  355. package/skills/write-cli-command/SKILL.md +1 -1
  356. package/skills/write-seeder/SKILL.md +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/templates/stubs.ts"],"sourcesContent":["import type { ParsedName } from \"../types\";\nimport { Name } from \"../utils/name-parser\";\n\n/**\n * Controller template stub\n *\n * Controllers default to the guarded handler type since application\n * routes run behind `guarded()`. When `withValidation` is set, the\n * schema's exported type + value are imported directly from the\n * `schema/` folder and bound to the handler — no `requests/` alias.\n */\nexport function controllerStub(\n name: ParsedName,\n options: { withValidation?: boolean } = {},\n): string {\n const { withValidation } = options;\n\n if (!withValidation) {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler = async (request, response) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n`;\n }\n\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type ${name.pascal}Schema, ${name.camel}Schema } from \"../schema/${name.kebab}.schema\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler<${name.pascal}Schema> = async (\n request,\n response,\n) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n\n${name.camel}Controller.validation = {\n schema: ${name.camel}Schema,\n};\n`;\n}\n\n/**\n * CRUD Create Controller template\n * Note: moduleName is the module (plural), we need singular entity name\n */\nexport function crudCreateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Create${moduleName.pascal}Schema, create${moduleName.pascal}Schema } from \"../schema/create-${moduleName.kebab}.schema\";\nimport { create${moduleName.pascal}Service } from \"../services/create-${moduleName.kebab}.service\";\n\nexport const create${moduleName.pascal}Controller: GuardedRequestHandler<Create${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await create${moduleName.pascal}Service(request.validated());\n\n return response.successCreate({\n ${moduleName.camel},\n });\n};\n\ncreate${moduleName.pascal}Controller.validation = {\n schema: create${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD Update Controller template\n */\nexport function crudUpdateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Update${moduleName.pascal}Schema, update${moduleName.pascal}Schema } from \"../schema/update-${moduleName.kebab}.schema\";\nimport { update${moduleName.pascal}Service } from \"../services/update-${moduleName.kebab}.service\";\n\nexport const update${moduleName.pascal}Controller: GuardedRequestHandler<Update${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await update${moduleName.pascal}Service(request.input(\"id\"), request.validated());\n\n return response.success({\n ${moduleName.camel},\n });\n};\n\nupdate${moduleName.pascal}Controller.validation = {\n schema: update${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD List Controller template\n */\nexport function crudListControllerStub(moduleName: Name): string {\n const plural = moduleName.plural;\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { list${plural.pascal}Service } from \"../services/list-${plural.kebab}.service\";\n\nexport const list${plural.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const { data, pagination } = await list${plural.pascal}Service(request.all());\n\n return response.success({\n data,\n pagination,\n });\n};\n`;\n}\n\n/**\n * CRUD Show/Get Controller template\n */\nexport function crudShowControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { get${moduleName.pascal}Service } from \"../services/get-${moduleName.kebab}.service\";\n\nexport const get${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await get${moduleName.pascal}Service(request.input(\"id\"));\n\n if (!${moduleName.camel}) {\n return response.notFound();\n }\n\n return response.success({\n ${moduleName.camel},\n });\n};\n`;\n}\n\n/**\n * CRUD Delete Controller template\n */\nexport function crudDeleteControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { delete${moduleName.pascal}Service } from \"../services/delete-${moduleName.kebab}.service\";\n\nexport const delete${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n await delete${moduleName.pascal}Service(request.input(\"id\"));\n\n return response.noContent();\n};\n`;\n}\n\n/**\n * CRUD Routes template\n */\nexport function crudRoutesStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { router } from \"@warlock.js/core\";\nimport { guarded } from \"app/shared/utils/router\";\nimport { create${singular.pascal}Controller } from \"./controllers/create-${singular.kebab}.controller\";\nimport { delete${singular.pascal}Controller } from \"./controllers/delete-${singular.kebab}.controller\";\nimport { get${singular.pascal}Controller } from \"./controllers/get-${singular.kebab}.controller\";\nimport { list${plural.pascal}Controller } from \"./controllers/list-${plural.kebab}.controller\";\nimport { update${singular.pascal}Controller } from \"./controllers/update-${singular.kebab}.controller\";\n\nguarded(() => {\n router\n .route(\"/${plural.kebab}\")\n .list(list${plural.pascal}Controller)\n .show(get${singular.pascal}Controller)\n .create(create${singular.pascal}Controller)\n .update(update${singular.pascal}Controller)\n .destroy(delete${singular.pascal}Controller);\n});\n`;\n}\n\n/**\n * CRUD Model template\n */\nexport function crudModelStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { Model, RegisterModel } from \"@warlock.js/cascade\";\nimport { type Infer, v } from \"@warlock.js/seal\";\nimport { ${singular.pascal}Resource } from \"app/${plural.kebab}/resources/${singular.kebab}.resource\";\n\nexport const ${singular.camel}Schema = v.object({\n // TODO: Add more fields\n});\n\nexport type ${singular.pascal}Schema = Infer.Output<typeof ${singular.camel}Schema>;\n\n@RegisterModel()\nexport class ${singular.pascal} extends Model<${singular.pascal}Schema> {\n public static table = \"${plural.snake}\";\n\n public static schema = ${singular.camel}Schema;\n\n public static relations = {};\n\n public static resource = ${singular.pascal}Resource;\n}\n`;\n}\n\n/**\n * CRUD Resource template\n */\nexport function crudResourceStub(moduleName: Name): string {\n // Get singular entity name\n const entity = moduleName.singular;\n\n return `import { defineResource } from \"@warlock.js/core\";\n\nexport const ${entity.pascal}Resource = defineResource({\n schema: {\n id: \"number\",\n // TODO: Add more resource fields\n },\n});\n`;\n}\n\n/**\n * CRUD Repository template\n */\nexport function crudRepositoryStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n const modulePluralName = entity.plural;\n return `import type { FilterRules, TypedRepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\n\ntype ${moduleSingularName.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${moduleSingularName.pascal}ListOptions = TypedRepositoryOptions<${moduleSingularName.pascal}ListFilter>;\n\nclass ${modulePluralName.pascal}Repository extends RepositoryManager<${moduleSingularName.pascal}, ${moduleSingularName.pascal}ListOptions> {\n public source = ${moduleSingularName.pascal};\n\n public simpleSelectColumns: string[] = [\"id\"];\n\n public filterBy: FilterRules = {\n id: \"=\",\n };\n\n public defaultOptions: RepositoryOptions = {\n orderBy: {\n id: \"desc\",\n },\n };\n}\n\nexport const ${modulePluralName.camel}Repository = new ${modulePluralName.pascal}Repository();\n`;\n}\n\n/**\n * CRUD Create Service template\n */\nexport function crudCreateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\nimport type { Create${moduleSingularName.pascal}Schema } from \"../schema/create-${moduleSingularName.kebab}.schema\";\n\nexport async function create${moduleSingularName.pascal}Service(data: Create${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await ${moduleSingularName.pascal}.create(data);\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD Update Service template\n */\nexport function crudUpdateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${moduleSingularName.pascal}Service } from \"./get-${moduleSingularName.kebab}.service\";\nimport type { Update${moduleSingularName.pascal}Schema } from \"../schema/update-${moduleSingularName.kebab}.schema\";\n\nexport async function update${moduleSingularName.pascal}Service(id: number | string, data: Update${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await get${moduleSingularName.pascal}Service(id);\n\n await ${moduleSingularName.camel}.save({ merge: data });\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD List Service template\n */\nexport function crudListServiceStub(entity: Name): string {\n const modulePluralName = entity.plural;\n return `import { ${modulePluralName.camel}Repository } from \"../repositories/${modulePluralName.kebab}.repository\";\n\nexport async function list${modulePluralName.pascal}Service(filters: any) {\n return ${modulePluralName.camel}Repository.listCached(filters);\n}\n`;\n}\n\n/**\n * CRUD Get Service template\n */\nexport function crudGetServiceStub(entity: Name): string {\n return `import { ${entity.plural.camel}Repository } from \"../repositories/${entity.plural.kebab}.repository\";\nimport { ResourceNotFoundError } from \"@warlock.js/core\";\n\nexport async function get${entity.singular.pascal}Service(id: number | string) {\n const ${entity.singular.camel} = await ${entity.plural.camel}Repository.getCached(id);\n\n if (!${entity.singular.camel}) {\n throw new ResourceNotFoundError(\"${entity.singular.pascal} resource not found!\");\n }\n\n return ${entity.singular.camel};\n}\n`;\n}\n\n/**\n * CRUD Delete Service template\n */\nexport function crudDeleteServiceStub(entity: Name): string {\n const singular = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${singular.pascal}Service } from \"./get-${singular.kebab}.service\";\n\nexport async function delete${singular.pascal}Service(id: number | string) {\n const ${singular.camel} = await get${singular.pascal}Service(id);\n if (!${singular.camel}) {\n throw new ResourceNotFoundError(\"${singular.pascal} not found\");\n }\n await ${singular.camel}.destroy();\n}\n`;\n}\n\n/**\n * CRUD Seed template\n */\nexport function crudSeedStub(entity: Name): string {\n return `import { seeder } from \"@warlock.js/core\";\nimport { ${entity.singular.pascal} } from \"../models/${entity.singular.kebab}\";\n\nexport default seeder({\n name: \"Seed ${entity.plural.pascal}\",\n once: true,\n enabled: true,\n run: async ({ track }) => {\n const total = 10;\n for (let i = 0; i < total; i++) {\n track(\n await ${entity.singular.pascal}.create({\n // TODO: Add more fields\n }),\n );\n }\n },\n});\n`;\n}\n\n/**\n * Migration template\n */\n/**\n * Migration Create template\n */\nexport function migrationStub(\n entityName: ParsedName,\n options: {\n columns?: string;\n imports?: string[];\n timestamps?: boolean;\n tableName?: string;\n } = {},\n): string {\n const { columns = \"\", imports = [], timestamps = true } = options;\n\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n let optionsString = \"\";\n if (timestamps === false) {\n optionsString = `, { timestamps: false }`;\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.create(${entityName.pascal}, {\n${columns ? columns : \" // add your columns here, id is auto added to the list\"}\n}${optionsString});\n`;\n}\n\n/**\n * Migration Alter template\n */\nexport function migrationAlterStub(\n entityName: ParsedName,\n options: {\n add?: string;\n drop?: string; // stringified array like `\"[\\\"col1\\\", \\\"col2\\\"]\"`\n rename?: string; // stringified object like `{ old: \"new\" }`\n imports?: string[];\n } = {},\n): string {\n const { add = \"\", drop, rename, imports = [] } = options;\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n // Build the schema object dynamically\n const schemaParts: string[] = [];\n\n if (add) {\n schemaParts.push(` add: {\\n${add}\\n },`);\n }\n\n if (drop) {\n schemaParts.push(` drop: ${drop},`);\n }\n\n if (rename) {\n schemaParts.push(` rename: ${rename},`);\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.alter(${entityName.pascal}, {\n${schemaParts.join(\"\\n\")}\n});\n`;\n}\n\n/**\n * CRUD Create Schema template\n * Outputs to: schema/create-{entity}.schema.ts\n */\nexport function crudCreateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const create${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Create${moduleName.pascal}Schema = Infer<typeof create${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * CRUD Update Schema template\n * Outputs to: schema/update-{entity}.schema.ts\n */\nexport function crudUpdateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const update${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Update${moduleName.pascal}Schema = Infer<typeof update${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * Service template stub\n */\nexport function serviceStub(name: Name): string {\n return `export async function ${name.camel}Service(data: any): Promise<any> {\n // TODO: Implement service logic\n throw new Error(\"${name.camel}Service not implemented\");\n}\n`;\n}\n\n/**\n * Schema template stub\n * Outputs to: schema/{name}.schema.ts\n */\nexport function schemaStub(name: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const ${name.camel}Schema = v.object({\n // TODO: Define validation schema\n});\n\nexport type ${name.pascal}Schema = Infer<typeof ${name.camel}Schema>;\n`;\n}\n\n/**\n * Model template stub\n */\nexport function modelStub(\n name: Name,\n options: { tableName?: string; withResource?: boolean } = {},\n): string {\n const { tableName = `${name.plural.snake}`, withResource } = options;\n\n return `import { Model, type StrictMode } from \"@warlock.js/cascade\";\nimport { v, type Infer } from \"@warlock.js/seal\";\n${withResource ? `import { ${name.singular.pascal}Resource } from \"../../resources/${name.singular.kebab}.resource\";` : \"\"}\n\nconst ${name.singular.camel}Schema = v.object({\n // TODO: Define model schema\n});\n\nexport type ${name.singular.pascal}Type = Infer.Output<typeof ${name.singular.camel}Schema>;\n\nexport class ${name.singular.pascal} extends Model<${name.singular.pascal}Type> {\n public static table = \"${tableName}\";\n public static strictMode: StrictMode = \"fail\";\n${withResource ? ` public static resource = ${name.singular.pascal}Resource;` : \"\"}\n\n public static schema = ${name.singular.camel}Schema;\n\n public static relations = {\n // TODO: Define relations\n };\n}\n`;\n}\n\n/**\n * Repository template stub\n */\nexport function repositoryStub(name: Name): string {\n return `import type { FilterByOptions, RepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${name.singular.pascal} } from \"../models/${name.singular.kebab}\";\n\ntype ${name.singular.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${name.singular.pascal}ListOptions = RepositoryOptions & ${name.singular.pascal}ListFilter;\n\nexport class ${name.plural.pascal}Repository extends RepositoryManager<${name.singular.pascal}, ${name.singular.pascal}ListFilter> {\n public source = ${name.singular.pascal};\n\n protected defaultOptions: RepositoryOptions = this.withDefaultOptions({});\n\n protected filterBy: FilterByOptions = this.withDefaultFilters({\n name: \"like\",\n });\n}\n\nexport const ${name.plural.camel}Repository = new ${name.plural.pascal}Repository();\n`;\n}\n\n/**\n * Resource template stub\n */\nexport function resourceStub(name: Name): string {\n return `import { Resource } from \"@warlock.js/core\";\n\nexport class ${name.singular.pascal}Resource extends Resource {\n public schema = {\n id: \"int\",\n name: \"string\",\n // TODO: Define resource schema\n };\n}\n`;\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,eACd,MACA,UAAwC,CAAC,GACjC;CACR,MAAM,EAAE,mBAAmB;CAE3B,IAAI,CAAC,gBACH,OAAO;;eAEI,KAAK,MAAM;;;;;CAOxB,OAAO;gBACO,KAAK,OAAO,UAAU,KAAK,MAAM,2BAA2B,KAAK,MAAM;;eAExE,KAAK,MAAM,oCAAo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KAAK,MAAM;;;AAGhC;;;;;AAMA,SAAgB,WAAW,MAAoB;CAC7C,OAAO;;eAEM,KAAK,MAAM;;;;cAIZ,KAAK,OAAO,wBAAwB,KAAK,MAAM;;AAE7D;;;;AAKA,SAAgB,UACd,MACA,UAA0D,CAAC,GACnD;CACR,MAAM,EAAE,YAAY,GAAG,KAAK,OAAO,SAAS,iBAAiB;CAE7D,OAAO;;EAEP,eAAe,YAAY,KAAK,SAAS,OAAO,mCAAmC,KAAK,SAAS,MAAM,eAAe,GAAG;;QAEnH,KAAK,SAAS,MAAM;;;;cAId,KAAK,SAAS,OAAO,6BAA6B,KAAK,SAAS,MAAM;;eAErE,KAAK,SAAS,OAAO,iBAAiB,KAAK,SAAS,OAAO;2BAC/C,UAAU;;EAEnC,eAAe,8BAA8B,KAAK,SAAS,OAAO,aAAa,GAAG;;2BAEzD,KAAK,SAAS,MAAM;;;;;;;AAO/C;;;;AAKA,SAAgB,eAAe,MAAoB;CACjD,OAAO;;WAEE,KAAK,SAAS,OAAO,qBAAqB,KAAK,SAAS,MAAM;;OAElE,KAAK,SAAS,OAAO;;;;cAId,KAAK,SAAS,OAAO,oCAAoC,KAAK,SAAS,OAAO;;eAE7E,KAAK,OAAO,OAAO,uCAAuC,KAAK,SAAS,OAAO,IAAI,KAAK,SAAS,OAAO;oBACnG,KAAK,SAAS,OAAO;;;;;;;;;eAS1B,KAAK,OAAO,MAAM,mBAAmB,KAAK,OAAO,OAAO;;AAEvE;;;;AAKA,SAAgB,aAAa,MAAoB;CAC/C,OAAO;;eAEM,KAAK,SAAS,OAAO;;;;;;;;AAQpC"}
1
+ {"version":3,"file":"stubs.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/templates/stubs.ts"],"sourcesContent":["import type { ParsedName } from \"../types\";\nimport { Name } from \"../utils/name-parser\";\n\n/**\n * Controller template stub\n *\n * Controllers default to the guarded handler type since application\n * routes run behind `guarded()`. When `withValidation` is set, the\n * schema's exported type + value are imported directly from the\n * `schema/` folder and bound to the handler — no `requests/` alias.\n */\nexport function controllerStub(\n name: ParsedName,\n options: { withValidation?: boolean } = {},\n): string {\n const { withValidation } = options;\n\n if (!withValidation) {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler = async (request, response) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n`;\n }\n\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type ${name.pascal}Schema, ${name.camel}Schema } from \"../schema/${name.kebab}.schema\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler<${name.pascal}Schema> = async (\n request,\n response,\n) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n\n${name.camel}Controller.validation = {\n schema: ${name.camel}Schema,\n};\n`;\n}\n\n/**\n * CRUD Create Controller template\n * Note: moduleName is the module (plural), we need singular entity name\n */\nexport function crudCreateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Create${moduleName.pascal}Schema, create${moduleName.pascal}Schema } from \"../schema/create-${moduleName.kebab}.schema\";\nimport { create${moduleName.pascal}Service } from \"../services/create-${moduleName.kebab}.service\";\n\nexport const create${moduleName.pascal}Controller: GuardedRequestHandler<Create${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await create${moduleName.pascal}Service(request.validated());\n\n return response.successCreate({\n ${moduleName.camel},\n });\n};\n\ncreate${moduleName.pascal}Controller.validation = {\n schema: create${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD Update Controller template\n */\nexport function crudUpdateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Update${moduleName.pascal}Schema, update${moduleName.pascal}Schema } from \"../schema/update-${moduleName.kebab}.schema\";\nimport { update${moduleName.pascal}Service } from \"../services/update-${moduleName.kebab}.service\";\n\nexport const update${moduleName.pascal}Controller: GuardedRequestHandler<Update${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await update${moduleName.pascal}Service(request.input(\"id\"), request.validated());\n\n return response.success({\n ${moduleName.camel},\n });\n};\n\nupdate${moduleName.pascal}Controller.validation = {\n schema: update${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD List Controller template\n */\nexport function crudListControllerStub(moduleName: Name): string {\n const plural = moduleName.plural;\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { list${plural.pascal}Service } from \"../services/list-${plural.kebab}.service\";\n\nexport const list${plural.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const { data, pagination } = await list${plural.pascal}Service(request.all());\n\n return response.success({\n data,\n pagination,\n });\n};\n`;\n}\n\n/**\n * CRUD Show/Get Controller template\n */\nexport function crudShowControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { get${moduleName.pascal}Service } from \"../services/get-${moduleName.kebab}.service\";\n\nexport const get${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await get${moduleName.pascal}Service(request.input(\"id\"));\n\n if (!${moduleName.camel}) {\n return response.notFound();\n }\n\n return response.success({\n ${moduleName.camel},\n });\n};\n`;\n}\n\n/**\n * CRUD Delete Controller template\n */\nexport function crudDeleteControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { delete${moduleName.pascal}Service } from \"../services/delete-${moduleName.kebab}.service\";\n\nexport const delete${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n await delete${moduleName.pascal}Service(request.input(\"id\"));\n\n return response.noContent();\n};\n`;\n}\n\n/**\n * CRUD Routes template\n */\nexport function crudRoutesStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { router } from \"@warlock.js/core\";\nimport { guarded } from \"app/shared/utils/router\";\nimport { create${singular.pascal}Controller } from \"./controllers/create-${singular.kebab}.controller\";\nimport { delete${singular.pascal}Controller } from \"./controllers/delete-${singular.kebab}.controller\";\nimport { get${singular.pascal}Controller } from \"./controllers/get-${singular.kebab}.controller\";\nimport { list${plural.pascal}Controller } from \"./controllers/list-${plural.kebab}.controller\";\nimport { update${singular.pascal}Controller } from \"./controllers/update-${singular.kebab}.controller\";\n\nguarded(() => {\n router\n .route(\"/${plural.kebab}\")\n .list(list${plural.pascal}Controller)\n .show(get${singular.pascal}Controller)\n .create(create${singular.pascal}Controller)\n .update(update${singular.pascal}Controller)\n .destroy(delete${singular.pascal}Controller);\n});\n`;\n}\n\n/**\n * CRUD Model template\n */\nexport function crudModelStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { Model, RegisterModel } from \"@warlock.js/cascade\";\nimport { type Infer, v } from \"@warlock.js/seal\";\nimport { ${singular.pascal}Resource } from \"app/${plural.kebab}/resources/${singular.kebab}.resource\";\n\nexport const ${singular.camel}Schema = v.object({\n // TODO: Add more fields\n});\n\nexport type ${singular.pascal}Schema = Infer.Output<typeof ${singular.camel}Schema>;\n\n@RegisterModel()\nexport class ${singular.pascal} extends Model<${singular.pascal}Schema> {\n public static table = \"${plural.snake}\";\n\n public static schema = ${singular.camel}Schema;\n\n public static relations = {};\n\n public static resource = ${singular.pascal}Resource;\n}\n`;\n}\n\n/**\n * CRUD Resource template\n */\nexport function crudResourceStub(moduleName: Name): string {\n // Get singular entity name\n const entity = moduleName.singular;\n\n return `import { defineResource } from \"@warlock.js/core\";\n\nexport const ${entity.pascal}Resource = defineResource({\n schema: {\n id: \"number\",\n // TODO: Add more resource fields\n },\n});\n`;\n}\n\n/**\n * CRUD Repository template\n */\nexport function crudRepositoryStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n const modulePluralName = entity.plural;\n return `import type { FilterRules, TypedRepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\n\ntype ${moduleSingularName.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${moduleSingularName.pascal}ListOptions = TypedRepositoryOptions<${moduleSingularName.pascal}ListFilter>;\n\nclass ${modulePluralName.pascal}Repository extends RepositoryManager<${moduleSingularName.pascal}, ${moduleSingularName.pascal}ListOptions> {\n public source = ${moduleSingularName.pascal};\n\n public simpleSelectColumns: string[] = [\"id\"];\n\n public filterBy: FilterRules = {\n id: \"=\",\n };\n\n public defaultOptions: RepositoryOptions = {\n orderBy: {\n id: \"desc\",\n },\n };\n}\n\nexport const ${modulePluralName.camel}Repository = new ${modulePluralName.pascal}Repository();\n`;\n}\n\n/**\n * CRUD Create Service template\n */\nexport function crudCreateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\nimport type { Create${moduleSingularName.pascal}Schema } from \"../schema/create-${moduleSingularName.kebab}.schema\";\n\nexport async function create${moduleSingularName.pascal}Service(data: Create${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await ${moduleSingularName.pascal}.create(data);\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD Update Service template\n */\nexport function crudUpdateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${moduleSingularName.pascal}Service } from \"./get-${moduleSingularName.kebab}.service\";\nimport type { Update${moduleSingularName.pascal}Schema } from \"../schema/update-${moduleSingularName.kebab}.schema\";\n\nexport async function update${moduleSingularName.pascal}Service(id: number | string, data: Update${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await get${moduleSingularName.pascal}Service(id);\n\n await ${moduleSingularName.camel}.save({ merge: data });\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD List Service template\n */\nexport function crudListServiceStub(entity: Name): string {\n const modulePluralName = entity.plural;\n return `import { ${modulePluralName.camel}Repository } from \"../repositories/${modulePluralName.kebab}.repository\";\n\nexport async function list${modulePluralName.pascal}Service(filters: any) {\n return ${modulePluralName.camel}Repository.listCached(filters);\n}\n`;\n}\n\n/**\n * CRUD Get Service template\n */\nexport function crudGetServiceStub(entity: Name): string {\n return `import { ${entity.plural.camel}Repository } from \"../repositories/${entity.plural.kebab}.repository\";\nimport { ResourceNotFoundError } from \"@warlock.js/core\";\n\nexport async function get${entity.singular.pascal}Service(id: number | string) {\n const ${entity.singular.camel} = await ${entity.plural.camel}Repository.getCached(id);\n\n if (!${entity.singular.camel}) {\n throw new ResourceNotFoundError(\"${entity.singular.pascal} resource not found!\");\n }\n\n return ${entity.singular.camel};\n}\n`;\n}\n\n/**\n * CRUD Delete Service template\n */\nexport function crudDeleteServiceStub(entity: Name): string {\n const singular = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${singular.pascal}Service } from \"./get-${singular.kebab}.service\";\n\nexport async function delete${singular.pascal}Service(id: number | string) {\n const ${singular.camel} = await get${singular.pascal}Service(id);\n if (!${singular.camel}) {\n throw new ResourceNotFoundError(\"${singular.pascal} not found\");\n }\n await ${singular.camel}.destroy();\n}\n`;\n}\n\n/**\n * CRUD Seed template\n */\nexport function crudSeedStub(entity: Name): string {\n return `import { seeder } from \"@warlock.js/core\";\nimport { ${entity.singular.pascal} } from \"../models/${entity.singular.kebab}\";\n\nexport default seeder({\n name: \"Seed ${entity.plural.pascal}\",\n once: true,\n enabled: true,\n run: async ({ track }) => {\n const total = 10;\n for (let i = 0; i < total; i++) {\n track(\n await ${entity.singular.pascal}.create({\n // TODO: Add more fields\n }),\n );\n }\n },\n});\n`;\n}\n\n/**\n * Migration template\n */\n/**\n * Migration Create template\n */\nexport function migrationStub(\n entityName: ParsedName,\n options: {\n columns?: string;\n imports?: string[];\n timestamps?: boolean;\n tableName?: string;\n } = {},\n): string {\n const { columns = \"\", imports = [], timestamps = true } = options;\n\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n let optionsString = \"\";\n if (timestamps === false) {\n optionsString = `, { timestamps: false }`;\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.create(${entityName.pascal}, {\n${columns ? columns : \" // add your columns here, id is auto added to the list\"}\n}${optionsString});\n`;\n}\n\n/**\n * Migration Alter template\n */\nexport function migrationAlterStub(\n entityName: ParsedName,\n options: {\n add?: string;\n drop?: string; // stringified array like `\"[\\\"col1\\\", \\\"col2\\\"]\"`\n rename?: string; // stringified object like `{ old: \"new\" }`\n imports?: string[];\n } = {},\n): string {\n const { add = \"\", drop, rename, imports = [] } = options;\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n // Build the schema object dynamically\n const schemaParts: string[] = [];\n\n if (add) {\n schemaParts.push(` add: {\\n${add}\\n },`);\n }\n\n if (drop) {\n schemaParts.push(` drop: ${drop},`);\n }\n\n if (rename) {\n schemaParts.push(` rename: ${rename},`);\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.alter(${entityName.pascal}, {\n${schemaParts.join(\"\\n\")}\n});\n`;\n}\n\n/**\n * CRUD Create Schema template\n * Outputs to: schema/create-{entity}.schema.ts\n */\nexport function crudCreateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const create${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Create${moduleName.pascal}Schema = Infer<typeof create${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * CRUD Update Schema template\n * Outputs to: schema/update-{entity}.schema.ts\n */\nexport function crudUpdateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const update${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Update${moduleName.pascal}Schema = Infer<typeof update${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * Service template stub\n */\nexport function serviceStub(name: Name): string {\n return `export async function ${name.camel}Service(data: any): Promise<any> {\n // TODO: Implement service logic\n throw new Error(\"${name.camel}Service not implemented\");\n}\n`;\n}\n\n/**\n * Schema template stub\n * Outputs to: schema/{name}.schema.ts\n */\nexport function schemaStub(name: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const ${name.camel}Schema = v.object({\n // TODO: Define validation schema\n});\n\nexport type ${name.pascal}Schema = Infer<typeof ${name.camel}Schema>;\n`;\n}\n\n/**\n * Model template stub\n */\nexport function modelStub(\n name: Name,\n options: { tableName?: string; withResource?: boolean } = {},\n): string {\n const { tableName = `${name.plural.snake}`, withResource } = options;\n\n return `import { Model, type StrictMode } from \"@warlock.js/cascade\";\nimport { v, type Infer } from \"@warlock.js/seal\";\n${withResource ? `import { ${name.singular.pascal}Resource } from \"../../resources/${name.singular.kebab}.resource\";` : \"\"}\n\nconst ${name.singular.camel}Schema = v.object({\n // TODO: Define model schema\n});\n\nexport type ${name.singular.pascal}Type = Infer.Output<typeof ${name.singular.camel}Schema>;\n\nexport class ${name.singular.pascal} extends Model<${name.singular.pascal}Type> {\n public static table = \"${tableName}\";\n public static strictMode: StrictMode = \"fail\";\n${withResource ? ` public static resource = ${name.singular.pascal}Resource;` : \"\"}\n\n public static schema = ${name.singular.camel}Schema;\n\n public static relations = {\n // TODO: Define relations\n };\n}\n`;\n}\n\n/**\n * Repository template stub\n */\nexport function repositoryStub(name: Name): string {\n return `import type { FilterByOptions, RepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${name.singular.pascal} } from \"../models/${name.singular.kebab}\";\n\ntype ${name.singular.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${name.singular.pascal}ListOptions = RepositoryOptions & ${name.singular.pascal}ListFilter;\n\nexport class ${name.plural.pascal}Repository extends RepositoryManager<${name.singular.pascal}, ${name.singular.pascal}ListFilter> {\n public source = ${name.singular.pascal};\n\n protected defaultOptions: RepositoryOptions = this.withDefaultOptions({});\n\n protected filterBy: FilterByOptions = this.withDefaultFilters({\n name: \"like\",\n });\n}\n\nexport const ${name.plural.camel}Repository = new ${name.plural.pascal}Repository();\n`;\n}\n\n/**\n * Resource template stub\n */\nexport function resourceStub(name: Name): string {\n return `import { Resource } from \"@warlock.js/core\";\n\nexport class ${name.singular.pascal}Resource extends Resource {\n public schema = {\n id: \"int\",\n name: \"string\",\n // TODO: Define resource schema\n };\n}\n`;\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,eACd,MACA,UAAwC,CAAC,GACjC;CACR,MAAM,EAAE,mBAAmB;CAE3B,IAAI,CAAC,gBACH,OAAO;;eAEI,KAAK,MAAM;;;;;CAOxB,OAAO;gBACO,KAAK,OAAO,UAAU,KAAK,MAAM,2BAA2B,KAAK,MAAM;;eAExE,KAAK,MAAM,oCAAoC,KAAK,OAAO;;;;;;;;EAQxE,KAAK,MAAM;YACD,KAAK,MAAM;;;AAGvB;;;;;AAMA,SAAgB,yBAAyB,YAA0B;CACjE,OAAO;sBACa,WAAW,OAAO,gBAAgB,WAAW,OAAO,kCAAkC,WAAW,MAAM;iBAC5G,WAAW,OAAO,qCAAqC,WAAW,MAAM;;qBAEpE,WAAW,OAAO,0CAA0C,WAAW,OAAO;;;;UAIzF,WAAW,MAAM,iBAAiB,WAAW,OAAO;;;MAGxD,WAAW,MAAM;;;;QAIf,WAAW,OAAO;kBACR,WAAW,OAAO;;;AAGpC;;;;AAKA,SAAgB,yBAAyB,YAA0B;CACjE,OAAO;sBACa,WAAW,OAAO,gBAAgB,WAAW,OAAO,kCAAkC,WAAW,MAAM;iBAC5G,WAAW,OAAO,qCAAqC,WAAW,MAAM;;qBAEpE,WAAW,OAAO,0CAA0C,WAAW,OAAO;;;;UAIzF,WAAW,MAAM,iBAAiB,WAAW,OAAO;;;MAGxD,WAAW,MAAM;;;;QAIf,WAAW,OAAO;k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AAM;;OAElE,KAAK,SAAS,OAAO;;;;cAId,KAAK,SAAS,OAAO,oCAAoC,KAAK,SAAS,OAAO;;eAE7E,KAAK,OAAO,OAAO,uCAAuC,KAAK,SAAS,OAAO,IAAI,KAAK,SAAS,OAAO;oBACnG,KAAK,SAAS,OAAO;;;;;;;;;eAS1B,KAAK,OAAO,MAAM,mBAAmB,KAAK,OAAO,OAAO;;AAEvE;;;;AAKA,SAAgB,aAAa,MAAoB;CAC/C,OAAO;;eAEM,KAAK,SAAS,OAAO;;;;;;;;AAQpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"name-parser.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/name-parser.ts"],"sourcesContent":["import { toCamelCase, toKebabCase, toSnakeCase, toStudlyCase } from \"@mongez/reinforcements\";\nimport pluralize from \"pluralize-esm\";\nimport type { ParsedName } from \"../types\";\n\n/**\n * Parse module path from input\n * Examples:\n * - \"users/create-user\" → { module: \"users\", name: \"create-user\" }\n * - \"create-user\" → { module: undefined, name: \"create-user\" }\n */\nexport function parseModulePath(input: string): { module?: string; name: string } {\n const parts = input.split(\"/\");\n\n if (parts.length === 1) {\n return { name: parts[0] };\n }\n\n return {\n module: parts[0],\n name: parts.slice(1).join(\"/\"),\n };\n}\n\n/**\n * Parse name into all case variants\n */\nexport function parseName(input: string): ParsedName {\n return new Name(input);\n}\n\n/**\n * Get plural name\n */\nexport function pluralName(name: string) {\n return new Name(pluralize(name));\n}\n\n/**\n * Get singular name\n */\nexport function singularName(name: string) {\n return new Name(pluralize.singular(name));\n}\n\nexport class Name {\n protected parsedData: {\n kebab: string;\n camel: string;\n snake: string;\n studly: string;\n };\n\n public constructor(public readonly raw: string) {\n this.parsedData = {\n kebab: toKebabCase(raw),\n camel: toCamelCase(raw),\n snake: toSnakeCase(raw),\n studly: toStudlyCase(raw),\n };\n }\n\n public get plural() {\n return new Name(pluralize(this.raw));\n }\n\n public get singular() {\n return new Name(pluralize.singular(this.raw));\n }\n\n public get pascal(): string {\n return this.parsedData.studly;\n }\n\n public get camel(): string {\n return this.parsedData.camel;\n }\n\n public get kebab(): string {\n return this.parsedData.kebab;\n }\n\n public get snake(): string {\n return this.parsedData.snake;\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,gBAAgB,OAAkD;CAChF,MAAM,QAAQ,MAAM,MAAM,GAAG;CAE7B,IAAI,MAAM,WAAW,GACnB,OAAO,EAAE,MAAM,MAAM,GAAG;CAG1B,OAAO;EACL,QAAQ,MAAM;EACd,MAAM,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;CAC/B;AACF;;;;AAKA,SAAgB,UAAU,OAA2B;CACnD,OAAO,IAAI,KAAK,KAAK;AACvB;;;;AAKA,SAAgB,WAAW,MAAc;CACvC,OAAO,IAAI,KAAK,UAAU,IAAI,CAAC;AACjC;;;;AAKA,SAAgB,aAAa,MAAc;CACzC,OAAO,IAAI,KAAK,UAAU,SAAS,IAAI,CAAC;AAC1C;AAEA,IAAa,OAAb,MAAa,KAAK;CAQhB,AAAO,YAAY,AAAgB,KAAa;EAAb;EACjC,KAAK,aAAa;GAChB,OAAO,YAAY,GAAG;GACtB,OAAO,YAAY,GAAG;GACtB,OAAO,YAAY,GAAG;GACtB,QAAQ,aAAa,GAAG;EAC1B;CACF;CAEA,IAAW,SAAS;EAClB,OAAO,IAAI,KAAK,UAAU,KAAK,GAAG,CAAC;CACrC;CAEA,IAAW,WAAW;EACpB,OAAO,IAAI,KAAK,UAAU,SAAS,KAAK,GAAG,CAAC;CAC9C;CAEA,IAAW,SAAiB;EAC1B,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;AACF"}
1
+ {"version":3,"file":"name-parser.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/name-parser.ts"],"sourcesContent":["import { toCamelCase, toKebabCase, toSnakeCase, toStudlyCase } from \"@mongez/reinforcements\";\nimport pluralize from \"pluralize-esm\";\nimport type { ParsedName } from \"../types\";\n\n/**\n * Parse module path from input\n * Examples:\n * - \"users/create-user\" → { module: \"users\", name: \"create-user\" }\n * - \"create-user\" → { module: undefined, name: \"create-user\" }\n */\nexport function parseModulePath(input: string): { module?: string; name: string } {\n const parts = input.split(\"/\");\n\n if (parts.length === 1) {\n return { name: parts[0] };\n }\n\n return {\n module: parts[0],\n name: parts.slice(1).join(\"/\"),\n };\n}\n\n/**\n * Parse name into all case variants\n */\n// Returns the Name class, which is what it has always constructed. Annotating it as\n// ParsedName understated the result: Name carries `plural` and `singular` getters that\n// the CRUD stubs need, and a protected member that makes it nominal in practice — so\n// four generators could not pass this value to a stub expecting a Name, even though\n// that is exactly what they had. Name still satisfies ParsedName for callers that only\n// want the cased strings.\nexport function parseName(input: string): Name {\n return new Name(input);\n}\n\n/**\n * Get plural name\n */\nexport function pluralName(name: string) {\n return new Name(pluralize(name));\n}\n\n/**\n * Get singular name\n */\nexport function singularName(name: string) {\n return new Name(pluralize.singular(name));\n}\n\nexport class Name {\n protected parsedData: {\n kebab: string;\n camel: string;\n snake: string;\n studly: string;\n };\n\n public constructor(public readonly raw: string) {\n this.parsedData = {\n kebab: toKebabCase(raw),\n camel: toCamelCase(raw),\n snake: toSnakeCase(raw),\n studly: toStudlyCase(raw),\n };\n }\n\n public get plural() {\n return new Name(pluralize(this.raw));\n }\n\n public get singular() {\n return new Name(pluralize.singular(this.raw));\n }\n\n public get pascal(): string {\n return this.parsedData.studly;\n }\n\n public get camel(): string {\n return this.parsedData.camel;\n }\n\n public get kebab(): string {\n return this.parsedData.kebab;\n }\n\n public get snake(): string {\n return this.parsedData.snake;\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,gBAAgB,OAAkD;CAChF,MAAM,QAAQ,MAAM,MAAM,GAAG;CAE7B,IAAI,MAAM,WAAW,GACnB,OAAO,EAAE,MAAM,MAAM,GAAG;CAG1B,OAAO;EACL,QAAQ,MAAM;EACd,MAAM,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG;CAC/B;AACF;;;;AAWA,SAAgB,UAAU,OAAqB;CAC7C,OAAO,IAAI,KAAK,KAAK;AACvB;;;;AAKA,SAAgB,WAAW,MAAc;CACvC,OAAO,IAAI,KAAK,UAAU,IAAI,CAAC;AACjC;;;;AAKA,SAAgB,aAAa,MAAc;CACzC,OAAO,IAAI,KAAK,UAAU,SAAS,IAAI,CAAC;AAC1C;AAEA,IAAa,OAAb,MAAa,KAAK;CAQhB,AAAO,YAAY,AAAgB,KAAa;EAAb;EACjC,KAAK,aAAa;GAChB,OAAO,YAAY,GAAG;GACtB,OAAO,YAAY,GAAG;GACtB,OAAO,YAAY,GAAG;GACtB,QAAQ,aAAa,GAAG;EAC1B;CACF;CAEA,IAAW,SAAS;EAClB,OAAO,IAAI,KAAK,UAAU,KAAK,GAAG,CAAC;CACrC;CAEA,IAAW,WAAW;EACpB,OAAO,IAAI,KAAK,UAAU,SAAS,KAAK,GAAG,CAAC;CAC9C;CAEA,IAAW,SAAiB;EAC1B,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;CAEA,IAAW,QAAgB;EACzB,OAAO,KAAK,WAAW;CACzB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/prompt.ts"],"sourcesContent":["import readline from \"node:readline\";\n\n/**\n * Prompt user for confirmation\n */\nexport async function confirm(message: string, defaultValue = false): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const defaultText = defaultValue ? \"Y/n\" : \"y/N\";\n rl.question(`${message} (${defaultText}): `, (answer) => {\n rl.close();\n\n if (!answer.trim()) {\n resolve(defaultValue);\n return;\n }\n\n const normalized = answer.toLowerCase().trim();\n resolve(normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user for text input\n */\nexport async function input(message: string, defaultValue?: string): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const prompt = defaultValue ? `${message} (${defaultValue}): ` : `${message}: `;\n\n rl.question(prompt, (answer) => {\n rl.close();\n resolve(answer.trim() || defaultValue || \"\");\n });\n });\n}\n\n/**\n * Prompt user to select from choices\n */\nexport async function select(message: string, choices: string[]): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n console.log(message);\n choices.forEach((choice, index) => {\n console.log(` ${index + 1}. ${choice}`);\n });\n\n rl.question(\"Select (1-\" + choices.length + \"): \", (answer) => {\n rl.close();\n\n const index = parseInt(answer.trim(), 10) - 1;\n\n if (index >= 0 && index < choices.length) {\n resolve(choices[index]);\n } else {\n resolve(choices[0]);\n }\n });\n });\n}\n"],"mappings":";;;;;;AAKA,eAAsB,QAAQ,SAAiB,eAAe,OAAyB;CACrF,MAAM,KAAK,SAAS,gBAAgB;EAClC,OAAO,QAAQ;EACf,QAAQ,QAAQ;CAClB,CAAC;CAED,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,cAAc,eAAe,QAAQ;EAC3C,GAAG,SAAS,GAAG,QAAQ,IAAI,YAAY,OAAO,WAAW;GACvD,GAAG,MAAM;GAET,IAAI,CAAC,OAAO,KAAK,GAAG;IAClB,QAAQ,YAAY;IACpB;GACF;GAEA,MAAM,aAAa,OAAO,YAAY,CAAC,CAAC,KAAK;GAC7C,QAAQ,eAAe,OAAO,eAAe,KAAK;EACpD,CAAC;CACH,CAAC;AACH"}
1
+ {"version":3,"file":"prompt.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/prompt.ts"],"sourcesContent":["import readline from \"node:readline\";\n\n/**\n * Prompt user for confirmation\n */\nexport async function confirm(message: string, defaultValue = false): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const defaultText = defaultValue ? \"Y/n\" : \"y/N\";\n rl.question(`${message} (${defaultText}): `, (answer) => {\n rl.close();\n\n if (!answer.trim()) {\n resolve(defaultValue);\n return;\n }\n\n const normalized = answer.toLowerCase().trim();\n resolve(normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user for text input\n */\nexport async function input(message: string, defaultValue?: string): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n const prompt = defaultValue ? `${message} (${defaultValue}): ` : `${message}: `;\n\n rl.question(prompt, (answer) => {\n rl.close();\n resolve(answer.trim() || defaultValue || \"\");\n });\n });\n}\n\n/**\n * Prompt user to select from choices\n */\nexport async function select(message: string, choices: string[]): Promise<string> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n console.log(message);\n choices.forEach((choice, index) => {\n console.log(` ${index + 1}. ${choice}`);\n });\n\n rl.question(\"Select (1-\" + choices.length + \"): \", (answer) => {\n rl.close();\n\n const index = parseInt(answer.trim(), 10) - 1;\n\n if (index >= 0 && index < choices.length) {\n resolve(choices[index]);\n } else {\n resolve(choices[0]);\n }\n });\n });\n}\n"],"mappings":";;;;;;AAKA,eAAsB,QAAQ,SAAiB,eAAe,OAAyB;CACrF,MAAM,KAAK,SAAS,gBAAgB;EAClC,OAAO,QAAQ;EACf,QAAQ,QAAQ;CAClB,CAAC;CAED,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,cAAc,eAAe,QAAQ;EAC3C,GAAG,SAAS,GAAG,QAAQ,IAAI,YAAY,OAAO,WAAW;GACvD,GAAG,MAAM;GAET,IAAI,CAAC,OAAO,KAAK,GAAG;IAClB,QAAQ,YAAY;IACpB;GACF;GAEA,MAAM,aAAa,OAAO,YAAY,EAAE,KAAK;GAC7C,QAAQ,eAAe,OAAO,eAAe,KAAK;EACpD,CAAC;CACH,CAAC;AACH"}
@@ -0,0 +1,84 @@
1
+ import { matchesDerivedRouteName } from "../../../router/route-name-method-suffix.mjs";
2
+
3
+ //#region ../core/src/cli/commands/routes/diff-page-routes.ts
4
+ /**
5
+ * The comparison half of `warlock routes:diff`, kept free of the filesystem,
6
+ * the boot and the console so it can be exercised directly.
7
+ *
8
+ * WHAT THE TWO SIDES ACTUALLY ARE
9
+ *
10
+ * `expected` comes from `page-routes.manifest.json`, which `warlock build`
11
+ * writes from a pure FILESYSTEM SCAN of the page graph. No application module
12
+ * is imported, no connector boots, no route is registered.
13
+ *
14
+ * `live` comes from the running router, after real registration.
15
+ *
16
+ * Every difference between the two that is NOT drift has to be removed on the
17
+ * producing side, so this comparison can stay a strict string equality — see
18
+ * `normalizeRoutePath` for the path half. Exactly one property survives that
19
+ * rule and is handled here instead, because it is genuinely unknowable at
20
+ * build time: the route-name method suffix (below).
21
+ */
22
+ /** Stable ordering for printed output: by path, then by name. */
23
+ function comparePageRoutes(left, right) {
24
+ return left.path.localeCompare(right.path) || left.name.localeCompare(right.name);
25
+ }
26
+ /**
27
+ * Whether a live route is the same route the build recorded.
28
+ *
29
+ * Method and path must match EXACTLY. The name is compared derived-to-derived:
30
+ * the router appends `.<method>` to a name already claimed by a route of
31
+ * another method (`Router.add`), and which routes get that suffix depends on
32
+ * the registration order across the whole route set — pages and API routes
33
+ * alike. `warlock build` never boots connectors, so the manifest cannot see the
34
+ * API routes that cause the collision and can never record the suffix.
35
+ *
36
+ * Ignoring it here is therefore not leniency, it is reading the manifest for
37
+ * what it is: a record of what each page's name was DERIVED as, not of what it
38
+ * was REGISTERED as. `matchesDerivedRouteName` accepts only the one suffix the
39
+ * router itself could have appended; any other name difference is still drift.
40
+ *
41
+ * THE LIMIT THIS BUYS: a clean diff does not prove that no page name collided
42
+ * at registration. Use `warlock routes` to see the names as registered.
43
+ */
44
+ function isSameRoute(expected, live) {
45
+ return live.method === expected.method && live.path === expected.path && matchesDerivedRouteName(expected.name, live.name, live.method);
46
+ }
47
+ /**
48
+ * Diff the build-time page route surface against the live one.
49
+ *
50
+ * Neither input is mutated and neither has to be pre-sorted; the returned lists
51
+ * are sorted for printing.
52
+ */
53
+ function diffPageRoutes(expected, live) {
54
+ const remainingExpected = new Set(expected);
55
+ const remainingLive = new Set(live);
56
+ const changes = [];
57
+ for (const before of expected) {
58
+ const after = [...remainingLive].find((candidate) => isSameRoute(before, candidate));
59
+ if (after) {
60
+ remainingExpected.delete(before);
61
+ remainingLive.delete(after);
62
+ }
63
+ }
64
+ for (const before of remainingExpected) {
65
+ const after = [...remainingLive].find((candidate) => candidate.source !== "" && candidate.source === before.source);
66
+ if (after && !isSameRoute(before, after)) {
67
+ changes.push({
68
+ before,
69
+ after
70
+ });
71
+ remainingExpected.delete(before);
72
+ remainingLive.delete(after);
73
+ }
74
+ }
75
+ return {
76
+ changes: changes.sort((left, right) => comparePageRoutes(left.before, right.before)),
77
+ removed: [...remainingExpected].sort(comparePageRoutes),
78
+ added: [...remainingLive].sort(comparePageRoutes)
79
+ };
80
+ }
81
+
82
+ //#endregion
83
+ export { comparePageRoutes, diffPageRoutes };
84
+ //# sourceMappingURL=diff-page-routes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-page-routes.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/diff-page-routes.ts"],"sourcesContent":["/**\n * The comparison half of `warlock routes:diff`, kept free of the filesystem,\n * the boot and the console so it can be exercised directly.\n *\n * WHAT THE TWO SIDES ACTUALLY ARE\n *\n * `expected` comes from `page-routes.manifest.json`, which `warlock build`\n * writes from a pure FILESYSTEM SCAN of the page graph. No application module\n * is imported, no connector boots, no route is registered.\n *\n * `live` comes from the running router, after real registration.\n *\n * Every difference between the two that is NOT drift has to be removed on the\n * producing side, so this comparison can stay a strict string equality — see\n * `normalizeRoutePath` for the path half. Exactly one property survives that\n * rule and is handled here instead, because it is genuinely unknowable at\n * build time: the route-name method suffix (below).\n */\nimport { matchesDerivedRouteName } from \"../../../router/route-name-method-suffix\";\n\nexport type PageRoute = {\n method: \"GET\";\n path: string;\n name: string;\n source: string;\n};\n\nexport type PageRouteChange = {\n before: PageRoute;\n after: PageRoute;\n};\n\nexport type PageRoutesDiff = {\n changes: PageRouteChange[];\n removed: PageRoute[];\n added: PageRoute[];\n};\n\n/** Stable ordering for printed output: by path, then by name. */\nexport function comparePageRoutes(left: PageRoute, right: PageRoute): number {\n return left.path.localeCompare(right.path) || left.name.localeCompare(right.name);\n}\n\n/**\n * Whether a live route is the same route the build recorded.\n *\n * Method and path must match EXACTLY. The name is compared derived-to-derived:\n * the router appends `.<method>` to a name already claimed by a route of\n * another method (`Router.add`), and which routes get that suffix depends on\n * the registration order across the whole route set — pages and API routes\n * alike. `warlock build` never boots connectors, so the manifest cannot see the\n * API routes that cause the collision and can never record the suffix.\n *\n * Ignoring it here is therefore not leniency, it is reading the manifest for\n * what it is: a record of what each page's name was DERIVED as, not of what it\n * was REGISTERED as. `matchesDerivedRouteName` accepts only the one suffix the\n * router itself could have appended; any other name difference is still drift.\n *\n * THE LIMIT THIS BUYS: a clean diff does not prove that no page name collided\n * at registration. Use `warlock routes` to see the names as registered.\n */\nfunction isSameRoute(expected: PageRoute, live: PageRoute): boolean {\n return (\n live.method === expected.method &&\n live.path === expected.path &&\n matchesDerivedRouteName(expected.name, live.name, live.method)\n );\n}\n\n/**\n * Diff the build-time page route surface against the live one.\n *\n * Neither input is mutated and neither has to be pre-sorted; the returned lists\n * are sorted for printing.\n */\nexport function diffPageRoutes(expected: PageRoute[], live: PageRoute[]): PageRoutesDiff {\n const remainingExpected = new Set(expected);\n const remainingLive = new Set(live);\n const changes: PageRouteChange[] = [];\n\n // Route identity is the comparison contract. A differing source is displayed\n // only as context and must not make an otherwise identical route drift (a\n // checkout can be relocated without changing its surface).\n for (const before of expected) {\n const after = [...remainingLive].find((candidate) => isSameRoute(before, candidate));\n\n if (after) {\n remainingExpected.delete(before);\n remainingLive.delete(after);\n }\n }\n\n // A stable source is diagnostic context, never itself a diff. It only groups\n // a changed page into one useful line instead of a removal plus an addition.\n for (const before of remainingExpected) {\n const after = [...remainingLive].find(\n (candidate) => candidate.source !== \"\" && candidate.source === before.source,\n );\n\n if (after && !isSameRoute(before, after)) {\n changes.push({ before, after });\n remainingExpected.delete(before);\n remainingLive.delete(after);\n }\n }\n\n return {\n changes: changes.sort((left, right) => comparePageRoutes(left.before, right.before)),\n removed: [...remainingExpected].sort(comparePageRoutes),\n added: [...remainingLive].sort(comparePageRoutes),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,kBAAkB,MAAiB,OAA0B;CAC3E,OAAO,KAAK,KAAK,cAAc,MAAM,IAAI,KAAK,KAAK,KAAK,cAAc,MAAM,IAAI;AAClF;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,YAAY,UAAqB,MAA0B;CAClE,OACE,KAAK,WAAW,SAAS,UACzB,KAAK,SAAS,SAAS,QACvB,wBAAwB,SAAS,MAAM,KAAK,MAAM,KAAK,MAAM;AAEjE;;;;;;;AAQA,SAAgB,eAAe,UAAuB,MAAmC;CACvF,MAAM,oBAAoB,IAAI,IAAI,QAAQ;CAC1C,MAAM,gBAAgB,IAAI,IAAI,IAAI;CAClC,MAAM,UAA6B,CAAC;CAKpC,KAAK,MAAM,UAAU,UAAU;EAC7B,MAAM,QAAQ,CAAC,GAAG,aAAa,EAAE,MAAM,cAAc,YAAY,QAAQ,SAAS,CAAC;EAEnF,IAAI,OAAO;GACT,kBAAkB,OAAO,MAAM;GAC/B,cAAc,OAAO,KAAK;EAC5B;CACF;CAIA,KAAK,MAAM,UAAU,mBAAmB;EACtC,MAAM,QAAQ,CAAC,GAAG,aAAa,EAAE,MAC9B,cAAc,UAAU,WAAW,MAAM,UAAU,WAAW,OAAO,MACxE;EAEA,IAAI,SAAS,CAAC,YAAY,QAAQ,KAAK,GAAG;GACxC,QAAQ,KAAK;IAAE;IAAQ;GAAM,CAAC;GAC9B,kBAAkB,OAAO,MAAM;GAC/B,cAAc,OAAO,KAAK;EAC5B;CACF;CAEA,OAAO;EACL,SAAS,QAAQ,MAAM,MAAM,UAAU,kBAAkB,KAAK,QAAQ,MAAM,MAAM,CAAC;EACnF,SAAS,CAAC,GAAG,iBAAiB,EAAE,KAAK,iBAAiB;EACtD,OAAO,CAAC,GAAG,aAAa,EAAE,KAAK,iBAAiB;CAClD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-routes-table.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/format-routes-table.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { methodRank, type RouteRow } from \"./route-row\";\n\n/** The columns rendered, in order, with their header labels. */\nconst COLUMNS = [\n { key: \"method\", header: \"METHOD\" },\n { key: \"path\", header: \"PATH\" },\n { key: \"name\", header: \"NAME\" },\n { key: \"action\", header: \"ACTION\" },\n { key: \"middleware\", header: \"MW\" },\n { key: \"source\", header: \"SOURCE\" },\n] as const;\n\ntype ColumnKey = (typeof COLUMNS)[number][\"key\"];\n\n/** Two spaces between columns. */\nconst GAP = \" \";\n\n/** Shown for an empty string cell so the column doesn't read as a gap. */\nconst EMPTY_CELL = \"—\";\n\n/**\n * The plain (uncolored) text of one cell. Numbers render as-is; an empty string\n * renders as {@link EMPTY_CELL}. This is the single source of truth for both\n * the width math and the rendered text, so colored and uncolored output stay\n * aligned.\n *\n * @param row - The row\n * @param key - The column key\n * @returns The cell's printable text\n */\nfunction cellText(row: RouteRow, key: ColumnKey): string {\n if (key === \"middleware\") return String(row.middleware);\n\n const value = row[key] as string;\n\n return value.length > 0 ? value : EMPTY_CELL;\n}\n\n/**\n * Per-column display width: the longest of the header and every cell.\n *\n * @param rows - The rows to measure\n * @returns One width per column, in column order\n */\nfunction columnWidths(rows: RouteRow[]): number[] {\n return COLUMNS.map((column) =>\n Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)),\n );\n}\n\n/**\n * Build a one-line, human-readable summary: the total plus a per-method\n * breakdown ordered by {@link methodRank}, e.g.\n * `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.\n *\n * @param rows - The rows being summarized\n * @returns The summary line\n */\nexport function routesSummary(rows: RouteRow[]): string {\n const noun = rows.length === 1 ? \"route\" : \"routes\";\n\n if (rows.length === 0) return `0 ${noun}`;\n\n const counts = new Map<string, number>();\n\n for (const row of rows) {\n counts.set(row.method, (counts.get(row.method) ?? 0) + 1);\n }\n\n const breakdown = [...counts.entries()]\n .sort(([a], [b]) => methodRank(a) - methodRank(b))\n .map(([method, count]) => `${count} ${method}`)\n .join(\" · \");\n\n return `${rows.length} ${noun} (${breakdown})`;\n}\n\n/**\n * Render the routes table as an ordered list of plain (uncolored) lines:\n * a header row, one row per route, a blank line, then the summary. Returned as\n * strings (not printed) so the layout is unit-testable without ANSI noise.\n *\n * @param rows - The rows to render (already filtered/sorted by the caller)\n * @returns The lines to print, top to bottom\n */\nexport function formatRoutesTableLines(rows: RouteRow[]): string[] {\n if (rows.length === 0) {\n return [\"No routes registered.\"];\n }\n\n const widths = columnWidths(rows);\n\n const renderRow = (cells: string[]) =>\n cells.map((text, index) => text.padEnd(widths[index])).join(GAP).trimEnd();\n\n const lines = [renderRow(COLUMNS.map((column) => column.header))];\n\n for (const row of rows) {\n lines.push(renderRow(COLUMNS.map((column) => cellText(row, column.key))));\n }\n\n lines.push(\"\");\n lines.push(routesSummary(rows));\n\n return lines;\n}\n\n/** Per-verb color for the METHOD column. Unknown verbs fall back to white. */\nconst METHOD_COLOR: Record<string, (input: string) => string> = {\n GET: colors.green,\n POST: colors.blue,\n PUT: colors.yellow,\n PATCH: colors.yellow,\n DELETE: colors.red,\n OPTIONS: colors.gray,\n HEAD: colors.gray,\n ALL: colors.magenta,\n};\n\n/**\n * Colorize the method label, then right-pad with plain spaces so column\n * alignment is computed from the visible width, not the ANSI-coded length.\n *\n * @param method - The uppercased HTTP verb\n * @param width - The METHOD column width\n * @returns The colored, padded cell\n */\nfunction colorizeMethodCell(method: string, width: number): string {\n const colorize = METHOD_COLOR[method] ?? colors.white;\n\n return colorize(method) + \" \".repeat(Math.max(0, width - method.length));\n}\n\n/**\n * Print the routes table to stdout with a bold header, verb-colored METHOD\n * column, and a dimmed summary. The empty case prints a single yellow notice\n * (a booted app with zero routes usually means a route module failed to load).\n *\n * Thin presentation wrapper over {@link formatRoutesTableLines} /\n * {@link routesSummary} — those stay the source of truth for layout.\n *\n * @param rows - The rows to print (already filtered/sorted by the caller)\n */\nexport function printRoutesTable(rows: RouteRow[]): void {\n if (rows.length === 0) {\n console.log(colors.yellow(\"No routes registered — did a route module fail to load?\"));\n return;\n }\n\n const widths = columnWidths(rows);\n\n const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index]))\n .join(GAP)\n .trimEnd();\n\n console.log(colors.bold(headerLine));\n\n for (const row of rows) {\n const cells = COLUMNS.map((column, index) => {\n if (column.key === \"method\") {\n return colorizeMethodCell(row.method, widths[index]);\n }\n\n return cellText(row, column.key).padEnd(widths[index]);\n });\n\n console.log(cells.join(GAP).trimEnd());\n }\n\n console.log(\"\");\n console.log(colors.gray(routesSummary(rows)));\n}\n"],"mappings":";;;;;AAIA,MAAM,UAAU;CACd;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAc,QAAQ;CAAK;CAClC;EAAE,KAAK;EAAU,QAAQ;CAAS;AACpC;;AAKA,MAAM,MAAM;;AAGZ,MAAM,aAAa;;;;;;;;;;;AAYnB,SAAS,SAAS,KAAe,KAAwB;CACvD,IAAI,QAAQ,cAAc,OAAO,OAAO,IAAI,UAAU;CAEtD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;CAEA,MAAM,SAAS,aAAa,IAAI;CAEhC,MAAM,aAAa,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,CACnF,KAAK,GAAG,CAAC,CACT,QAAQ;CAEX,QAAQ,IAAI,OAAO,KAAK,UAAU,CAAC;CAEnC,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,QAAQ,KAAK,QAAQ,UAAU;GAC3C,IAAI,OAAO,QAAQ,UACjB,OAAO,mBAAmB,IAAI,QAAQ,OAAO,MAAM;GAGrD,OAAO,SAAS,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO,OAAO,MAAM;EACvD,CAAC;EAED,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC;CACvC;CAEA,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,OAAO,KAAK,cAAc,IAAI,CAAC,CAAC;AAC9C"}
1
+ {"version":3,"file":"format-routes-table.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/format-routes-table.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { methodRank, type RouteRow } from \"./route-row\";\n\n/** The columns rendered, in order, with their header labels. */\nconst COLUMNS = [\n { key: \"method\", header: \"METHOD\" },\n { key: \"path\", header: \"PATH\" },\n { key: \"name\", header: \"NAME\" },\n { key: \"action\", header: \"ACTION\" },\n { key: \"middleware\", header: \"MW\" },\n { key: \"source\", header: \"SOURCE\" },\n] as const;\n\ntype ColumnKey = (typeof COLUMNS)[number][\"key\"];\n\n/** Two spaces between columns. */\nconst GAP = \" \";\n\n/** Shown for an empty string cell so the column doesn't read as a gap. */\nconst EMPTY_CELL = \"—\";\n\n/**\n * The plain (uncolored) text of one cell. Numbers render as-is; an empty string\n * renders as {@link EMPTY_CELL}. This is the single source of truth for both\n * the width math and the rendered text, so colored and uncolored output stay\n * aligned.\n *\n * @param row - The row\n * @param key - The column key\n * @returns The cell's printable text\n */\nfunction cellText(row: RouteRow, key: ColumnKey): string {\n if (key === \"middleware\") return String(row.middleware);\n\n const value = row[key] as string;\n\n return value.length > 0 ? value : EMPTY_CELL;\n}\n\n/**\n * Per-column display width: the longest of the header and every cell.\n *\n * @param rows - The rows to measure\n * @returns One width per column, in column order\n */\nfunction columnWidths(rows: RouteRow[]): number[] {\n return COLUMNS.map((column) =>\n Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)),\n );\n}\n\n/**\n * Build a one-line, human-readable summary: the total plus a per-method\n * breakdown ordered by {@link methodRank}, e.g.\n * `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.\n *\n * @param rows - The rows being summarized\n * @returns The summary line\n */\nexport function routesSummary(rows: RouteRow[]): string {\n const noun = rows.length === 1 ? \"route\" : \"routes\";\n\n if (rows.length === 0) return `0 ${noun}`;\n\n const counts = new Map<string, number>();\n\n for (const row of rows) {\n counts.set(row.method, (counts.get(row.method) ?? 0) + 1);\n }\n\n const breakdown = [...counts.entries()]\n .sort(([a], [b]) => methodRank(a) - methodRank(b))\n .map(([method, count]) => `${count} ${method}`)\n .join(\" · \");\n\n return `${rows.length} ${noun} (${breakdown})`;\n}\n\n/**\n * Render the routes table as an ordered list of plain (uncolored) lines:\n * a header row, one row per route, a blank line, then the summary. Returned as\n * strings (not printed) so the layout is unit-testable without ANSI noise.\n *\n * @param rows - The rows to render (already filtered/sorted by the caller)\n * @returns The lines to print, top to bottom\n */\nexport function formatRoutesTableLines(rows: RouteRow[]): string[] {\n if (rows.length === 0) {\n return [\"No routes registered.\"];\n }\n\n const widths = columnWidths(rows);\n\n const renderRow = (cells: string[]) =>\n cells.map((text, index) => text.padEnd(widths[index])).join(GAP).trimEnd();\n\n const lines = [renderRow(COLUMNS.map((column) => column.header))];\n\n for (const row of rows) {\n lines.push(renderRow(COLUMNS.map((column) => cellText(row, column.key))));\n }\n\n lines.push(\"\");\n lines.push(routesSummary(rows));\n\n return lines;\n}\n\n/** Per-verb color for the METHOD column. Unknown verbs fall back to white. */\nconst METHOD_COLOR: Record<string, (input: string) => string> = {\n GET: colors.green,\n POST: colors.blue,\n PUT: colors.yellow,\n PATCH: colors.yellow,\n DELETE: colors.red,\n OPTIONS: colors.gray,\n HEAD: colors.gray,\n ALL: colors.magenta,\n};\n\n/**\n * Colorize the method label, then right-pad with plain spaces so column\n * alignment is computed from the visible width, not the ANSI-coded length.\n *\n * @param method - The uppercased HTTP verb\n * @param width - The METHOD column width\n * @returns The colored, padded cell\n */\nfunction colorizeMethodCell(method: string, width: number): string {\n const colorize = METHOD_COLOR[method] ?? colors.white;\n\n return colorize(method) + \" \".repeat(Math.max(0, width - method.length));\n}\n\n/**\n * Print the routes table to stdout with a bold header, verb-colored METHOD\n * column, and a dimmed summary. The empty case prints a single yellow notice\n * (a booted app with zero routes usually means a route module failed to load).\n *\n * Thin presentation wrapper over {@link formatRoutesTableLines} /\n * {@link routesSummary} — those stay the source of truth for layout.\n *\n * @param rows - The rows to print (already filtered/sorted by the caller)\n */\nexport function printRoutesTable(rows: RouteRow[]): void {\n if (rows.length === 0) {\n console.log(colors.yellow(\"No routes registered — did a route module fail to load?\"));\n return;\n }\n\n const widths = columnWidths(rows);\n\n const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index]))\n .join(GAP)\n .trimEnd();\n\n console.log(colors.bold(headerLine));\n\n for (const row of rows) {\n const cells = COLUMNS.map((column, index) => {\n if (column.key === \"method\") {\n return colorizeMethodCell(row.method, widths[index]);\n }\n\n return cellText(row, column.key).padEnd(widths[index]);\n });\n\n console.log(cells.join(GAP).trimEnd());\n }\n\n console.log(\"\");\n console.log(colors.gray(routesSummary(rows)));\n}\n"],"mappings":";;;;;AAIA,MAAM,UAAU;CACd;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAA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AAI,GAAG,QAAQ,OAAO,MAAM,CAAC;AACzE;;;;;;;;;;;AAYA,SAAgB,iBAAiB,MAAwB;CACvD,IAAI,KAAK,WAAW,GAAG;EACrB,QAAQ,IAAI,OAAO,OAAO,yDAAyD,CAAC;EACpF;CACF;CAEA,MAAM,SAAS,aAAa,IAAI;CAEhC,MAAM,aAAa,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,CAAC,EAClF,KAAK,GAAG,EACR,QAAQ;CAEX,QAAQ,IAAI,OAAO,KAAK,UAAU,CAAC;CAEnC,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,QAAQ,KAAK,QAAQ,UAAU;GAC3C,IAAI,OAAO,QAAQ,UACjB,OAAO,mBAAmB,IAAI,QAAQ,OAAO,MAAM;GAGrD,OAAO,SAAS,KAAK,OAAO,GAAG,EAAE,OAAO,OAAO,MAAM;EACvD,CAAC;EAED,QAAQ,IAAI,MAAM,KAAK,GAAG,EAAE,QAAQ,CAAC;CACvC;CAEA,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,OAAO,KAAK,cAAc,IAAI,CAAC,CAAC;AAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"route-row.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/route-row.ts"],"sourcesContent":["import type { Route } from \"../../../router/types\";\n\n/**\n * A single registered route, normalized to the flat, display-ready shape the\n * `warlock routes` table (and its `--json` output) render. Kept separate from\n * the live {@link Route} so the formatter and filters never touch the handler\n * function, validation object, or Fastify server options — only printable\n * scalars.\n */\nexport type RouteRow = {\n /** Uppercased HTTP verb (`\"all\"` → `\"ALL\"`). */\n method: string;\n\n /** Full request path (prefix already folded in by the router). */\n path: string;\n\n /** Route name, or `\"\"` when the route was registered without one. */\n name: string;\n\n /** Handler/controller-action label — the handler function name, or `\"anonymous\"`. */\n action: string;\n\n /** Number of middleware attached to the route. */\n middleware: number;\n\n /** Relative source file the route was registered from, or `\"\"`. */\n source: string;\n};\n\n/** Filters accepted by `warlock routes`, each optional and additive (AND-ed). */\nexport type RouteFilter = {\n /** Exact HTTP method (case-insensitive). */\n method?: string;\n\n /** Case-insensitive substring matched against the path. */\n path?: string;\n\n /** Case-insensitive substring matched against the route name. */\n name?: string;\n};\n\n/**\n * Display order of HTTP methods — used to rank rows within a path and to order\n * the per-method breakdown in the summary line.\n */\nexport const METHOD_ORDER = [\n \"GET\",\n \"POST\",\n \"PUT\",\n \"PATCH\",\n \"DELETE\",\n \"OPTIONS\",\n \"HEAD\",\n \"ALL\",\n];\n\n/**\n * Rank of a method for sorting. Unknown methods sort last (stable among\n * themselves).\n *\n * @param method - Uppercased HTTP verb\n * @returns The sort index\n */\nexport function methodRank(method: string): number {\n const index = METHOD_ORDER.indexOf(method);\n return index === -1 ? METHOD_ORDER.length : index;\n}\n\n/**\n * Derive the handler/controller-action label for a route. Uses the handler\n * function's name, stripping the `bound ` prefix that `Function.prototype.bind`\n * prepends, and falls back to `\"anonymous\"` for an unnamed handler.\n *\n * @param route - The route to label\n * @returns A printable action label\n */\nfunction routeAction(route: Route): string {\n const handler = route.handler as unknown;\n\n if (typeof handler !== \"function\") return \"anonymous\";\n\n const name = handler.name?.replace(/^bound /, \"\").trim();\n\n return name ? name : \"anonymous\";\n}\n\n/**\n * Normalize a live {@link Route} into a printable {@link RouteRow}.\n *\n * @param route - The registered route\n * @returns The display-ready row\n */\nexport function toRouteRow(route: Route): RouteRow {\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name ?? \"\",\n action: routeAction(route),\n middleware: route.middleware?.length ?? 0,\n source: route.sourceFile ?? \"\",\n };\n}\n\n/**\n * Apply the `--method` / `--path` / `--name` filters to a set of rows. An\n * omitted filter matches everything; provided filters are AND-ed.\n *\n * @param rows - The rows to filter\n * @param filter - The active filters\n * @returns The matching rows (a new array)\n */\nexport function filterRouteRows(rows: RouteRow[], filter: RouteFilter): RouteRow[] {\n const method = filter.method?.toUpperCase();\n const path = filter.path?.toLowerCase();\n const name = filter.name?.toLowerCase();\n\n return rows.filter((row) => {\n if (method && row.method !== method) return false;\n if (path && !row.path.toLowerCase().includes(path)) return false;\n if (name && !row.name.toLowerCase().includes(name)) return false;\n return true;\n });\n}\n\n/**\n * Sort rows by path (ascending), then by HTTP-method order within a path, so\n * every verb of one resource lists together in a predictable sequence.\n *\n * @param rows - The rows to sort\n * @returns A new, sorted array\n */\nexport function sortRouteRows(rows: RouteRow[]): RouteRow[] {\n return [...rows].sort((a, b) => {\n if (a.path !== b.path) return a.path < b.path ? -1 : 1;\n return methodRank(a.method) - methodRank(b.method);\n });\n}\n"],"mappings":";;;;;AA6CA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,WAAW,QAAwB;CACjD,MAAM,QAAQ,aAAa,QAAQ,MAAM;CACzC,OAAO,UAAU,KAAK,aAAa,SAAS;AAC9C;;;;;;;;;AAUA,SAAS,YAAY,OAAsB;CACzC,MAAM,UAAU,MAAM;CAEtB,IAAI,OAAO,YAAY,YAAY,OAAO;CAE1C,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,EAAE,CAAC,CAAC,KAAK;CAEvD,OAAO,OAAO,OAAO;AACvB;;;;;;;AAQA,SAAgB,WAAW,OAAwB;CACjD,OAAO;EACL,QAAQ,MAAM,OAAO,YAAY;EACjC,MAAM,MAAM;EACZ,MAAM,MAAM,QAAQ;EACpB,QAAQ,YAAY,KAAK;EACzB,YAAY,MAAM,YAAY,UAAU;EACxC,QAAQ,MAAM,cAAc;CAC9B;AACF;;;;;;;;;AAUA,SAAgB,gBAAgB,MAAkB,QAAiC;CACjF,MAAM,SAAS,OAAO,QAAQ,YAAY;CAC1C,MAAM,OAAO,OAAO,MAAM,YAAY;CACtC,MAAM,OAAO,OAAO,MAAM,YAAY;CAEtC,OAAO,KAAK,QAAQ,QAAQ;EAC1B,IAAI,UAAU,IAAI,WAAW,QAAQ,OAAO;EAC5C,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,OAAO;CACT,CAAC;AACH;;;;;;;;AASA,SAAgB,cAAc,MAA8B;CAC1D,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;EAC9B,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK;EACrD,OAAO,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM;CACnD,CAAC;AACH"}
1
+ {"version":3,"file":"route-row.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/route-row.ts"],"sourcesContent":["import type { Route } from \"../../../router/types\";\n\n/**\n * A single registered route, normalized to the flat, display-ready shape the\n * `warlock routes` table (and its `--json` output) render. Kept separate from\n * the live {@link Route} so the formatter and filters never touch the handler\n * function, validation object, or Fastify server options — only printable\n * scalars.\n */\nexport type RouteRow = {\n /** Uppercased HTTP verb (`\"all\"` → `\"ALL\"`). */\n method: string;\n\n /** Full request path (prefix already folded in by the router). */\n path: string;\n\n /** Route name, or `\"\"` when the route was registered without one. */\n name: string;\n\n /** Handler/controller-action label — the handler function name, or `\"anonymous\"`. */\n action: string;\n\n /** Number of middleware attached to the route. */\n middleware: number;\n\n /** Relative source file the route was registered from, or `\"\"`. */\n source: string;\n};\n\n/** Filters accepted by `warlock routes`, each optional and additive (AND-ed). */\nexport type RouteFilter = {\n /** Exact HTTP method (case-insensitive). */\n method?: string;\n\n /** Case-insensitive substring matched against the path. */\n path?: string;\n\n /** Case-insensitive substring matched against the route name. */\n name?: string;\n};\n\n/**\n * Display order of HTTP methods — used to rank rows within a path and to order\n * the per-method breakdown in the summary line.\n */\nexport const METHOD_ORDER = [\n \"GET\",\n \"POST\",\n \"PUT\",\n \"PATCH\",\n \"DELETE\",\n \"OPTIONS\",\n \"HEAD\",\n \"ALL\",\n];\n\n/**\n * Rank of a method for sorting. Unknown methods sort last (stable among\n * themselves).\n *\n * @param method - Uppercased HTTP verb\n * @returns The sort index\n */\nexport function methodRank(method: string): number {\n const index = METHOD_ORDER.indexOf(method);\n return index === -1 ? METHOD_ORDER.length : index;\n}\n\n/**\n * Derive the handler/controller-action label for a route. Uses the handler\n * function's name, stripping the `bound ` prefix that `Function.prototype.bind`\n * prepends, and falls back to `\"anonymous\"` for an unnamed handler.\n *\n * @param route - The route to label\n * @returns A printable action label\n */\nfunction routeAction(route: Route): string {\n const handler = route.handler as unknown;\n\n if (typeof handler !== \"function\") return \"anonymous\";\n\n const name = handler.name?.replace(/^bound /, \"\").trim();\n\n return name ? name : \"anonymous\";\n}\n\n/**\n * Normalize a live {@link Route} into a printable {@link RouteRow}.\n *\n * @param route - The registered route\n * @returns The display-ready row\n */\nexport function toRouteRow(route: Route): RouteRow {\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name ?? \"\",\n action: routeAction(route),\n middleware: route.middleware?.length ?? 0,\n source: route.sourceFile ?? \"\",\n };\n}\n\n/**\n * Apply the `--method` / `--path` / `--name` filters to a set of rows. An\n * omitted filter matches everything; provided filters are AND-ed.\n *\n * @param rows - The rows to filter\n * @param filter - The active filters\n * @returns The matching rows (a new array)\n */\nexport function filterRouteRows(rows: RouteRow[], filter: RouteFilter): RouteRow[] {\n const method = filter.method?.toUpperCase();\n const path = filter.path?.toLowerCase();\n const name = filter.name?.toLowerCase();\n\n return rows.filter((row) => {\n if (method && row.method !== method) return false;\n if (path && !row.path.toLowerCase().includes(path)) return false;\n if (name && !row.name.toLowerCase().includes(name)) return false;\n return true;\n });\n}\n\n/**\n * Sort rows by path (ascending), then by HTTP-method order within a path, so\n * every verb of one resource lists together in a predictable sequence.\n *\n * @param rows - The rows to sort\n * @returns A new, sorted array\n */\nexport function sortRouteRows(rows: RouteRow[]): RouteRow[] {\n return [...rows].sort((a,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EAAE,OAAO,KAAK;EACrD,OAAO,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM;CACnD,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { printRoutesTable } from \"./format-routes-table\";\r\nimport { filterRouteRows, sortRouteRows, toRouteRow } from \"./route-row\";\r\n\r\n/**\r\n * Read the active option as a trimmed string, or `undefined` when it is absent\r\n * or not a string (a bare boolean flag).\r\n *\r\n * @param value - The parsed option value\r\n * @returns The string value, or `undefined`\r\n */\r\nfunction stringOption(value: string | number | boolean | undefined): string | undefined {\r\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\r\n}\r\n\r\n/**\r\n * Action behind `warlock routes`. Reads the registered routes from the router\r\n * singleton (populated by the `bootstrap` preload, with no connectors started),\r\n * applies the `--method` / `--path` / `--name` filters, sorts them, and either\r\n * prints a verb-colored table or — with `--json` — emits the normalized rows as\r\n * JSON for piping into scripts/CI.\r\n *\r\n * Read-only: it never opens a database/cache/socket connection and never\r\n * mutates the router.\r\n *\r\n * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).\r\n */\r\nexport function routesCommandAction({ options }: CommandActionData): void {\r\n const rows = sortRouteRows(\r\n filterRouteRows(router.list().map(toRouteRow), {\r\n method: stringOption(options.method),\r\n path: stringOption(options.path),\r\n name: stringOption(options.name),\r\n }),\r\n );\r\n\r\n if (options.json) {\r\n console.log(JSON.stringify(rows, null, 2));\r\n return;\r\n }\r\n\r\n printRoutesTable(rows);\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aAAa,OAAkE;CACtF,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,EAAE,WAAoC;CACxE,MAAM,OAAO,cACX,gBAAgB,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,GAAG;EAC7C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,aAAa,QAAQ,IAAI;CACjC,CAAC,CACH;CAEA,IAAI,QAAQ,MAAM;EAChB,QAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;EACzC;CACF;CAEA,iBAAiB,IAAI;AACvB"}
1
+ {"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { printRoutesTable } from \"./format-routes-table\";\r\nimport { filterRouteRows, sortRouteRows, toRouteRow } from \"./route-row\";\r\n\r\n/**\r\n * Read the active option as a trimmed string, or `undefined` when it is absent\r\n * or not a string (a bare boolean flag).\r\n *\r\n * @param value - The parsed option value\r\n * @returns The string value, or `undefined`\r\n */\r\nfunction stringOption(value: string | number | boolean | undefined): string | undefined {\r\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\r\n}\r\n\r\n/**\r\n * Action behind `warlock routes`. Reads the registered routes from the router\r\n * singleton (populated by the `bootstrap` preload, with no connectors started),\r\n * applies the `--method` / `--path` / `--name` filters, sorts them, and either\r\n * prints a verb-colored table or — with `--json` — emits the normalized rows as\r\n * JSON for piping into scripts/CI.\r\n *\r\n * Read-only: it never opens a database/cache/socket connection and never\r\n * mutates the router.\r\n *\r\n * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).\r\n */\r\nexport function routesCommandAction({ options }: CommandActionData): void {\r\n const rows = sortRouteRows(\r\n filterRouteRows(router.list().map(toRouteRow), {\r\n method: stringOption(options.method),\r\n path: stringOption(options.path),\r\n name: stringOption(options.name),\r\n }),\r\n );\r\n\r\n if (options.json) {\r\n console.log(JSON.stringify(rows, null, 2));\r\n return;\r\n }\r\n\r\n printRoutesTable(rows);\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aAAa,OAAkE;CACtF,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,EAAE,WAAoC;CACxE,MAAM,OAAO,cACX,gBAAgB,OAAO,KAAK,EAAE,IAAI,UAAU,GAAG;EAC7C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,aAAa,QAAQ,IAAI;CACjC,CAAC,CACH;CAEA,IAAI,QAAQ,MAAM;EAChB,QAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;EACzC;CACF;CAEA,iBAAiB,IAAI;AACvB"}
@@ -0,0 +1,84 @@
1
+ import { router } from "../../../router/router.mjs";
2
+ import { resolveBuildConfig } from "../../../production/resolve-build-config.mjs";
3
+ import { bootForDiagnostics } from "../doctor/boot-for-diagnostics.mjs";
4
+ import { comparePageRoutes, diffPageRoutes } from "./diff-page-routes.mjs";
5
+ import path from "node:path";
6
+ import fs from "node:fs";
7
+
8
+ //#region ../core/src/cli/commands/routes/routes-diff.action.ts
9
+ const SNAPSHOT_FILE = "page-routes.manifest.json";
10
+ /**
11
+ * What a clean `warlock routes:diff` does and does NOT prove, printed on a
12
+ * clean run so the guarantee is stated where it is relied on.
13
+ */
14
+ const CLEAN_RUN_LIMIT = "Note: page names are compared as DERIVED by the build, so a clean diff does not prove that no route name collided at registration (the router appends `.<method>` to a name already claimed by another method). Run `warlock routes` to see the registered names.";
15
+ function routeFromLive(route) {
16
+ return {
17
+ method: route.method.toUpperCase(),
18
+ path: route.path,
19
+ name: route.name ?? "",
20
+ source: route.sourceFile ?? ""
21
+ };
22
+ }
23
+ function snapshotPath() {
24
+ return path.join(resolveBuildConfig().outdir, SNAPSHOT_FILE);
25
+ }
26
+ function readSnapshot(file) {
27
+ let raw;
28
+ try {
29
+ raw = fs.readFileSync(file, "utf-8");
30
+ } catch {
31
+ throw new Error(`Cannot compare page routes: no build snapshot exists at "${file}". Run \`warlock build\` successfully, then run \`warlock routes:diff\` again.`);
32
+ }
33
+ try {
34
+ const parsed = JSON.parse(raw);
35
+ if (typeof parsed !== "object" || parsed === null || parsed.version !== 1 || !Array.isArray(parsed.routes) || !parsed.routes.every((route) => typeof route === "object" && route !== null && route.method === "GET" && typeof route.path === "string" && typeof route.name === "string" && typeof route.source === "string")) throw new Error("invalid shape");
36
+ return parsed;
37
+ } catch {
38
+ throw new Error(`Cannot compare page routes: build snapshot "${file}" is malformed. Run \`warlock build\` successfully to replace it, then retry.`);
39
+ }
40
+ }
41
+ function printRoute(prefix, route) {
42
+ const source = route.source ? ` (${route.source})` : "";
43
+ console.log(`${prefix} GET ${route.path} ${route.name}${source}`);
44
+ }
45
+ /**
46
+ * Compare the last successful production page surface with the live dev
47
+ * surface.
48
+ *
49
+ * The comparison itself lives in `diff-page-routes.ts`, which also documents
50
+ * why the route-name method suffix is the one registration-time difference the
51
+ * build-time manifest cannot record — and therefore what a clean run of this
52
+ * command does not prove.
53
+ */
54
+ async function routesDiffCommandAction() {
55
+ const snapshot = readSnapshot(snapshotPath());
56
+ const context = await bootForDiagnostics();
57
+ if (!context.booted || context.moduleFailures.length > 0 || context.connectors.failures.length > 0 || context.connectors.registrationError !== void 0) {
58
+ const details = [
59
+ ...context.moduleFailures.map(({ file, message }) => `${file}: ${message}`),
60
+ ...context.connectors.failures.map(({ name, message }) => `${name}: ${message}`),
61
+ ...context.connectors.registrationError ? [context.connectors.registrationError] : []
62
+ ];
63
+ throw new Error(`Cannot compare page routes because diagnostic boot failed.${details.length ? `\n${details.join("\n")}` : ""}`);
64
+ }
65
+ const live = router.list().filter((route) => route.isPage).map(routeFromLive).sort(comparePageRoutes);
66
+ const expected = [...snapshot.routes].sort(comparePageRoutes);
67
+ const { changes, removed, added } = diffPageRoutes(expected, live);
68
+ if (changes.length === 0 && removed.length === 0 && added.length === 0) {
69
+ console.log(`Page routes match (${expected.length} routes).`);
70
+ console.log(CLEAN_RUN_LIMIT);
71
+ return;
72
+ }
73
+ for (const { before, after } of changes) {
74
+ printRoute("changed -", before);
75
+ printRoute(" +", after);
76
+ }
77
+ for (const route of removed) printRoute("removed -", route);
78
+ for (const route of added) printRoute("added +", route);
79
+ throw new Error(`Page route drift: ${changes.length} changed, ${removed.length} removed, ${added.length} added. Run \`warlock build\` after reviewing these changes.`);
80
+ }
81
+
82
+ //#endregion
83
+ export { routesDiffCommandAction };
84
+ //# sourceMappingURL=routes-diff.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-diff.action.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/routes/routes-diff.action.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveBuildConfig } from \"../../../production/resolve-build-config\";\nimport { router } from \"../../../router/router\";\nimport type { Route } from \"../../../router/types\";\nimport { bootForDiagnostics } from \"../doctor/boot-for-diagnostics\";\nimport { comparePageRoutes, diffPageRoutes, type PageRoute } from \"./diff-page-routes\";\n\ntype PageRoutesSnapshot = {\n version: 1;\n routes: PageRoute[];\n};\n\nconst SNAPSHOT_FILE = \"page-routes.manifest.json\";\n\n/**\n * What a clean `warlock routes:diff` does and does NOT prove, printed on a\n * clean run so the guarantee is stated where it is relied on.\n */\nconst CLEAN_RUN_LIMIT =\n \"Note: page names are compared as DERIVED by the build, so a clean diff does not prove \" +\n \"that no route name collided at registration (the router appends `.<method>` to a name \" +\n \"already claimed by another method). Run `warlock routes` to see the registered names.\";\n\nfunction routeFromLive(route: Route): PageRoute {\n return {\n method: route.method.toUpperCase() as \"GET\",\n path: route.path,\n name: route.name ?? \"\",\n source: route.sourceFile ?? \"\",\n };\n}\n\nfunction snapshotPath(): string {\n return path.join(resolveBuildConfig().outdir, SNAPSHOT_FILE);\n}\n\nfunction readSnapshot(file: string): PageRoutesSnapshot {\n let raw: string;\n\n try {\n raw = fs.readFileSync(file, \"utf-8\");\n } catch {\n throw new Error(\n `Cannot compare page routes: no build snapshot exists at \"${file}\". Run \\`warlock build\\` successfully, then run \\`warlock routes:diff\\` again.`,\n );\n }\n\n try {\n const parsed: unknown = JSON.parse(raw);\n\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n (parsed as { version?: unknown }).version !== 1 ||\n !Array.isArray((parsed as { routes?: unknown }).routes) ||\n !(parsed as { routes: unknown[] }).routes.every(\n (route) =>\n typeof route === \"object\" &&\n route !== null &&\n (route as PageRoute).method === \"GET\" &&\n typeof (route as PageRoute).path === \"string\" &&\n typeof (route as PageRoute).name === \"string\" &&\n typeof (route as PageRoute).source === \"string\",\n )\n ) {\n throw new Error(\"invalid shape\");\n }\n\n return parsed as PageRoutesSnapshot;\n } catch {\n throw new Error(\n `Cannot compare page routes: build snapshot \"${file}\" is malformed. Run \\`warlock build\\` successfully to replace it, then retry.`,\n );\n }\n}\n\nfunction printRoute(prefix: string, route: PageRoute): void {\n const source = route.source ? ` (${route.source})` : \"\";\n console.log(`${prefix} GET ${route.path} ${route.name}${source}`);\n}\n\n/**\n * Compare the last successful production page surface with the live dev\n * surface.\n *\n * The comparison itself lives in `diff-page-routes.ts`, which also documents\n * why the route-name method suffix is the one registration-time difference the\n * build-time manifest cannot record — and therefore what a clean run of this\n * command does not prove.\n */\nexport async function routesDiffCommandAction(): Promise<void> {\n const snapshot = readSnapshot(snapshotPath());\n const context = await bootForDiagnostics();\n\n if (\n !context.booted ||\n context.moduleFailures.length > 0 ||\n context.connectors.failures.length > 0 ||\n context.connectors.registrationError !== undefined\n ) {\n const details = [\n ...context.moduleFailures.map(({ file, message }) => `${file}: ${message}`),\n ...context.connectors.failures.map(({ name, message }) => `${name}: ${message}`),\n ...(context.connectors.registrationError ? [context.connectors.registrationError] : []),\n ];\n throw new Error(\n `Cannot compare page routes because diagnostic boot failed.${details.length ? `\\n${details.join(\"\\n\")}` : \"\"}`,\n );\n }\n\n const live = router\n .list()\n .filter((route) => route.isPage)\n .map(routeFromLive)\n .sort(comparePageRoutes);\n const expected = [...snapshot.routes].sort(comparePageRoutes);\n const { changes, removed, added } = diffPageRoutes(expected, live);\n\n if (changes.length === 0 && removed.length === 0 && added.length === 0) {\n console.log(`Page routes match (${expected.length} routes).`);\n console.log(CLEAN_RUN_LIMIT);\n return;\n }\n\n for (const { before, after } of changes) {\n printRoute(\"changed -\", before);\n printRoute(\" +\", after);\n }\n for (const route of removed) printRoute(\"removed -\", route);\n for (const route of added) printRoute(\"added +\", route);\n\n throw new Error(\n `Page route drift: ${changes.length} changed, ${removed.length} removed, ${added.length} added. Run \\`warlock build\\` after reviewing these changes.`,\n );\n}\n"],"mappings":";;;;;;;;AAaA,MAAM,gBAAgB;;;;;AAMtB,MAAM,kBACJ;AAIF,SAAS,cAAc,OAAyB;CAC9C,OAAO;EACL,QAAQ,MAAM,OAAO,YAAY;EACjC,MAAM,MAAM;EACZ,MAAM,MAAM,QAAQ;EACpB,QAAQ,MAAM,cAAc;CAC9B;AACF;AAEA,SAAS,eAAuB;CAC9B,OAAO,KAAK,KAAK,mBAAmB,EAAE,QAAQ,aAAa;AAC7D;AAEA,SAAS,aAAa,MAAkC;CACtD,IAAI;CAEJ,IAAI;EACF,MAAM,GAAG,aAAa,MAAM,OAAO;CACrC,QAAQ;EACN,MAAM,IAAI,MACR,4DAA4D,KAAK,+EACnE;CACF;CAEA,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,GAAG;EAEtC,IACE,OAAO,WAAW,YAClB,WAAW,QACV,OAAiC,YAAY,KAC9C,CAAC,MAAM,QAAS,OAAgC,MAAM,KACtD,CAAE,OAAiC,OAAO,OACvC,UACC,OAAO,UAAU,YACjB,UAAU,QACT,MAAoB,WAAW,SAChC,OAAQ,MAAoB,SAAS,YACrC,OAAQ,MAAoB,SAAS,YACrC,OAAQ,MAAoB,WAAW,QAC3C,GAEA,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,SAAS;EACvC,WAAW,aAAa,MAAM;EAC9B,WAAW,aAAa,KAAK;CAC/B;CACA,KAAK,MAAM,SAAS,SAAS,WAAW,aAAa,KAAK;CAC1D,KAAK,MAAM,SAAS,OAAO,WAAW,aAAa,KAAK;CAExD,MAAM,IAAI,MACR,qBAAqB,QAAQ,OAAO,YAAY,QAAQ,OAAO,YAAY,MAAM,OAAO,6DAC1F;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { command } from "../../commands/cli-command.mjs";
2
2
  import { routesCommandAction } from "./routes/routes-command.action.mjs";
3
+ import { routesDiffCommandAction } from "./routes/routes-diff.action.mjs";
3
4
 
4
5
  //#region ../core/src/cli/commands/routes.command.ts
5
6
  /**
@@ -45,7 +46,20 @@ const routesCommand = command({
45
46
  }
46
47
  ]
47
48
  });
49
+ /** Compare live development page routes with the last successful build. */
50
+ const routesDiffCommand = command({
51
+ name: "routes:diff",
52
+ description: "Compare live page routes with the last successful production build",
53
+ action: routesDiffCommandAction,
54
+ preload: {
55
+ runtimeStrategy: "development",
56
+ warlockConfig: true,
57
+ config: true,
58
+ env: true,
59
+ bootstrap: true
60
+ }
61
+ });
48
62
 
49
63
  //#endregion
50
- export { routesCommand };
64
+ export { routesCommand, routesDiffCommand };
51
65
  //# sourceMappingURL=routes.command.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\r\nimport { routesCommandAction } from \"./routes/routes-command.action\";\r\n\r\n/**\r\n * `warlock routes` — list every registered HTTP route as a table (a read-only\r\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\r\n * or emit the normalized rows as JSON with `--json`.\r\n *\r\n * Preload plan: load config + bootstrap app code so route modules register on\r\n * the router singleton, but start NO connectors — listing routes must never\r\n * open a database/cache/socket connection. Because the route-module loader is\r\n * fail-loud, a route file that throws on import surfaces here instead of being\r\n * silently omitted from the table.\r\n */\r\nexport const routesCommand = command({\r\n name: \"routes\",\r\n description:\r\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\r\n action: routesCommandAction,\r\n preload: {\r\n config: true,\r\n env: true,\r\n bootstrap: true,\r\n },\r\n options: [\r\n {\r\n text: \"--method, -m\",\r\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--path, -p\",\r\n description: \"Filter by a case-insensitive path substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--name, -n\",\r\n description: \"Filter by a case-insensitive route-name substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--json, -j\",\r\n description: \"Output the routes as JSON instead of a table\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\r\nimport { routesCommandAction } from \"./routes/routes-command.action\";\nimport { routesDiffCommandAction } from \"./routes/routes-diff.action\";\n\r\n/**\r\n * `warlock routes` — list every registered HTTP route as a table (a read-only\r\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\r\n * or emit the normalized rows as JSON with `--json`.\r\n *\r\n * Preload plan: load config + bootstrap app code so route modules register on\r\n * the router singleton, but start NO connectors — listing routes must never\r\n * open a database/cache/socket connection. Because the route-module loader is\r\n * fail-loud, a route file that throws on import surfaces here instead of being\r\n * silently omitted from the table.\r\n */\r\nexport const routesCommand = command({\n name: \"routes\",\r\n description:\r\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\r\n action: routesCommandAction,\r\n preload: {\r\n config: true,\r\n env: true,\r\n bootstrap: true,\r\n },\r\n options: [\r\n {\r\n text: \"--method, -m\",\r\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--path, -p\",\r\n description: \"Filter by a case-insensitive path substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--name, -n\",\r\n description: \"Filter by a case-insensitive route-name substring\",\r\n type: \"string\",\r\n },\r\n {\r\n text: \"--json, -j\",\r\n description: \"Output the routes as JSON instead of a table\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\n\n/** Compare live development page routes with the last successful build. */\nexport const routesDiffCommand = command({\n name: \"routes:diff\",\n description: \"Compare live page routes with the last successful production build\",\n action: routesDiffCommandAction,\n preload: {\n runtimeStrategy: \"development\",\n warlockConfig: true,\n config: true,\n env: true,\n bootstrap: true,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;;AAGD,MAAa,oBAAoB,QAAQ;CACvC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,SAAS;EACP,iBAAiB;EACjB,eAAe;EACf,QAAQ;EACR,KAAK;EACL,WAAW;CACb;AACF,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { command } from "../../commands/cli-command.mjs";
2
2
  import { resolveBuildConfig } from "../../production/resolve-build-config.mjs";
3
+ import { checkDistReadyToStartAsync } from "../../production/assert-dist-ready-to-start.mjs";
3
4
  import { superviseProductionProcess } from "../../production/production-supervisor.mjs";
4
5
 
5
6
  //#region ../core/src/cli/commands/start-production.command.ts
@@ -9,7 +10,13 @@ const startProductionCommand = command({
9
10
  persistent: true,
10
11
  preload: { warlockConfig: true },
11
12
  action: async () => {
12
- const { entryPath, sourcemap } = resolveBuildConfig();
13
+ const { entryPath, sourcemap, outdir } = resolveBuildConfig();
14
+ const readiness = await checkDistReadyToStartAsync(outdir);
15
+ if (!readiness.ready) {
16
+ console.error(`✖ ${readiness.reason}`);
17
+ process.exit(1);
18
+ return;
19
+ }
13
20
  const nodeArgs = [];
14
21
  if (sourcemap !== false) nodeArgs.push("--enable-source-maps");
15
22
  nodeArgs.push(entryPath);
@@ -1 +1 @@
1
- {"version":3,"file":"start-production.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/start-production.command.ts"],"sourcesContent":["import { superviseProductionProcess } from \"../../production/production-supervisor\";\r\nimport { resolveBuildConfig } from \"../../production/resolve-build-config\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const startProductionCommand = command({\r\n name: \"start\",\r\n description: \"Start production server\",\r\n persistent: true,\r\n preload: {\r\n warlockConfig: true,\r\n },\r\n action: async () => {\r\n const { entryPath, sourcemap } = resolveBuildConfig();\r\n\r\n // Build node args\r\n const nodeArgs: string[] = [];\r\n\r\n // Enable source maps if configured\r\n if (sourcemap !== false) {\r\n nodeArgs.push(\"--enable-source-maps\");\r\n }\r\n\r\n // Add entry file\r\n nodeArgs.push(entryPath);\r\n\r\n // Pass through any additional flags after \"start\" command\r\n // process.argv = [node, cli.ts, start, ...extra]\r\n const startIndex = process.argv.findIndex((arg) => arg === \"start\");\r\n if (startIndex !== -1 && startIndex < process.argv.length - 1) {\r\n const extraArgs = process.argv.slice(startIndex + 1);\r\n nodeArgs.push(...extraArgs);\r\n }\r\n\r\n // Progress goes to stderr, never stdout. Stdout carries exactly one claim —\r\n // \"started\" — so that whatever greps it cannot mistake an intention for an\r\n // outcome. The banner that used to print here, in `preAction`, printed\r\n // before the child had even been spawned.\r\n console.error(`🚀 Starting production server...\\n`);\r\n\r\n const { exitCode } = await superviseProductionProcess({ nodeArgs });\r\n\r\n process.exit(exitCode);\r\n },\r\n});\r\n"],"mappings":";;;;;AAIA,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,aAAa;CACb,YAAY;CACZ,SAAS,EACP,eAAe,KACjB;CACA,QAAQ,YAAY;EAClB,MAAM,EAAE,WAAW,cAAc,mBAAmB;EAGpD,MAAM,WAAqB,CAAC;EAG5B,IAAI,cAAc,OAChB,SAAS,KAAK,sBAAsB;EAItC,SAAS,KAAK,SAAS;EAIvB,MAAM,aAAa,QAAQ,KAAK,WAAW,QAAQ,QAAQ,OAAO;EAClE,IAAI,eAAe,MAAM,aAAa,QAAQ,KAAK,SAAS,GAAG;GAC7D,MAAM,YAAY,QAAQ,KAAK,MAAM,aAAa,CAAC;GACnD,SAAS,KAAK,GAAG,SAAS;EAC5B;EAMA,QAAQ,MAAM,oCAAoC;EAElD,MAAM,EAAE,aAAa,MAAM,2BAA2B,EAAE,SAAS,CAAC;EAElE,QAAQ,KAAK,QAAQ;CACvB;AACF,CAAC"}
1
+ {"version":3,"file":"start-production.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/start-production.command.ts"],"sourcesContent":["import { checkDistReadyToStartAsync } from \"../../production/assert-dist-ready-to-start\";\r\nimport { superviseProductionProcess } from \"../../production/production-supervisor\";\r\nimport { resolveBuildConfig } from \"../../production/resolve-build-config\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const startProductionCommand = command({\r\n name: \"start\",\r\n description: \"Start production server\",\r\n persistent: true,\r\n preload: {\r\n warlockConfig: true,\r\n },\r\n action: async () => {\r\n const { entryPath, sourcemap, outdir } = resolveBuildConfig();\r\n\r\n // Refuse a `dist` that did not come from a successful `warlock build` —\r\n // named explicitly, rather than failing later and incidentally because\r\n // some file the server happens to need (the client manifest, say) is\r\n // missing. See `assert-dist-ready-to-start.ts`.\r\n const readiness = await checkDistReadyToStartAsync(outdir);\r\n\r\n if (!readiness.ready) {\r\n console.error(`✖ ${readiness.reason}`);\r\n process.exit(1);\r\n return;\r\n }\r\n\r\n // Build node args\r\n const nodeArgs: string[] = [];\r\n\r\n // Enable source maps if configured\r\n if (sourcemap !== false) {\r\n nodeArgs.push(\"--enable-source-maps\");\r\n }\r\n\r\n // Add entry file\r\n nodeArgs.push(entryPath);\r\n\r\n // Pass through any additional flags after \"start\" command\r\n // process.argv = [node, cli.ts, start, ...extra]\r\n const startIndex = process.argv.findIndex((arg) => arg === \"start\");\r\n if (startIndex !== -1 && startIndex < process.argv.length - 1) {\r\n const extraArgs = process.argv.slice(startIndex + 1);\r\n nodeArgs.push(...extraArgs);\r\n }\r\n\r\n // Progress goes to stderr, never stdout. Stdout carries exactly one claim —\r\n // \"started\" — so that whatever greps it cannot mistake an intention for an\r\n // outcome. The banner that used to print here, in `preAction`, printed\r\n // before the child had even been spawned.\r\n console.error(`🚀 Starting production server...\\n`);\r\n\r\n const { exitCode } = await superviseProductionProcess({ nodeArgs });\r\n\r\n process.exit(exitCode);\r\n },\r\n});\r\n"],"mappings":";;;;;;AAKA,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,aAAa;CACb,YAAY;CACZ,SAAS,EACP,eAAe,KACjB;CACA,QAAQ,YAAY;EAClB,MAAM,EAAE,WAAW,WAAW,WAAW,mBAAmB;EAM5D,MAAM,YAAY,MAAM,2BAA2B,MAAM;EAEzD,IAAI,CAAC,UAAU,OAAO;GACpB,QAAQ,MAAM,KAAK,UAAU,QAAQ;GACrC,QAAQ,KAAK,CAAC;GACd;EACF;EAGA,MAAM,WAAqB,CAAC;EAG5B,IAAI,cAAc,OAChB,SAAS,KAAK,sBAAsB;EAItC,SAAS,KAAK,SAAS;EAIvB,MAAM,aAAa,QAAQ,KAAK,WAAW,QAAQ,QAAQ,OAAO;EAClE,IAAI,eAAe,MAAM,aAAa,QAAQ,KAAK,SAAS,GAAG;GAC7D,MAAM,YAAY,QAAQ,KAAK,MAAM,aAAa,CAAC;GACnD,SAAS,KAAK,GAAG,SAAS;EAC5B;EAMA,QAAQ,MAAM,oCAAoC;EAElD,MAAM,EAAE,aAAa,MAAM,2BAA2B,EAAE,SAAS,CAAC;EAElE,QAAQ,KAAK,QAAQ;CACvB;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-put.action.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.action.ts"],"sourcesContent":["import fs from \"fs/promises\";\r\nimport path from \"path\";\r\nimport { config } from \"../../config\";\r\nimport { storage } from \"../../storage\";\r\nimport type { CommandActionData } from \"../../commands/types\";\r\n\r\n/**\r\n * Action for `warlock storage.put <localPath> [destination] [--driver <name>] [--concurrency <n>]`\r\n *\r\n * Uploads a local file or directory into any configured storage driver.\r\n * Auto-detects whether <localPath> is a file or directory and calls the\r\n * appropriate storage method.\r\n *\r\n * @example\r\n * # Upload entire uploads directory to R2 (root of bucket)\r\n * warlock storage.put ./uploads --driver r2\r\n *\r\n * @example\r\n * # Upload to a specific destination prefix\r\n * warlock storage.put ./uploads backups/2026 --driver r2\r\n *\r\n * @example\r\n * # Single file upload with custom concurrency\r\n * warlock storage.put ./public/logo.png assets/logo.png --driver s3\r\n */\r\nexport async function storagePutAction({ args, options }: CommandActionData): Promise<void> {\r\n const [localPath, destination = \"\"] = args;\r\n\r\n if (!localPath) {\r\n console.error(\"✖ Missing required argument: <localPath>\");\r\n console.error(\" Usage: warlock storage.put <localPath> [destination] [--driver <name>]\");\r\n process.exit(1);\r\n }\r\n\r\n // Resolve to absolute path relative to CWD\r\n const absolutePath = path.resolve(process.cwd(), localPath);\r\n const driverName = options.driver as string | undefined;\r\n const concurrency = options.concurrency ? Number(options.concurrency) : 5;\r\n\r\n // Verify the local path exists\r\n let stat: Awaited<ReturnType<typeof fs.stat>>;\r\n try {\r\n stat = await fs.stat(absolutePath);\r\n } catch {\r\n console.error(`✖ Path not found: ${absolutePath}`);\r\n process.exit(1);\r\n }\r\n\r\n // Select the driver — use named driver or fall back to default\r\n const store = driverName ? storage.use(driverName) : storage;\r\n const driverLabel = driverName ?? config.get(\"storage.default\");\r\n\r\n console.log(`\\n Driver : ${driverLabel}`);\r\n console.log(` Source : ${absolutePath}`);\r\n console.log(` Dest : ${destination || \"(root)\"}\\n`);\r\n\r\n if (stat.isDirectory()) {\r\n // ── Directory upload ────────────────────────────────────────────────────\r\n const result = await store.putDirectory(absolutePath, destination, {\r\n concurrency,\r\n // Skip hidden files (e.g. .DS_Store) by default\r\n filter: (_, rel) => !path.basename(rel).startsWith(\".\"),\r\n onProgress: (done, total, file) => {\r\n process.stdout.write(`\\r Progress : ${done}/${total} ${file.path}`);\r\n },\r\n });\r\n\r\n // Clear the progress line and print summary\r\n process.stdout.write(\"\\n\");\r\n console.log(`\\n ✔ ${result.uploaded.length} file(s) uploaded`);\r\n\r\n if (result.failed.length > 0) {\r\n console.warn(`\\n ⚠ ${result.failed.length} file(s) failed:`);\r\n for (const { localPath: fp, error } of result.failed) {\r\n console.warn(` - ${fp}: ${error.message}`);\r\n }\r\n }\r\n } else {\r\n // ── Single file upload ──────────────────────────────────────────────────\r\n // Destination is used as the storage path; if empty, fall back to filename\r\n const storagePath = destination || path.basename(absolutePath);\r\n\r\n console.log(` Uploading : ${path.basename(absolutePath)} → ${storagePath}`);\r\n\r\n const file = await store.put(absolutePath, storagePath);\r\n\r\n console.log(`\\n ✔ Uploaded: ${file.url}`);\r\n }\r\n\r\n console.log();\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,iBAAiB,EAAE,MAAM,WAA6C;CAC1F,MAAM,CAAC,WAAW,cAAc,MAAM;CAEtC,IAAI,CA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S,YAAY,EAAE,KAAK,aAAa;EAE3E,MAAM,OAAO,MAAM,MAAM,IAAI,cAAc,WAAW;EAEtD,QAAQ,IAAI,oBAAoB,KAAK,KAAK;CAC5C;CAEA,QAAQ,IAAI;AACd"}
1
+ {"version":3,"file":"storage-put.action.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.action.ts"],"sourcesContent":["import fs from \"fs/promises\";\r\nimport path from \"path\";\r\nimport { config } from \"../../config\";\r\nimport { storage } from \"../../storage\";\r\nimport type { CommandActionData } from \"../../commands/types\";\r\n\r\n/**\r\n * Action for `warlock storage.put <localPath> [destination] [--driver <name>] [--concurrency <n>]`\r\n *\r\n * Uploads a local file or directory into any configured storage driver.\r\n * Auto-detects whether <localPath> is a file or directory and calls the\r\n * appropriate storage method.\r\n *\r\n * @example\r\n * # Upload entire uploads directory to R2 (root of bucket)\r\n * warlock storage.put ./uploads --driver r2\r\n *\r\n * @example\r\n * # Upload to a specific destination prefix\r\n * warlock storage.put ./uploads backups/2026 --driver r2\r\n *\r\n * @example\r\n * # Single file upload with custom concurrency\r\n * warlock storage.put ./public/logo.png assets/logo.png --driver s3\r\n */\r\nexport async function storagePutAction({ args, options }: CommandActionData): Promise<void> {\r\n const [localPath, destination = \"\"] = args;\r\n\r\n if (!localPath) {\r\n console.error(\"✖ Missing required argument: <localPath>\");\r\n console.error(\" Usage: warlock storage.put <localPath> [destination] [--driver <name>]\");\r\n process.exit(1);\r\n }\r\n\r\n // Resolve to absolute path relative to CWD\r\n const absolutePath = path.resolve(process.cwd(), localPath);\r\n const driverName = options.driver as string | undefined;\r\n const concurrency = options.concurrency ? Number(options.concurrency) : 5;\r\n\r\n // Verify the local path exists\r\n let stat: Awaited<ReturnType<typeof fs.stat>>;\r\n try {\r\n stat = await fs.stat(absolutePath);\r\n } catch {\r\n console.error(`✖ Path not found: ${absolutePath}`);\r\n process.exit(1);\r\n }\r\n\r\n // Select the driver — use named driver or fall back to default\r\n const store = driverName ? storage.use(driverName) : storage;\r\n const driverLabel = driverName ?? config.get(\"storage.default\");\r\n\r\n console.log(`\\n Driver : ${driverLabel}`);\r\n console.log(` Source : ${absolutePath}`);\r\n console.log(` Dest : ${destination || \"(root)\"}\\n`);\r\n\r\n if (stat.isDirectory()) {\r\n // ── Directory upload ────────────────────────────────────────────────────\r\n const result = await store.putDirectory(absolutePath, destination, {\r\n concurrency,\r\n // Skip hidden files (e.g. .DS_Store) by default\r\n filter: (_, rel) => !path.basename(rel).startsWith(\".\"),\r\n onProgress: (done, total, file) => {\r\n process.stdout.write(`\\r Progress : ${done}/${total} ${file.path}`);\r\n },\r\n });\r\n\r\n // Clear the progress line and print summary\r\n process.stdout.write(\"\\n\");\r\n console.log(`\\n ✔ ${result.uploaded.length} file(s) uploaded`);\r\n\r\n if (result.failed.length > 0) {\r\n console.warn(`\\n ⚠ ${result.failed.length} file(s) failed:`);\r\n for (const { localPath: fp, error } of result.failed) {\r\n console.warn(` - ${fp}: ${error.message}`);\r\n }\r\n }\r\n } else {\r\n // ── Single file upload ──────────────────────────────────────────────────\r\n // Destination is used as the storage path; if empty, fall back to filename\r\n const storagePath = destination || path.basename(absolutePath);\r\n\r\n console.log(` Uploading : ${path.basename(absolutePath)} → ${storagePath}`);\r\n\r\n const file = await store.put(absolutePath, storagePath);\r\n\r\n console.log(`\\n ✔ Uploaded: ${file.url}`);\r\n }\r\n\r\n console.log();\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,iBAAiB,EAAE,MAAM,WAA6C;CAC1F,MAAM,CAAC,WAAW,cAAc,MAAM;CAEtC,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,2CAA2C;EACzD,QAAQ,MAAM,2EAA2E;EACzF,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,eAAe,KAAK,QAAQ,QAAQ,IAAI,GAAG,SAAS;CAC1D,MAAM,aAAa,QAAQ;CAC3B,MAAM,cAAc,QAAQ,cAAc,OAAO,QAAQ,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-generator.command.ts"],"sourcesContent":["import { filesOrchestrator } from \"../../dev-server/files-orchestrator\";\r\nimport { Path } from \"../../utils/normalized-path\";\r\nimport { typeGenerator } from \"../../dev-server/type-generator\";\r\nimport { getFilesFromDirectory } from \"../../dev-server/utils\";\r\nimport { srcPath } from \"../../utils\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const typingsGeneratorCommand = command({\r\n name: \"generate.typings\",\r\n description: \"Generate type definitions for the project\",\r\n options: [\r\n {\r\n text: \"--files, -f\",\r\n description:\r\n \"Files to generate typings for, if not passed, it will generate typings for all files\",\r\n },\r\n ],\r\n action: async ({ options }) => {\r\n const configFilesPaths: string[] = [];\r\n if (options.files) {\r\n const files = String(options.files)\r\n .split(\",\")\r\n .map((file) => {\r\n if (file.startsWith(\"./\")) {\r\n return Path.toAbsolute(file);\r\n }\r\n\r\n return file;\r\n });\r\n\r\n if (files?.length) {\r\n configFilesPaths.push(...files);\r\n }\r\n }\r\n\r\n if (configFilesPaths.length === 0) {\r\n // grab all config files\r\n const configFiles = await getFilesFromDirectory(srcPath(\"config\"));\r\n configFilesPaths.push(...configFiles);\r\n }\r\n\r\n const results = await Promise.allSettled(\r\n configFilesPaths.map((path) => filesOrchestrator.add(Path.toRelative(path))),\r\n );\r\n\r\n const failed = results.filter((r) => r.status === \"rejected\");\r\n\r\n if (failed.length) {\r\n console.warn(`Failed to process ${failed.length} files`);\r\n }\r\n\r\n await typeGenerator.generateAll();\r\n },\r\n});\r\n"],"mappings":";;;;;;;;;AAOA,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,aAAa;CACb,SAAS,CACP;EACE,MAAM;EACN,aACE;CACJ,CACF;CACA,QAAQ,OAAO,EAAE,cAAc;EAC7B,MAAM,mBAA6B,CAAC;EACpC,IAAI,QAAQ,OAAO;GACjB,MAAM,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAChC,MAAM,GAAG,CAAC,CACV,KAAK,SAAS;IACb,IAAI,KAAK,WAAW,IAAI,GACtB,OAAO,KAAK,WAAW,IAAI;IAG7B,OAAO;GACT,CAAC;GAEH,IAAI,OAAO,QACT,iBAAiB,KAAK,GAAG,KAAK;EAElC;EAEA,IAAI,iBAAiB,WAAW,GAAG;GAEjC,MAAM,cAAc,MAAM,sBAAsB,QAAQ,QAAQ,CAAC;GACjE,iBAAiB,KAAK,GAAG,WAAW;EACtC;EAMA,MAAM,UAAS,MAJO,QAAQ,WAC5B,iBAAiB,KAAK,SAAS,kBAAkB,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,CAC7E,EAEsB,CAAC,QAAQ,MAAM,EAAE,WAAW,UAAU;EAE5D,IAAI,OAAO,QACT,QAAQ,KAAK,qBAAqB,OAAO,OAAO,OAAO;EAGzD,MAAM,cAAc,YAAY;CAClC;AACF,CAAC"}
1
+ {"version":3,"file":"typings-generator.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/typings-generator.command.ts"],"sourcesContent":["import { filesOrchestrator } from \"../../dev-server/files-orchestrator\";\r\nimport { Path } from \"../../utils/normalized-path\";\r\nimport { typeGenerator } from \"../../dev-server/type-generator\";\r\nimport { getFilesFromDirectory } from \"../../dev-server/utils\";\r\nimport { srcPath } from \"../../utils\";\r\nimport { command } from \"../../commands/cli-command\";\r\n\r\nexport const typingsGeneratorCommand = command({\r\n name: \"generate.typings\",\r\n description: \"Generate type definitions for the project\",\r\n options: [\r\n {\r\n text: \"--files, -f\",\r\n description:\r\n \"Files to generate typings for, if not passed, it will generate typings for all files\",\r\n },\r\n ],\r\n action: async ({ options }) => {\r\n const configFilesPaths: string[] = [];\r\n if (options.files) {\r\n const files = String(options.files)\r\n .split(\",\")\r\n .map((file) => {\r\n if (file.startsWith(\"./\")) {\r\n return Path.toAbsolute(file);\r\n }\r\n\r\n return file;\r\n });\r\n\r\n if (files?.length) {\r\n configFilesPaths.push(...files);\r\n }\r\n }\r\n\r\n if (configFilesPaths.length === 0) {\r\n // grab all config files\r\n const configFiles = await getFilesFromDirectory(srcPath(\"config\"));\r\n configFilesPaths.push(...configFiles);\r\n }\r\n\r\n const results = await Promise.allSettled(\r\n configFilesPaths.map((path) => filesOrchestrator.add(Path.toRelative(path))),\r\n );\r\n\r\n const failed = results.filter((r) => r.status === \"rejected\");\r\n\r\n if (failed.length) {\r\n console.warn(`Failed to process ${failed.length} files`);\r\n }\r\n\r\n await typeGenerator.generateAll();\r\n },\r\n});\r\n"],"mappings":";;;;;;;;;AAOA,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,aAAa;CACb,SAAS,CACP;EACE,MAAM;EACN,aACE;CACJ,CACF;CACA,QAAQ,OAAO,EAAE,cAAc;EAC7B,MAAM,mBAA6B,CAAC;EACpC,IAAI,QAAQ,OAAO;GACjB,MAAM,QAAQ,OAAO,QAAQ,KAAK,EAC/B,MAAM,GAAG,EACT,KAAK,SAAS;IACb,IAAI,KAAK,WAAW,IAAI,GACtB,OAAO,KAAK,WAAW,IAAI;IAG7B,OAAO;GACT,CAAC;GAEH,IAAI,OAAO,QACT,iBAAiB,KAAK,GAAG,KAAK;EAElC;EAEA,IAAI,iBAAiB,WAAW,GAAG;GAEjC,MAAM,cAAc,MAAM,sBAAsB,QAAQ,QAAQ,CAAC;GACjE,iBAAiB,KAAK,GAAG,WAAW;EACtC;EAMA,MAAM,UAAS,MAJO,QAAQ,WAC5B,iBAAiB,KAAK,SAAS,kBAAkB,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,CAC7E,GAEuB,QAAQ,MAAM,EAAE,WAAW,UAAU;EAE5D,IAAI,OAAO,QACT,QAAQ,KAAK,qBAAqB,OAAO,OAAO,OAAO;EAGzD,MAAM,cAAc,YAAY;CAClC;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"commands-loader.mjs","names":[],"sources":["../../../../../../../core/src/cli/commands-loader.ts"],"sourcesContent":["import { filesOrchestrator } from \"../dev-server/files-orchestrator\";\r\nimport { Path } from \"../utils/normalized-path\";\r\nimport { getFilesFromDirectory } from \"../dev-server/utils\";\r\nimport { srcPath } from \"../utils\";\r\nimport { CLICommand } from \"../commands/cli-command\";\r\nimport { isMatchingCommandName } from \"./cli-commands.utils\";\r\n\r\nexport class CLICommandsLoader {\r\n /**\r\n * Locate command by name\r\n */\r\n public async locate(commandName: string): Promise<CLICommand | undefined> {\r\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\r\n // now convert them into relative paths\r\n const relativeFiles = files.map((path) => Path.toRelative(path));\r\n\r\n for (const relativeFile of relativeFiles) {\r\n const command = await this.load(relativeFile);\r\n if (command) {\r\n command.$relativePath(relativeFile);\r\n if (isMatchingCommandName(command.name, commandName)) {\r\n return command;\r\n }\r\n }\r\n }\r\n\r\n return;\r\n }\r\n\r\n /**\r\n * Scan all project commands and return them\r\n * Used for warm cache functionality\r\n */\r\n public async scanAll(): Promise<CLICommand[]> {\r\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\r\n const relativeFiles = files.map((path) => Path.toRelative(path));\r\n const commands: CLICommand[] = [];\r\n\r\n for (const relativeFile of relativeFiles) {\r\n const command = await this.load(relativeFile);\r\n if (command) {\r\n command.$relativePath(relativeFile);\r\n commands.push(command);\r\n }\r\n }\r\n\r\n return commands;\r\n }\r\n\r\n /**\r\n * Load command from a relative path\r\n */\r\n public async load(relativePath: string): Promise<CLICommand | undefined> {\r\n const output = await filesOrchestrator.load<{ default: CLICommand }>(relativePath);\r\n\r\n return output?.default;\r\n }\r\n}\r\n\r\nexport const cliCommandsLoader = new CLICommandsLoader();\r\n"],"mappings":";;;;;;;;AAOA,IAAa,oBAAb,MAA+B;;;;CAI7B,MAAa,OAAO,aAAsD;EAGxE,MAAM,iBAAgB,MAFF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,EAEvD,CAAC,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAE/D,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,IAAI,sBAAsB,QAAQ,MAAM,WAAW,GACjD,OAAO;GAEX;EACF;CAGF;;;;;CAMA,MAAa,UAAiC;EAE5C,MAAM,iBAAgB,MADF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,EACvD,CAAC,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAC/D,MAAM,WAAyB,CAAC;EAEhC,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,SAAS,KAAK,OAAO;GACvB;EACF;EAEA,OAAO;CACT;;;;CAKA,MAAa,KAAK,cAAuD;EAGvE,QAAO,MAFc,kBAAkB,KAA8B,YAAY,EAEpE,EAAE;CACjB;AACF;AAEA,MAAa,oBAAoB,IAAI,kBAAkB"}
1
+ {"version":3,"file":"commands-loader.mjs","names":[],"sources":["../../../../../../../core/src/cli/commands-loader.ts"],"sourcesContent":["import { filesOrchestrator } from \"../dev-server/files-orchestrator\";\r\nimport { Path } from \"../utils/normalized-path\";\r\nimport { getFilesFromDirectory } from \"../dev-server/utils\";\r\nimport { srcPath } from \"../utils\";\r\nimport { CLICommand } from \"../commands/cli-command\";\r\nimport { isMatchingCommandName } from \"./cli-commands.utils\";\r\n\r\nexport class CLICommandsLoader {\r\n /**\r\n * Locate command by name\r\n */\r\n public async locate(commandName: string): Promise<CLICommand | undefined> {\r\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\r\n // now convert them into relative paths\r\n const relativeFiles = files.map((path) => Path.toRelative(path));\r\n\r\n for (const relativeFile of relativeFiles) {\r\n const command = await this.load(relativeFile);\r\n if (command) {\r\n command.$relativePath(relativeFile);\r\n if (isMatchingCommandName(command.name, commandName)) {\r\n return command;\r\n }\r\n }\r\n }\r\n\r\n return;\r\n }\r\n\r\n /**\r\n * Scan all project commands and return them\r\n * Used for warm cache functionality\r\n */\r\n public async scanAll(): Promise<CLICommand[]> {\r\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\r\n const relativeFiles = files.map((path) => Path.toRelative(path));\r\n const commands: CLICommand[] = [];\r\n\r\n for (const relativeFile of relativeFiles) {\r\n const command = await this.load(relativeFile);\r\n if (command) {\r\n command.$relativePath(relativeFile);\r\n commands.push(command);\r\n }\r\n }\r\n\r\n return commands;\r\n }\r\n\r\n /**\r\n * Load command from a relative path\r\n */\r\n public async load(relativePath: string): Promise<CLICommand | undefined> {\r\n const output = await filesOrchestrator.load<{ default: CLICommand }>(relativePath);\r\n\r\n return output?.default;\r\n }\r\n}\r\n\r\nexport const cliCommandsLoader = new CLICommandsLoader();\r\n"],"mappings":";;;;;;;;AAOA,IAAa,oBAAb,MAA+B;;;;CAI7B,MAAa,OAAO,aAAsD;EAGxE,MAAM,iBAAgB,MAFF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,GAEtD,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAE/D,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,IAAI,sBAAsB,QAAQ,MAAM,WAAW,GACjD,OAAO;GAEX;EACF;CAGF;;;;;CAMA,MAAa,UAAiC;EAE5C,MAAM,iBAAgB,MADF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,GACtD,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAC/D,MAAM,WAAyB,CAAC;EAEhC,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,SAAS,KAAK,OAAO;GACvB;EACF;EAEA,OAAO;CACT;;;;CAKA,MAAa,KAAK,cAAuD;EAGvE,QAAO,MAFc,kBAAkB,KAA8B,YAAY,IAElE;CACjB;AACF;AAEA,MAAa,oBAAoB,IAAI,kBAAkB"}