@sdxc/kit 2026.10.21 → 2026.10.24
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 +84 -4
- package/changelog.jsonl +168 -0
- package/config.schema.json +154 -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 +71 -2
- package/dist/commands/make.js +46 -0
- package/dist/commands/run.d.ts +15 -11
- package/dist/commands/run.js +21 -16
- package/dist/commands/scaffold.d.ts +1 -1
- package/dist/commands/setup.d.ts +26 -0
- package/dist/commands/setup.js +33 -0
- package/dist/config.d.ts +52 -0
- package/dist/config.js +88 -1
- package/dist/contract.d.ts +52 -3
- package/dist/contract.js +124 -2
- package/dist/dependencies.js +7 -1
- package/dist/deploy/plan.d.ts +5 -0
- package/dist/deploy/plan.js +10 -0
- package/dist/destroy.js +13 -6
- 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 +24 -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/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/imports.js +7 -5
- package/dist/make/schema-diff.js +8 -1
- 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/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 +11 -8
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/breadcrumbs.json +6 -3
- package/registry/ui/group.json +6 -3
- package/registry/ui/link-button.json +3 -3
- package/registry/ui/link.json +6 -3
- package/registry/ui/nav-link.json +6 -3
- package/registry/ui/navigation-menu.json +6 -3
- package/registry/ui/pagination.json +3 -3
- package/registry/ui/sidebar.json +3 -3
- package/templates/app/AGENTS.md +14 -1
- package/templates/app/package.json +1 -1
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,7 +76,7 @@ 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>;
|
|
64
81
|
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
65
82
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -167,6 +184,27 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
167
184
|
readonly stubs: import("@sdxc/cli").Command<{
|
|
168
185
|
readonly kinds: import("@sdxc/cli").Argument<(import("./make/kinds.js").KindName | "scaffold")[]>;
|
|
169
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
|
+
}>;
|
|
170
208
|
}, "description" | "hidden" | "arguments" | "flags" | "tasks">, {
|
|
171
209
|
readonly kind: import("@sdxc/cli").Argument<import("./make/kinds.js").KindName>;
|
|
172
210
|
readonly name: import("@sdxc/cli").Argument<string>;
|
|
@@ -209,7 +247,7 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
209
247
|
readonly mcp: import("@sdxc/cli").Flag<boolean>;
|
|
210
248
|
readonly command: import("@sdxc/cli").Flag<boolean>;
|
|
211
249
|
readonly api: import("@sdxc/cli").Flag<boolean>;
|
|
212
|
-
readonly skip: import("@sdxc/cli").ValueFlag<"
|
|
250
|
+
readonly skip: import("@sdxc/cli").ValueFlag<"model" | "validator" | "migration" | "factory" | "policy" | "pages", false, true, false>;
|
|
213
251
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
214
252
|
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
215
253
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -217,9 +255,20 @@ export declare const SDXC_COMMANDS: import("@sdxc/cli").Group<Omit<{
|
|
|
217
255
|
readonly schedule: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
218
256
|
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
219
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
|
+
}>;
|
|
220
265
|
readonly stats: import("@sdxc/cli").Command<Readonly<Record<string, import("@sdxc/cli").Argument<unknown>>>, {
|
|
221
266
|
readonly json: import("@sdxc/cli").Flag<boolean>;
|
|
222
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
|
+
}>;
|
|
223
272
|
readonly ui: import("@sdxc/cli").Group<Omit<{
|
|
224
273
|
readonly description: "Copy @sdxc/ui components into the project and keep imports on the copies";
|
|
225
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. */
|
|
@@ -155,7 +159,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
155
159
|
],
|
|
156
160
|
}),
|
|
157
161
|
doctor: command({
|
|
158
|
-
description: "Lint release drift, secrets, migrations, app layout and project checks",
|
|
162
|
+
description: "Lint release drift, secrets, migrations, app layout, complexity and project checks",
|
|
159
163
|
flags: {
|
|
160
164
|
json: flag.boolean("json", { description: "Print the report as JSON for an agent" }),
|
|
161
165
|
only: flag
|
|
@@ -169,6 +173,25 @@ export const SDXC_COMMANDS = commands({
|
|
|
169
173
|
},
|
|
170
174
|
examples: ["doctor", "doctor --json", "doctor --only pins,remix", "doctor --skip ui"],
|
|
171
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
|
+
}),
|
|
172
195
|
init: command({
|
|
173
196
|
description: "Write .config/sdxc.jsonc with every default spelled out",
|
|
174
197
|
flags: { dryRun: flag.boolean("dry-run", { description: "Print it and write nothing" }) },
|
|
@@ -409,6 +432,65 @@ export const SDXC_COMMANDS = commands({
|
|
|
409
432
|
}),
|
|
410
433
|
},
|
|
411
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
|
+
}),
|
|
412
494
|
}),
|
|
413
495
|
middleware: command({
|
|
414
496
|
description: "Print each router's global middleware and every chain in app/http/middleware",
|
|
@@ -493,7 +575,7 @@ export const SDXC_COMMANDS = commands({
|
|
|
493
575
|
],
|
|
494
576
|
}),
|
|
495
577
|
run: command({
|
|
496
|
-
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)",
|
|
497
579
|
arguments: {
|
|
498
580
|
args: argument.rest({
|
|
499
581
|
valueName: "command",
|
|
@@ -552,11 +634,51 @@ export const SDXC_COMMANDS = commands({
|
|
|
552
634
|
flags: { json: flag.boolean("json", { description: "Print the schedule as JSON" }) },
|
|
553
635
|
examples: ["schedule", "schedule --json"],
|
|
554
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
|
+
}),
|
|
555
664
|
stats: command({
|
|
556
665
|
description: "Count lines of code per kind of code the app layout names, and the test ratio",
|
|
557
666
|
flags: { json: flag.boolean("json", { description: "Print the counts as JSON" }) },
|
|
558
667
|
examples: ["stats", "stats --json"],
|
|
559
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
|
+
}),
|
|
560
682
|
ui: commands({
|
|
561
683
|
description: "Copy @sdxc/ui components into the project and keep imports on the copies",
|
|
562
684
|
list: command({ description: "Every component, marking copies that are edited or behind" }),
|
package/dist/dependencies.js
CHANGED
|
@@ -74,7 +74,13 @@ export async function missingDependencies(root, files, signal) {
|
|
|
74
74
|
let dependencies = { ...section(manifest.data.dependencies) };
|
|
75
75
|
for (let [name, version] of versions.data)
|
|
76
76
|
dependencies[name] = version;
|
|
77
|
-
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
|
+
}));
|
|
78
84
|
let indent = /^[ \t]+/m.exec(before.data)?.[0] ?? "\t";
|
|
79
85
|
return success({
|
|
80
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.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
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
16
|
import { exists, folderOf, specPathOf } from "./make/generate.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);
|
|
@@ -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. */
|
package/dist/doctor/checks.js
CHANGED
|
@@ -6,21 +6,33 @@
|
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
+
import { complexityCheck } from "./complexity.js";
|
|
10
|
+
import { crapCheck } from "./crap.js";
|
|
11
|
+
import { dependenciesCheck } from "./dependencies.js";
|
|
12
|
+
import { duplicationCheck } from "./duplication.js";
|
|
9
13
|
import { emailsCheck } from "./emails.js";
|
|
10
14
|
import { envCheck } from "./env.js";
|
|
15
|
+
import { fanOutCheck } from "./fan-out.js";
|
|
16
|
+
import { featureScatterCheck } from "./feature-scatter.js";
|
|
11
17
|
import { installedCheck } from "./installed.js";
|
|
12
18
|
import { jsdocCheck } from "./jsdoc.js";
|
|
13
19
|
import { layoutCheck } from "./layout.js";
|
|
14
20
|
import { migrationsCheck } from "./migrations.js";
|
|
15
21
|
import { modelsCheck } from "./models.js";
|
|
22
|
+
import { moduleSizeCheck } from "./module-size.js";
|
|
23
|
+
import { mutationCheck } from "./mutation.js";
|
|
24
|
+
import { orphansCheck } from "./orphans.js";
|
|
16
25
|
import { pinsCheck } from "./pins.js";
|
|
17
26
|
import { remixCheck } from "./remix.js";
|
|
27
|
+
import { resultThrowsCheck } from "./result-throws.js";
|
|
18
28
|
import { routesCheck } from "./routes.js";
|
|
29
|
+
import { testRatioCheck } from "./test-ratio.js";
|
|
19
30
|
import { typegenCheck } from "./typegen.js";
|
|
20
31
|
import { uiCheck } from "./ui.js";
|
|
21
32
|
/**
|
|
22
33
|
* Every built-in check: release drift, the install and the `remix` peer first, then the
|
|
23
|
-
* Worker's secrets and types, then the app's own code, layout
|
|
34
|
+
* Worker's secrets and types, then the app's own code, layout and quality metrics, then
|
|
35
|
+
* copied components.
|
|
24
36
|
*/
|
|
25
37
|
export const CHECKS = [
|
|
26
38
|
pinsCheck,
|
|
@@ -34,6 +46,17 @@ export const CHECKS = [
|
|
|
34
46
|
modelsCheck,
|
|
35
47
|
emailsCheck,
|
|
36
48
|
jsdocCheck,
|
|
49
|
+
complexityCheck,
|
|
50
|
+
moduleSizeCheck,
|
|
51
|
+
dependenciesCheck,
|
|
52
|
+
fanOutCheck,
|
|
53
|
+
orphansCheck,
|
|
54
|
+
featureScatterCheck,
|
|
55
|
+
duplicationCheck,
|
|
56
|
+
resultThrowsCheck,
|
|
57
|
+
testRatioCheck,
|
|
58
|
+
crapCheck,
|
|
59
|
+
mutationCheck,
|
|
37
60
|
uiCheck,
|
|
38
61
|
];
|
|
39
62
|
/** Whether any check failed, which makes `sdxc doctor` exit 1. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `complexity` check: every function's cyclomatic complexity stays at or under the
|
|
3
|
+
* configured maximum (default 4), so agent-written branches stay small enough to test and
|
|
4
|
+
* review. Oxlint's `complexity` rule is left off; this check is project-aware and configurable.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/**
|
|
11
|
+
* Warns on each function whose cyclomatic complexity exceeds `doctor.complexity.max`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const complexityCheck: Check;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `complexity` check: every function's cyclomatic complexity stays at or under the
|
|
3
|
+
* configured maximum (default 4), so agent-written branches stay small enough to test and
|
|
4
|
+
* review. Oxlint's `complexity` rule is left off; this check is project-aware and configurable.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from "node:fs/promises";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { isFailure, wrap } from "@sdxc/result";
|
|
12
|
+
import { measureComplexity } from "../architecture/complexity.js";
|
|
13
|
+
import { PROJECT_FOLDERS } from "../stats.js";
|
|
14
|
+
import { passed, skipped } from "./check.js";
|
|
15
|
+
import { isAppSource, listFiles } from "./files.js";
|
|
16
|
+
/**
|
|
17
|
+
* Warns on each function whose cyclomatic complexity exceeds `doctor.complexity.max`.
|
|
18
|
+
*/
|
|
19
|
+
export const complexityCheck = {
|
|
20
|
+
name: "complexity",
|
|
21
|
+
async run(context) {
|
|
22
|
+
let max = context.config.doctor.complexity.max;
|
|
23
|
+
let findings = [];
|
|
24
|
+
let files = 0;
|
|
25
|
+
for (let folder of PROJECT_FOLDERS) {
|
|
26
|
+
for (let file of (await listFiles(context.root, folder)).filter(isAppSource)) {
|
|
27
|
+
files += 1;
|
|
28
|
+
let source = await wrap(() => readFile(join(context.root, file), "utf8"));
|
|
29
|
+
if (isFailure(source))
|
|
30
|
+
continue;
|
|
31
|
+
for (let fn of measureComplexity(file, source.data)) {
|
|
32
|
+
if (fn.complexity <= max)
|
|
33
|
+
continue;
|
|
34
|
+
findings.push(`${file}:${fn.line}: ${fn.name} has complexity ${fn.complexity} (max ${max})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (files === 0)
|
|
39
|
+
return skipped("No app source to measure complexity");
|
|
40
|
+
if (findings.length === 0) {
|
|
41
|
+
return passed(`Every function stays at cyclomatic complexity ${max} or below`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
status: "warn",
|
|
45
|
+
message: findings.length === 1
|
|
46
|
+
? "Found 1 function above the cyclomatic complexity limit"
|
|
47
|
+
: `Found ${findings.length} functions above the cyclomatic complexity limit`,
|
|
48
|
+
findings,
|
|
49
|
+
fix: `Split each function so its decision points stay at ${max} or fewer, or raise doctor.complexity.max in .config/sdxc.jsonc`,
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `crap` check: CRAP scores from cyclomatic complexity and Istanbul coverage stay at or
|
|
3
|
+
* under the configured maximum (default 12). Without a coverage report the check skips, since a
|
|
4
|
+
* score without coverage would only restate complexity.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/**
|
|
11
|
+
* Warns on each function whose CRAP score exceeds `doctor.crap.max` when coverage data is
|
|
12
|
+
* present at `doctor.crap.coverage`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const crapCheck: Check;
|