@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.
- package/README.md +390 -20
- package/changelog.jsonl +1160 -1092
- package/config.schema.json +47 -1
- package/dist/cli.js +12 -0
- package/dist/commands/deploy.d.ts +23 -0
- package/dist/commands/deploy.js +167 -0
- package/dist/commands/destroy.d.ts +22 -0
- package/dist/commands/destroy.js +92 -0
- package/dist/commands/doctor.d.ts +26 -0
- package/dist/commands/doctor.js +65 -0
- package/dist/commands/initializers.d.ts +16 -0
- package/dist/commands/initializers.js +23 -0
- package/dist/commands/make.d.ts +72 -6
- package/dist/commands/make.js +127 -19
- package/dist/commands/middleware.d.ts +16 -0
- package/dist/commands/middleware.js +21 -0
- package/dist/commands/models.d.ts +18 -0
- package/dist/commands/models.js +29 -0
- package/dist/commands/notes.d.ts +17 -0
- package/dist/commands/notes.js +27 -0
- package/dist/commands/routes.d.ts +25 -0
- package/dist/commands/routes.js +50 -0
- package/dist/commands/run.d.ts +16 -0
- package/dist/commands/run.js +32 -11
- package/dist/commands/scaffold.d.ts +29 -0
- package/dist/commands/scaffold.js +33 -0
- package/dist/commands/schedule.d.ts +16 -0
- package/dist/commands/schedule.js +21 -0
- package/dist/commands/stats.d.ts +16 -0
- package/dist/commands/stats.js +21 -0
- package/dist/commands/ui/update.d.ts +6 -3
- package/dist/commands/ui/update.js +24 -7
- package/dist/commands/upgrade.d.ts +3 -1
- package/dist/commands/upgrade.js +88 -23
- package/dist/config.d.ts +18 -0
- package/dist/config.js +28 -1
- package/dist/contract.d.ts +97 -3
- package/dist/contract.js +360 -26
- package/dist/create/templates.js +3 -2
- package/dist/dependencies.d.ts +4 -1
- package/dist/dependencies.js +13 -1
- package/dist/deploy/plan.d.ts +49 -0
- package/dist/deploy/plan.js +68 -0
- package/dist/destroy.d.ts +40 -0
- package/dist/destroy.js +311 -0
- package/dist/doctor/check.d.ts +71 -0
- package/dist/doctor/check.js +53 -0
- package/dist/doctor/checks.d.ts +23 -0
- package/dist/doctor/checks.js +68 -0
- package/dist/doctor/define.d.ts +59 -0
- package/dist/doctor/define.js +16 -0
- package/dist/doctor/emails.d.ts +18 -0
- package/dist/doctor/emails.js +243 -0
- package/dist/doctor/env.d.ts +26 -0
- package/dist/doctor/env.js +88 -0
- package/dist/doctor/files.d.ts +14 -0
- package/dist/doctor/files.js +34 -0
- package/dist/doctor/fixture.d.ts +23 -0
- package/dist/doctor/fixture.js +46 -0
- package/dist/doctor/install.d.ts +17 -0
- package/dist/doctor/install.js +37 -0
- package/dist/doctor/installed.d.ts +11 -0
- package/dist/doctor/installed.js +79 -0
- package/dist/doctor/layout.d.ts +23 -0
- package/dist/doctor/layout.js +83 -0
- package/dist/doctor/migrations.d.ts +16 -0
- package/dist/doctor/migrations.js +96 -0
- package/dist/doctor/models.d.ts +13 -0
- package/dist/doctor/models.js +69 -0
- package/dist/doctor/pins.d.ts +15 -0
- package/dist/doctor/pins.js +79 -0
- package/dist/doctor/project.d.ts +58 -0
- package/dist/doctor/project.js +261 -0
- package/dist/doctor/remix.d.ts +14 -0
- package/dist/doctor/remix.js +44 -0
- package/dist/doctor/routes.d.ts +11 -0
- package/dist/doctor/routes.js +49 -0
- package/dist/doctor/typegen.d.ts +13 -0
- package/dist/doctor/typegen.js +57 -0
- package/dist/doctor/ui.d.ts +14 -0
- package/dist/doctor/ui.js +51 -0
- package/dist/initializers.d.ts +25 -0
- package/dist/initializers.js +89 -0
- package/dist/lock.d.ts +2 -2
- package/dist/make/actions.d.ts +23 -0
- package/dist/make/actions.js +82 -0
- package/dist/make/declare.d.ts +31 -3
- package/dist/make/declare.js +284 -9
- package/dist/make/email.d.ts +23 -0
- package/dist/make/email.js +111 -0
- package/dist/make/from-fields.d.ts +30 -0
- package/dist/make/from-fields.js +162 -0
- package/dist/make/from-model.d.ts +39 -0
- package/dist/make/from-model.js +161 -0
- package/dist/make/generate.d.ts +16 -5
- package/dist/make/generate.js +38 -15
- package/dist/make/guard.d.ts +35 -0
- package/dist/make/guard.js +73 -0
- package/dist/make/imports.d.ts +6 -0
- package/dist/make/imports.js +19 -0
- package/dist/make/index.d.ts +47 -4
- package/dist/make/index.js +287 -29
- package/dist/make/kinds.d.ts +29 -2
- package/dist/make/kinds.js +79 -7
- package/dist/make/mount.d.ts +25 -0
- package/dist/make/mount.js +135 -0
- package/dist/make/schema-diff.d.ts +58 -0
- package/dist/make/schema-diff.js +609 -0
- package/dist/make/schema.d.ts +76 -0
- package/dist/make/schema.js +206 -0
- package/dist/make/stubs.d.ts +7 -5
- package/dist/make/stubs.js +16 -5
- package/dist/make/test.d.ts +43 -0
- package/dist/make/test.js +149 -0
- package/dist/make/trigger.d.ts +31 -0
- package/dist/make/trigger.js +163 -0
- package/dist/models.d.ts +42 -0
- package/dist/models.js +149 -0
- package/dist/notes.d.ts +28 -0
- package/dist/notes.js +66 -0
- package/dist/reference.d.ts +27 -0
- package/dist/reference.js +103 -0
- package/dist/releases.d.ts +9 -0
- package/dist/releases.js +29 -8
- package/dist/routes/chains.d.ts +34 -0
- package/dist/routes/chains.js +95 -0
- package/dist/routes/filter.d.ts +53 -0
- package/dist/routes/filter.js +147 -0
- package/dist/routes/format.d.ts +23 -0
- package/dist/routes/format.js +123 -0
- package/dist/routes/helpers.d.ts +21 -0
- package/dist/routes/helpers.js +165 -0
- package/dist/routes/index.d.ts +56 -0
- package/dist/routes/index.js +167 -0
- package/dist/routes/modules.d.ts +116 -0
- package/dist/routes/modules.js +235 -0
- package/dist/routes/parse.d.ts +161 -0
- package/dist/routes/parse.js +621 -0
- package/dist/routes/routers.d.ts +69 -0
- package/dist/routes/routers.js +327 -0
- package/dist/scaffold/fields.d.ts +129 -0
- package/dist/scaffold/fields.js +421 -0
- package/dist/scaffold/index.d.ts +37 -0
- package/dist/scaffold/index.js +613 -0
- package/dist/scaffold/render.d.ts +51 -0
- package/dist/scaffold/render.js +332 -0
- package/dist/schedule.d.ts +45 -0
- package/dist/schedule.js +124 -0
- package/dist/stats.d.ts +37 -0
- package/dist/stats.js +126 -0
- package/dist/ui/commands.d.ts +10 -3
- package/dist/ui/commands.js +85 -15
- package/dist/ui/registry.d.ts +8 -8
- package/dist/upgrade/agents.d.ts +49 -0
- package/dist/upgrade/agents.js +110 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +4 -0
- package/dist/upgrade/project.js +11 -1
- package/dist/upgrade/prompt.d.ts +11 -0
- package/dist/upgrade/prompt.js +50 -7
- package/package.json +6 -4
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/color-picker.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/file-trigger.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/message-scroller.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/resizable.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/stubs/controller.api.resource.stub +23 -0
- package/stubs/controller.form.stub +2 -2
- package/stubs/controller.form.test.stub +2 -2
- package/stubs/controller.resource.form.stub +67 -0
- package/stubs/controller.resource.stub +28 -0
- package/stubs/email.stub +9 -14
- package/stubs/email.test.stub +9 -9
- package/stubs/factory.stub +1 -1
- package/stubs/model.stub +3 -3
- package/stubs/policy.test.stub +34 -8
- package/stubs/scaffold.api.create.stub +34 -0
- package/stubs/scaffold.api.create.test.stub +37 -0
- package/stubs/scaffold.api.destroy.stub +34 -0
- package/stubs/scaffold.api.destroy.test.stub +44 -0
- package/stubs/scaffold.api.index.stub +23 -0
- package/stubs/scaffold.api.index.test.stub +31 -0
- package/stubs/scaffold.api.show.stub +27 -0
- package/stubs/scaffold.api.show.test.stub +41 -0
- package/stubs/scaffold.api.update.stub +44 -0
- package/stubs/scaffold.api.update.test.stub +46 -0
- package/stubs/scaffold.command.create.stub +22 -0
- package/stubs/scaffold.command.create.test.stub +30 -0
- package/stubs/scaffold.command.delete.stub +20 -0
- package/stubs/scaffold.command.delete.test.stub +39 -0
- package/stubs/scaffold.command.list.stub +18 -0
- package/stubs/scaffold.command.list.test.stub +31 -0
- package/stubs/scaffold.command.show.stub +19 -0
- package/stubs/scaffold.command.show.test.stub +37 -0
- package/stubs/scaffold.controller.destroy.stub +35 -0
- package/stubs/scaffold.controller.destroy.test.stub +65 -0
- package/stubs/scaffold.controller.edit.stub +97 -0
- package/stubs/scaffold.controller.edit.test.stub +91 -0
- package/stubs/scaffold.controller.index.stub +55 -0
- package/stubs/scaffold.controller.index.test.stub +32 -0
- package/stubs/scaffold.controller.new.stub +70 -0
- package/stubs/scaffold.controller.new.test.stub +81 -0
- package/stubs/scaffold.controller.show.stub +59 -0
- package/stubs/scaffold.controller.show.test.stub +43 -0
- package/stubs/scaffold.factory.stub +16 -0
- package/stubs/scaffold.form.stub +75 -0
- package/stubs/scaffold.mcp.create.stub +24 -0
- package/stubs/scaffold.mcp.create.test.stub +36 -0
- package/stubs/scaffold.mcp.delete.stub +31 -0
- package/stubs/scaffold.mcp.delete.test.stub +43 -0
- package/stubs/scaffold.mcp.get.stub +21 -0
- package/stubs/scaffold.mcp.get.test.stub +31 -0
- package/stubs/scaffold.mcp.list.stub +23 -0
- package/stubs/scaffold.mcp.list.test.stub +25 -0
- package/stubs/scaffold.mcp.update.stub +37 -0
- package/stubs/scaffold.mcp.update.test.stub +40 -0
- package/stubs/scaffold.migration.stub +2 -0
- package/stubs/scaffold.model.stub +35 -0
- package/stubs/scaffold.model.test.stub +25 -0
- package/stubs/scaffold.test-database.stub +33 -0
- package/stubs/scaffold.test-mcp.stub +92 -0
- package/stubs/scaffold.validator.stub +18 -0
- package/stubs/scaffold.validator.test.stub +26 -0
- package/templates/app/AGENTS.md +163 -0
- package/templates/app/CLAUDE.md +1 -0
- package/templates/app/README.md +28 -13
- package/templates/app/app/commands/console.test.ts +26 -0
- package/templates/app/app/commands/console.ts +19 -0
- package/templates/app/app/commands/db/fresh.test.ts +57 -0
- package/templates/app/app/commands/db/fresh.ts +37 -0
- package/templates/app/app/commands/db/migrate.test.ts +17 -1
- package/templates/app/app/commands/db/migrate.ts +51 -18
- package/templates/app/app/commands/db/prepare.test.ts +39 -0
- package/templates/app/app/commands/db/prepare.ts +35 -0
- package/templates/app/app/commands/db/seed.test.ts +38 -0
- package/templates/app/app/commands/db/seed.ts +26 -0
- package/templates/app/app/commands/deploy.test.ts +34 -0
- package/templates/app/app/commands/deploy.ts +18 -0
- package/templates/app/app/commands/emails/preview.test.tsx +63 -0
- package/templates/app/app/commands/emails/preview.ts +24 -0
- package/templates/app/app/commands/index.ts +57 -2
- package/templates/app/app/emails/index.ts +10 -0
- package/templates/app/app/http/middleware/access.test.ts +43 -0
- package/templates/app/app/http/middleware/access.ts +41 -0
- package/templates/app/app/http/middleware/api.ts +12 -3
- package/templates/app/app/http/middleware/page.test.ts +4 -1
- package/templates/app/app/http/middleware/page.ts +7 -5
- package/templates/app/app/initializers/cli.ts +28 -2
- package/templates/app/app/initializers/dispatcher.ts +9 -1
- package/templates/app/app/initializers/mail-transport.test.ts +27 -0
- package/templates/app/app/initializers/mail-transport.ts +26 -0
- package/templates/app/app/initializers/mail.test.ts +17 -17
- package/templates/app/app/initializers/mail.ts +15 -7
- package/templates/app/app/initializers/router.test.ts +7 -0
- package/templates/app/app/initializers/router.tsx +13 -3
- package/templates/app/app/jobs/email.test.tsx +70 -0
- package/templates/app/app/jobs/email.ts +16 -0
- package/templates/app/app/jobs/index.ts +6 -2
- package/templates/app/app/policies/abilities.ts +13 -0
- package/templates/app/app/policies/policy.test.ts +15 -0
- package/templates/app/app/policies/policy.ts +30 -0
- package/templates/app/app/services/commands.ts +30 -0
- package/templates/app/app/services/migrations.test.ts +48 -1
- package/templates/app/app/services/migrations.ts +66 -9
- package/templates/app/app/test/local-database.ts +67 -0
- package/templates/app/app/test/session.ts +28 -0
- package/templates/app/bootstrap/console.ts +13 -0
- package/templates/app/cloudflare.config.ts +3 -3
- package/templates/app/database/seed.ts +12 -0
- package/templates/app/package.json +2 -1
- 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 {
|
|
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: [
|
|
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: {
|
|
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: {
|
|
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: {
|
|
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: "
|
|
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", "
|
|
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: {
|
|
190
|
-
|
|
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
|
|
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(), {
|
|
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",
|
package/dist/create/templates.js
CHANGED
|
@@ -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));
|
package/dist/dependencies.d.ts
CHANGED
|
@@ -23,7 +23,10 @@ export interface DependencyEdit {
|
|
|
23
23
|
version: string;
|
|
24
24
|
}>;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
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
|
package/dist/dependencies.js
CHANGED
|
@@ -18,7 +18,17 @@ const LISTING_FIELDS = [
|
|
|
18
18
|
"optionalDependencies",
|
|
19
19
|
"peerDependencies",
|
|
20
20
|
];
|
|
21
|
-
/**
|
|
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;
|