@sdxc/kit 2026.10.16 → 2026.10.20

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 (358) hide show
  1. package/README.md +391 -20
  2. package/changelog.jsonl +1160 -1035
  3. package/config.schema.json +47 -1
  4. package/dist/author.d.ts +36 -0
  5. package/dist/author.js +107 -0
  6. package/dist/cli.js +12 -0
  7. package/dist/commands/create.js +9 -4
  8. package/dist/commands/deploy.d.ts +23 -0
  9. package/dist/commands/deploy.js +167 -0
  10. package/dist/commands/destroy.d.ts +22 -0
  11. package/dist/commands/destroy.js +92 -0
  12. package/dist/commands/doctor.d.ts +26 -0
  13. package/dist/commands/doctor.js +65 -0
  14. package/dist/commands/initializers.d.ts +16 -0
  15. package/dist/commands/initializers.js +23 -0
  16. package/dist/commands/make.d.ts +72 -6
  17. package/dist/commands/make.js +127 -19
  18. package/dist/commands/middleware.d.ts +16 -0
  19. package/dist/commands/middleware.js +21 -0
  20. package/dist/commands/models.d.ts +18 -0
  21. package/dist/commands/models.js +29 -0
  22. package/dist/commands/notes.d.ts +17 -0
  23. package/dist/commands/notes.js +27 -0
  24. package/dist/commands/routes.d.ts +25 -0
  25. package/dist/commands/routes.js +50 -0
  26. package/dist/commands/run.d.ts +18 -2
  27. package/dist/commands/run.js +35 -12
  28. package/dist/commands/scaffold.d.ts +29 -0
  29. package/dist/commands/scaffold.js +33 -0
  30. package/dist/commands/schedule.d.ts +16 -0
  31. package/dist/commands/schedule.js +21 -0
  32. package/dist/commands/stats.d.ts +16 -0
  33. package/dist/commands/stats.js +21 -0
  34. package/dist/commands/ui/update.d.ts +6 -3
  35. package/dist/commands/ui/update.js +24 -7
  36. package/dist/commands/upgrade.d.ts +3 -1
  37. package/dist/commands/upgrade.js +88 -23
  38. package/dist/config.d.ts +18 -0
  39. package/dist/config.js +28 -1
  40. package/dist/contract.d.ts +97 -3
  41. package/dist/contract.js +360 -26
  42. package/dist/create/templates.d.ts +8 -1
  43. package/dist/create/templates.js +26 -2
  44. package/dist/dependencies.d.ts +4 -1
  45. package/dist/dependencies.js +13 -1
  46. package/dist/deploy/plan.d.ts +49 -0
  47. package/dist/deploy/plan.js +68 -0
  48. package/dist/destroy.d.ts +40 -0
  49. package/dist/destroy.js +311 -0
  50. package/dist/doctor/check.d.ts +71 -0
  51. package/dist/doctor/check.js +53 -0
  52. package/dist/doctor/checks.d.ts +23 -0
  53. package/dist/doctor/checks.js +68 -0
  54. package/dist/doctor/define.d.ts +59 -0
  55. package/dist/doctor/define.js +16 -0
  56. package/dist/doctor/emails.d.ts +18 -0
  57. package/dist/doctor/emails.js +243 -0
  58. package/dist/doctor/env.d.ts +26 -0
  59. package/dist/doctor/env.js +88 -0
  60. package/dist/doctor/files.d.ts +14 -0
  61. package/dist/doctor/files.js +34 -0
  62. package/dist/doctor/fixture.d.ts +23 -0
  63. package/dist/doctor/fixture.js +46 -0
  64. package/dist/doctor/install.d.ts +17 -0
  65. package/dist/doctor/install.js +37 -0
  66. package/dist/doctor/installed.d.ts +11 -0
  67. package/dist/doctor/installed.js +79 -0
  68. package/dist/doctor/layout.d.ts +23 -0
  69. package/dist/doctor/layout.js +83 -0
  70. package/dist/doctor/migrations.d.ts +16 -0
  71. package/dist/doctor/migrations.js +96 -0
  72. package/dist/doctor/models.d.ts +13 -0
  73. package/dist/doctor/models.js +69 -0
  74. package/dist/doctor/pins.d.ts +15 -0
  75. package/dist/doctor/pins.js +79 -0
  76. package/dist/doctor/project.d.ts +58 -0
  77. package/dist/doctor/project.js +261 -0
  78. package/dist/doctor/remix.d.ts +14 -0
  79. package/dist/doctor/remix.js +44 -0
  80. package/dist/doctor/routes.d.ts +11 -0
  81. package/dist/doctor/routes.js +49 -0
  82. package/dist/doctor/typegen.d.ts +13 -0
  83. package/dist/doctor/typegen.js +57 -0
  84. package/dist/doctor/ui.d.ts +14 -0
  85. package/dist/doctor/ui.js +51 -0
  86. package/dist/init.d.ts +5 -3
  87. package/dist/init.js +15 -7
  88. package/dist/initializers.d.ts +25 -0
  89. package/dist/initializers.js +89 -0
  90. package/dist/lock.d.ts +2 -2
  91. package/dist/make/actions.d.ts +23 -0
  92. package/dist/make/actions.js +82 -0
  93. package/dist/make/declare.d.ts +32 -4
  94. package/dist/make/declare.js +405 -27
  95. package/dist/make/email.d.ts +23 -0
  96. package/dist/make/email.js +111 -0
  97. package/dist/make/from-fields.d.ts +30 -0
  98. package/dist/make/from-fields.js +162 -0
  99. package/dist/make/from-model.d.ts +39 -0
  100. package/dist/make/from-model.js +161 -0
  101. package/dist/make/generate.d.ts +16 -5
  102. package/dist/make/generate.js +43 -14
  103. package/dist/make/guard.d.ts +35 -0
  104. package/dist/make/guard.js +73 -0
  105. package/dist/make/imports.d.ts +6 -0
  106. package/dist/make/imports.js +19 -0
  107. package/dist/make/index.d.ts +47 -4
  108. package/dist/make/index.js +287 -25
  109. package/dist/make/kinds.d.ts +31 -3
  110. package/dist/make/kinds.js +82 -9
  111. package/dist/make/mount.d.ts +25 -0
  112. package/dist/make/mount.js +135 -0
  113. package/dist/make/schema-diff.d.ts +58 -0
  114. package/dist/make/schema-diff.js +609 -0
  115. package/dist/make/schema.d.ts +76 -0
  116. package/dist/make/schema.js +206 -0
  117. package/dist/make/stubs.d.ts +7 -5
  118. package/dist/make/stubs.js +16 -5
  119. package/dist/make/test.d.ts +43 -0
  120. package/dist/make/test.js +149 -0
  121. package/dist/make/trigger.d.ts +31 -0
  122. package/dist/make/trigger.js +163 -0
  123. package/dist/models.d.ts +42 -0
  124. package/dist/models.js +149 -0
  125. package/dist/notes.d.ts +28 -0
  126. package/dist/notes.js +66 -0
  127. package/dist/reference.d.ts +27 -0
  128. package/dist/reference.js +103 -0
  129. package/dist/releases.d.ts +9 -0
  130. package/dist/releases.js +29 -8
  131. package/dist/routes/chains.d.ts +34 -0
  132. package/dist/routes/chains.js +95 -0
  133. package/dist/routes/filter.d.ts +53 -0
  134. package/dist/routes/filter.js +147 -0
  135. package/dist/routes/format.d.ts +23 -0
  136. package/dist/routes/format.js +123 -0
  137. package/dist/routes/helpers.d.ts +21 -0
  138. package/dist/routes/helpers.js +165 -0
  139. package/dist/routes/index.d.ts +56 -0
  140. package/dist/routes/index.js +167 -0
  141. package/dist/routes/modules.d.ts +116 -0
  142. package/dist/routes/modules.js +235 -0
  143. package/dist/routes/parse.d.ts +161 -0
  144. package/dist/routes/parse.js +621 -0
  145. package/dist/routes/routers.d.ts +69 -0
  146. package/dist/routes/routers.js +327 -0
  147. package/dist/scaffold/fields.d.ts +129 -0
  148. package/dist/scaffold/fields.js +421 -0
  149. package/dist/scaffold/index.d.ts +37 -0
  150. package/dist/scaffold/index.js +613 -0
  151. package/dist/scaffold/render.d.ts +51 -0
  152. package/dist/scaffold/render.js +332 -0
  153. package/dist/schedule.d.ts +45 -0
  154. package/dist/schedule.js +124 -0
  155. package/dist/stats.d.ts +37 -0
  156. package/dist/stats.js +126 -0
  157. package/dist/testing.d.ts +12 -2
  158. package/dist/testing.js +22 -3
  159. package/dist/ui/commands.d.ts +10 -3
  160. package/dist/ui/commands.js +85 -15
  161. package/dist/ui/registry.d.ts +8 -8
  162. package/dist/upgrade/agents.d.ts +49 -0
  163. package/dist/upgrade/agents.js +110 -0
  164. package/dist/upgrade/changelog.d.ts +2 -2
  165. package/dist/upgrade/project.d.ts +4 -0
  166. package/dist/upgrade/project.js +11 -1
  167. package/dist/upgrade/prompt.d.ts +11 -0
  168. package/dist/upgrade/prompt.js +50 -7
  169. package/package.json +6 -4
  170. package/registry/ui/alert-dialog.json +2 -2
  171. package/registry/ui/attachment.json +2 -2
  172. package/registry/ui/calendar.json +2 -2
  173. package/registry/ui/color-picker.json +2 -2
  174. package/registry/ui/command.json +2 -2
  175. package/registry/ui/date-picker.json +2 -2
  176. package/registry/ui/date-range-picker.json +2 -2
  177. package/registry/ui/dialog.json +2 -2
  178. package/registry/ui/file-trigger.json +2 -2
  179. package/registry/ui/heading-scope.json +2 -2
  180. package/registry/ui/message-scroller.json +2 -2
  181. package/registry/ui/number-field.json +2 -2
  182. package/registry/ui/range-calendar.json +2 -2
  183. package/registry/ui/resizable.json +2 -2
  184. package/registry/ui/select.json +2 -2
  185. package/registry/ui/shared-element.json +2 -2
  186. package/stubs/command.stub +4 -0
  187. package/stubs/command.test.stub +3 -0
  188. package/stubs/controller.api.resource.stub +23 -0
  189. package/stubs/controller.api.stub +21 -0
  190. package/stubs/controller.api.test.stub +18 -0
  191. package/stubs/controller.form.stub +40 -10
  192. package/stubs/controller.form.test.stub +61 -0
  193. package/stubs/controller.resource.form.stub +67 -0
  194. package/stubs/controller.resource.stub +28 -0
  195. package/stubs/controller.stub +15 -8
  196. package/stubs/controller.test.stub +3 -0
  197. package/stubs/email.stub +15 -38
  198. package/stubs/email.test.stub +12 -7
  199. package/stubs/factory.stub +4 -1
  200. package/stubs/initializer.stub +2 -0
  201. package/stubs/initializer.test.stub +3 -0
  202. package/stubs/job.cron.stub +4 -0
  203. package/stubs/job.stub +4 -0
  204. package/stubs/job.test.stub +3 -0
  205. package/stubs/mcp.resource.stub +3 -0
  206. package/stubs/mcp.stub +3 -0
  207. package/stubs/mcp.test.stub +3 -0
  208. package/stubs/middleware.stub +6 -1
  209. package/stubs/middleware.test.stub +3 -0
  210. package/stubs/model.stub +12 -3
  211. package/stubs/model.test.stub +3 -0
  212. package/stubs/policy.test.stub +36 -7
  213. package/stubs/scaffold.api.create.stub +34 -0
  214. package/stubs/scaffold.api.create.test.stub +37 -0
  215. package/stubs/scaffold.api.destroy.stub +34 -0
  216. package/stubs/scaffold.api.destroy.test.stub +44 -0
  217. package/stubs/scaffold.api.index.stub +23 -0
  218. package/stubs/scaffold.api.index.test.stub +31 -0
  219. package/stubs/scaffold.api.show.stub +27 -0
  220. package/stubs/scaffold.api.show.test.stub +41 -0
  221. package/stubs/scaffold.api.update.stub +44 -0
  222. package/stubs/scaffold.api.update.test.stub +46 -0
  223. package/stubs/scaffold.command.create.stub +22 -0
  224. package/stubs/scaffold.command.create.test.stub +30 -0
  225. package/stubs/scaffold.command.delete.stub +20 -0
  226. package/stubs/scaffold.command.delete.test.stub +39 -0
  227. package/stubs/scaffold.command.list.stub +18 -0
  228. package/stubs/scaffold.command.list.test.stub +31 -0
  229. package/stubs/scaffold.command.show.stub +19 -0
  230. package/stubs/scaffold.command.show.test.stub +37 -0
  231. package/stubs/scaffold.controller.destroy.stub +35 -0
  232. package/stubs/scaffold.controller.destroy.test.stub +65 -0
  233. package/stubs/scaffold.controller.edit.stub +97 -0
  234. package/stubs/scaffold.controller.edit.test.stub +91 -0
  235. package/stubs/scaffold.controller.index.stub +55 -0
  236. package/stubs/scaffold.controller.index.test.stub +32 -0
  237. package/stubs/scaffold.controller.new.stub +70 -0
  238. package/stubs/scaffold.controller.new.test.stub +81 -0
  239. package/stubs/scaffold.controller.show.stub +59 -0
  240. package/stubs/scaffold.controller.show.test.stub +43 -0
  241. package/stubs/scaffold.factory.stub +16 -0
  242. package/stubs/scaffold.form.stub +75 -0
  243. package/stubs/scaffold.mcp.create.stub +24 -0
  244. package/stubs/scaffold.mcp.create.test.stub +36 -0
  245. package/stubs/scaffold.mcp.delete.stub +31 -0
  246. package/stubs/scaffold.mcp.delete.test.stub +43 -0
  247. package/stubs/scaffold.mcp.get.stub +21 -0
  248. package/stubs/scaffold.mcp.get.test.stub +31 -0
  249. package/stubs/scaffold.mcp.list.stub +23 -0
  250. package/stubs/scaffold.mcp.list.test.stub +25 -0
  251. package/stubs/scaffold.mcp.update.stub +37 -0
  252. package/stubs/scaffold.mcp.update.test.stub +40 -0
  253. package/stubs/scaffold.migration.stub +2 -0
  254. package/stubs/scaffold.model.stub +35 -0
  255. package/stubs/scaffold.model.test.stub +25 -0
  256. package/stubs/scaffold.test-database.stub +33 -0
  257. package/stubs/scaffold.test-mcp.stub +92 -0
  258. package/stubs/scaffold.validator.stub +18 -0
  259. package/stubs/scaffold.validator.test.stub +26 -0
  260. package/stubs/service.stub +4 -0
  261. package/stubs/service.test.stub +3 -0
  262. package/stubs/validator.stub +3 -0
  263. package/stubs/validator.test.stub +3 -0
  264. package/templates/app/.env.example +16 -0
  265. package/templates/app/AGENTS.md +163 -0
  266. package/templates/app/CLAUDE.md +1 -0
  267. package/templates/app/README.md +79 -37
  268. package/templates/app/app/commands/about.test.ts +1 -1
  269. package/templates/app/app/commands/console.test.ts +26 -0
  270. package/templates/app/app/commands/console.ts +19 -0
  271. package/templates/app/app/commands/db/console.ts +6 -0
  272. package/templates/app/app/commands/db/fresh.test.ts +57 -0
  273. package/templates/app/app/commands/db/fresh.ts +37 -0
  274. package/templates/app/app/commands/db/migrate.test.ts +46 -0
  275. package/templates/app/app/commands/db/migrate.ts +88 -0
  276. package/templates/app/app/commands/db/prepare.test.ts +39 -0
  277. package/templates/app/app/commands/db/prepare.ts +35 -0
  278. package/templates/app/app/commands/db/seed.test.ts +38 -0
  279. package/templates/app/app/commands/db/seed.ts +26 -0
  280. package/templates/app/app/commands/deploy.test.ts +34 -0
  281. package/templates/app/app/commands/deploy.ts +18 -0
  282. package/templates/app/app/commands/emails/preview.test.tsx +63 -0
  283. package/templates/app/app/commands/emails/preview.ts +24 -0
  284. package/templates/app/app/commands/index.ts +72 -1
  285. package/templates/app/app/commands/typegen.test.ts +17 -0
  286. package/templates/app/app/commands/typegen.ts +16 -0
  287. package/templates/app/app/emails/index.ts +10 -0
  288. package/templates/app/app/http/controllers/api/health.tsx +15 -0
  289. package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
  290. package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
  291. package/templates/app/app/http/controllers/home.tsx +21 -13
  292. package/templates/app/app/http/controllers/mcp.tsx +16 -0
  293. package/templates/app/app/http/controllers/not-found.tsx +23 -18
  294. package/templates/app/app/http/controllers/robots.test.ts +18 -0
  295. package/templates/app/app/http/controllers/robots.ts +24 -0
  296. package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
  297. package/templates/app/app/http/controllers/sitemap.ts +25 -0
  298. package/templates/app/app/http/middleware/access.test.ts +43 -0
  299. package/templates/app/app/http/middleware/access.ts +41 -0
  300. package/templates/app/app/http/middleware/api.ts +19 -0
  301. package/templates/app/app/http/middleware/page.test.ts +43 -0
  302. package/templates/app/app/http/middleware/page.ts +51 -0
  303. package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
  304. package/templates/app/app/http/middleware/server-timing.ts +42 -0
  305. package/templates/app/app/initializers/assets.ts +1 -1
  306. package/templates/app/app/initializers/captcha.ts +11 -0
  307. package/templates/app/app/initializers/cli.ts +68 -2
  308. package/templates/app/app/initializers/database.test.ts +18 -0
  309. package/templates/app/app/initializers/database.ts +18 -0
  310. package/templates/app/app/initializers/dispatcher.ts +26 -0
  311. package/templates/app/app/initializers/honeypot.ts +11 -0
  312. package/templates/app/app/initializers/i18n.test.ts +16 -0
  313. package/templates/app/app/initializers/i18n.ts +28 -0
  314. package/templates/app/app/initializers/local-database.test.ts +33 -0
  315. package/templates/app/app/initializers/local-database.ts +53 -0
  316. package/templates/app/app/initializers/mail-transport.test.ts +27 -0
  317. package/templates/app/app/initializers/mail-transport.ts +26 -0
  318. package/templates/app/app/initializers/mail.test.ts +27 -0
  319. package/templates/app/app/initializers/mail.ts +19 -0
  320. package/templates/app/app/initializers/mcp.ts +1 -1
  321. package/templates/app/app/initializers/openapi.ts +21 -0
  322. package/templates/app/app/initializers/router.test.ts +68 -0
  323. package/templates/app/app/initializers/router.tsx +81 -25
  324. package/templates/app/app/initializers/seo.ts +15 -0
  325. package/templates/app/app/initializers/session.test.ts +34 -0
  326. package/templates/app/app/initializers/session.ts +29 -0
  327. package/templates/app/app/initializers/spam.ts +10 -0
  328. package/templates/app/app/jobs/email.test.tsx +70 -0
  329. package/templates/app/app/jobs/email.ts +16 -0
  330. package/templates/app/app/jobs/index.ts +6 -2
  331. package/templates/app/app/models/index.ts +10 -0
  332. package/templates/app/app/policies/abilities.ts +13 -0
  333. package/templates/app/app/policies/policy.test.ts +15 -0
  334. package/templates/app/app/policies/policy.ts +30 -0
  335. package/templates/app/app/services/commands.ts +30 -0
  336. package/templates/app/app/services/migrations.test.ts +92 -0
  337. package/templates/app/app/services/migrations.ts +117 -0
  338. package/templates/app/app/test/cloudflare-workers.ts +25 -0
  339. package/templates/app/app/test/local-database.ts +67 -0
  340. package/templates/app/app/test/session.ts +28 -0
  341. package/templates/app/bootstrap/cli.ts +1 -1
  342. package/templates/app/bootstrap/console.ts +13 -0
  343. package/templates/app/bootstrap/worker.ts +4 -4
  344. package/templates/app/cloudflare.config.ts +30 -2
  345. package/templates/app/config/constants.ts +19 -0
  346. package/templates/app/config/problems.ts +24 -0
  347. package/templates/app/config/security-policy.ts +34 -0
  348. package/templates/app/config/security-txt.ts +28 -0
  349. package/templates/app/database/migrations/.gitkeep +0 -0
  350. package/templates/app/database/seed.ts +12 -0
  351. package/templates/app/package.json +37 -6
  352. package/templates/app/resources/layouts/document.tsx +28 -7
  353. package/templates/app/resources/locales/en.json +10 -0
  354. package/templates/app/routes/api.ts +29 -0
  355. package/templates/app/routes/web.ts +6 -4
  356. package/templates/app/vite.config.ts +4 -0
  357. package/stubs/policy.stub +0 -13
  358. package/templates/app/config/router-context.d.ts +0 -20
