@sdxc/kit 2026.10.17 → 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 (282) hide show
  1. package/README.md +390 -20
  2. package/changelog.jsonl +1160 -1092
  3. package/config.schema.json +47 -1
  4. package/dist/cli.js +12 -0
  5. package/dist/commands/deploy.d.ts +23 -0
  6. package/dist/commands/deploy.js +167 -0
  7. package/dist/commands/destroy.d.ts +22 -0
  8. package/dist/commands/destroy.js +92 -0
  9. package/dist/commands/doctor.d.ts +26 -0
  10. package/dist/commands/doctor.js +65 -0
  11. package/dist/commands/initializers.d.ts +16 -0
  12. package/dist/commands/initializers.js +23 -0
  13. package/dist/commands/make.d.ts +72 -6
  14. package/dist/commands/make.js +127 -19
  15. package/dist/commands/middleware.d.ts +16 -0
  16. package/dist/commands/middleware.js +21 -0
  17. package/dist/commands/models.d.ts +18 -0
  18. package/dist/commands/models.js +29 -0
  19. package/dist/commands/notes.d.ts +17 -0
  20. package/dist/commands/notes.js +27 -0
  21. package/dist/commands/routes.d.ts +25 -0
  22. package/dist/commands/routes.js +50 -0
  23. package/dist/commands/run.d.ts +16 -0
  24. package/dist/commands/run.js +32 -11
  25. package/dist/commands/scaffold.d.ts +29 -0
  26. package/dist/commands/scaffold.js +33 -0
  27. package/dist/commands/schedule.d.ts +16 -0
  28. package/dist/commands/schedule.js +21 -0
  29. package/dist/commands/stats.d.ts +16 -0
  30. package/dist/commands/stats.js +21 -0
  31. package/dist/commands/ui/update.d.ts +6 -3
  32. package/dist/commands/ui/update.js +24 -7
  33. package/dist/commands/upgrade.d.ts +3 -1
  34. package/dist/commands/upgrade.js +88 -23
  35. package/dist/config.d.ts +18 -0
  36. package/dist/config.js +28 -1
  37. package/dist/contract.d.ts +97 -3
  38. package/dist/contract.js +360 -26
  39. package/dist/create/templates.js +3 -2
  40. package/dist/dependencies.d.ts +4 -1
  41. package/dist/dependencies.js +13 -1
  42. package/dist/deploy/plan.d.ts +49 -0
  43. package/dist/deploy/plan.js +68 -0
  44. package/dist/destroy.d.ts +40 -0
  45. package/dist/destroy.js +311 -0
  46. package/dist/doctor/check.d.ts +71 -0
  47. package/dist/doctor/check.js +53 -0
  48. package/dist/doctor/checks.d.ts +23 -0
  49. package/dist/doctor/checks.js +68 -0
  50. package/dist/doctor/define.d.ts +59 -0
  51. package/dist/doctor/define.js +16 -0
  52. package/dist/doctor/emails.d.ts +18 -0
  53. package/dist/doctor/emails.js +243 -0
  54. package/dist/doctor/env.d.ts +26 -0
  55. package/dist/doctor/env.js +88 -0
  56. package/dist/doctor/files.d.ts +14 -0
  57. package/dist/doctor/files.js +34 -0
  58. package/dist/doctor/fixture.d.ts +23 -0
  59. package/dist/doctor/fixture.js +46 -0
  60. package/dist/doctor/install.d.ts +17 -0
  61. package/dist/doctor/install.js +37 -0
  62. package/dist/doctor/installed.d.ts +11 -0
  63. package/dist/doctor/installed.js +79 -0
  64. package/dist/doctor/layout.d.ts +23 -0
  65. package/dist/doctor/layout.js +83 -0
  66. package/dist/doctor/migrations.d.ts +16 -0
  67. package/dist/doctor/migrations.js +96 -0
  68. package/dist/doctor/models.d.ts +13 -0
  69. package/dist/doctor/models.js +69 -0
  70. package/dist/doctor/pins.d.ts +15 -0
  71. package/dist/doctor/pins.js +79 -0
  72. package/dist/doctor/project.d.ts +58 -0
  73. package/dist/doctor/project.js +261 -0
  74. package/dist/doctor/remix.d.ts +14 -0
  75. package/dist/doctor/remix.js +44 -0
  76. package/dist/doctor/routes.d.ts +11 -0
  77. package/dist/doctor/routes.js +49 -0
  78. package/dist/doctor/typegen.d.ts +13 -0
  79. package/dist/doctor/typegen.js +57 -0
  80. package/dist/doctor/ui.d.ts +14 -0
  81. package/dist/doctor/ui.js +51 -0
  82. package/dist/initializers.d.ts +25 -0
  83. package/dist/initializers.js +89 -0
  84. package/dist/lock.d.ts +2 -2
  85. package/dist/make/actions.d.ts +23 -0
  86. package/dist/make/actions.js +82 -0
  87. package/dist/make/declare.d.ts +31 -3
  88. package/dist/make/declare.js +284 -9
  89. package/dist/make/email.d.ts +23 -0
  90. package/dist/make/email.js +111 -0
  91. package/dist/make/from-fields.d.ts +30 -0
  92. package/dist/make/from-fields.js +162 -0
  93. package/dist/make/from-model.d.ts +39 -0
  94. package/dist/make/from-model.js +161 -0
  95. package/dist/make/generate.d.ts +16 -5
  96. package/dist/make/generate.js +38 -15
  97. package/dist/make/guard.d.ts +35 -0
  98. package/dist/make/guard.js +73 -0
  99. package/dist/make/imports.d.ts +6 -0
  100. package/dist/make/imports.js +19 -0
  101. package/dist/make/index.d.ts +47 -4
  102. package/dist/make/index.js +287 -29
  103. package/dist/make/kinds.d.ts +29 -2
  104. package/dist/make/kinds.js +79 -7
  105. package/dist/make/mount.d.ts +25 -0
  106. package/dist/make/mount.js +135 -0
  107. package/dist/make/schema-diff.d.ts +58 -0
  108. package/dist/make/schema-diff.js +609 -0
  109. package/dist/make/schema.d.ts +76 -0
  110. package/dist/make/schema.js +206 -0
  111. package/dist/make/stubs.d.ts +7 -5
  112. package/dist/make/stubs.js +16 -5
  113. package/dist/make/test.d.ts +43 -0
  114. package/dist/make/test.js +149 -0
  115. package/dist/make/trigger.d.ts +31 -0
  116. package/dist/make/trigger.js +163 -0
  117. package/dist/models.d.ts +42 -0
  118. package/dist/models.js +149 -0
  119. package/dist/notes.d.ts +28 -0
  120. package/dist/notes.js +66 -0
  121. package/dist/reference.d.ts +27 -0
  122. package/dist/reference.js +103 -0
  123. package/dist/releases.d.ts +9 -0
  124. package/dist/releases.js +29 -8
  125. package/dist/routes/chains.d.ts +34 -0
  126. package/dist/routes/chains.js +95 -0
  127. package/dist/routes/filter.d.ts +53 -0
  128. package/dist/routes/filter.js +147 -0
  129. package/dist/routes/format.d.ts +23 -0
  130. package/dist/routes/format.js +123 -0
  131. package/dist/routes/helpers.d.ts +21 -0
  132. package/dist/routes/helpers.js +165 -0
  133. package/dist/routes/index.d.ts +56 -0
  134. package/dist/routes/index.js +167 -0
  135. package/dist/routes/modules.d.ts +116 -0
  136. package/dist/routes/modules.js +235 -0
  137. package/dist/routes/parse.d.ts +161 -0
  138. package/dist/routes/parse.js +621 -0
  139. package/dist/routes/routers.d.ts +69 -0
  140. package/dist/routes/routers.js +327 -0
  141. package/dist/scaffold/fields.d.ts +129 -0
  142. package/dist/scaffold/fields.js +421 -0
  143. package/dist/scaffold/index.d.ts +37 -0
  144. package/dist/scaffold/index.js +613 -0
  145. package/dist/scaffold/render.d.ts +51 -0
  146. package/dist/scaffold/render.js +332 -0
  147. package/dist/schedule.d.ts +45 -0
  148. package/dist/schedule.js +124 -0
  149. package/dist/stats.d.ts +37 -0
  150. package/dist/stats.js +126 -0
  151. package/dist/ui/commands.d.ts +10 -3
  152. package/dist/ui/commands.js +85 -15
  153. package/dist/ui/registry.d.ts +8 -8
  154. package/dist/upgrade/agents.d.ts +49 -0
  155. package/dist/upgrade/agents.js +110 -0
  156. package/dist/upgrade/changelog.d.ts +2 -2
  157. package/dist/upgrade/project.d.ts +4 -0
  158. package/dist/upgrade/project.js +11 -1
  159. package/dist/upgrade/prompt.d.ts +11 -0
  160. package/dist/upgrade/prompt.js +50 -7
  161. package/package.json +6 -4
  162. package/registry/ui/alert-dialog.json +2 -2
  163. package/registry/ui/attachment.json +2 -2
  164. package/registry/ui/calendar.json +2 -2
  165. package/registry/ui/color-picker.json +2 -2
  166. package/registry/ui/command.json +2 -2
  167. package/registry/ui/date-picker.json +2 -2
  168. package/registry/ui/date-range-picker.json +2 -2
  169. package/registry/ui/dialog.json +2 -2
  170. package/registry/ui/file-trigger.json +2 -2
  171. package/registry/ui/heading-scope.json +2 -2
  172. package/registry/ui/message-scroller.json +2 -2
  173. package/registry/ui/number-field.json +2 -2
  174. package/registry/ui/range-calendar.json +2 -2
  175. package/registry/ui/resizable.json +2 -2
  176. package/registry/ui/select.json +2 -2
  177. package/registry/ui/shared-element.json +2 -2
  178. package/stubs/controller.api.resource.stub +23 -0
  179. package/stubs/controller.form.stub +2 -2
  180. package/stubs/controller.form.test.stub +2 -2
  181. package/stubs/controller.resource.form.stub +67 -0
  182. package/stubs/controller.resource.stub +28 -0
  183. package/stubs/email.stub +9 -14
  184. package/stubs/email.test.stub +9 -9
  185. package/stubs/factory.stub +1 -1
  186. package/stubs/model.stub +3 -3
  187. package/stubs/policy.test.stub +34 -8
  188. package/stubs/scaffold.api.create.stub +34 -0
  189. package/stubs/scaffold.api.create.test.stub +37 -0
  190. package/stubs/scaffold.api.destroy.stub +34 -0
  191. package/stubs/scaffold.api.destroy.test.stub +44 -0
  192. package/stubs/scaffold.api.index.stub +23 -0
  193. package/stubs/scaffold.api.index.test.stub +31 -0
  194. package/stubs/scaffold.api.show.stub +27 -0
  195. package/stubs/scaffold.api.show.test.stub +41 -0
  196. package/stubs/scaffold.api.update.stub +44 -0
  197. package/stubs/scaffold.api.update.test.stub +46 -0
  198. package/stubs/scaffold.command.create.stub +22 -0
  199. package/stubs/scaffold.command.create.test.stub +30 -0
  200. package/stubs/scaffold.command.delete.stub +20 -0
  201. package/stubs/scaffold.command.delete.test.stub +39 -0
  202. package/stubs/scaffold.command.list.stub +18 -0
  203. package/stubs/scaffold.command.list.test.stub +31 -0
  204. package/stubs/scaffold.command.show.stub +19 -0
  205. package/stubs/scaffold.command.show.test.stub +37 -0
  206. package/stubs/scaffold.controller.destroy.stub +35 -0
  207. package/stubs/scaffold.controller.destroy.test.stub +65 -0
  208. package/stubs/scaffold.controller.edit.stub +97 -0
  209. package/stubs/scaffold.controller.edit.test.stub +91 -0
  210. package/stubs/scaffold.controller.index.stub +55 -0
  211. package/stubs/scaffold.controller.index.test.stub +32 -0
  212. package/stubs/scaffold.controller.new.stub +70 -0
  213. package/stubs/scaffold.controller.new.test.stub +81 -0
  214. package/stubs/scaffold.controller.show.stub +59 -0
  215. package/stubs/scaffold.controller.show.test.stub +43 -0
  216. package/stubs/scaffold.factory.stub +16 -0
  217. package/stubs/scaffold.form.stub +75 -0
  218. package/stubs/scaffold.mcp.create.stub +24 -0
  219. package/stubs/scaffold.mcp.create.test.stub +36 -0
  220. package/stubs/scaffold.mcp.delete.stub +31 -0
  221. package/stubs/scaffold.mcp.delete.test.stub +43 -0
  222. package/stubs/scaffold.mcp.get.stub +21 -0
  223. package/stubs/scaffold.mcp.get.test.stub +31 -0
  224. package/stubs/scaffold.mcp.list.stub +23 -0
  225. package/stubs/scaffold.mcp.list.test.stub +25 -0
  226. package/stubs/scaffold.mcp.update.stub +37 -0
  227. package/stubs/scaffold.mcp.update.test.stub +40 -0
  228. package/stubs/scaffold.migration.stub +2 -0
  229. package/stubs/scaffold.model.stub +35 -0
  230. package/stubs/scaffold.model.test.stub +25 -0
  231. package/stubs/scaffold.test-database.stub +33 -0
  232. package/stubs/scaffold.test-mcp.stub +92 -0
  233. package/stubs/scaffold.validator.stub +18 -0
  234. package/stubs/scaffold.validator.test.stub +26 -0
  235. package/templates/app/AGENTS.md +163 -0
  236. package/templates/app/CLAUDE.md +1 -0
  237. package/templates/app/README.md +28 -13
  238. package/templates/app/app/commands/console.test.ts +26 -0
  239. package/templates/app/app/commands/console.ts +19 -0
  240. package/templates/app/app/commands/db/fresh.test.ts +57 -0
  241. package/templates/app/app/commands/db/fresh.ts +37 -0
  242. package/templates/app/app/commands/db/migrate.test.ts +17 -1
  243. package/templates/app/app/commands/db/migrate.ts +51 -18
  244. package/templates/app/app/commands/db/prepare.test.ts +39 -0
  245. package/templates/app/app/commands/db/prepare.ts +35 -0
  246. package/templates/app/app/commands/db/seed.test.ts +38 -0
  247. package/templates/app/app/commands/db/seed.ts +26 -0
  248. package/templates/app/app/commands/deploy.test.ts +34 -0
  249. package/templates/app/app/commands/deploy.ts +18 -0
  250. package/templates/app/app/commands/emails/preview.test.tsx +63 -0
  251. package/templates/app/app/commands/emails/preview.ts +24 -0
  252. package/templates/app/app/commands/index.ts +57 -2
  253. package/templates/app/app/emails/index.ts +10 -0
  254. package/templates/app/app/http/middleware/access.test.ts +43 -0
  255. package/templates/app/app/http/middleware/access.ts +41 -0
  256. package/templates/app/app/http/middleware/api.ts +12 -3
  257. package/templates/app/app/http/middleware/page.test.ts +4 -1
  258. package/templates/app/app/http/middleware/page.ts +7 -5
  259. package/templates/app/app/initializers/cli.ts +28 -2
  260. package/templates/app/app/initializers/dispatcher.ts +9 -1
  261. package/templates/app/app/initializers/mail-transport.test.ts +27 -0
  262. package/templates/app/app/initializers/mail-transport.ts +26 -0
  263. package/templates/app/app/initializers/mail.test.ts +17 -17
  264. package/templates/app/app/initializers/mail.ts +15 -7
  265. package/templates/app/app/initializers/router.test.ts +7 -0
  266. package/templates/app/app/initializers/router.tsx +13 -3
  267. package/templates/app/app/jobs/email.test.tsx +70 -0
  268. package/templates/app/app/jobs/email.ts +16 -0
  269. package/templates/app/app/jobs/index.ts +6 -2
  270. package/templates/app/app/policies/abilities.ts +13 -0
  271. package/templates/app/app/policies/policy.test.ts +15 -0
  272. package/templates/app/app/policies/policy.ts +30 -0
  273. package/templates/app/app/services/commands.ts +30 -0
  274. package/templates/app/app/services/migrations.test.ts +48 -1
  275. package/templates/app/app/services/migrations.ts +66 -9
  276. package/templates/app/app/test/local-database.ts +67 -0
  277. package/templates/app/app/test/session.ts +28 -0
  278. package/templates/app/bootstrap/console.ts +13 -0
  279. package/templates/app/cloudflare.config.ts +3 -3
  280. package/templates/app/database/seed.ts +12 -0
  281. package/templates/app/package.json +2 -1
  282. package/stubs/policy.stub +0 -16
