@sdxc/kit 2026.10.17 → 2026.10.21

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