@@ -70,6 +70,52 @@
70
70
  "stubs": ".config/sdxc/stubs"
71
71
  }
72
72
  },
73
+ "doctor": {
74
+ "type": "object",
75
+ "properties": {
76
+ "checks": {
77
+ "type": "string",
78
+ "default": ".config/sdxc/checks",
79
+ "description": "Folder of the project's own checks, each module run by `sdxc doctor`"
80
+ },
81
+ "migrations": {
82
+ "type": "object",
83
+ "properties": {
84
+ "accept": {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "object",
88
+ "properties": {
89
+ "file": {
90
+ "type": "string",
91
+ "description": "Migration file name, without its folder"
92
+ },
93
+ "column": {
94
+ "type": "string",
95
+ "description": "Column SQLite's error names"
96
+ }
97
+ },
98
+ "required": ["file", "column"],
99
+ "additionalProperties": false
100
+ },
101
+ "default": [],
102
+ "description": "Migration errors `sdxc doctor` steps past, each a file that already ran and the column its error names"
103
+ }
104
+ },
105
+ "additionalProperties": false,
106
+ "default": {
107
+ "accept": []
108
+ }
109
+ }
110
+ },
111
+ "additionalProperties": false,
112
+ "default": {
113
+ "checks": ".config/sdxc/checks",
114
+ "migrations": {
115
+ "accept": []
116
+ }
117
+ }
118
+ },
73
119
  "format": {
74
120
  "type": "array",
75
121
  "items": {
@@ -77,7 +123,7 @@
77
123
  },
78
124
  "minItems": 1,
79
125
  "description": "Command run on every file the CLI writes or edits, paths appended",
80
- "examples": [["bunx", "vp", "fmt"]]
126
+ "examples": [["bunx", "vp", "fmt", "--no-error-on-unmatched-pattern"]]
81
127
  },
