@sdxc/kit 2026.10.20 → 2026.10.23
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 +178 -93
- package/changelog.jsonl +97 -0
- package/config.schema.json +160 -0
- package/dist/architecture/complexity.d.ts +73 -0
- package/dist/architecture/complexity.js +185 -0
- package/dist/architecture/crap.d.ts +62 -0
- package/dist/architecture/crap.js +121 -0
- package/dist/architecture/graph.d.ts +55 -0
- package/dist/architecture/graph.js +194 -0
- package/dist/architecture/layers.d.ts +29 -0
- package/dist/architecture/layers.js +81 -0
- package/dist/architecture/mermaid.d.ts +20 -0
- package/dist/architecture/mermaid.js +51 -0
- package/dist/cli.js +9 -0
- package/dist/commands/create.js +4 -3
- package/dist/commands/deploy.js +10 -9
- package/dist/commands/destroy.d.ts +1 -1
- package/dist/commands/diagram.d.ts +17 -0
- package/dist/commands/diagram.js +45 -0
- package/dist/commands/fix.d.ts +69 -0
- package/dist/commands/fix.js +102 -0
- package/dist/commands/make.d.ts +77 -2
- package/dist/commands/make.js +53 -1
- package/dist/commands/run.d.ts +15 -11
- package/dist/commands/run.js +21 -16
- package/dist/commands/scaffold.d.ts +2 -1
- package/dist/commands/scaffold.js +1 -0
- package/dist/commands/setup.d.ts +26 -0
- package/dist/commands/setup.js +33 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.js +92 -1
- package/dist/contract.d.ts +56 -3
- package/dist/contract.js +140 -7
- package/dist/dependencies.d.ts +2 -1
- package/dist/dependencies.js +11 -2
- package/dist/deploy/plan.d.ts +5 -0
- package/dist/deploy/plan.js +10 -0
- package/dist/destroy.d.ts +4 -4
- package/dist/destroy.js +24 -11
- package/dist/diagram.d.ts +32 -0
- package/dist/diagram.js +47 -0
- package/dist/doctor/checks.d.ts +2 -1
- package/dist/doctor/checks.js +26 -1
- package/dist/doctor/complexity.d.ts +13 -0
- package/dist/doctor/complexity.js +52 -0
- package/dist/doctor/crap.d.ts +14 -0
- package/dist/doctor/crap.js +67 -0
- package/dist/doctor/dependencies.d.ts +13 -0
- package/dist/doctor/dependencies.js +42 -0
- package/dist/doctor/duplication.d.ts +19 -0
- package/dist/doctor/duplication.js +106 -0
- package/dist/doctor/fan-out.d.ts +12 -0
- package/dist/doctor/fan-out.js +42 -0
- package/dist/doctor/feature-scatter.d.ts +15 -0
- package/dist/doctor/feature-scatter.js +84 -0
- package/dist/doctor/jsdoc.d.ts +44 -0
- package/dist/doctor/jsdoc.js +201 -0
- package/dist/doctor/module-size.d.ts +13 -0
- package/dist/doctor/module-size.js +50 -0
- package/dist/doctor/mutation.d.ts +20 -0
- package/dist/doctor/mutation.js +97 -0
- package/dist/doctor/orphans.d.ts +13 -0
- package/dist/doctor/orphans.js +50 -0
- package/dist/doctor/project.js +8 -5
- package/dist/doctor/result-throws.d.ts +17 -0
- package/dist/doctor/result-throws.js +72 -0
- package/dist/doctor/test-ratio.d.ts +12 -0
- package/dist/doctor/test-ratio.js +31 -0
- package/dist/fix/commands.d.ts +37 -0
- package/dist/fix/commands.js +63 -0
- package/dist/fix/emails.d.ts +21 -0
- package/dist/fix/emails.js +159 -0
- package/dist/fix/env.d.ts +29 -0
- package/dist/fix/env.js +58 -0
- package/dist/fix/index.d.ts +11 -0
- package/dist/fix/index.js +11 -0
- package/dist/fix/models.d.ts +20 -0
- package/dist/fix/models.js +95 -0
- package/dist/lock.js +12 -2
- package/dist/make/binding.d.ts +42 -0
- package/dist/make/binding.js +237 -0
- package/dist/make/generate.d.ts +11 -2
- package/dist/make/generate.js +47 -16
- package/dist/make/imports.js +7 -5
- package/dist/make/index.d.ts +4 -2
- package/dist/make/index.js +4 -1
- package/dist/make/kinds.d.ts +5 -0
- package/dist/make/kinds.js +14 -2
- package/dist/make/schema-diff.js +8 -1
- package/dist/make/stubs.d.ts +7 -2
- package/dist/make/stubs.js +8 -3
- package/dist/make/test.js +1 -0
- package/dist/models.js +7 -7
- package/dist/routes/modules.js +8 -5
- package/dist/routes/parse.js +8 -7
- package/dist/routes/routers.js +9 -5
- package/dist/scaffold/index.d.ts +2 -0
- package/dist/scaffold/index.js +13 -4
- package/dist/scaffold/render.d.ts +11 -1
- package/dist/scaffold/render.js +86 -1
- package/dist/setup/auth.d.ts +12 -0
- package/dist/setup/auth.js +209 -0
- package/dist/setup/billing.d.ts +11 -0
- package/dist/setup/billing.js +116 -0
- package/dist/setup/catalog.d.ts +25 -0
- package/dist/setup/catalog.js +34 -0
- package/dist/setup/credit.d.ts +13 -0
- package/dist/setup/credit.js +21 -0
- package/dist/setup/flags.d.ts +11 -0
- package/dist/setup/flags.js +62 -0
- package/dist/setup/index.d.ts +25 -0
- package/dist/setup/index.js +53 -0
- package/dist/setup/plan.d.ts +38 -0
- package/dist/setup/plan.js +62 -0
- package/dist/testing.js +3 -3
- package/dist/ui/layout.js +1 -1
- package/dist/ui/registry.d.ts +2 -2
- package/dist/upgrade/project.d.ts +2 -2
- package/dist/upgrade/prompt.js +7 -5
- package/package.json +10 -7
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/sidebar.json +3 -3
- package/registry/ui/typeset.json +3 -3
- package/stubs/command.spec.stub +15 -0
- package/stubs/controller.api.spec.stub +15 -0
- package/stubs/controller.spec.stub +15 -0
- package/stubs/mcp.spec.stub +16 -0
- package/stubs/scaffold.migration.stub +2 -1
- package/stubs/scaffold.spec.stub +7 -0
- package/templates/app/AGENTS.md +21 -4
- package/templates/app/README.md +6 -3
- package/templates/app/app/commands/typegen.test.ts +20 -1
- package/templates/app/app/commands/typegen.ts +16 -2
- package/templates/app/app/initializers/cli.ts +7 -0
- package/templates/app/app/initializers/mail-transport.test.ts +8 -2
- package/templates/app/app/test/cloudflare-workers.ts +2 -0
- package/templates/app/package.json +1 -0
- package/templates/app/spec/config.jsonc +16 -0
package/dist/contract.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
22
22
|
readonly skip: import("@sdxc/cli").ValueFlag<"build" | "migrate" | "deploy", false, true, false>;
|
|
23
23
|
}>;
|
|
24
24
|
readonly destroy: import("@sdxc/cli").Command<{
|
|
25
|
-
readonly kind: import("@sdxc/cli").Argument<"email" | "command" | "
|
|
25
|
+
readonly kind: import("@sdxc/cli").Argument<"email" | "command" | "model" | "service" | "controller" | "middleware" | "validator" | "job" | "factory" | "initializer" | "mcp">;
|
|
26
26
|
readonly name: import("@sdxc/cli").Argument<string>;
|
|
27
27
|
}, {
|
|
28
28
|
readonly yes: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -34,6 +34,23 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
34
34
|
readonly only: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
35
35
|
readonly skip: import("@sdxc/cli").ValueFlag<string, false, true, false>;
|
|
36
36
|
}>;
|
|
37
|
+
readonly fix: import("@sdxc/cli").Group<Omit<{
|
|
38
|
+
readonly description: "Apply doctor repairs the kit can make safely";
|
|
39
|
+
readonly flags: {
|
|
40
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
41
|
+
};
|
|
42
|
+
readonly env: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
43
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
44
|
+
}>;
|
|
45
|
+
readonly models: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
46
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
47
|
+
}>;
|
|
48
|
+
readonly emails: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
49
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
50
|
+
}>;
|
|
51
|
+
}, "description" | "hidden" | "arguments" | "flags" | "tasks">, Record<never, never>, {
|
|
52
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
53
|
+
}>;
|
|
37
54
|
readonly init: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
38
55
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
39
56
|
}>;
|
|
@@ -59,8 +76,9 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
59
76
|
readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
60
77
|
readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
61
78
|
readonly resource: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
62
|
-
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "
|
|
79
|
+
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "new" | "all" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
|
|
63
80
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
81
|
+
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
64
82
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
65
83
|
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
66
84
|
}>;
|
|
@@ -145,6 +163,7 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
145
163
|
}, {
|
|
146
164
|
readonly resource: import("@sdxc/cli").Flag<boolean>;
|
|
147
165
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
166
|
+
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
148
167
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
149
168
|
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
150
169
|
}>;
|
|
@@ -152,6 +171,7 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
152
171
|
readonly name: import("@sdxc/cli").Argument<string>;
|
|
153
172
|
}, {
|
|
154
173
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
174
|
+
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
155
175
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
156
176
|
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
157
177
|
}>;
|
|
@@ -164,6 +184,27 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
164
184
|
readonly stubs: import("@sdxc/cli").Command<{
|
|
165
185
|
readonly kinds: import("@sdxc/cli").Argument<(import("./make/kinds.js").KindName | "scaffold")[]>;
|
|
166
186
|
}, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>;
|
|
187
|
+
readonly secret: import("@sdxc/cli").Command<{
|
|
188
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
189
|
+
}, {
|
|
190
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
191
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
192
|
+
}>;
|
|
193
|
+
readonly binding: import("@sdxc/cli").Command<{
|
|
194
|
+
readonly kind: import("@sdxc/cli").Argument<"secret" | "kv" | "d1" | "r2" | "queue" | "rateLimit" | "sendEmail" | "durableObject">;
|
|
195
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
196
|
+
}, {
|
|
197
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
198
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
199
|
+
}>;
|
|
200
|
+
readonly do: import("@sdxc/cli").Command<{
|
|
201
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
202
|
+
}, {
|
|
203
|
+
readonly role: import("@sdxc/cli").ValueFlag<"model" | "service", true, false, false>;
|
|
204
|
+
readonly binding: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
205
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
206
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
207
|
+
}>;
|
|
167
208
|
}, "description" | "hidden" | "arguments" | "flags" | "tasks">, {
|
|
168
209
|
readonly kind: import("@sdxc/cli").Argument<import("./make/kinds.js").KindName>;
|
|
169
210
|
readonly name: import("@sdxc/cli").Argument<string>;
|
|
@@ -206,16 +247,28 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
206
247
|
readonly mcp: import("@sdxc/cli").Flag<boolean>;
|
|
207
248
|
readonly command: import("@sdxc/cli").Flag<boolean>;
|
|
208
249
|
readonly api: import("@sdxc/cli").Flag<boolean>;
|
|
209
|
-
readonly skip: import("@sdxc/cli").ValueFlag<"
|
|
250
|
+
readonly skip: import("@sdxc/cli").ValueFlag<"model" | "validator" | "migration" | "factory" | "policy" | "pages", false, true, false>;
|
|
210
251
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
252
|
+
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
211
253
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
212
254
|
}>;
|
|
213
255
|
readonly schedule: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
214
256
|
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
215
257
|
}>;
|
|
258
|
+
readonly setup: import("@sdxc/cli").Command<{
|
|
259
|
+
readonly feature: import("@sdxc/cli").Argument<string | undefined>;
|
|
260
|
+
}, {
|
|
261
|
+
readonly provider: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
262
|
+
readonly yes: import("@sdxc/cli").Flag<boolean>;
|
|
263
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
264
|
+
}>;
|
|
216
265
|
readonly stats: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
217
266
|
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
218
267
|
}>;
|
|
268
|
+
readonly diagram: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
269
|
+
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
270
|
+
readonly svg: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
271
|
+
}>;
|
|
219
272
|
readonly ui: import("@sdxc/cli").Group<Omit<{
|
|
220
273
|
readonly description: "Copy @sdxc/ui components into the project and keep imports on the copies";
|
|
221
274
|
readonly list: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>;
|
package/dist/contract.js
CHANGED
|
@@ -10,10 +10,14 @@ 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
12
|
import { DEPLOY_STEPS } from "./deploy/plan.js";
|
|
13
|
+
import { BINDING_KINDS } from "./make/binding.js";
|
|
13
14
|
import { ACTION_NAMES, DESTROY_KINDS, KINDS, MODEL_COMPANIONS, SCAFFOLD_PIECES, } from "./make/kinds.js";
|
|
14
15
|
import { DEFAULT_TAGS } from "./notes.js";
|
|
15
16
|
import { ROUTE_SORTS } from "./routes/filter.js";
|
|
16
17
|
import { FIELD_TYPE_NAMES } from "./scaffold/fields.js";
|
|
18
|
+
import { SETUP_FEATURES } from "./setup/catalog.js";
|
|
19
|
+
/** Feature names `sdxc setup` accepts, as a non-empty tuple for the argument schema. */
|
|
20
|
+
const SETUP_FEATURE_NAMES = SETUP_FEATURES.map((feature) => feature.name);
|
|
17
21
|
/** Route methods `make controller --method` accepts; `form` declares a GET page with a POST action. */
|
|
18
22
|
export const METHODS = ["get", "post", "put", "patch", "delete", "form"];
|
|
19
23
|
/** Every kind `sdxc make` writes, in the order its help lists them. */
|
|
@@ -54,16 +58,24 @@ const TEST_FLAG = flag.boolean("test", {
|
|
|
54
58
|
default: undefined,
|
|
55
59
|
description: "Write a test beside the file, or skip it with --no-test (default: make.tests)",
|
|
56
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* `--spec` / `--no-spec`, for kinds that write a pairing `.spec` under `spec/`; unset, it takes
|
|
63
|
+
* `make.specs`.
|
|
64
|
+
*/
|
|
65
|
+
const SPEC_FLAG = flag.boolean("spec", {
|
|
66
|
+
default: undefined,
|
|
67
|
+
description: "Write a pairing .spec under spec/, or skip it with --no-spec (default: make.specs)",
|
|
68
|
+
});
|
|
57
69
|
/** `--dry-run`, shared by every command that can print what it would write instead. */
|
|
58
70
|
const DRY_RUN_FLAG = flag.boolean("dry-run", {
|
|
59
71
|
description: "Print what would be written and change nothing",
|
|
60
72
|
});
|
|
61
73
|
/**
|
|
62
|
-
* `--force`, shared by every kind whose file takes its own name: an existing file
|
|
63
|
-
* are replaced, and the declaration and mapping they already have are kept.
|
|
74
|
+
* `--force`, shared by every kind whose file takes its own name: an existing file, its test and
|
|
75
|
+
* its pairing `.spec` are replaced, and the declaration and mapping they already have are kept.
|
|
64
76
|
*/
|
|
65
77
|
const FORCE_FLAG = flag.boolean("force", {
|
|
66
|
-
description: "Replace the file and its
|
|
78
|
+
description: "Replace the file, its test and its pairing .spec when they exist, keeping their declaration",
|
|
67
79
|
});
|
|
68
80
|
/** Every command `sdxc` takes. */
|
|
69
81
|
export const SDXC_COMMANDS = commands({
|
|
@@ -121,7 +133,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
121
133
|
],
|
|
122
134
|
}),
|
|
123
135
|
destroy: command({
|
|
124
|
-
description: "Remove a file sdxc make wrote, its test, its mapping and its declaration",
|
|
136
|
+
description: "Remove a file sdxc make wrote, its test, its pairing .spec, its mapping and its declaration",
|
|
125
137
|
arguments: {
|
|
126
138
|
kind: argument(s.enum_(DESTROY_KINDS), {
|
|
127
139
|
description: "What to remove; every make kind but migration and policy",
|
|
@@ -147,7 +159,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
147
159
|
],
|
|
148
160
|
}),
|
|
149
161
|
doctor: command({
|
|
150
|
-
description: "Lint release drift, secrets, migrations, app layout and project checks",
|
|
162
|
+
description: "Lint release drift, secrets, migrations, app layout, complexity and project checks",
|
|
151
163
|
flags: {
|
|
152
164
|
json: flag.boolean("json", { description: "Print the report as JSON for an agent" }),
|
|
153
165
|
only: flag
|
|
@@ -161,6 +173,25 @@ export const SDXC_COMMANDS = commands({
|
|
|
161
173
|
},
|
|
162
174
|
examples: ["doctor", "doctor --json", "doctor --only pins,remix", "doctor --skip ui"],
|
|
163
175
|
}),
|
|
176
|
+
fix: commands({
|
|
177
|
+
description: "Apply doctor repairs the kit can make safely",
|
|
178
|
+
flags: { dryRun: DRY_RUN_FLAG },
|
|
179
|
+
env: command({
|
|
180
|
+
description: "Append missing bindings.secret() keys to .env.example",
|
|
181
|
+
flags: { dryRun: DRY_RUN_FLAG },
|
|
182
|
+
examples: ["fix env", "fix env --dry-run"],
|
|
183
|
+
}),
|
|
184
|
+
models: command({
|
|
185
|
+
description: "Register unmapped createModel modules in app/models/index.ts",
|
|
186
|
+
flags: { dryRun: DRY_RUN_FLAG },
|
|
187
|
+
examples: ["fix models", "fix models --dry-run"],
|
|
188
|
+
}),
|
|
189
|
+
emails: command({
|
|
190
|
+
description: "Map unmapped emails in app/initializers/mail.ts",
|
|
191
|
+
flags: { dryRun: DRY_RUN_FLAG },
|
|
192
|
+
examples: ["fix emails", "fix emails --dry-run"],
|
|
193
|
+
}),
|
|
194
|
+
}),
|
|
164
195
|
init: command({
|
|
165
196
|
description: "Write .config/sdxc.jsonc with every default spelled out",
|
|
166
197
|
flags: { dryRun: flag.boolean("dry-run", { description: "Print it and write nothing" }) },
|
|
@@ -214,6 +245,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
214
245
|
})
|
|
215
246
|
.list(),
|
|
216
247
|
test: TEST_FLAG,
|
|
248
|
+
spec: SPEC_FLAG,
|
|
217
249
|
dryRun: DRY_RUN_FLAG,
|
|
218
250
|
force: FORCE_FLAG,
|
|
219
251
|
},
|
|
@@ -360,6 +392,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
360
392
|
description: "A resource in app/mcp/resources instead of a tool",
|
|
361
393
|
}),
|
|
362
394
|
test: TEST_FLAG,
|
|
395
|
+
spec: SPEC_FLAG,
|
|
363
396
|
dryRun: DRY_RUN_FLAG,
|
|
364
397
|
force: FORCE_FLAG,
|
|
365
398
|
},
|
|
@@ -368,7 +401,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
368
401
|
description: "A command-line command in app/commands, declared and mapped",
|
|
369
402
|
tasks: true,
|
|
370
403
|
arguments: { name: nameArgument("command", "users/grant") },
|
|
371
|
-
flags: { test: TEST_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
|
|
404
|
+
flags: { test: TEST_FLAG, spec: SPEC_FLAG, dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
|
|
372
405
|
examples: ["make command users/grant"],
|
|
373
406
|
}),
|
|
374
407
|
test: command({
|
|
@@ -399,6 +432,65 @@ export const SDXC_COMMANDS = commands({
|
|
|
399
432
|
}),
|
|
400
433
|
},
|
|
401
434
|
}),
|
|
435
|
+
secret: command({
|
|
436
|
+
description: "Declare a bindings.secret() in cloudflare.config.ts and append .env.example",
|
|
437
|
+
tasks: true,
|
|
438
|
+
arguments: {
|
|
439
|
+
name: argument(nonEmpty("Name it"), {
|
|
440
|
+
valueName: "NAME",
|
|
441
|
+
description: "The binding key, SCREAMING_SNAKE or kebab-case",
|
|
442
|
+
prompt: prompt.text({
|
|
443
|
+
message: "What should the secret be called?",
|
|
444
|
+
placeholder: "API_KEY",
|
|
445
|
+
}),
|
|
446
|
+
}),
|
|
447
|
+
},
|
|
448
|
+
flags: { dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
|
|
449
|
+
examples: ["make secret API_KEY", "make secret api-key --dry-run"],
|
|
450
|
+
}),
|
|
451
|
+
binding: command({
|
|
452
|
+
description: "Declare a Cloudflare binding in cloudflare.config.ts",
|
|
453
|
+
tasks: true,
|
|
454
|
+
arguments: {
|
|
455
|
+
kind: argument(s.enum_(BINDING_KINDS), {
|
|
456
|
+
description: `The bindings helper: ${BINDING_KINDS.join(", ")}`,
|
|
457
|
+
}),
|
|
458
|
+
name: argument(nonEmpty("Name it"), {
|
|
459
|
+
valueName: "NAME",
|
|
460
|
+
description: "The binding key, SCREAMING_SNAKE or kebab-case",
|
|
461
|
+
}),
|
|
462
|
+
},
|
|
463
|
+
flags: { dryRun: DRY_RUN_FLAG, force: FORCE_FLAG },
|
|
464
|
+
examples: ["make binding kv CACHE", "make binding secret API_KEY"],
|
|
465
|
+
}),
|
|
466
|
+
do: command({
|
|
467
|
+
description: "Write a Durable Object class, re-export it from bootstrap/worker.ts, and declare its binding",
|
|
468
|
+
tasks: true,
|
|
469
|
+
arguments: {
|
|
470
|
+
name: argument(nonEmpty("Name it"), {
|
|
471
|
+
description: "The class name, such as Feed or geo-fetch",
|
|
472
|
+
prompt: prompt.text({
|
|
473
|
+
message: "What should the Durable Object be called?",
|
|
474
|
+
placeholder: "Feed",
|
|
475
|
+
}),
|
|
476
|
+
}),
|
|
477
|
+
},
|
|
478
|
+
flags: {
|
|
479
|
+
role: flag.string("role", {
|
|
480
|
+
valueName: "role",
|
|
481
|
+
schema: s.enum_(["model", "service"]),
|
|
482
|
+
default: "service",
|
|
483
|
+
description: "app/models when it owns stored state, app/services otherwise (default: service)",
|
|
484
|
+
}),
|
|
485
|
+
binding: flag.string("binding", {
|
|
486
|
+
valueName: "NAME",
|
|
487
|
+
description: "The env binding key (default: derived from the class name)",
|
|
488
|
+
}),
|
|
489
|
+
dryRun: DRY_RUN_FLAG,
|
|
490
|
+
force: FORCE_FLAG,
|
|
491
|
+
},
|
|
492
|
+
examples: ["make do Feed --role model", "make do geo-fetch --binding GEO_FETCH"],
|
|
493
|
+
}),
|
|
402
494
|
}),
|
|
403
495
|
middleware: command({
|
|
404
496
|
description: "Print each router's global middleware and every chain in app/http/middleware",
|
|
@@ -483,7 +575,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
483
575
|
],
|
|
484
576
|
}),
|
|
485
577
|
run: command({
|
|
486
|
-
description: "Run the project's own command line, bootstrap/cli.ts
|
|
578
|
+
description: "Run the project's own command line (run.entry, default bootstrap/cli.ts)",
|
|
487
579
|
arguments: {
|
|
488
580
|
args: argument.rest({
|
|
489
581
|
valueName: "command",
|
|
@@ -527,6 +619,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
527
619
|
})
|
|
528
620
|
.list(),
|
|
529
621
|
test: TEST_FLAG,
|
|
622
|
+
spec: SPEC_FLAG,
|
|
530
623
|
dryRun: DRY_RUN_FLAG,
|
|
531
624
|
},
|
|
532
625
|
examples: [
|
|
@@ -541,11 +634,51 @@ export const SDXC_COMMANDS = commands({
|
|
|
541
634
|
flags: { json: flag.boolean("json", { description: "Print the schedule as JSON" }) },
|
|
542
635
|
examples: ["schedule", "schedule --json"],
|
|
543
636
|
}),
|
|
637
|
+
setup: command({
|
|
638
|
+
description: "Install a multi-file feature (auth, billing, flags); lists known features with no name",
|
|
639
|
+
arguments: {
|
|
640
|
+
feature: argument(s.enum_(SETUP_FEATURE_NAMES), {
|
|
641
|
+
optional: true,
|
|
642
|
+
description: "The feature to install; lists the catalog when left out",
|
|
643
|
+
}),
|
|
644
|
+
},
|
|
645
|
+
flags: {
|
|
646
|
+
provider: flag.string("provider", {
|
|
647
|
+
valueName: "provider",
|
|
648
|
+
description: "Backend for features that vary (auth: r3-auth; billing: polar)",
|
|
649
|
+
}),
|
|
650
|
+
yes: flag.boolean("yes", {
|
|
651
|
+
short: "y",
|
|
652
|
+
description: "Write the plan; without it the plan is printed and nothing changes",
|
|
653
|
+
}),
|
|
654
|
+
dryRun: DRY_RUN_FLAG,
|
|
655
|
+
},
|
|
656
|
+
examples: [
|
|
657
|
+
"setup",
|
|
658
|
+
"setup auth",
|
|
659
|
+
"setup auth --provider r3-auth -y",
|
|
660
|
+
"setup billing --provider polar --dry-run",
|
|
661
|
+
"setup flags -y",
|
|
662
|
+
],
|
|
663
|
+
}),
|
|
544
664
|
stats: command({
|
|
545
665
|
description: "Count lines of code per kind of code the app layout names, and the test ratio",
|
|
546
666
|
flags: { json: flag.boolean("json", { description: "Print the counts as JSON" }) },
|
|
547
667
|
examples: ["stats", "stats --json"],
|
|
548
668
|
}),
|
|
669
|
+
diagram: command({
|
|
670
|
+
description: "Draw the project's layer architecture as Mermaid, or as SVG through @sdxc/diagram",
|
|
671
|
+
flags: {
|
|
672
|
+
json: flag.boolean("json", {
|
|
673
|
+
description: "Print the import graph as JSON instead of Mermaid",
|
|
674
|
+
}),
|
|
675
|
+
svg: flag.string("svg", {
|
|
676
|
+
valueName: "path",
|
|
677
|
+
description: "Write an SVG drawing to this path (relative to the project root) via @sdxc/diagram",
|
|
678
|
+
}),
|
|
679
|
+
},
|
|
680
|
+
examples: ["diagram", "diagram --json", "diagram --svg architecture.svg"],
|
|
681
|
+
}),
|
|
549
682
|
ui: commands({
|
|
550
683
|
description: "Copy @sdxc/ui components into the project and keep imports on the copies",
|
|
551
684
|
list: command({ description: "Every component, marking copies that are edited or behind" }),
|
package/dist/dependencies.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export interface DependencyEdit {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Every `@sdxc/*` package `files` import, statically or dynamically, with the optional peers
|
|
28
|
-
* an imported subpath needs at runtime,
|
|
28
|
+
* an imported subpath needs at runtime, and `@sdxc/spec` when any file is a pairing `.spec`,
|
|
29
|
+
* sorted.
|
|
29
30
|
*/
|
|
30
31
|
export declare function importedPackages(files: readonly SourceText[]): string[];
|
|
31
32
|
/**
|
package/dist/dependencies.js
CHANGED
|
@@ -27,11 +27,14 @@ const SUBPATH_PEERS = {
|
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Every `@sdxc/*` package `files` import, statically or dynamically, with the optional peers
|
|
30
|
-
* an imported subpath needs at runtime,
|
|
30
|
+
* an imported subpath needs at runtime, and `@sdxc/spec` when any file is a pairing `.spec`,
|
|
31
|
+
* sorted.
|
|
31
32
|
*/
|
|
32
33
|
export function importedPackages(files) {
|
|
33
34
|
let names = new Set();
|
|
34
35
|
for (let file of files) {
|
|
36
|
+
if (file.path.endsWith(".spec"))
|
|
37
|
+
names.add("@sdxc/spec");
|
|
35
38
|
let references = findModuleReferences(file.path, file.content);
|
|
36
39
|
if (isFailure(references))
|
|
37
40
|
continue;
|
|
@@ -71,7 +74,13 @@ export async function missingDependencies(root, files, signal) {
|
|
|
71
74
|
let dependencies = { ...section(manifest.data.dependencies) };
|
|
72
75
|
for (let [name, version] of versions.data)
|
|
73
76
|
dependencies[name] = version;
|
|
74
|
-
manifest.data.dependencies = Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) =>
|
|
77
|
+
manifest.data.dependencies = Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => {
|
|
78
|
+
if (a < b)
|
|
79
|
+
return -1;
|
|
80
|
+
if (a > b)
|
|
81
|
+
return 1;
|
|
82
|
+
return 0;
|
|
83
|
+
}));
|
|
75
84
|
let indent = /^[ \t]+/m.exec(before.data)?.[0] ?? "\t";
|
|
76
85
|
return success({
|
|
77
86
|
path: "package.json",
|
package/dist/deploy/plan.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export declare function parsePending(stdout: string): string[];
|
|
|
43
43
|
export declare function isUnknown(error: Error, kind: "command" | "flag"): boolean;
|
|
44
44
|
/** Whether the migration step applies anything once the plan is confirmed. */
|
|
45
45
|
export declare function migrates(step: MigrationStep): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The child output a failed `db migrate --remote --pending` left behind, so the deploy
|
|
48
|
+
* failure names wrangler/cf's reason instead of only the exit code.
|
|
49
|
+
*/
|
|
50
|
+
export declare function execDetail(error: Error): string;
|
|
46
51
|
/** The plan as the terminal shows it, one fact per line and one line per pending migration. */
|
|
47
52
|
export declare function formatPlan(plan: Plan): string;
|
|
48
53
|
/** Where production stands when the app's `deploy` fails after the migration step. */
|
package/dist/deploy/plan.js
CHANGED
|
@@ -32,6 +32,16 @@ export function isUnknown(error, kind) {
|
|
|
32
32
|
export function migrates(step) {
|
|
33
33
|
return step.status === "unlisted" || (step.status === "pending" && step.names.length > 0);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The child output a failed `db migrate --remote --pending` left behind, so the deploy
|
|
37
|
+
* failure names wrangler/cf's reason instead of only the exit code.
|
|
38
|
+
*/
|
|
39
|
+
export function execDetail(error) {
|
|
40
|
+
if (!(error instanceof ExecError))
|
|
41
|
+
return error.message;
|
|
42
|
+
let detail = error.stderr.trim() || error.stdout.trim();
|
|
43
|
+
return detail === "" ? error.message : `${error.message}\n${detail}`;
|
|
44
|
+
}
|
|
35
45
|
/** The plan as the terminal shows it, one fact per line and one line per pending migration. */
|
|
36
46
|
export function formatPlan(plan) {
|
|
37
47
|
let lines = [
|
package/dist/destroy.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `sdxc destroy <kind> <name>`: the reverse of `sdxc make`. It removes the file, its test
|
|
3
|
-
* for a model, its factory, then the mapping that loads the file, the
|
|
4
|
-
* names and the Worker trigger of a schedule no other job runs on.
|
|
5
|
-
* listed for the user to remove.
|
|
2
|
+
* `sdxc destroy <kind> <name>`: the reverse of `sdxc make`. It removes the file, its test, its
|
|
3
|
+
* pairing `.spec` and, for a model, its factory, then the mapping that loads the file, the
|
|
4
|
+
* declaration that mapping names and the Worker trigger of a schedule no other job runs on.
|
|
5
|
+
* Every other reference is listed for the user to remove.
|
|
6
6
|
*
|
|
7
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
package/dist/destroy.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `sdxc destroy <kind> <name>`: the reverse of `sdxc make`. It removes the file, its test
|
|
3
|
-
* for a model, its factory, then the mapping that loads the file, the
|
|
4
|
-
* names and the Worker trigger of a schedule no other job runs on.
|
|
5
|
-
* listed for the user to remove.
|
|
2
|
+
* `sdxc destroy <kind> <name>`: the reverse of `sdxc make`. It removes the file, its test, its
|
|
3
|
+
* pairing `.spec` and, for a model, its factory, then the mapping that loads the file, the
|
|
4
|
+
* declaration that mapping names and the Worker trigger of a schedule no other job runs on.
|
|
5
|
+
* Every other reference is listed for the user to remove.
|
|
6
6
|
*
|
|
7
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
import { readFile, stat } from "node:fs/promises";
|
|
11
11
|
import { join, posix } from "node:path";
|
|
12
12
|
import { findStatements, removeProperty, removeStatements, tokenize } from "@sdxc/codemod";
|
|
13
|
+
import { iife } from "@sdxc/iife";
|
|
13
14
|
import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
14
15
|
import { listFiles } from "./doctor/files.js";
|
|
15
|
-
import { exists, folderOf } from "./make/generate.js";
|
|
16
|
+
import { exists, folderOf, specPathOf } from "./make/generate.js";
|
|
16
17
|
import { KINDS } from "./make/kinds.js";
|
|
17
18
|
import { parseName } from "./make/names.js";
|
|
18
19
|
import { planUntrigger } from "./make/trigger.js";
|
|
@@ -36,11 +37,13 @@ function specifiers(file, from) {
|
|
|
36
37
|
}
|
|
37
38
|
/** The project file a specifier written in `from` names, or `null` for a package. */
|
|
38
39
|
async function resolveModule(root, from, specifier) {
|
|
39
|
-
let base =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
let base = iife(() => {
|
|
41
|
+
if (specifier.startsWith("~/"))
|
|
42
|
+
return specifier.slice(2);
|
|
43
|
+
if (specifier.startsWith("."))
|
|
44
|
+
return posix.normalize(posix.join(posix.dirname(from), specifier));
|
|
45
|
+
return null;
|
|
46
|
+
});
|
|
44
47
|
if (base === null)
|
|
45
48
|
return null;
|
|
46
49
|
let bare = base.replace(/\.[cm]?js$/, "");
|
|
@@ -95,7 +98,11 @@ async function unmap(root, kind, file, resource, edits, notes) {
|
|
|
95
98
|
declared = [local, ...path].join(".");
|
|
96
99
|
let imported = new RegExp(`import\\s+${local}\\s+from\\s+"([^"]+)"`).exec(source)?.[1];
|
|
97
100
|
let module = imported === undefined ? null : await resolveModule(root, initializer, imported);
|
|
98
|
-
let call =
|
|
101
|
+
let call = iife(() => {
|
|
102
|
+
if (kind === "mcp")
|
|
103
|
+
return resource ? "resources" : "tools";
|
|
104
|
+
return DECLARATION_CALLS[kind];
|
|
105
|
+
});
|
|
99
106
|
if (module === null || call === undefined || path.length === 0)
|
|
100
107
|
continue;
|
|
101
108
|
let declarations = await current(root, edits, module);
|
|
@@ -255,6 +262,12 @@ export async function planDestroy(root, input) {
|
|
|
255
262
|
return failure(new Error(`${file} does not exist; sdxc destroy removes what sdxc make wrote`));
|
|
256
263
|
}
|
|
257
264
|
let candidates = [file, `${base}.test${kind.extension}`];
|
|
265
|
+
if (kind.specs === true) {
|
|
266
|
+
candidates.push(specPathOf({
|
|
267
|
+
kind: input.kind,
|
|
268
|
+
name: name.data,
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
258
271
|
if (input.kind === "model")
|
|
259
272
|
candidates.push(`database/factories/${name.data.segments.join("/")}.ts`);
|
|
260
273
|
let remove = [];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sdxc diagram`: the project's layer import graph as Mermaid, optionally drawn to SVG through
|
|
3
|
+
* `@sdxc/diagram`, so an agent can read the architecture without opening every file.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import type { Result } from "@sdxc/result";
|
|
9
|
+
import type { ProjectGraph } from "./architecture/graph.js";
|
|
10
|
+
/** What the command prints or writes. */
|
|
11
|
+
export interface DiagramResult {
|
|
12
|
+
/** Mermaid flowchart source. */
|
|
13
|
+
mermaid: string;
|
|
14
|
+
/** The graph behind the diagram, for `--json`. */
|
|
15
|
+
graph: ProjectGraph;
|
|
16
|
+
/** Absolute path of a written SVG, when one was requested. */
|
|
17
|
+
svgPath: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Options for {@link buildDiagram}. */
|
|
20
|
+
export interface DiagramOptions {
|
|
21
|
+
/** When set, render SVG with `@sdxc/diagram` and write it to this path (relative to root). */
|
|
22
|
+
svg?: string;
|
|
23
|
+
/** Accessible name for the SVG title. */
|
|
24
|
+
title?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds the architecture diagram for the project at `root`. With `svg`, writes the drawing and
|
|
28
|
+
* returns its path; without it, only the Mermaid text is produced.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildDiagram(root: string, options?: DiagramOptions): Promise<Result<DiagramResult, Error>>;
|
|
31
|
+
/** Human-readable summary of the graph for a terminal without Mermaid rendering. */
|
|
32
|
+
export declare function formatDiagramSummary(graph: ProjectGraph): string;
|
package/dist/diagram.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sdxc diagram`: the project's layer import graph as Mermaid, optionally drawn to SVG through
|
|
3
|
+
* `@sdxc/diagram`, so an agent can read the architecture without opening every file.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { writeFile } from "node:fs/promises";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { toSVG } from "@sdxc/diagram";
|
|
11
|
+
import { failure, isFailure, success, wrap } from "@sdxc/result";
|
|
12
|
+
import { projectGraph } from "./architecture/graph.js";
|
|
13
|
+
import { toMermaid } from "./architecture/mermaid.js";
|
|
14
|
+
/**
|
|
15
|
+
* Builds the architecture diagram for the project at `root`. With `svg`, writes the drawing and
|
|
16
|
+
* returns its path; without it, only the Mermaid text is produced.
|
|
17
|
+
*/
|
|
18
|
+
export async function buildDiagram(root, options = {}) {
|
|
19
|
+
let graph = await projectGraph(root);
|
|
20
|
+
let mermaid = toMermaid(graph, { title: options.title });
|
|
21
|
+
if (!options.svg) {
|
|
22
|
+
return success({ mermaid, graph, svgPath: null });
|
|
23
|
+
}
|
|
24
|
+
let drawn = toSVG(mermaid, { alt: options.title ?? "Architecture" });
|
|
25
|
+
if (isFailure(drawn)) {
|
|
26
|
+
return failure(new Error(drawn.error.message));
|
|
27
|
+
}
|
|
28
|
+
let svgPath = join(root, options.svg);
|
|
29
|
+
let written = await wrap(() => writeFile(svgPath, drawn.data));
|
|
30
|
+
if (isFailure(written))
|
|
31
|
+
return failure(written.error);
|
|
32
|
+
return success({ mermaid, graph, svgPath });
|
|
33
|
+
}
|
|
34
|
+
/** Human-readable summary of the graph for a terminal without Mermaid rendering. */
|
|
35
|
+
export function formatDiagramSummary(graph) {
|
|
36
|
+
let lines = [
|
|
37
|
+
`Modules: ${graph.modules.length}`,
|
|
38
|
+
`Imports: ${graph.edges.length}`,
|
|
39
|
+
`Layer edges: ${graph.layers.length}`,
|
|
40
|
+
`Dependency-rule breaches: ${graph.violations.length}`,
|
|
41
|
+
`Import cycles: ${graph.cycles.length}`,
|
|
42
|
+
"",
|
|
43
|
+
toMermaid(graph).trimEnd(),
|
|
44
|
+
"",
|
|
45
|
+
];
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
package/dist/doctor/checks.d.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import type { Check, CheckReport } from "./check.js";
|
|
10
10
|
/**
|
|
11
11
|
* Every built-in check: release drift, the install and the `remix` peer first, then the
|
|
12
|
-
* Worker's secrets and types, then the app's own code, layout
|
|
12
|
+
* Worker's secrets and types, then the app's own code, layout and quality metrics, then
|
|
13
|
+
* copied components.
|
|
13
14
|
*/
|
|
14
15
|
export declare const CHECKS: readonly Check[];
|
|
15
16
|
/** Whether any check failed, which makes `sdxc doctor` exit 1. */
|