@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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc fix` handlers: command-shaped repairs, `.env.example` secrets, and model/email
|
|
3
|
+
* registration through the same codemods `make` uses.
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { isFailure } from "@sdxc/result";
|
|
10
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
11
|
+
import { fixCommands, fixEmails, fixEnv, fixModels } from "../fix/index.js";
|
|
12
|
+
import { packageRoot, project } from "../middleware.js";
|
|
13
|
+
import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
|
|
14
|
+
import { readManifest } from "../upgrade/project.js";
|
|
15
|
+
/** Middleware every `fix` handler runs behind. */
|
|
16
|
+
const FIX_MIDDLEWARE = [project(), packageRoot()];
|
|
17
|
+
/** `sdxc fix` with no member: command-shaped repairs from doctor. */
|
|
18
|
+
export const group = createCommand(SDXC_COMMANDS.fix, {
|
|
19
|
+
middleware: FIX_MIDDLEWARE,
|
|
20
|
+
async handler(ctx) {
|
|
21
|
+
let read = await readManifest(ctx.project.root);
|
|
22
|
+
if (isFailure(read))
|
|
23
|
+
return read;
|
|
24
|
+
let manager = await packageManager({
|
|
25
|
+
declared: read.data.manifest.packageManager,
|
|
26
|
+
findLockFile: lockFileAtOrAbove(ctx.project.root),
|
|
27
|
+
});
|
|
28
|
+
let fixed = await fixCommands(ctx, {
|
|
29
|
+
root: ctx.project.root,
|
|
30
|
+
packageRoot: ctx.packageRoot,
|
|
31
|
+
manager,
|
|
32
|
+
config: ctx.project.config,
|
|
33
|
+
manifest: read.data.manifest,
|
|
34
|
+
dryRun: ctx.flags.dryRun,
|
|
35
|
+
});
|
|
36
|
+
if (isFailure(fixed))
|
|
37
|
+
return fixed;
|
|
38
|
+
if (fixed.data.length === 0)
|
|
39
|
+
ctx.stdout("Nothing to fix\n");
|
|
40
|
+
return success();
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
/** `sdxc fix env`. */
|
|
44
|
+
export const env = createCommand(SDXC_COMMANDS.fix.env, {
|
|
45
|
+
middleware: FIX_MIDDLEWARE,
|
|
46
|
+
async handler(ctx) {
|
|
47
|
+
let fixed = await fixEnv(ctx.project.root, { dryRun: ctx.flags.dryRun });
|
|
48
|
+
if (isFailure(fixed))
|
|
49
|
+
return fixed;
|
|
50
|
+
if (fixed.data.missing.length === 0) {
|
|
51
|
+
ctx.stdout("Every secret is already in .env.example\n");
|
|
52
|
+
return success();
|
|
53
|
+
}
|
|
54
|
+
if (ctx.flags.dryRun)
|
|
55
|
+
ctx.stdout(fixed.data.diff);
|
|
56
|
+
else
|
|
57
|
+
ctx.stdout(`appended ${fixed.data.missing.join(", ")} to .env.example\n`);
|
|
58
|
+
return success();
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
/** `sdxc fix models`. */
|
|
62
|
+
export const models = createCommand(SDXC_COMMANDS.fix.models, {
|
|
63
|
+
middleware: FIX_MIDDLEWARE,
|
|
64
|
+
async handler(ctx) {
|
|
65
|
+
let fixed = await fixModels(ctx.project.root, { dryRun: ctx.flags.dryRun });
|
|
66
|
+
if (isFailure(fixed))
|
|
67
|
+
return fixed;
|
|
68
|
+
if (fixed.data.length === 0) {
|
|
69
|
+
ctx.stdout("Every model is already registered\n");
|
|
70
|
+
return success();
|
|
71
|
+
}
|
|
72
|
+
for (let row of fixed.data) {
|
|
73
|
+
if (ctx.flags.dryRun)
|
|
74
|
+
for (let diff of row.diffs)
|
|
75
|
+
ctx.stdout(diff);
|
|
76
|
+
else
|
|
77
|
+
ctx.stdout(`registered ${row.file}\n`);
|
|
78
|
+
}
|
|
79
|
+
return success();
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
/** `sdxc fix emails`. */
|
|
83
|
+
export const emails = createCommand(SDXC_COMMANDS.fix.emails, {
|
|
84
|
+
middleware: FIX_MIDDLEWARE,
|
|
85
|
+
async handler(ctx) {
|
|
86
|
+
let fixed = await fixEmails(ctx.project.root, { dryRun: ctx.flags.dryRun });
|
|
87
|
+
if (isFailure(fixed))
|
|
88
|
+
return fixed;
|
|
89
|
+
if (fixed.data.length === 0) {
|
|
90
|
+
ctx.stdout("Every declared email is already mapped\n");
|
|
91
|
+
return success();
|
|
92
|
+
}
|
|
93
|
+
for (let row of fixed.data) {
|
|
94
|
+
if (ctx.flags.dryRun)
|
|
95
|
+
for (let diff of row.diffs)
|
|
96
|
+
ctx.stdout(diff);
|
|
97
|
+
else
|
|
98
|
+
ctx.stdout(`mapped ${row.name} → ${row.template}\n`);
|
|
99
|
+
}
|
|
100
|
+
return success();
|
|
101
|
+
},
|
|
102
|
+
});
|
package/dist/commands/make.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const controller: import("@sdxc/cli").CommandAction<import("@sdxc
|
|
|
14
14
|
readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
15
15
|
readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
16
16
|
readonly resource: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
17
|
-
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "
|
|
17
|
+
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "new" | "all" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
|
|
18
18
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
19
19
|
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
20
20
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -257,6 +257,54 @@ export declare const stubs: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
|
|
|
257
257
|
value: string;
|
|
258
258
|
property: "packageRoot";
|
|
259
259
|
}>]>;
|
|
260
|
+
/** `sdxc make secret`. */
|
|
261
|
+
export declare const secret: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
262
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
263
|
+
}, {
|
|
264
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
265
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
266
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
267
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
268
|
+
value: import("../middleware.js").Project;
|
|
269
|
+
property: "project";
|
|
270
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
271
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
272
|
+
value: string;
|
|
273
|
+
property: "packageRoot";
|
|
274
|
+
}>]>;
|
|
275
|
+
/** `sdxc make binding`. */
|
|
276
|
+
export declare const binding: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
277
|
+
readonly kind: import("@sdxc/cli").Argument<"secret" | "kv" | "d1" | "r2" | "queue" | "rateLimit" | "sendEmail" | "durableObject">;
|
|
278
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
279
|
+
}, {
|
|
280
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
281
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
282
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
283
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
284
|
+
value: import("../middleware.js").Project;
|
|
285
|
+
property: "project";
|
|
286
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
287
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
288
|
+
value: string;
|
|
289
|
+
property: "packageRoot";
|
|
290
|
+
}>]>;
|
|
291
|
+
/** `sdxc make do`. */
|
|
292
|
+
export declare const durableObject: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
293
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
294
|
+
}, {
|
|
295
|
+
readonly role: import("@sdxc/cli").ValueFlag<"model" | "service", true, false, false>;
|
|
296
|
+
readonly binding: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
297
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
298
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
299
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
300
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
301
|
+
value: import("../middleware.js").Project;
|
|
302
|
+
property: "project";
|
|
303
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
304
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
305
|
+
value: string;
|
|
306
|
+
property: "packageRoot";
|
|
307
|
+
}>]>;
|
|
260
308
|
/**
|
|
261
309
|
* `sdxc make` with no kind: the contract asks for the kind and the name on a terminal, and this
|
|
262
310
|
* asks a controller's method, then makes it with every flag of the kind at its default. Without
|
|
@@ -281,7 +329,7 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
|
|
|
281
329
|
readonly path: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
282
330
|
readonly routes: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
283
331
|
readonly resource: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
284
|
-
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "
|
|
332
|
+
readonly actions: import("@sdxc/cli").ValueFlag<"index" | "new" | "all" | "show" | "edit" | "create" | "update" | "destroy", false, true, false>;
|
|
285
333
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
286
334
|
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
287
335
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -389,6 +437,27 @@ export declare const group: import("@sdxc/cli").CommandAction<import("@sdxc/cli"
|
|
|
389
437
|
readonly stubs: import("@sdxc/cli").Command<{
|
|
390
438
|
readonly kinds: import("@sdxc/cli").Argument<(import("../make/kinds.js").KindName | "scaffold")[]>;
|
|
391
439
|
}, Readonly<Record<string, import("@sdxc/cli").Flag<unknown>>>>;
|
|
440
|
+
readonly secret: import("@sdxc/cli").Command<{
|
|
441
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
442
|
+
}, {
|
|
443
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
444
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
445
|
+
}>;
|
|
446
|
+
readonly binding: import("@sdxc/cli").Command<{
|
|
447
|
+
readonly kind: import("@sdxc/cli").Argument<"secret" | "kv" | "d1" | "r2" | "queue" | "rateLimit" | "sendEmail" | "durableObject">;
|
|
448
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
449
|
+
}, {
|
|
450
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
451
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
452
|
+
}>;
|
|
453
|
+
readonly do: import("@sdxc/cli").Command<{
|
|
454
|
+
readonly name: import("@sdxc/cli").Argument<string>;
|
|
455
|
+
}, {
|
|
456
|
+
readonly role: import("@sdxc/cli").ValueFlag<"model" | "service", true, false, false>;
|
|
457
|
+
readonly binding: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
458
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
459
|
+
readonly force: import("@sdxc/cli").Flag<boolean>;
|
|
460
|
+
}>;
|
|
392
461
|
}, "description" | "hidden" | "arguments" | "flags" | "tasks">, {
|
|
393
462
|
readonly kind: import("@sdxc/cli").Argument<import("../make/kinds.js").KindName>;
|
|
394
463
|
readonly name: import("@sdxc/cli").Argument<string>;
|
package/dist/commands/make.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createCommand, success, usage } from "@sdxc/cli";
|
|
|
10
10
|
import { isFailure } from "@sdxc/result";
|
|
11
11
|
import { METHODS, SDXC_COMMANDS } from "../contract.js";
|
|
12
12
|
import { makeActions } from "../make/actions.js";
|
|
13
|
+
import { makeBinding, makeDo, makeSecret } from "../make/binding.js";
|
|
13
14
|
import { make } from "../make/index.js";
|
|
14
15
|
import { copyStubs } from "../make/stubs.js";
|
|
15
16
|
import { makeTest } from "../make/test.js";
|
|
@@ -232,6 +233,51 @@ export const stubs = createCommand(SDXC_COMMANDS.make.stubs, {
|
|
|
232
233
|
return success();
|
|
233
234
|
},
|
|
234
235
|
});
|
|
236
|
+
/** `sdxc make secret`. */
|
|
237
|
+
export const secret = createCommand(SDXC_COMMANDS.make.secret, {
|
|
238
|
+
middleware: MAKE_MIDDLEWARE,
|
|
239
|
+
async handler(ctx) {
|
|
240
|
+
let made = await makeSecret(ctx, ctx.project.root, {
|
|
241
|
+
name: ctx.arguments.name,
|
|
242
|
+
dryRun: ctx.flags.dryRun,
|
|
243
|
+
force: ctx.flags.force,
|
|
244
|
+
});
|
|
245
|
+
if (isFailure(made))
|
|
246
|
+
return made;
|
|
247
|
+
return success();
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
/** `sdxc make binding`. */
|
|
251
|
+
export const binding = createCommand(SDXC_COMMANDS.make.binding, {
|
|
252
|
+
middleware: MAKE_MIDDLEWARE,
|
|
253
|
+
async handler(ctx) {
|
|
254
|
+
let made = await makeBinding(ctx, ctx.project.root, {
|
|
255
|
+
kind: ctx.arguments.kind,
|
|
256
|
+
name: ctx.arguments.name,
|
|
257
|
+
dryRun: ctx.flags.dryRun,
|
|
258
|
+
force: ctx.flags.force,
|
|
259
|
+
});
|
|
260
|
+
if (isFailure(made))
|
|
261
|
+
return made;
|
|
262
|
+
return success();
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
/** `sdxc make do`. */
|
|
266
|
+
export const durableObject = createCommand(SDXC_COMMANDS.make.do, {
|
|
267
|
+
middleware: MAKE_MIDDLEWARE,
|
|
268
|
+
async handler(ctx) {
|
|
269
|
+
let made = await makeDo(ctx, ctx.project.root, ctx.packageRoot, {
|
|
270
|
+
name: ctx.arguments.name,
|
|
271
|
+
role: ctx.flags.role,
|
|
272
|
+
binding: ctx.flags.binding,
|
|
273
|
+
dryRun: ctx.flags.dryRun,
|
|
274
|
+
force: ctx.flags.force,
|
|
275
|
+
});
|
|
276
|
+
if (isFailure(made))
|
|
277
|
+
return made;
|
|
278
|
+
return success();
|
|
279
|
+
},
|
|
280
|
+
});
|
|
235
281
|
/**
|
|
236
282
|
* `sdxc make` with no kind: the contract asks for the kind and the name on a terminal, and this
|
|
237
283
|
* asks a controller's method, then makes it with every flag of the kind at its default. Without
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `sdxc run` handler: runs the project's own command line
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The `sdxc run` handler: runs the project's own command line with the project's runtime and
|
|
3
|
+
* every token after `run` as typed, so a globally installed `sdxc` reaches any project's
|
|
4
|
+
* commands without a package script. The entry module defaults to `bootstrap/cli.ts` and a
|
|
5
|
+
* project overrides it with `run.entry` in `.config/sdxc.jsonc`.
|
|
5
6
|
*
|
|
6
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
8
|
* @copyright Sergio Xalambrí 2026
|
|
8
9
|
*/
|
|
9
10
|
import type { Result } from "@sdxc/result";
|
|
10
|
-
/** Where
|
|
11
|
-
export declare const
|
|
11
|
+
/** Where an app's command line starts when `run.entry` is left at its default. */
|
|
12
|
+
export declare const DEFAULT_CLI_ENTRY = "bootstrap/cli.ts";
|
|
12
13
|
/**
|
|
13
14
|
* `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
|
|
14
15
|
* runs the project's own `cf` or `vp` in place of a global one.
|
|
@@ -18,16 +19,19 @@ export declare const CLI_ENTRY = "bootstrap/cli.ts";
|
|
|
18
19
|
*/
|
|
19
20
|
export declare function projectPath(root: string, path: string | undefined): string;
|
|
20
21
|
/**
|
|
21
|
-
* The command that starts the project's command line with `args`: under Bun for a
|
|
22
|
-
* Bun and under Node otherwise.
|
|
22
|
+
* The command that starts the project's command line at `entry` with `args`: under Bun for a
|
|
23
|
+
* project on Bun and under Node otherwise.
|
|
23
24
|
*
|
|
24
25
|
* @param root - The project root, whose `package.json` and lock file name the package manager
|
|
26
|
+
* @param entry - The module to start, relative to the project root
|
|
27
|
+
* @param args - Tokens after `sdxc run`
|
|
25
28
|
*/
|
|
26
|
-
export declare function commandLine(root: string, args: readonly string[]): Promise<Result<string[], Error>>;
|
|
29
|
+
export declare function commandLine(root: string, entry: string, args: readonly string[]): Promise<Result<string[], Error>>;
|
|
27
30
|
/**
|
|
28
|
-
* Runs
|
|
29
|
-
* output on the terminal and the project's `node_modules/.bin` first on
|
|
30
|
-
* script has it; the app's exit code is `sdxc run`'s, and only the app's
|
|
31
|
+
* Runs the configured command-line entry under Bun for a project on Bun and under Node
|
|
32
|
+
* otherwise, with its output on the terminal and the project's `node_modules/.bin` first on
|
|
33
|
+
* `PATH`, as a package script has it; the app's exit code is `sdxc run`'s, and only the app's
|
|
34
|
+
* messages print on failure.
|
|
31
35
|
*/
|
|
32
36
|
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
33
37
|
readonly args: import("@sdxc/cli").Argument<string[]>;
|
package/dist/commands/run.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `sdxc run` handler: runs the project's own command line
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The `sdxc run` handler: runs the project's own command line with the project's runtime and
|
|
3
|
+
* every token after `run` as typed, so a globally installed `sdxc` reaches any project's
|
|
4
|
+
* commands without a package script. The entry module defaults to `bootstrap/cli.ts` and a
|
|
5
|
+
* project overrides it with `run.entry` in `.config/sdxc.jsonc`.
|
|
5
6
|
*
|
|
6
7
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
8
|
* @copyright Sergio Xalambrí 2026
|
|
@@ -14,8 +15,8 @@ import { SDXC_COMMANDS } from "../contract.js";
|
|
|
14
15
|
import { project } from "../middleware.js";
|
|
15
16
|
import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
|
|
16
17
|
import { readManifest } from "../upgrade/project.js";
|
|
17
|
-
/** Where
|
|
18
|
-
export const
|
|
18
|
+
/** Where an app's command line starts when `run.entry` is left at its default. */
|
|
19
|
+
export const DEFAULT_CLI_ENTRY = "bootstrap/cli.ts";
|
|
19
20
|
/**
|
|
20
21
|
* `PATH` with the project's `node_modules/.bin` first, as a package script has it, so a child
|
|
21
22
|
* runs the project's own `cf` or `vp` in place of a global one.
|
|
@@ -28,12 +29,14 @@ export function projectPath(root, path) {
|
|
|
28
29
|
return path === undefined ? bin : `${bin}${delimiter}${path}`;
|
|
29
30
|
}
|
|
30
31
|
/**
|
|
31
|
-
* The command that starts the project's command line with `args`: under Bun for a
|
|
32
|
-
* Bun and under Node otherwise.
|
|
32
|
+
* The command that starts the project's command line at `entry` with `args`: under Bun for a
|
|
33
|
+
* project on Bun and under Node otherwise.
|
|
33
34
|
*
|
|
34
35
|
* @param root - The project root, whose `package.json` and lock file name the package manager
|
|
36
|
+
* @param entry - The module to start, relative to the project root
|
|
37
|
+
* @param args - Tokens after `sdxc run`
|
|
35
38
|
*/
|
|
36
|
-
export async function commandLine(root, args) {
|
|
39
|
+
export async function commandLine(root, entry, args) {
|
|
37
40
|
let manifest = await readManifest(root);
|
|
38
41
|
if (isFailure(manifest))
|
|
39
42
|
return manifest;
|
|
@@ -41,23 +44,25 @@ export async function commandLine(root, args) {
|
|
|
41
44
|
declared: manifest.data.manifest.packageManager,
|
|
42
45
|
findLockFile: lockFileAtOrAbove(root),
|
|
43
46
|
});
|
|
44
|
-
return success([manager.name === "bun" ? "bun" : "node",
|
|
47
|
+
return success([manager.name === "bun" ? "bun" : "node", entry, ...args]);
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
|
-
* Runs
|
|
48
|
-
* output on the terminal and the project's `node_modules/.bin` first on
|
|
49
|
-
* script has it; the app's exit code is `sdxc run`'s, and only the app's
|
|
50
|
+
* Runs the configured command-line entry under Bun for a project on Bun and under Node
|
|
51
|
+
* otherwise, with its output on the terminal and the project's `node_modules/.bin` first on
|
|
52
|
+
* `PATH`, as a package script has it; the app's exit code is `sdxc run`'s, and only the app's
|
|
53
|
+
* messages print on failure.
|
|
50
54
|
*/
|
|
51
55
|
export default createCommand(SDXC_COMMANDS.run, {
|
|
52
56
|
middleware: [project()],
|
|
53
57
|
/** Fails naming the missing entry; otherwise hands the app's exit code back unchanged. */
|
|
54
58
|
async handler(ctx) {
|
|
55
59
|
let root = ctx.project.root;
|
|
56
|
-
let entry =
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
let entry = ctx.project.config.run.entry;
|
|
61
|
+
let absolute = join(root, entry);
|
|
62
|
+
if (!isSuccess(await wrap(() => stat(absolute)))) {
|
|
63
|
+
return failure(new Error(`${entry} not found in ${root}; an app's command line starts there`));
|
|
59
64
|
}
|
|
60
|
-
let command = await commandLine(root, ctx.arguments.args);
|
|
65
|
+
let command = await commandLine(root, entry, ctx.arguments.args);
|
|
61
66
|
if (isFailure(command))
|
|
62
67
|
return command;
|
|
63
68
|
let ran = await ctx.exec(command.data, {
|
|
@@ -14,7 +14,7 @@ declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Co
|
|
|
14
14
|
readonly mcp: import("@sdxc/cli").Flag<boolean>;
|
|
15
15
|
readonly command: import("@sdxc/cli").Flag<boolean>;
|
|
16
16
|
readonly api: import("@sdxc/cli").Flag<boolean>;
|
|
17
|
-
readonly skip: import("@sdxc/cli").ValueFlag<"
|
|
17
|
+
readonly skip: import("@sdxc/cli").ValueFlag<"model" | "validator" | "migration" | "factory" | "policy" | "pages", false, true, false>;
|
|
18
18
|
readonly test: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
19
19
|
readonly spec: import("@sdxc/cli").Flag<boolean | undefined>;
|
|
20
20
|
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc setup` handler: lists known features with no name, or installs auth / billing /
|
|
3
|
+
* flags from a printed plan (`-y` writes; without it the plan is dry-run).
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `sdxc setup` with no feature: lists the catalog. With a feature argument, installs it.
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: import("@sdxc/cli").CommandAction<import("@sdxc/cli").Command<{
|
|
12
|
+
readonly feature: import("@sdxc/cli").Argument<string | undefined>;
|
|
13
|
+
}, {
|
|
14
|
+
readonly provider: import("@sdxc/cli").ValueFlag<string, false, false, false>;
|
|
15
|
+
readonly yes: import("@sdxc/cli").Flag<boolean>;
|
|
16
|
+
readonly dryRun: import("@sdxc/cli").Flag<boolean>;
|
|
17
|
+
}>, readonly [import("@sdxc/cli").CommandMiddleware<{
|
|
18
|
+
key: typeof import("../middleware.js").CurrentProject;
|
|
19
|
+
value: import("../middleware.js").Project;
|
|
20
|
+
property: "project";
|
|
21
|
+
}>, import("@sdxc/cli").CommandMiddleware<{
|
|
22
|
+
key: typeof import("../middleware.js").PackageRoot;
|
|
23
|
+
value: string;
|
|
24
|
+
property: "packageRoot";
|
|
25
|
+
}>]>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `sdxc setup` handler: lists known features with no name, or installs auth / billing /
|
|
3
|
+
* flags from a printed plan (`-y` writes; without it the plan is dry-run).
|
|
4
|
+
*
|
|
5
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
6
|
+
* @copyright Sergio Xalambrí 2026
|
|
7
|
+
*/
|
|
8
|
+
import { createCommand, success } from "@sdxc/cli";
|
|
9
|
+
import { isFailure } from "@sdxc/result";
|
|
10
|
+
import { SDXC_COMMANDS } from "../contract.js";
|
|
11
|
+
import { packageRoot, project } from "../middleware.js";
|
|
12
|
+
import { listFeatures, runSetup } from "../setup/index.js";
|
|
13
|
+
/**
|
|
14
|
+
* `sdxc setup` with no feature: lists the catalog. With a feature argument, installs it.
|
|
15
|
+
*/
|
|
16
|
+
export default createCommand(SDXC_COMMANDS.setup, {
|
|
17
|
+
middleware: [project(), packageRoot()],
|
|
18
|
+
async handler(ctx) {
|
|
19
|
+
if (ctx.arguments.feature === undefined) {
|
|
20
|
+
ctx.stdout(listFeatures());
|
|
21
|
+
return success();
|
|
22
|
+
}
|
|
23
|
+
let ran = await runSetup(ctx.project.root, ctx.arguments.feature, {
|
|
24
|
+
provider: ctx.flags.provider,
|
|
25
|
+
dryRun: ctx.flags.dryRun,
|
|
26
|
+
yes: ctx.flags.yes,
|
|
27
|
+
stdout: (text) => ctx.stdout(text),
|
|
28
|
+
});
|
|
29
|
+
if (isFailure(ran))
|
|
30
|
+
return ran;
|
|
31
|
+
return success();
|
|
32
|
+
},
|
|
33
|
+
});
|
package/dist/config.d.ts
CHANGED
|
@@ -38,6 +38,32 @@ export declare const CONFIG_SCHEMA: s.Schema<{
|
|
|
38
38
|
}[] | undefined;
|
|
39
39
|
} | undefined;
|
|
40
40
|
checks?: string | undefined;
|
|
41
|
+
complexity?: {
|
|
42
|
+
max?: number | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
moduleSize?: {
|
|
45
|
+
maxLines?: number | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
crap?: {
|
|
48
|
+
max?: number | undefined;
|
|
49
|
+
coverage?: string | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
testRatio?: {
|
|
52
|
+
min?: number | undefined;
|
|
53
|
+
} | undefined;
|
|
54
|
+
fanOut?: {
|
|
55
|
+
max?: number | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
duplication?: {
|
|
58
|
+
minLines?: number | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
mutation?: {
|
|
61
|
+
report?: string | undefined;
|
|
62
|
+
maxSurvived?: number | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
run?: {
|
|
66
|
+
entry?: string | undefined;
|
|
41
67
|
} | undefined;
|
|
42
68
|
lock?: string | undefined;
|
|
43
69
|
}, {
|
|
@@ -61,6 +87,32 @@ export declare const CONFIG_SCHEMA: s.Schema<{
|
|
|
61
87
|
}[];
|
|
62
88
|
};
|
|
63
89
|
checks: string;
|
|
90
|
+
complexity: {
|
|
91
|
+
max: number;
|
|
92
|
+
};
|
|
93
|
+
moduleSize: {
|
|
94
|
+
maxLines: number;
|
|
95
|
+
};
|
|
96
|
+
crap: {
|
|
97
|
+
max: number;
|
|
98
|
+
coverage: string;
|
|
99
|
+
};
|
|
100
|
+
testRatio: {
|
|
101
|
+
min: number;
|
|
102
|
+
};
|
|
103
|
+
fanOut: {
|
|
104
|
+
max: number;
|
|
105
|
+
};
|
|
106
|
+
duplication: {
|
|
107
|
+
minLines: number;
|
|
108
|
+
};
|
|
109
|
+
mutation: {
|
|
110
|
+
report: string;
|
|
111
|
+
maxSurvived: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
run: {
|
|
115
|
+
entry: string;
|
|
64
116
|
};
|
|
65
117
|
lock: string;
|
|
66
118
|
$schema?: string | undefined;
|
package/dist/config.js
CHANGED
|
@@ -37,8 +37,42 @@ const ACCEPTED_MIGRATION_FAILURE = s.object({
|
|
|
37
37
|
const DOCTOR_MIGRATIONS_DEFAULTS = {
|
|
38
38
|
accept: [],
|
|
39
39
|
};
|
|
40
|
+
/** The `doctor.complexity` group as a project with no such key gets it. */
|
|
41
|
+
const DOCTOR_COMPLEXITY_DEFAULTS = { max: 4 };
|
|
42
|
+
/** The `doctor.moduleSize` group as a project with no such key gets it. */
|
|
43
|
+
const DOCTOR_MODULE_SIZE_DEFAULTS = { maxLines: 200 };
|
|
44
|
+
/** The `doctor.crap` group as a project with no such key gets it. */
|
|
45
|
+
const DOCTOR_CRAP_DEFAULTS = { max: 12, coverage: "coverage/coverage-final.json" };
|
|
46
|
+
/** Integer at least 1; shared so doctor leaf schemas stay under the nested-call ceiling. */
|
|
47
|
+
const POSITIVE_INTEGER = s.integer().pipe(checks.min(1));
|
|
48
|
+
/** Integer at least 0; shared so doctor leaf schemas stay under the nested-call ceiling. */
|
|
49
|
+
const NON_NEGATIVE_INTEGER = s.integer().pipe(checks.min(0));
|
|
50
|
+
/** Integer at least 2; shared so doctor leaf schemas stay under the nested-call ceiling. */
|
|
51
|
+
const INTEGER_AT_LEAST_TWO = s.integer().pipe(checks.min(2));
|
|
52
|
+
/** Number at least 0; shared so doctor leaf schemas stay under the nested-call ceiling. */
|
|
53
|
+
const NON_NEGATIVE_NUMBER = s.number().pipe(checks.min(0));
|
|
54
|
+
/** The `doctor.testRatio` group as a project with no such key gets it. */
|
|
55
|
+
const DOCTOR_TEST_RATIO_DEFAULTS = { min: 0.3 };
|
|
56
|
+
/** The `doctor.fanOut` group as a project with no such key gets it. */
|
|
57
|
+
const DOCTOR_FAN_OUT_DEFAULTS = { max: 15 };
|
|
58
|
+
/** The `doctor.duplication` group as a project with no such key gets it. */
|
|
59
|
+
const DOCTOR_DUPLICATION_DEFAULTS = { minLines: 8 };
|
|
60
|
+
/** The `doctor.mutation` group as a project with no such key gets it. */
|
|
61
|
+
const DOCTOR_MUTATION_DEFAULTS = { report: "reports/mutation/mutation.json", maxSurvived: 0 };
|
|
40
62
|
/** The `doctor` group as a project with no `doctor` key gets it. */
|
|
41
|
-
const DOCTOR_DEFAULTS = {
|
|
63
|
+
const DOCTOR_DEFAULTS = {
|
|
64
|
+
checks: ".config/sdxc/checks",
|
|
65
|
+
migrations: DOCTOR_MIGRATIONS_DEFAULTS,
|
|
66
|
+
complexity: DOCTOR_COMPLEXITY_DEFAULTS,
|
|
67
|
+
moduleSize: DOCTOR_MODULE_SIZE_DEFAULTS,
|
|
68
|
+
crap: DOCTOR_CRAP_DEFAULTS,
|
|
69
|
+
testRatio: DOCTOR_TEST_RATIO_DEFAULTS,
|
|
70
|
+
fanOut: DOCTOR_FAN_OUT_DEFAULTS,
|
|
71
|
+
duplication: DOCTOR_DUPLICATION_DEFAULTS,
|
|
72
|
+
mutation: DOCTOR_MUTATION_DEFAULTS,
|
|
73
|
+
};
|
|
74
|
+
/** The `run` group as a project with no `run` key gets it. */
|
|
75
|
+
const RUN_DEFAULTS = { entry: "bootstrap/cli.ts" };
|
|
42
76
|
/**
|
|
43
77
|
* Every configuration key. Each leaf carries its default, or an example when it has none, and
|
|
44
78
|
* a description that becomes its comment in `sdxc init`'s output; an unknown key is an error, so
|
|
@@ -88,7 +122,57 @@ export const CONFIG_SCHEMA = s.object({
|
|
|
88
122
|
description: "Migration errors `sdxc doctor` steps past, each a file that already ran and the column its error names",
|
|
89
123
|
}),
|
|
90
124
|
}, { unknownKeys: "error" }), DOCTOR_MIGRATIONS_DEFAULTS),
|
|
125
|
+
complexity: s.defaulted(s.object({
|
|
126
|
+
max: s.defaulted(POSITIVE_INTEGER, DOCTOR_COMPLEXITY_DEFAULTS.max).meta({
|
|
127
|
+
description: "Maximum cyclomatic complexity per function; the complexity check warns above it",
|
|
128
|
+
}),
|
|
129
|
+
}, { unknownKeys: "error" }), DOCTOR_COMPLEXITY_DEFAULTS),
|
|
130
|
+
moduleSize: s.defaulted(s.object({
|
|
131
|
+
maxLines: s.defaulted(POSITIVE_INTEGER, DOCTOR_MODULE_SIZE_DEFAULTS.maxLines).meta({
|
|
132
|
+
description: "Maximum code lines per module; the module-size check warns above it",
|
|
133
|
+
}),
|
|
134
|
+
}, { unknownKeys: "error" }), DOCTOR_MODULE_SIZE_DEFAULTS),
|
|
135
|
+
crap: s.defaulted(s.object({
|
|
136
|
+
max: s.defaulted(POSITIVE_INTEGER, DOCTOR_CRAP_DEFAULTS.max).meta({
|
|
137
|
+
description: "Maximum CRAP score per function; the crap check warns above it",
|
|
138
|
+
}),
|
|
139
|
+
coverage: s.defaulted(s.string(), DOCTOR_CRAP_DEFAULTS.coverage).meta({
|
|
140
|
+
description: "Istanbul coverage-final.json the crap check reads, relative to the project root",
|
|
141
|
+
}),
|
|
142
|
+
}, { unknownKeys: "error" }), DOCTOR_CRAP_DEFAULTS),
|
|
143
|
+
testRatio: s.defaulted(s.object({
|
|
144
|
+
min: s.defaulted(NON_NEGATIVE_NUMBER, DOCTOR_TEST_RATIO_DEFAULTS.min).meta({
|
|
145
|
+
description: "Minimum tests/code ratio from sdxc stats; the test-ratio check warns below it",
|
|
146
|
+
}),
|
|
147
|
+
}, { unknownKeys: "error" }), DOCTOR_TEST_RATIO_DEFAULTS),
|
|
148
|
+
fanOut: s.defaulted(s.object({
|
|
149
|
+
max: s.defaulted(POSITIVE_INTEGER, DOCTOR_FAN_OUT_DEFAULTS.max).meta({
|
|
150
|
+
description: "Maximum distinct modules one file may import; the fan-out check warns above it",
|
|
151
|
+
}),
|
|
152
|
+
}, { unknownKeys: "error" }), DOCTOR_FAN_OUT_DEFAULTS),
|
|
153
|
+
duplication: s.defaulted(s.object({
|
|
154
|
+
minLines: s
|
|
155
|
+
.defaulted(INTEGER_AT_LEAST_TWO, DOCTOR_DUPLICATION_DEFAULTS.minLines)
|
|
156
|
+
.meta({
|
|
157
|
+
description: "Minimum consecutive code lines that count as a duplicated block",
|
|
158
|
+
}),
|
|
159
|
+
}, { unknownKeys: "error" }), DOCTOR_DUPLICATION_DEFAULTS),
|
|
160
|
+
mutation: s.defaulted(s.object({
|
|
161
|
+
report: s.defaulted(s.string(), DOCTOR_MUTATION_DEFAULTS.report).meta({
|
|
162
|
+
description: "Mutation report JSON the mutation check reads, relative to the project root",
|
|
163
|
+
}),
|
|
164
|
+
maxSurvived: s
|
|
165
|
+
.defaulted(NON_NEGATIVE_INTEGER, DOCTOR_MUTATION_DEFAULTS.maxSurvived)
|
|
166
|
+
.meta({
|
|
167
|
+
description: "Maximum surviving mutants the mutation check allows",
|
|
168
|
+
}),
|
|
169
|
+
}, { unknownKeys: "error" }), DOCTOR_MUTATION_DEFAULTS),
|
|
91
170
|
}, { unknownKeys: "error" }), DOCTOR_DEFAULTS),
|
|
171
|
+
run: s.defaulted(s.object({
|
|
172
|
+
entry: s.defaulted(s.string(), RUN_DEFAULTS.entry).meta({
|
|
173
|
+
description: "Module `sdxc run` starts, relative to the project root; apps keep the default",
|
|
174
|
+
}),
|
|
175
|
+
}, { unknownKeys: "error" }), RUN_DEFAULTS),
|
|
92
176
|
format: s.optional(s.array(s.string()).pipe(checks.minItems(1))).meta({
|
|
93
177
|
description: "Command run on every file the CLI writes or edits, paths appended",
|
|
94
178
|
examples: [["bunx", "vp", "fmt", "--no-error-on-unmatched-pattern"]],
|
|
@@ -175,6 +259,9 @@ function configuredPaths(config) {
|
|
|
175
259
|
["ui.directory", config.ui.directory],
|
|
176
260
|
["make.stubs", config.make.stubs],
|
|
177
261
|
["doctor.checks", config.doctor.checks],
|
|
262
|
+
["doctor.crap.coverage", config.doctor.crap.coverage],
|
|
263
|
+
["doctor.mutation.report", config.doctor.mutation.report],
|
|
264
|
+
["run.entry", config.run.entry],
|
|
178
265
|
["lock", config.lock],
|
|
179
266
|
];
|
|
180
267
|
for (let [chain, folder] of Object.entries(config.make.migrations)) {
|