82
128
  "lock": {
83
129
  "type": "string",
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The `@author` and `@copyright` tags closing the module JSDoc of every file `make` and `create`
3
+ * write, credited to the project's package.json `author` or else the git user, so a generated
4
+ * file opens with the header the project's documentation rules ask for.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Who a generated file credits; `url` is linked from the `@author` tag when present. */
10
+ export interface Author {
11
+ name: string;
12
+ url: string | null;
13
+ }
14
+ /**
15
+ * Reads a package.json `author` in either npm form: `"Name <email> (url)"`, where the email and
16
+ * url are optional, or `{ name, email, url }`. Anything without a name is `null`.
17
+ */
18
+ export declare function parseAuthor(field: unknown): Author | null;
19
+ /**
20
+ * The author of files written under `directory`: the `author` of the nearest package.json from
21
+ * `directory` up to the repository root (the first folder holding `.git`), else `git config
22
+ * user.name` there, else `null`, so a file carries no tags rather than a guessed name.
23
+ * `directory` may not exist yet; the search starts from it all the same.
24
+ */
25
+ export declare function resolveAuthor(directory: string): Promise<Author | null>;
26
+ /**
27
+ * The lines a module JSDoc ends with to credit `author`: a blank comment line, `@author` (linked
28
+ * when there is a url) and `@copyright` with the UTC `year`, each led by a newline so the result
29
+ * splices in right before the line that closes the block. With no author it is empty.
30
+ */
31
+ export declare function headerTags(author: Author | null, year?: number): string;
32
+ /**
33
+ * `source` with `tags` added to the module JSDoc it opens with (after a `#!` line, if any). A
34
+ * file that opens with no JSDoc, or whose JSDoc already has an `@author`, is answered as it is.
35
+ */
36
+ export declare function addHeaderTags(source: string, tags: string): string;
package/dist/author.js ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The `@author` and `@copyright` tags closing the module JSDoc of every file `make` and `create`
3
+ * write, credited to the project's package.json `author` or else the git user, so a generated
4
+ * file opens with the header the project's documentation rules ask for.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { execFile } from "node:child_process";
10
+ import { readFile, stat } from "node:fs/promises";
11
+ import { dirname, join } from "node:path";
12
+ import { isFailure, isSuccess, wrap } from "@sdxc/result";
13
+ /**
14
+ * Reads a package.json `author` in either npm form: `"Name <email> (url)"`, where the email and
15
+ * url are optional, or `{ name, email, url }`. Anything without a name is `null`.
16
+ */
17
+ export function parseAuthor(field) {
18
+ if (typeof field === "string") {
19
+ let match = /^([^<(]*?)\s*(?:<[^>]*>)?\s*(?:\(([^)]*)\))?\s*$/.exec(field.trim());
20
+ let name = match?.[1]?.trim() ?? "";
21
+ if (name === "")
22
+ return null;
23
+ let url = match?.[2]?.trim() ?? "";
24
+ return { name, url: url === "" ? null : url };
25
+ }
26
+ if (typeof field !== "object" || field === null || Array.isArray(field))
27
+ return null;
28
+ let { name, url } = field;
29
+ if (typeof name !== "string" || name.trim() === "")
30
+ return null;
31
+ return {
32
+ name: name.trim(),
33
+ url: typeof url === "string" && url.trim() !== "" ? url.trim() : null,
34
+ };
35
+ }
36
+ /**
37
+ * The author of files written under `directory`: the `author` of the nearest package.json from
38
+ * `directory` up to the repository root (the first folder holding `.git`), else `git config
39
+ * user.name` there, else `null`, so a file carries no tags rather than a guessed name.
40
+ * `directory` may not exist yet; the search starts from it all the same.
41
+ */
42
+ export async function resolveAuthor(directory) {
43
+ let existing = null;
44
+ for (let current = directory;; current = dirname(current)) {
45
+ let found = await wrap(() => stat(current));
46
+ if (isSuccess(found) && found.data.isDirectory()) {
47
+ existing ??= current;
48
+ let text = await wrap(() => readFile(join(current, "package.json"), "utf8"));
49
+ if (isSuccess(text)) {
50
+ let manifest = wrap(() => JSON.parse(text.data));
51
+ let author = isFailure(manifest) ? null : parseAuthor(manifest.data.author);
52
+ if (author !== null)
53
+ return author;
54
+ }
55
+ if (isSuccess(await wrap(() => stat(join(current, ".git")))))
56
+ break;
57
+ }
58
+ if (dirname(current) === current)
59
+ break;
60
+ }
61
+ if (existing === null)
62
+ return null;
63
+ let name = await gitUserName(existing);
64
+ return name === null ? null : { name, url: null };
65
+ }
66
+ /** `git config user.name` as git resolves it in `cwd`, or `null` when git or the name is missing. */
67
+ function gitUserName(cwd) {
68
+ return new Promise((resolve) => {
69
+ execFile("git", ["config", "user.name"], { cwd }, (error, stdout) => {
70
+ let name = error === null ? stdout.trim() : "";
71
+ resolve(name === "" ? null : name);
72
+ });
73
+ });
74
+ }
75
+ /**
76
+ * The lines a module JSDoc ends with to credit `author`: a blank comment line, `@author` (linked
77
+ * when there is a url) and `@copyright` with the UTC `year`, each led by a newline so the result
78
+ * splices in right before the line that closes the block. With no author it is empty.
79
+ */
80
+ export function headerTags(author, year = new Date().getUTCFullYear()) {
81
+ if (author === null)
82
+ return "";
83
+ let credit = author.url === null ? author.name : `[${author.name}](${author.url})`;
84
+ return `\n *\n * @author ${credit}\n * @copyright ${author.name} ${year}`;
85
+ }
86
+ /**
87
+ * `source` with `tags` added to the module JSDoc it opens with (after a `#!` line, if any). A
88
+ * file that opens with no JSDoc, or whose JSDoc already has an `@author`, is answered as it is.
89
+ */
90
+ export function addHeaderTags(source, tags) {
91
+ if (tags === "")
92
+ return source;
93
+ let start = source.startsWith("#!") ? source.indexOf("\n") + 1 : 0;
94
+ if (!source.startsWith("/**", start))
95
+ return source;
96
+ let end = source.indexOf("*/", start);
97
+ if (end === -1)
98
+ return source;
99
+ let block = source.slice(start, end);
100
+ if (block.includes("@author"))
101
+ return source;
102
+ let close = block.lastIndexOf("\n");
103
+ if (close === -1)
104
+ return source;
105
+ let at = start + close;
106
+ return `${source.slice(0, at)}${tags}${source.slice(at)}`;
107
+ }
package/dist/cli.js CHANGED
@@ -31,7 +31,16 @@ export function createSDXC(options = {}) {
31
31
  middleware: [packageRoot(options.packageRoot)],
32
32
  });