package/dist/contract.js CHANGED
@@ -9,7 +9,11 @@
9
9
  import { argument, command, commands, flag, prompt } from "@sdxc/cli";
10
10
  import * as s from "remix/data-schema";
11
11
  import { BUILTIN_TEMPLATES, DEFAULT_TEMPLATE } from "./create/templates.js";
12
- import { KINDS } from "./make/kinds.js";
12
+ import { DEPLOY_STEPS } from "./deploy/plan.js";
13
+ import { ACTION_NAMES, DESTROY_KINDS, KINDS, MODEL_COMPANIONS, SCAFFOLD_PIECES, } from "./make/kinds.js";
14
+ import { DEFAULT_TAGS } from "./notes.js";
15
+ import { ROUTE_SORTS } from "./routes/filter.js";
16
+ import { FIELD_TYPE_NAMES } from "./scaffold/fields.js";
13
17
  /** Route methods `make controller --method` accepts; `form` declares a GET page with a POST action. */
14
18
  export const METHODS = ["get", "post", "put", "patch", "delete", "form"];
15
19
  /** Every kind `sdxc make` writes, in the order its help lists them. */
@@ -30,6 +34,18 @@ function nameArgument(kind, placeholder) {
30
34
  prompt: prompt.text({ message: `What should the ${kind} be called?`, placeholder }),
31
35
  });