33
33
  cli.map(SDXC_COMMANDS.create, lazy(() => import("./commands/create.js")));
34
+ cli.map(SDXC_COMMANDS.deploy, lazy(() => import("./commands/deploy.js")));
35
+ cli.map(SDXC_COMMANDS.destroy, lazy(() => import("./commands/destroy.js")));
36
+ cli.map(SDXC_COMMANDS.doctor, lazy(() => import("./commands/doctor.js")));
34
37
  cli.map(SDXC_COMMANDS.init, lazy(() => import("./commands/init.js")));
38
+ cli.map(SDXC_COMMANDS.initializers, lazy(() => import("./commands/initializers.js")));
39
+ cli.map(SDXC_COMMANDS.middleware, lazy(() => import("./commands/middleware.js")));
40
+ cli.map(SDXC_COMMANDS.models, lazy(() => import("./commands/models.js")));
41
+ cli.map(SDXC_COMMANDS.notes, lazy(() => import("./commands/notes.js")));
42
+ cli.map(SDXC_COMMANDS.schedule, lazy(() => import("./commands/schedule.js")));
43
+ cli.map(SDXC_COMMANDS.stats, lazy(() => import("./commands/stats.js")));
35
44
  cli.map(SDXC_COMMANDS.make, lazy(() => import("./commands/make.js").then((module) => ({ default: module.group }))));
36
45
  cli.map(SDXC_COMMANDS.make.controller, lazy(() => import("./commands/make.js").then((module) => ({ default: module.controller }))));
37
46
  cli.map(SDXC_COMMANDS.make.middleware, lazy(() => import("./commands/make.js").then((module) => ({ default: module.middleware }))));
@@ -46,7 +55,10 @@ export function createSDXC(options = {}) {
46
55
  cli.map(SDXC_COMMANDS.make.email, lazy(() => import("./commands/make.js").then((module) => ({ default: module.email }))));
47
56
  cli.map(SDXC_COMMANDS.make.mcp, lazy(() => import("./commands/make.js").then((module) => ({ default: module.mcp }))));
48
57
  cli.map(SDXC_COMMANDS.make.command, lazy(() => import("./commands/make.js").then((module) => ({ default: module.command }))));
58
+ cli.map(SDXC_COMMANDS.make.test, lazy(() => import("./commands/make.js").then((module) => ({ default: module.test }))));
49
59
  cli.map(SDXC_COMMANDS.make.stubs, lazy(() => import("./commands/make.js").then((module) => ({ default: module.stubs }))));
60
+ cli.map(SDXC_COMMANDS.routes, lazy(() => import("./commands/routes.js")));
61
+ cli.map(SDXC_COMMANDS.scaffold, lazy(() => import("./commands/scaffold.js")));
50
62
  cli.map(SDXC_COMMANDS.run, lazy(() => import("./commands/run.js")));
51
63
  cli.map(SDXC_COMMANDS.ui.list, lazy(() => import("./commands/ui/list.js")));
52
64
  cli.map(SDXC_COMMANDS.ui.add, lazy(() => import("./commands/ui/add.js")));
@@ -9,10 +9,11 @@
9
9
  import { relative } from "node:path";
10
10
  import { createCommand, success } from "@sdxc/cli";
11
11
  import { failure, isFailure, wrap } from "@sdxc/result";
12
+ import { headerTags, resolveAuthor } from "../author.js";
12
13
  import { SDXC_COMMANDS } from "../contract.js";
13
14
  import { describe, downloadTemplate, GitHubRefusal, githubToken } from "../create/github.js";
14
15
  import { resolveTarget } from "../create/target.js";
15
- import { completeBuiltin, nameProject, parseTemplate, readBuiltinTemplate, writeTree, } from "../create/templates.js";
16
+ import { completeBuiltin, creditTemplate, nameProject, parseTemplate, readBuiltinTemplate, writeTree, } from "../create/templates.js";
16
17
  import { packageRoot } from "../middleware.js";
17
18
  import { packageManager, scriptCommand } from "../package-manager.js";
18
19
  /** The middleware `create` runs behind; it runs outside any project. */
@@ -28,7 +29,7 @@ export default createCommand(SDXC_COMMANDS.create, {
28
29
  let target = await resolveTarget(ctx.cwd, ctx.arguments.directory);
29
30
  if (isFailure(target))
30
31
  return target;
31
- let fetched = await fetchTemplate(ctx, source.data, target.data.name);
32
+ let fetched = await fetchTemplate(ctx, source.data, target.data.name, target.data.directory);
32
33
  if (isFailure(fetched))
33
34
  return fetched;
34
35
  let written = await writeTree(target.data.directory, fetched.data.tree);
@@ -95,8 +96,11 @@ async function initializeGit(ctx, wanted, directory, shown) {
95
96
  ctx.stdout("Initialized a git repository\n");
96
97
  return success(undefined);
97
98
  }
98
- /** Reads the template `source` names and completes it for the project `name`. */
99
- async function fetchTemplate(ctx, source, name) {
99
+ /**
100
+ * Reads the template `source` names and completes it for the project `name`. A built-in
101
+ * template's modules credit the author resolved from `directory`, where the project is written.
102
+ */
103
+ async function fetchTemplate(ctx, source, name, directory) {
100
104
  if (source.kind === "github") {
101
105
  let extracted = await download(ctx, source);
102
106
  if (isFailure(extracted))
@@ -113,6 +117,7 @@ async function fetchTemplate(ctx, source, name) {
113
117
  let completed = await completeBuiltin(tree.data, name, ctx.packageRoot);
114
118
  if (isFailure(completed))
115
119
  return completed;
120
+ creditTemplate(tree.data, headerTags(await resolveAuthor(directory)));
116
121
  return success({ tree: tree.data, description: `the ${source.name} template` });
117
122
  }
118
123
  /**
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The `sdxc deploy` handler: builds the project, then runs the app's own `db migrate --remote`
3
+ * and `deploy` commands, so new code never reaches production ahead of the schema it expects
4
+ * and each app decides how it is migrated and where it ships.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /**
10
+ * Runs build, `db migrate --remote` and `deploy` in that order and stops at the first failure,
11
+ * whose message says what production now runs. Every remote change waits for a yes: `--yes`, or
12
+ * a terminal answer after the plan; without a terminal, a missing `--yes` is a usage error.
13
+ */
14
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
15
+ readonly yes: import("@sdxc/cli").Flag<boolean>;
16
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
17
+ readonly skip: import("@sdxc/cli").ValueFlag<"build" | "migrate" | "deploy", false, true, false>;
18
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
19
+ key: typeof import("../middleware.js").CurrentProject;
20
+ value: import("../middleware.js").Project;
21
+ property: "project";
22
+ }>]>;
23
+ export default _default;
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The `sdxc deploy` handler: builds the project, then runs the app's own `db migrate --remote`
3
+ * and `deploy` commands, so new code never reaches production ahead of the schema it expects
4
+ * and each app decides how it is migrated and where it ships.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { stat } from "node:fs/promises";
10
+ import { basename, join } from "node:path";
11
+ import { createCommand, ExecError, exit, failure, success, usage } from "@sdxc/cli";
12
+ import { isFailure, isSuccess, wrap } from "@sdxc/result";
13
+ import { SDXC_COMMANDS } from "../contract.js";
14
+ import { deployFailure, formatPlan, isUnknown, migrates, parsePending } from "../deploy/plan.js";
15
+ import { project } from "../middleware.js";
16
+ import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
17
+ import { readManifest } from "../upgrade/project.js";
18
+ import { CLI_ENTRY, commandLine, projectPath } from "./run.js";
19
+ /**
20
+ * Runs build, `db migrate --remote` and `deploy` in that order and stops at the first failure,
21
+ * whose message says what production now runs. Every remote change waits for a yes: `--yes`, or
22
+ * a terminal answer after the plan; without a terminal, a missing `--yes` is a usage error.
23
+ */
24
+ export default createCommand(SDXC_COMMANDS.deploy, {
25
+ middleware: [project()],
26
+ /** Fails naming the step that stopped the run and the steps that already ran. */
27
+ async handler(ctx) {
28
+ let { yes, dryRun } = ctx.flags;
29
+ let skip = new Set(ctx.flags.skip);
30
+ if (!yes && !dryRun && !ctx.stdin.isTTY) {
31
+ return usage("Deploying to production without a terminal needs --yes");
32
+ }
33
+ if (skip.has("migrate") && skip.has("deploy")) {
34
+ return usage("--skip migrate and --skip deploy leave nothing to run in production");
35
+ }
36
+ let root = ctx.project.root;
37
+ let path = projectPath(root, ctx.env.PATH);
38
+ if (!isSuccess(await wrap(() => stat(join(root, CLI_ENTRY))))) {
39
+ return failure(new Error(`${CLI_ENTRY} is missing; sdxc deploy runs the app's db migrate --remote and deploy commands from it`));
40
+ }
41
+ let manifest = await readManifest(root);
42
+ if (isFailure(manifest))
43
+ return manifest;
44
+ let app = manifest.data.manifest.name ?? basename(root);
45
+ if (!skip.has("build")) {
46
+ if (manifest.data.manifest.scripts?.build === undefined) {
47
+ return failure(new Error("package.json has no build script; add one, or pass --skip build"));
48
+ }
49
+ let manager = await packageManager({
50
+ declared: manifest.data.manifest.packageManager,
51
+ findLockFile: lockFileAtOrAbove(root),
52
+ });
53
+ let built = await ctx.exec([...manager.run, "build"], {
54
+ cwd: root,
55
+ stdio: "inherit",
56
+ env: { PATH: path },
57
+ });
58
+ if (isFailure(built)) {
59
+ return failure(new Error("Build failed; nothing was migrated or deployed"));
60
+ }
61
+ }
62
+ let migrations = { status: "skipped", reason: "--skip migrate" };
63
+ if (!skip.has("migrate")) {
64
+ let listing = await commandLine(root, ["db", "migrate", "--remote", "--pending"]);
65
+ if (isFailure(listing))
66
+ return listing;
67
+ let listed = await ctx.exec(listing.data, {
68
+ cwd: root,
69
+ stdio: "collect",
70
+ env: { PATH: path },
71
+ });
72
+ if (isSuccess(listed)) {
73
+ migrations = { status: "pending", names: parsePending(listed.data.stdout) };
74
+ }
75
+ else if (isUnknown(listed.error, "flag")) {
76
+ migrations = { status: "unlisted" };
77
+ }
78
+ else if (isUnknown(listed.error, "command")) {
79
+ return failure(new Error("The app's command line has no db migrate command; add one that applies production migrations with --remote, or pass --skip migrate"));
80
+ }
81
+ else {
82
+ return failure(new Error(`Listing pending migrations with db migrate --remote --pending failed; nothing was migrated or deployed: ${listed.error.message}`));
83
+ }
84
+ }
85
+ if (!skip.has("deploy")) {
86
+ let checking = await commandLine(root, ["deploy", "--dry-run"]);
87
+ if (isFailure(checking))
88
+ return checking;
89
+ let checked = await ctx.exec(checking.data, {
90
+ cwd: root,
91
+ stdio: "inherit",
92
+ env: { PATH: path },
93
+ });
94
+ if (isFailure(checked)) {
95
+ return failure(new Error(exitCode(checked.error) === 2
96
+ ? "The app's command line has no deploy command taking --dry-run; add one, or pass --skip deploy"
97
+ : "The app's deploy --dry-run failed; nothing was migrated or deployed"));
98
+ }
99
+ }
100
+ ctx.stdout(formatPlan({
101
+ app,
102
+ build: !skip.has("build"),
103
+ migrations,
104
+ deploy: !skip.has("deploy"),
105
+ }));
106
+ if (dryRun) {
107
+ ctx.stdout("Dry run: nothing was migrated or deployed\n");
108
+ return success();
109
+ }
110
+ if (!yes) {
111
+ let confirmed = await ctx.prompt.confirm({
112
+ message: skip.has("deploy")
113
+ ? `Apply ${app}'s migrations to production?`
114
+ : `Deploy ${app} to production?`,
115
+ default: false,
116
+ name: "confirm",
117
+ });
118
+ if (isFailure(confirmed))
119
+ return confirmed;
120
+ if (!confirmed.data)
121
+ return exit(1, "Not confirmed; nothing was migrated or deployed");
122
+ }
123
+ if (migrates(migrations)) {
124
+ let command = await commandLine(root, ["db", "migrate", "--remote"]);
125
+ if (isFailure(command))
126
+ return command;
127
+ /** `CI=1` makes `cf` take the yes this run already got instead of asking again. */
128
+ let migrated = await ctx.exec(command.data, {
129
+ cwd: root,
130
+ stdio: "inherit",
131
+ env: { PATH: path, CI: "1" },
132
+ });
133
+ if (isFailure(migrated)) {
134
+ return failure(new Error("Migrations failed, so nothing was deployed; the ones before the failure may be applied"));
135
+ }
136
+ }
137
+ if (skip.has("deploy")) {
138
+ ctx.stdout(`${migrated(migrations)}; deploy skipped\n`);
139
+ return success();
140
+ }
141
+ let command = await commandLine(root, ["deploy"]);
142
+ if (isFailure(command))
143
+ return command;
144
+ let deployed = await ctx.exec(command.data, {
145
+ cwd: root,
146
+ stdio: "inherit",
147
+ env: { PATH: path },
148
+ });
149
+ if (isFailure(deployed))
150
+ return failure(new Error(deployFailure(migrations)));
151
+ ctx.stdout(`${migrated(migrations)} and deployed ${app}\n`);
152
+ return success();
153
+ },
154
+ });
155
+ /** The exit code a failed child reported; `undefined` when it never ran or was killed. */
156
+ function exitCode(error) {
157
+ return error instanceof ExecError && error.code !== null ? error.code : undefined;
158
+ }
159
+ /** What the migration step did, as the closing line reports it. */
160
+ function migrated(step) {
161
+ if (step.status === "unlisted")
162
+ return "Ran db migrate --remote";
163
+ if (step.status === "pending" && step.names.length > 0) {
164
+ return `Applied ${step.names.length} migrations`;
165
+ }
166
+ return "Applied no migrations";
167
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The `sdxc destroy` handler: prints what it removes and edits, asks once, then deletes the
3
+ * files, makes the edits, runs the project's `format` over the edited files, and ends with every
4
+ * reference left for the user to remove.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Removes what `sdxc make` wrote for one kind and name, after one confirmation. */
10
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
11
+ readonly kind: import("@sdxc/cli").Argument<"email" | "command" | "controller" | "middleware" | "validator" | "job" | "model" | "factory" | "service" | "initializer" | "mcp">;
12
+ readonly name: import("@sdxc/cli").Argument<string>;
13
+ }, {
14
+ readonly yes: import("@sdxc/cli").Flag<boolean>;
15
+ readonly dryRun: import("@sdxc/cli").Flag<boolean>;
16
+ readonly resource: import("@sdxc/cli").Flag<boolean>;
17
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
18
+ key: typeof import("../middleware.js").CurrentProject;
19
+ value: import("../middleware.js").Project;
20
+ property: "project";
21
+ }>]>;
22
+ export default _default;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The `sdxc destroy` handler: prints what it removes and edits, asks once, then deletes the
3
+ * files, makes the edits, runs the project's `format` over the edited files, and ends with every
4
+ * reference left for the user to remove.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { rm, writeFile } from "node:fs/promises";
10
+ import { join } from "node:path";
11
+ import { createCommand, exit, success, usage } from "@sdxc/cli";
12
+ import { isFailure, wrap } from "@sdxc/result";
13
+ import { SDXC_COMMANDS } from "../contract.js";
14
+ import { planDestroy } from "../destroy.js";
15
+ import { unifiedDiff } from "../diff.js";
16
+ import { formatFiles } from "../format.js";
17
+ import { project } from "../middleware.js";
18
+ /** Removes what `sdxc make` wrote for one kind and name, after one confirmation. */
19
+ export default createCommand(SDXC_COMMANDS.destroy, {
20
+ middleware: [project()],
21
+ /**
22
+ * Nothing changes without a yes: `--yes`, or a terminal answer after the plan; without a
23
+ * terminal, a missing `--yes` is a usage error. `--dry-run` prints the plan and the diffs.
24
+ */
25
+ async handler(ctx) {
26
+ let { yes, dryRun, resource } = ctx.flags;
27
+ if (!yes && !dryRun && !ctx.stdin.isTTY) {
28
+ return usage("Destroying files without a terminal needs --yes");
29
+ }
30
+ let { root, config } = ctx.project;
31
+ let plan = await planDestroy(root, {
32
+ kind: ctx.arguments.kind,
33
+ name: ctx.arguments.name,
34
+ resource,
35
+ });
36
+ if (isFailure(plan))
37
+ return plan;
38
+ let { remove, edits, references, notes } = plan.data;
39
+ let lines = [
40
+ "Removes:",
41
+ ...remove.map((path) => ` ${path}`),
42
+ ...(edits.length === 0 ? [] : ["Edits:", ...edits.map((edit) => ` ${edit.path}`)]),
43
+ ];
44
+ ctx.stdout(`${lines.join("\n")}\n`);
45
+ let leftovers = [
46
+ ...(references.length === 0
47
+ ? []
48
+ : [
49
+ `Still referenced, to remove by hand:\n${references.map((line) => ` ${line}`).join("\n")}\n`,
50
+ ]),
51
+ ...notes,
52
+ ];
53
+ if (dryRun) {
54
+ for (let edit of edits)
55
+ ctx.stdout(unifiedDiff(edit.path, edit.before, edit.after));
56
+ for (let leftover of leftovers)
57
+ ctx.stdout(leftover);
58
+ return success();
59
+ }
60
+ if (!yes) {
61
+ let confirmed = await ctx.prompt.confirm({
62
+ message: `Remove ${remove.length} file${remove.length === 1 ? "" : "s"}${edits.length === 0 ? "" : ` and edit ${edits.length}`}?`,
63
+ default: false,
64
+ name: "confirm",
65
+ });
66
+ if (isFailure(confirmed))
67
+ return confirmed;
68
+ if (!confirmed.data)
69
+ return exit(1, "Not confirmed; nothing was removed");
70
+ }
71
+ let applied = await wrap(async () => {
72
+ for (let path of remove)
73
+ await rm(join(root, path));
74
+ for (let edit of edits)
75
+ await writeFile(join(root, edit.path), edit.after);
76
+ });
77
+ if (isFailure(applied))
78
+ return applied;
79
+ for (let path of remove)
80
+ ctx.stdout(`Removed ${path}\n`);
81
+ for (let edit of edits)
82
+ ctx.stdout(`Edited ${edit.path}\n`);
83
+ let formatted = edits.length === 0
84
+ ? null
85
+ : await formatFiles(ctx, config.format, edits.map((edit) => edit.path), root);
86
+ for (let leftover of leftovers)
87
+ ctx.stdout(leftover);
88
+ if (formatted !== null && isFailure(formatted))
89
+ return formatted;
90
+ return success();
91
+ },
92
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The `sdxc doctor` handler: runs every built-in check and every check the project defines, and
3
+ * prints one line per check, or one JSON document with `--json`, so a person and an agent read
4
+ * the same verdict. It changes nothing; each warning and failure carries the command that fixes it.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /**
10
+ * Exits 1 when any check fails; a warning or a skipped check leaves the exit code at 0. A name
11
+ * in `--only` or `--skip` that no check has ends the run with the names there are.
12
+ */
13
+ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
14
+ readonly json: import("@sdxc/cli").Flag<boolean>;
15
+ readonly only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
16
+ readonly skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
17
+ }>, readonly [import("@sdxc/cli").CommandMiddleware<{
18
+ key: typeof import("../middleware.js").CurrentProject;
19
+ value: import("../middleware.js").Project;
20
+ property: "project";
21
+ }>, import("@sdxc/cli").CommandMiddleware<{
22
+ key: typeof import("../middleware.js").PackageRoot;
23
+ value: string;
24
+ property: "packageRoot";
25
+ }>]>;
26
+ export default _default;