32
36
  }
37
+ /**
38
+ * The fields `make model` and `scaffold` take, each typed by convention from its name unless it
39
+ * names a type; `scaffold` writes pages for every type but a reference.
40
+ */
41
+ function fieldsArgument(references) {
42
+ let types = FIELD_TYPE_NAMES.filter((type) => references || type !== "references");
43
+ let reference = references ? ", *_id references" : "";
44
+ return argument.variadic(s.string(), {
45
+ valueName: "field[:type][?]",
46
+ description: `name, name:type or name? (nullable), each with :index or :unique to index the column; a bare name is typed by convention: *_at timestamp, *_on date, is_* and published boolean, *_count integer, email, *_url url, body text${reference}, else string; types: ${types.join(", ")}`,
47
+ });
48
+ }
33
49
  /**
34
50
  * `--test` / `--no-test`, shared by every kind that writes a test beside its file; unset, it
35
51
  * takes `make.tests`.
@@ -42,6 +58,13 @@ const TEST_FLAG = flag.boolean("test", {
42
58
  const DRY_RUN_FLAG = flag.boolean("dry-run", {
43
59
  description: "Print what would be written and change nothing",
44
60
  });
61
+ /**
62
+ * `--force`, shared by every kind whose file takes its own name: an existing file and its test
63
+ * are replaced, and the declaration and mapping they already have are kept.
64
+ */
65
+ const FORCE_FLAG = flag.boolean("force", {
66
+ description: "Replace the file and its test when they exist, keeping their declaration",
67
+ });
45
68
  /** Every command `sdxc` takes. */
46
69
  export const SDXC_COMMANDS = commands({
47
70
  create: command({
@@ -72,10 +95,81 @@ export const SDXC_COMMANDS = commands({
72
95
  tasks: true,
73
96
  examples: ["create blog", "create blog --template org/repo/apps/blog#main --no-git"],
74
97
  }),
98
+ deploy: command({
99
+ description: "Build, then run the app's db migrate --remote and deploy commands",
100
+ flags: {
101
+ yes: flag.boolean("yes", {
102
+ short: "y",
103
+ description: "Deploy without asking; required without a terminal",
104
+ }),
105
+ dryRun: flag.boolean("dry-run", {
106
+ description: "Build and print the plan; migrate and deploy nothing",
107
+ }),
108
+ skip: flag
109
+ .string("skip", {
110
+ valueName: "step",
111
+ schema: s.enum_(DEPLOY_STEPS),
112
+ description: "Leave out build, migrate or deploy; repeat it or list them",
113
+ })
114
+ .list(),
115
+ },
116
+ examples: [
117
+ "deploy",
118
+ "deploy --dry-run",
119
+ "deploy --yes --skip build",
120
+ "deploy --skip build --skip migrate",
121
+ ],
122
+ }),
123
+ destroy: command({
124
+ description: "Remove a file sdxc make wrote, its test, its mapping and its declaration",
125
+ arguments: {
126
+ kind: argument(s.enum_(DESTROY_KINDS), {
127
+ description: "What to remove; every make kind but migration and policy",
128
+ }),
129
+ name: argument(nonEmpty("Name it"), {
130
+ description: "The name it was made with",
131
+ }),
132
+ },
133
+ flags: {
134
+ yes: flag.boolean("yes", {
135
+ short: "y",
136
+ description: "Remove without asking; required without a terminal",
137
+ }),
138
+ dryRun: DRY_RUN_FLAG,
139
+ resource: flag.boolean("resource", {
140
+ description: "With mcp, a resource in app/mcp/resources instead of a tool",
141
+ }),
142
+ },
143
+ examples: [
144
+ "destroy controller posts/archive",
145
+ "destroy job digest --dry-run",
146
+ "destroy model post --yes",
147
+ ],
148
+ }),
149
+ doctor: command({
150
+ description: "Lint release drift, secrets, migrations, app layout and project checks",
151
+ flags: {
152
+ json: flag.boolean("json", { description: "Print the report as JSON for an agent" }),
153
+ only: flag
154
+ .string("only", { valueName: "check", description: "Run only the named checks" })
155
+ .multiple()
156
+ .list(),
157
+ skip: flag
158
+ .string("skip", { valueName: "check", description: "Leave out the named checks" })
159
+ .multiple()
160
+ .list(),
161
+ },
162
+ examples: ["doctor", "doctor --json", "doctor --only pins,remix", "doctor --skip ui"],
163
+ }),
75
164
  init: command({
76
165
  description: "Write .config/sdxc.jsonc with every default spelled out",
77
166
  flags: { dryRun: flag.boolean("dry-run", { description: "Print it and write nothing" }) },
78
167
  }),
168
+ initializers: command({
169
+ description: "List the initializers in app/initializers, their exports and what builds them",
170
+ flags: { json: flag.boolean("json", { description: "Print a JSON array instead of a table" }) },
171
+ examples: ["initializers", "initializers --json"],
172
+ }),
79
173
  make: commands({
80
174
  description: "Write a controller, job, model or other file where the app layout puts it",
81
175
  arguments: {
@@ -88,7 +182,7 @@ export const SDXC_COMMANDS = commands({
88
182
  prompt: prompt.text({ message: "What should it be called?" }),
89
183
  }),
90
184
  },
91
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
185
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
92
186
  tasks: true,
93
187
  controller: command({
94
188
  description: "A route handler in app/http/controllers, declared and mapped",
@@ -96,11 +190,9 @@ export const SDXC_COMMANDS = commands({
96
190
  arguments: { name: nameArgument("controller", "admin/users") },
97
191
  flags: {
98
192
  method: flag.string("method", {
99
- default: "get",
100
193
  valueName: "method",
101
194
  schema: s.enum_(METHODS),
102
- description: METHODS.join(", "),
103
- prompt: prompt.select({ message: "Which method?", options: METHODS, ask: "always" }),
195
+ description: `${METHODS.join(", ")}; asked on a terminal (default: get)`,
104
196
  }),
105
197
  path: flag.string("path", {
106
198
  valueName: "path",
@@ -110,22 +202,48 @@ export const SDXC_COMMANDS = commands({
110
202
  valueName: "contract",
111
203
  description: "The route contract in routes/ (default: make.routes)",
112
204
  }),
205
+ resource: flag.string("resource", {
206
+ valueName: "name",
207
+ description: "Check the resource's ability the method implies (get reads, form and post create, put and patch update, delete deletes); a read, update or delete route takes /<name>/:id",
208
+ }),
209
+ actions: flag
210
+ .string("actions", {
211
+ valueName: "action",
212
+ schema: s.enum_(ACTION_NAMES),
213
+ description: "One controller per action under <name>: index, new, show, edit and destroy pages, or with --routes api index, show, create, update and destroy endpoints; all writes each",
214
+ })
215
+ .list(),
113
216
  test: TEST_FLAG,
114
217
  dryRun: DRY_RUN_FLAG,
218
+ force: FORCE_FLAG,
115
219
  },
116
- examples: ["make controller api/keys --routes api", "make controller ping --method post"],
220
+ examples: [
221
+ "make controller api/keys --routes api",
222
+ "make controller ping --method post",
223
+ "make controller posts/archive --resource post --method delete",
224
+ "make controller posts --actions all --resource post",
225
+ ],
117
226
  }),
118
227
  middleware: command({
119
228
  description: "A middleware in app/http/middleware",
120
229
  tasks: true,
121
230
  arguments: { name: nameArgument("middleware", "require-user") },
122
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
231
+ flags: {
232
+ mount: flag.string("mount", {
233
+ valueName: "target",
234
+ description: "Also call it last in a chain: a router initializer (router) or a chain module (page, api)",
235
+ }),
236
+ test: TEST_FLAG,
237
+ dryRun: DRY_RUN_FLAG,
238
+ force: FORCE_FLAG,
239
+ },
240
+ examples: ["make middleware require-user --mount page"],
123
241
  }),
124
242
  validator: command({
125
243
  description: "An input validator in app/http/validators",
126
244
  tasks: true,
127
245
  arguments: { name: nameArgument("validator", "signup") },
128
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
246
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
129
247
  }),
130
248
  job: command({
131
249
  description: "A background job in app/jobs, declared and mapped",
@@ -134,60 +252,104 @@ export const SDXC_COMMANDS = commands({
134
252
  flags: {
135
253
  cron: flag.string("cron", {
136
254
  valueName: "expression",
137
- description: "A scheduled job instead of one with input",
255
+ description: "A scheduled job instead of one with input, with the Worker trigger that fires it",
138
256
  }),
139
257
  test: TEST_FLAG,
140
258
  dryRun: DRY_RUN_FLAG,
259
+ force: FORCE_FLAG,
141
260
  },
142
261
  examples: ['make job digest --cron "0 8 * * *"'],
143
262
  }),
144
263
  model: command({
145
- description: "A model in app/models",
264
+ description: "A model in app/models, with the migration creating its table and its factory",
146
265
  tasks: true,
147
- arguments: { name: nameArgument("model", "post") },
148
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
266
+ arguments: { name: nameArgument("model", "post"), fields: fieldsArgument(true) },
267
+ flags: {
268
+ chain: flag.string("chain", {
269
+ valueName: "chain",
270
+ description: "The chain in make.migrations the migration goes in (default: default)",
271
+ }),
272
+ skip: flag
273
+ .string("skip", {
274
+ valueName: "file",
275
+ schema: s.enum_(MODEL_COMPANIONS),
276
+ description: "Leave out the migration or the factory; repeat it or list them",
277
+ })
278
+ .list(),
279
+ test: TEST_FLAG,
280
+ dryRun: DRY_RUN_FLAG,
281
+ force: FORCE_FLAG,
282
+ },
283
+ examples: [
284
+ "make model post title body published_at author_id",
285
+ "make model post title 'subtitle?' views:integer",
286
+ "make model post title --skip migration,factory",
287
+ ],
149
288
  }),
150
289
  migration: command({
151
290
  description: "A numbered SQL migration in a configured chain",
152
291
  tasks: true,
153
- arguments: { name: nameArgument("migration", "create-posts") },
292
+ arguments: {
293
+ name: nameArgument("migration", "create-posts"),
294
+ fields: argument.variadic(s.string(), {
295
+ valueName: "field[:type][?]",
296
+ description: "Columns, typed as make model types them, for a name create-<table>, add-<columns>-to-<table> or remove-<columns>-from-<table>; an added column needs ? unless it is a boolean",
297
+ }),
298
+ },
154
299
  flags: {
155
300
  chain: flag.string("chain", {
156
301
  valueName: "chain",
157
302
  description: "The chain in make.migrations (default: default)",
158
303
  }),
304
+ fromModel: flag.string("from-model", {
305
+ valueName: "model",
306
+ description: "Write the SQL that brings the chain in step with app/models/<model>.ts",
307
+ }),
159
308
  dryRun: DRY_RUN_FLAG,
160
309
  },
310
+ examples: [
311
+ "make migration create-posts title body published_at author_id",
312
+ "make migration add-slug-to-posts 'slug?' featured",
313
+ "make migration remove-slug-from-posts slug",
314
+ "make migration sync-posts --from-model post",
315
+ ],
161
316
  }),
162
317
  factory: command({
163
318
  description: "A test factory in database/factories",
164
319
  tasks: true,
165
320
  arguments: { name: nameArgument("factory", "post") },
166
- flags: { dryRun: DRY_RUN_FLAG },
321
+ flags: { dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
167
322
  }),
168
323
  service: command({
169
324
  description: "A service in app/services",
170
325
  tasks: true,
171
326
  arguments: { name: nameArgument("service", "billing/charge") },
172
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
327
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
173
328
  }),
174
329
  policy: command({
175
- description: "An authorization policy in app/policies",
330
+ description: "A resource's create, read, update and delete abilities in app/policies, with their test",
176
331
  tasks: true,
177
- arguments: { name: nameArgument("policy", "can-edit") },
178
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
332
+ arguments: { name: nameArgument("policy", "post") },
333
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
179
334
  }),
180
335
  initializer: command({
181
336
  description: "An initializer in app/initializers",
182
337
  tasks: true,
183
338
  arguments: { name: nameArgument("initializer", "cache") },
184
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
339
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
185
340
  }),
186
341
  email: command({
187
- description: "An email template in app/emails",
342
+ description: "An email template in app/emails, its props declared and the template mapped",
188
343
  tasks: true,
189
- arguments: { name: nameArgument("email", "welcome") },
190
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
344
+ arguments: {
345
+ name: nameArgument("email", "welcome"),
346
+ fields: argument.variadic(s.string(), {
347
+ valueName: "field[:type][?]",
348
+ description: "Props, typed as make model types them, each optional with ?; the first text prop is the subject and heading; none declares heading and body",
349
+ }),
350
+ },
351
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
352
+ examples: ["make email welcome", "make email teams/invite team invite_url 'expires_on?'"],
191
353
  }),
192
354
  mcp: command({
193
355
  description: "An MCP tool in app/mcp/tools, or a resource, declared and mapped",
@@ -199,25 +361,127 @@ export const SDXC_COMMANDS = commands({
199
361
  }),
200
362
  test: TEST_FLAG,
201
363
  dryRun: DRY_RUN_FLAG,
364
+ force: FORCE_FLAG,
202
365
  },
203
366
  }),
204
367
  command: command({
205
368
  description: "A command-line command in app/commands, declared and mapped",
206
369
  tasks: true,
207
370
  arguments: { name: nameArgument("command", "users/grant") },
208
- flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG },
371
+ flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
209
372
  examples: ["make command users/grant"],
210
373
  }),
374
+ test: command({
375
+ description: "The test make writes beside a file, for an existing file without one",
376
+ tasks: true,
377
+ arguments: {
378
+ file: argument(nonEmpty("Name the file"), {
379
+ valueName: "file",
380
+ description: "The file to test, such as app/services/billing/charge.ts",
381
+ prompt: prompt.text({
382
+ message: "Which file needs a test?",
383
+ placeholder: "app/services/billing/charge.ts",
384
+ }),
385
+ }),
386
+ },
387
+ flags: {
388
+ dryRun: DRY_RUN_FLAG,
389
+ force: flag.boolean("force", { description: "Replace the test when it exists" }),
390
+ },
391
+ examples: ["make test app/services/billing/charge.ts"],
392
+ }),
211
393
  stubs: command({
212
394
  description: "Copy the built-in stubs into make.stubs to edit",
213
395
  arguments: {
214
- kinds: argument.variadic(s.enum_(KIND_NAMES), {
396
+ kinds: argument.variadic(s.enum_([...KIND_NAMES, "scaffold"]), {
215
397
  valueName: "kind",
216
- description: "The kinds whose stubs to copy; every kind when left out",
398
+ description: "The kinds whose stubs to copy, or scaffold; every one when left out",
217
399
  }),
218
400
  },
219
401
  }),
220
402
  }),
403
+ middleware: command({
404
+ description: "Print each router's global middleware and every chain in app/http/middleware",
405
+ flags: { json: flag.boolean("json", { description: "Print the chains as JSON" }) },
406
+ examples: ["middleware", "middleware --json"],
407
+ }),
408
+ models: command({
409
+ description: "Print each model's table and whether the migrations create it, from app/models",
410
+ tasks: false,
411
+ arguments: {
412
+ names: argument.variadic(s.string(), {
413
+ valueName: "model",
414
+ description: "The models to print in full, as sdxc make model names them; every one listed when left out",
415
+ }),
416
+ },
417
+ flags: { json: flag.boolean("json", { description: "Print the models as JSON" }) },
418
+ examples: ["models", "models post", "models post comment --json"],
419
+ }),
420
+ notes: command({
421
+ description: "List the TODO, FIXME, HACK and OPTIMIZE comments in the app's code",
422
+ flags: {
423
+ tag: flag
424
+ .string("tag", {
425
+ valueName: "tag",
426
+ description: `The tags to list instead of ${DEFAULT_TAGS.join(", ")}; repeat it or list them`,
427
+ })
428
+ .multiple()
429
+ .list(),
430
+ json: flag.boolean("json", { description: "Print a JSON array instead of a list" }),
431
+ },
432
+ examples: ["notes", "notes --tag TODO", "notes --tag TODO,REVIEW --json"],
433
+ }),
434
+ routes: command({
435
+ description: "Print every route with its controller and the middleware that runs for it",
436
+ flags: {
437
+ json: flag.boolean("json", { description: "Print a JSON array instead of a table" }),
438
+ expanded: flag.boolean("expanded", {
439
+ short: "E",
440
+ description: "Print one block per route with every field, for a narrow terminal",
441
+ }),
442
+ grep: flag.string("grep", {
443
+ short: "g",
444
+ valueName: "pattern",
445
+ description: "Keep routes whose name, pattern, method or controller matches",
446
+ }),
447
+ controller: flag.string("controller", {
448
+ short: "c",
449
+ valueName: "path",
450
+ description: "Keep routes of a controller file or folder, as posts or posts/show",
451
+ }),
452
+ method: flag.string("method", {
453
+ valueName: "method",
454
+ description: "Keep routes answering a method; ANY routes answer every one",
455
+ }),
456
+ contract: flag.string("contract", {
457
+ valueName: "contract",
458
+ description: "Keep routes declared in a contract in routes/, as web",
459
+ }),
460
+ unused: flag.boolean("unused", {
461
+ description: "Keep routes no router maps, and report controllers no route maps",
462
+ }),
463
+ exceptPath: flag
464
+ .string("except-path", {
465
+ valueName: "path",
466
+ description: "Leave out routes under a path, as /api or /mcp; repeat it or list them",
467
+ })
468
+ .multiple()
469
+ .list(),
470
+ sort: flag.string("sort", {
471
+ valueName: "field",
472
+ schema: s.enum_(ROUTE_SORTS),
473
+ description: `Order routes by ${ROUTE_SORTS.join(", ")} instead of declaration order`,
474
+ }),
475
+ },
476
+ examples: [
477
+ "routes",
478
+ "routes --json",
479
+ "routes -g posts",
480
+ "routes -c admin/users --method post",
481
+ "routes --unused",
482
+ "routes --except-path /api,/mcp --sort pattern",
483
+ ],
484
+ }),
221
485
  run: command({
222
486
  description: "Run the project's own command line, bootstrap/cli.ts, with its runtime",
223
487
  arguments: {
@@ -228,6 +492,60 @@ export const SDXC_COMMANDS = commands({
228
492
  },
229
493
  examples: ["run users find ada@example.com --limit 5", "run --help"],
230
494
  }),
495
+ scaffold: command({
496
+ description: "Write a resource's model, migration, pages, tests and more, declared and mapped",
497
+ tasks: true,
498
+ arguments: {
499
+ name: argument(nonEmpty("Name it"), {
500
+ description: "The resource's singular name, such as post or blog-post",
501
+ prompt: prompt.text({
502
+ message: "What should the resource be called?",
503
+ placeholder: "post",
504
+ }),
505
+ }),
506
+ fields: fieldsArgument(false),
507
+ },
508
+ flags: {
509
+ plural: flag.string("plural", {
510
+ valueName: "word",
511
+ description: "The plural the table, URLs and folders take (default: <name>s)",
512
+ }),
513
+ mcp: flag.boolean("mcp", {
514
+ description: "Also write MCP tools to list, get, create, update and delete",
515
+ }),
516
+ command: flag.boolean("command", {
517
+ description: "Also write app commands to list, show, create and delete",
518
+ }),
519
+ api: flag.boolean("api", {
520
+ description: "JSON endpoints in routes/api.ts with their OpenAPI operations, instead of pages",
521
+ }),
522
+ skip: flag
523
+ .string("skip", {
524
+ valueName: "piece",
525
+ schema: s.enum_(SCAFFOLD_PIECES),
526
+ description: `Leave out pieces the project already has: ${SCAFFOLD_PIECES.join(", ")}; repeat it or list them`,
527
+ })
528
+ .list(),
529
+ test: TEST_FLAG,
530
+ dryRun: DRY_RUN_FLAG,
531
+ },
532
+ examples: [
533
+ "scaffold post title body published_at featured view_count:integer",
534
+ "scaffold person name email website 'bio?' born_on --plural people --mcp --command",
535
+ "scaffold post title body --skip model,migration,factory",
536
+ "scaffold post title body --api",
537
+ ],
538
+ }),
539
+ schedule: command({
540
+ description: "List the scheduled jobs, their next runs and the Worker triggers that fire them",
541
+ flags: { json: flag.boolean("json", { description: "Print the schedule as JSON" }) },
542
+ examples: ["schedule", "schedule --json"],
543
+ }),
544
+ stats: command({
545
+ description: "Count lines of code per kind of code the app layout names, and the test ratio",
546
+ flags: { json: flag.boolean("json", { description: "Print the counts as JSON" }) },
547
+ examples: ["stats", "stats --json"],
548
+ }),
231
549
  ui: commands({
232
550
  description: "Copy @sdxc/ui components into the project and keep imports on the copies",
233
551
  list: command({ description: "Every component, marking copies that are edited or behind" }),
@@ -255,12 +573,22 @@ export const SDXC_COMMANDS = commands({
255
573
  description: "Replace copied files with the installed version",
256
574
  tasks: true,
257
575
  arguments: {
258
- components: argument.variadic(s.string(), { min: 1, valueName: "component" }),
576
+ components: argument.variadic(s.string(), {
577
+ valueName: "component",
578
+ description: "The copies to update; --all updates every one instead",
579
+ }),
259
580
  },
260
581
  flags: {
582
+ all: flag.boolean("all", {
583
+ description: "Update every copy, leaving edited files unless --force",
584
+ }),
585
+ withDeps: flag.boolean("with-deps", {
586
+ description: "Also copy components the new versions reach and the project lacks",
587
+ }),
261
588
  force: flag.boolean("force", { description: "Replace edited files without asking" }),
262
589
  dryRun: DRY_RUN_FLAG,
263
590
  },
591
+ examples: ["ui update dialog", "ui update --all --dry-run"],
264
592
  }),
265
593
  remove: command({
266
594
  description: "Delete copies and point imports back at @sdxc/ui/<name>",
@@ -299,6 +627,12 @@ export const SDXC_COMMANDS = commands({
299
627
  valueName: "version",
300
628
  description: "The release the project moved from, with --prompt",
301
629
  }),
630
+ since: flag
631
+ .string("since", {
632
+ valueName: "package@version",
633
+ description: "A package's own pinned release when it lagged behind --from, with --prompt; repeatable",
634
+ })
635
+ .multiple(),
302
636
  remixFrom: flag.string("remix-from", {
303
637
  valueName: "version",
304
638
  description: "The remix version the project moved from, with --prompt",
@@ -28,9 +28,10 @@ export const BUILTIN_TEMPLATES = ["app"];
28
28
  const RENAMED_FILES = new Map([["gitignore", ".gitignore"]]);
29
29
  /**
30
30
  * The configuration every built-in template ships beyond `sdxc init`'s defaults: each one checks
31
- * with Vite+, so the files `make` and `ui add` write are formatted as `vp check` expects.
31
+ * with Vite+, so the files `make` and `ui add` write are formatted as `vp check` expects. A run
32
+ * that wrote only files `vp fmt` has no formatter for, such as a migration, succeeds.
32
33
  */
33
- const BUILTIN_CONFIG = { format: ["bunx", "vp", "fmt"] };
34
+ const BUILTIN_CONFIG = { format: ["bunx", "vp", "fmt", "--no-error-on-unmatched-pattern"] };
34
35
  /** The directory of the installed `@sdxc/kit` package, which holds `templates/` and `package.json`. */
35
36
  export function defaultPackageRoot() {
36
37
  return fileURLToPath(new URL("../../", import.meta.url));
@@ -23,7 +23,10 @@ export interface DependencyEdit {
23
23
  version: string;
24
24
  }>;
25
25
  }
26
- /** Every `@sdxc/*` package `files` import, statically or dynamically, sorted. */
26
+ /**
27
+ * Every `@sdxc/*` package `files` import, statically or dynamically, with the optional peers
28
+ * an imported subpath needs at runtime, sorted.
29
+ */
27
30
  export declare function importedPackages(files: readonly SourceText[]): string[];
28
31
  /**
29
32
  * The edit adding to the project at `root` every `@sdxc/*` package `files` import that its
@@ -18,7 +18,17 @@ const LISTING_FIELDS = [
18
18
  "optionalDependencies",
19
19
  "peerDependencies",
20
20
  ];
21
- /** Every `@sdxc/*` package `files` import, statically or dynamically, sorted. */
21
+ /**
22
+ * Optional peers a package subpath imports at runtime: a project importing the subpath lists
23
+ * them itself, since installing the subpath's package leaves its optional peers out.
24
+ */
25
+ const SUBPATH_PEERS = {
26
+ "@sdxc/data-model/testing": ["@sdxc/sample"],
27
+ };
28
+ /**
29
+ * Every `@sdxc/*` package `files` import, statically or dynamically, with the optional peers
30
+ * an imported subpath needs at runtime, sorted.
31
+ */
22
32
  export function importedPackages(files) {
23
33
  let names = new Set();
24
34
  for (let file of files) {
@@ -29,6 +39,8 @@ export function importedPackages(files) {
29
39
  let name = scopedPackageOf(specifier);
30
40
  if (name !== null)
31
41
  names.add(name);
42
+ for (let peer of SUBPATH_PEERS[specifier] ?? [])
43
+ names.add(peer);
32
44
  }
33
45
  }
34
46
  return [...names].sort();
@@ -0,0 +1,49 @@
1
+ /**
2
+ * What `sdxc deploy` shows before it touches production and says when a step fails: the steps
3
+ * it runs, the migrations the app's own `db migrate --remote --pending` lists, and where
4
+ * production stands after a failure, worded from what already ran.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** The steps `sdxc deploy` runs, in order; `--skip` names any of them. */
10
+ export declare const DEPLOY_STEPS: readonly ["build", "migrate", "deploy"];
11
+ /** One of the steps `sdxc deploy` runs. */
12
+ export type DeployStep = (typeof DEPLOY_STEPS)[number];
13
+ /**
14
+ * What the migration step does, as the plan reports it. `unlisted` is an app whose `db migrate`
15
+ * has no `--pending`: its `--remote` run still happens, since applying is safe to repeat.
16
+ */
17
+ export type MigrationStep = {
18
+ status: "pending";
19
+ names: string[];
20
+ } | {
21
+ status: "unlisted";
22
+ } | {
23
+ status: "skipped";
24
+ reason: string;
25
+ };
26
+ /** Everything the confirmation prints. */
27
+ export interface Plan {
28
+ app: string;
29
+ /** `false` when `--skip build` deploys the output an earlier build wrote. */
30
+ build: boolean;
31
+ migrations: MigrationStep;
32
+ deploy: boolean;
33
+ }
34
+ /** The migration names `db migrate --pending` printed, one per line, in the order it applies them. */
35
+ export declare function parsePending(stdout: string): string[];
36
+ /**
37
+ * Whether the app's command line ended with the usage error its parser prints for `kind`, such
38
+ * as `Unknown command "deploy" for blog` or `Unknown flag --pending`.
39
+ *
40
+ * @param error - The failure of a run whose stderr was collected
41
+ * @param kind - The word the message starts with
42
+ */
43
+ export declare function isUnknown(error: Error, kind: "command" | "flag"): boolean;
44
+ /** Whether the migration step applies anything once the plan is confirmed. */
45
+ export declare function migrates(step: MigrationStep): boolean;
46
+ /** The plan as the terminal shows it, one fact per line and one line per pending migration. */
47
+ export declare function formatPlan(plan: Plan): string;
48
+ /** Where production stands when the app's `deploy` fails after the migration step. */
49
+ export declare function deployFailure(step: MigrationStep): string;