@sdxc/kit 2026.10.17 → 2026.10.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +397 -22
- package/changelog.jsonl +1171 -1092
- package/config.schema.json +53 -1
- package/dist/cli.js +12 -0
- package/dist/commands/deploy.d.ts +23 -0
- package/dist/commands/deploy.js +167 -0
- package/dist/commands/destroy.d.ts +22 -0
- package/dist/commands/destroy.js +92 -0
- package/dist/commands/doctor.d.ts +26 -0
- package/dist/commands/doctor.js +65 -0
- package/dist/commands/initializers.d.ts +16 -0
- package/dist/commands/initializers.js +23 -0
- package/dist/commands/make.d.ts +78 -6
- package/dist/commands/make.js +134 -20
- package/dist/commands/middleware.d.ts +16 -0
- package/dist/commands/middleware.js +21 -0
- package/dist/commands/models.d.ts +18 -0
- package/dist/commands/models.js +29 -0
- package/dist/commands/notes.d.ts +17 -0
- package/dist/commands/notes.js +27 -0
- package/dist/commands/routes.d.ts +25 -0
- package/dist/commands/routes.js +50 -0
- package/dist/commands/run.d.ts +16 -0
- package/dist/commands/run.js +32 -11
- package/dist/commands/scaffold.d.ts +30 -0
- package/dist/commands/scaffold.js +34 -0
- package/dist/commands/schedule.d.ts +16 -0
- package/dist/commands/schedule.js +21 -0
- package/dist/commands/stats.d.ts +16 -0
- package/dist/commands/stats.js +21 -0
- package/dist/commands/ui/update.d.ts +6 -3
- package/dist/commands/ui/update.js +24 -7
- package/dist/commands/upgrade.d.ts +3 -1
- package/dist/commands/upgrade.js +88 -23
- package/dist/config.d.ts +20 -0
- package/dist/config.js +32 -1
- package/dist/contract.d.ts +101 -3
- package/dist/contract.js +371 -26
- package/dist/create/templates.js +3 -2
- package/dist/dependencies.d.ts +5 -1
- package/dist/dependencies.js +16 -1
- package/dist/deploy/plan.d.ts +49 -0
- package/dist/deploy/plan.js +68 -0
- package/dist/destroy.d.ts +40 -0
- package/dist/destroy.js +317 -0
- package/dist/doctor/check.d.ts +71 -0
- package/dist/doctor/check.js +53 -0
- package/dist/doctor/checks.d.ts +23 -0
- package/dist/doctor/checks.js +70 -0
- package/dist/doctor/define.d.ts +59 -0
- package/dist/doctor/define.js +16 -0
- package/dist/doctor/emails.d.ts +18 -0
- package/dist/doctor/emails.js +243 -0
- package/dist/doctor/env.d.ts +26 -0
- package/dist/doctor/env.js +88 -0
- package/dist/doctor/files.d.ts +14 -0
- package/dist/doctor/files.js +34 -0
- package/dist/doctor/fixture.d.ts +23 -0
- package/dist/doctor/fixture.js +46 -0
- package/dist/doctor/install.d.ts +17 -0
- package/dist/doctor/install.js +37 -0
- package/dist/doctor/installed.d.ts +11 -0
- package/dist/doctor/installed.js +79 -0
- package/dist/doctor/jsdoc.d.ts +44 -0
- package/dist/doctor/jsdoc.js +201 -0
- package/dist/doctor/layout.d.ts +23 -0
- package/dist/doctor/layout.js +83 -0
- package/dist/doctor/migrations.d.ts +16 -0
- package/dist/doctor/migrations.js +96 -0
- package/dist/doctor/models.d.ts +13 -0
- package/dist/doctor/models.js +69 -0
- package/dist/doctor/pins.d.ts +15 -0
- package/dist/doctor/pins.js +79 -0
- package/dist/doctor/project.d.ts +58 -0
- package/dist/doctor/project.js +261 -0
- package/dist/doctor/remix.d.ts +14 -0
- package/dist/doctor/remix.js +44 -0
- package/dist/doctor/routes.d.ts +11 -0
- package/dist/doctor/routes.js +49 -0
- package/dist/doctor/typegen.d.ts +13 -0
- package/dist/doctor/typegen.js +57 -0
- package/dist/doctor/ui.d.ts +14 -0
- package/dist/doctor/ui.js +51 -0
- package/dist/initializers.d.ts +25 -0
- package/dist/initializers.js +89 -0
- package/dist/lock.d.ts +2 -2
- package/dist/make/actions.d.ts +23 -0
- package/dist/make/actions.js +82 -0
- package/dist/make/declare.d.ts +31 -3
- package/dist/make/declare.js +284 -9
- package/dist/make/email.d.ts +23 -0
- package/dist/make/email.js +111 -0
- package/dist/make/from-fields.d.ts +30 -0
- package/dist/make/from-fields.js +162 -0
- package/dist/make/from-model.d.ts +39 -0
- package/dist/make/from-model.js +161 -0
- package/dist/make/generate.d.ts +25 -5
- package/dist/make/generate.js +76 -22
- package/dist/make/guard.d.ts +35 -0
- package/dist/make/guard.js +73 -0
- package/dist/make/imports.d.ts +6 -0
- package/dist/make/imports.js +19 -0
- package/dist/make/index.d.ts +49 -4
- package/dist/make/index.js +290 -29
- package/dist/make/kinds.d.ts +34 -2
- package/dist/make/kinds.js +92 -8
- package/dist/make/mount.d.ts +25 -0
- package/dist/make/mount.js +135 -0
- package/dist/make/schema-diff.d.ts +58 -0
- package/dist/make/schema-diff.js +609 -0
- package/dist/make/schema.d.ts +76 -0
- package/dist/make/schema.js +206 -0
- package/dist/make/stubs.d.ts +14 -7
- package/dist/make/stubs.js +24 -8
- package/dist/make/test.d.ts +43 -0
- package/dist/make/test.js +150 -0
- package/dist/make/trigger.d.ts +31 -0
- package/dist/make/trigger.js +163 -0
- package/dist/models.d.ts +42 -0
- package/dist/models.js +149 -0
- package/dist/notes.d.ts +28 -0
- package/dist/notes.js +66 -0
- package/dist/reference.d.ts +27 -0
- package/dist/reference.js +103 -0
- package/dist/releases.d.ts +9 -0
- package/dist/releases.js +29 -8
- package/dist/routes/chains.d.ts +34 -0
- package/dist/routes/chains.js +95 -0
- package/dist/routes/filter.d.ts +53 -0
- package/dist/routes/filter.js +147 -0
- package/dist/routes/format.d.ts +23 -0
- package/dist/routes/format.js +123 -0
- package/dist/routes/helpers.d.ts +21 -0
- package/dist/routes/helpers.js +165 -0
- package/dist/routes/index.d.ts +56 -0
- package/dist/routes/index.js +167 -0
- package/dist/routes/modules.d.ts +116 -0
- package/dist/routes/modules.js +235 -0
- package/dist/routes/parse.d.ts +161 -0
- package/dist/routes/parse.js +621 -0
- package/dist/routes/routers.d.ts +69 -0
- package/dist/routes/routers.js +327 -0
- package/dist/scaffold/fields.d.ts +129 -0
- package/dist/scaffold/fields.js +421 -0
- package/dist/scaffold/index.d.ts +39 -0
- package/dist/scaffold/index.js +622 -0
- package/dist/scaffold/render.d.ts +61 -0
- package/dist/scaffold/render.js +417 -0
- package/dist/schedule.d.ts +45 -0
- package/dist/schedule.js +124 -0
- package/dist/stats.d.ts +37 -0
- package/dist/stats.js +126 -0
- package/dist/ui/commands.d.ts +10 -3
- package/dist/ui/commands.js +85 -15
- package/dist/ui/registry.d.ts +8 -8
- package/dist/upgrade/agents.d.ts +49 -0
- package/dist/upgrade/agents.js +110 -0
- package/dist/upgrade/changelog.d.ts +2 -2
- package/dist/upgrade/project.d.ts +4 -0
- package/dist/upgrade/project.js +11 -1
- package/dist/upgrade/prompt.d.ts +11 -0
- package/dist/upgrade/prompt.js +50 -7
- package/package.json +6 -4
- package/registry/ui/alert-dialog.json +2 -2
- package/registry/ui/attachment.json +2 -2
- package/registry/ui/calendar.json +2 -2
- package/registry/ui/color-picker.json +2 -2
- package/registry/ui/command.json +2 -2
- package/registry/ui/date-picker.json +2 -2
- package/registry/ui/date-range-picker.json +2 -2
- package/registry/ui/dialog.json +2 -2
- package/registry/ui/file-trigger.json +2 -2
- package/registry/ui/heading-scope.json +2 -2
- package/registry/ui/message-scroller.json +2 -2
- package/registry/ui/number-field.json +2 -2
- package/registry/ui/range-calendar.json +2 -2
- package/registry/ui/resizable.json +2 -2
- package/registry/ui/select.json +2 -2
- package/registry/ui/shared-element.json +2 -2
- package/registry/ui/sidebar.json +3 -3
- package/registry/ui/typeset.json +3 -3
- package/stubs/command.spec.stub +15 -0
- package/stubs/controller.api.resource.stub +23 -0
- package/stubs/controller.api.spec.stub +15 -0
- package/stubs/controller.form.stub +2 -2
- package/stubs/controller.form.test.stub +2 -2
- package/stubs/controller.resource.form.stub +67 -0
- package/stubs/controller.resource.stub +28 -0
- package/stubs/controller.spec.stub +15 -0
- package/stubs/email.stub +9 -14
- package/stubs/email.test.stub +9 -9
- package/stubs/factory.stub +1 -1
- package/stubs/mcp.spec.stub +16 -0
- package/stubs/model.stub +3 -3
- package/stubs/policy.test.stub +34 -8
- package/stubs/scaffold.api.create.stub +34 -0
- package/stubs/scaffold.api.create.test.stub +37 -0
- package/stubs/scaffold.api.destroy.stub +34 -0
- package/stubs/scaffold.api.destroy.test.stub +44 -0
- package/stubs/scaffold.api.index.stub +23 -0
- package/stubs/scaffold.api.index.test.stub +31 -0
- package/stubs/scaffold.api.show.stub +27 -0
- package/stubs/scaffold.api.show.test.stub +41 -0
- package/stubs/scaffold.api.update.stub +44 -0
- package/stubs/scaffold.api.update.test.stub +46 -0
- package/stubs/scaffold.command.create.stub +22 -0
- package/stubs/scaffold.command.create.test.stub +30 -0
- package/stubs/scaffold.command.delete.stub +20 -0
- package/stubs/scaffold.command.delete.test.stub +39 -0
- package/stubs/scaffold.command.list.stub +18 -0
- package/stubs/scaffold.command.list.test.stub +31 -0
- package/stubs/scaffold.command.show.stub +19 -0
- package/stubs/scaffold.command.show.test.stub +37 -0
- package/stubs/scaffold.controller.destroy.stub +35 -0
- package/stubs/scaffold.controller.destroy.test.stub +65 -0
- package/stubs/scaffold.controller.edit.stub +97 -0
- package/stubs/scaffold.controller.edit.test.stub +91 -0
- package/stubs/scaffold.controller.index.stub +55 -0
- package/stubs/scaffold.controller.index.test.stub +32 -0
- package/stubs/scaffold.controller.new.stub +70 -0
- package/stubs/scaffold.controller.new.test.stub +81 -0
- package/stubs/scaffold.controller.show.stub +59 -0
- package/stubs/scaffold.controller.show.test.stub +43 -0
- package/stubs/scaffold.factory.stub +16 -0
- package/stubs/scaffold.form.stub +75 -0
- package/stubs/scaffold.mcp.create.stub +24 -0
- package/stubs/scaffold.mcp.create.test.stub +36 -0
- package/stubs/scaffold.mcp.delete.stub +31 -0
- package/stubs/scaffold.mcp.delete.test.stub +43 -0
- package/stubs/scaffold.mcp.get.stub +21 -0
- package/stubs/scaffold.mcp.get.test.stub +31 -0
- package/stubs/scaffold.mcp.list.stub +23 -0
- package/stubs/scaffold.mcp.list.test.stub +25 -0
- package/stubs/scaffold.mcp.update.stub +37 -0
- package/stubs/scaffold.mcp.update.test.stub +40 -0
- package/stubs/scaffold.migration.stub +3 -0
- package/stubs/scaffold.model.stub +35 -0
- package/stubs/scaffold.model.test.stub +25 -0
- package/stubs/scaffold.spec.stub +7 -0
- package/stubs/scaffold.test-database.stub +33 -0
- package/stubs/scaffold.test-mcp.stub +92 -0
- package/stubs/scaffold.validator.stub +18 -0
- package/stubs/scaffold.validator.test.stub +26 -0
- package/templates/app/AGENTS.md +167 -0
- package/templates/app/CLAUDE.md +1 -0
- package/templates/app/README.md +33 -15
- package/templates/app/app/commands/console.test.ts +26 -0
- package/templates/app/app/commands/console.ts +19 -0
- package/templates/app/app/commands/db/fresh.test.ts +57 -0
- package/templates/app/app/commands/db/fresh.ts +37 -0
- package/templates/app/app/commands/db/migrate.test.ts +17 -1
- package/templates/app/app/commands/db/migrate.ts +51 -18
- package/templates/app/app/commands/db/prepare.test.ts +39 -0
- package/templates/app/app/commands/db/prepare.ts +35 -0
- package/templates/app/app/commands/db/seed.test.ts +38 -0
- package/templates/app/app/commands/db/seed.ts +26 -0
- package/templates/app/app/commands/deploy.test.ts +34 -0
- package/templates/app/app/commands/deploy.ts +18 -0
- package/templates/app/app/commands/emails/preview.test.tsx +63 -0
- package/templates/app/app/commands/emails/preview.ts +24 -0
- package/templates/app/app/commands/index.ts +57 -2
- package/templates/app/app/commands/typegen.test.ts +20 -1
- package/templates/app/app/commands/typegen.ts +16 -2
- package/templates/app/app/emails/index.ts +10 -0
- package/templates/app/app/http/middleware/access.test.ts +43 -0
- package/templates/app/app/http/middleware/access.ts +41 -0
- package/templates/app/app/http/middleware/api.ts +12 -3
- package/templates/app/app/http/middleware/page.test.ts +4 -1
- package/templates/app/app/http/middleware/page.ts +7 -5
- package/templates/app/app/initializers/cli.ts +35 -2
- package/templates/app/app/initializers/dispatcher.ts +9 -1
- package/templates/app/app/initializers/mail-transport.test.ts +33 -0
- package/templates/app/app/initializers/mail-transport.ts +26 -0
- package/templates/app/app/initializers/mail.test.ts +17 -17
- package/templates/app/app/initializers/mail.ts +15 -7
- package/templates/app/app/initializers/router.test.ts +7 -0
- package/templates/app/app/initializers/router.tsx +13 -3
- package/templates/app/app/jobs/email.test.tsx +70 -0
- package/templates/app/app/jobs/email.ts +16 -0
- package/templates/app/app/jobs/index.ts +6 -2
- package/templates/app/app/policies/abilities.ts +13 -0
- package/templates/app/app/policies/policy.test.ts +15 -0
- package/templates/app/app/policies/policy.ts +30 -0
- package/templates/app/app/services/commands.ts +30 -0
- package/templates/app/app/services/migrations.test.ts +48 -1
- package/templates/app/app/services/migrations.ts +66 -9
- package/templates/app/app/test/cloudflare-workers.ts +2 -0
- package/templates/app/app/test/local-database.ts +67 -0
- package/templates/app/app/test/session.ts +28 -0
- package/templates/app/bootstrap/console.ts +13 -0
- package/templates/app/cloudflare.config.ts +3 -3
- package/templates/app/database/seed.ts +12 -0
- package/templates/app/package.json +3 -1
- package/templates/app/spec/config.jsonc +16 -0
- package/stubs/policy.stub +0 -16
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The install commands `sdxc doctor` prints as fixes, spelled for the project's package manager:
|
|
3
|
+
* each pins an exact version and keeps a package in the dependency section that lists it, so
|
|
4
|
+
* running the fix changes only the versions the check flagged.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** How each package manager adds an exact version, and the flag that keeps it a dev dependency. */
|
|
10
|
+
const EXACT_ADD = {
|
|
11
|
+
bun: { add: ["bun", "add", "--exact"], dev: "--dev" },
|
|
12
|
+
npm: { add: ["npm", "install", "--save-exact"], dev: "--save-dev" },
|
|
13
|
+
pnpm: { add: ["pnpm", "add", "--save-exact"], dev: "--save-dev" },
|
|
14
|
+
yarn: { add: ["yarn", "add", "--exact"], dev: "--dev" },
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The command that pins each package to its version: one for the packages in `dependencies`
|
|
18
|
+
* and one for those in `devDependencies`, joined with `&&` when both are needed.
|
|
19
|
+
*
|
|
20
|
+
* @param versions - The exact version to pin, by package name
|
|
21
|
+
*/
|
|
22
|
+
export function exactInstallCommand(manager, manifest, versions) {
|
|
23
|
+
let spelling = EXACT_ADD[manager.name];
|
|
24
|
+
let runtime = [];
|
|
25
|
+
let development = [];
|
|
26
|
+
for (let [name, version] of versions) {
|
|
27
|
+
let target = manifest.devDependencies?.[name] === undefined ? runtime : development;
|
|
28
|
+
target.push(`${name}@${version}`);
|
|
29
|
+
}
|
|
30
|
+
let commands = [];
|
|
31
|
+
if (runtime.length > 0)
|
|
32
|
+
commands.push([...spelling.add, ...runtime].join(" "));
|
|
33
|
+
if (development.length > 0) {
|
|
34
|
+
commands.push([...spelling.add, spelling.dev, ...development].join(" "));
|
|
35
|
+
}
|
|
36
|
+
return commands.join(" && ");
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `installed` check: every `@sdxc/*` package and `remix` that `package.json` lists is in
|
|
3
|
+
* `node_modules` at the version it pins, found the way Node resolves it from the project root,
|
|
4
|
+
* so a hoisted workspace install counts and a `package.json` edited without an install does not.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/** Fails on a listed package that is missing or installed at another version than its pin. */
|
|
11
|
+
export declare const installedCheck: Check;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `installed` check: every `@sdxc/*` package and `remix` that `package.json` lists is in
|
|
3
|
+
* `node_modules` at the version it pins, found the way Node resolves it from the project root,
|
|
4
|
+
* so a hoisted workspace install counts and a `package.json` edited without an install does not.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { readFile } from "node:fs/promises";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { isFailure, isSuccess, wrap } from "@sdxc/result";
|
|
12
|
+
import { parse } from "@sdxc/semver";
|
|
13
|
+
import { datedPin } from "../releases.js";
|
|
14
|
+
import { listedScopedPackages, lists } from "../upgrade/project.js";
|
|
15
|
+
import { passed, rangeOf, skipped } from "./check.js";
|
|
16
|
+
/** Fails on a listed package that is missing or installed at another version than its pin. */
|
|
17
|
+
export const installedCheck = {
|
|
18
|
+
name: "installed",
|
|
19
|
+
async run(context) {
|
|
20
|
+
let names = listedScopedPackages(context.manifest);
|
|
21
|
+
if (lists(context.manifest, "remix"))
|
|
22
|
+
names.push("remix");
|
|
23
|
+
if (names.length === 0)
|
|
24
|
+
return skipped("package.json lists no @sdxc package or remix");
|
|
25
|
+
let findings = [];
|
|
26
|
+
for (let name of names) {
|
|
27
|
+
let range = rangeOf(context.manifest, name);
|
|
28
|
+
let installed = await installedVersion(context.root, name);
|
|
29
|
+
if (installed === null) {
|
|
30
|
+
findings.push(`${name} is not installed`);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
let pinned = exactVersion(range);
|
|
34
|
+
if (pinned !== null && pinned !== installed) {
|
|
35
|
+
findings.push(`${name} ${installed} is installed, package.json pins ${pinned}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (findings.length === 0) {
|
|
39
|
+
return passed(`${names.length} packages are installed at the versions package.json pins`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
status: "fail",
|
|
43
|
+
message: "node_modules differs from package.json",
|
|
44
|
+
findings,
|
|
45
|
+
fix: context.manager.install.join(" "),
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The exact version a range pins, `null` for a range that admits several, which any installed
|
|
51
|
+
* version satisfies as far as this check is concerned.
|
|
52
|
+
*/
|
|
53
|
+
function exactVersion(range) {
|
|
54
|
+
let dated = datedPin(range);
|
|
55
|
+
if (dated !== null)
|
|
56
|
+
return dated;
|
|
57
|
+
let bare = range.trim().replace(/^=?v?/, "");
|
|
58
|
+
return isSuccess(parse(bare)) ? bare : null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The version of `name` installed in the nearest `node_modules` at or above `root`, or `null`
|
|
62
|
+
* when no directory up to the filesystem root holds it.
|
|
63
|
+
*/
|
|
64
|
+
async function installedVersion(root, name) {
|
|
65
|
+
let directory = root;
|
|
66
|
+
while (true) {
|
|
67
|
+
let text = await wrap(() => readFile(join(directory, "node_modules", name, "package.json"), "utf8"));
|
|
68
|
+
if (isSuccess(text)) {
|
|
69
|
+
let manifest = wrap(() => JSON.parse(text.data));
|
|
70
|
+
if (isFailure(manifest))
|
|
71
|
+
return null;
|
|
72
|
+
return typeof manifest.data.version === "string" ? manifest.data.version : null;
|
|
73
|
+
}
|
|
74
|
+
let parent = dirname(directory);
|
|
75
|
+
if (parent === directory)
|
|
76
|
+
return null;
|
|
77
|
+
directory = parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `jsdoc` check: every comment in the app's source is a JSDoc block whose description stays
|
|
3
|
+
* within three prose lines, so an edit cannot leave a long narrative or a `//` aside beside the
|
|
4
|
+
* code it describes. Tags are left out of the line budget; `@param`, `@returns` and `@throws`
|
|
5
|
+
* stay on one line, and `@description` is refused.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { Check } from "./check.js";
|
|
11
|
+
/** The most prose lines a JSDoc description may hold. */
|
|
12
|
+
export declare const MAX_DESCRIPTION_LINES = 3;
|
|
13
|
+
/** One finding the check reports for a comment. */
|
|
14
|
+
export interface JsdocFinding {
|
|
15
|
+
/** The file, relative to the project root. */
|
|
16
|
+
file: string;
|
|
17
|
+
/** The 1-based line the comment starts on. */
|
|
18
|
+
line: number;
|
|
19
|
+
/** What is wrong with the comment. */
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Warns on each non-JSDoc comment that is not a tooling directive, each description longer than
|
|
24
|
+
* three prose lines, each banned `@description`, and each `@param` / `@returns` / `@throws` that
|
|
25
|
+
* spills onto a second line.
|
|
26
|
+
*/
|
|
27
|
+
export declare const jsdocCheck: Check;
|
|
28
|
+
/**
|
|
29
|
+
* Every rule breach in `source`, in source order. A file the scanner cannot tokenize is left
|
|
30
|
+
* alone so the type checker names the syntax error.
|
|
31
|
+
*
|
|
32
|
+
* @param file - Path reported in each finding.
|
|
33
|
+
* @param source - The module's text.
|
|
34
|
+
*/
|
|
35
|
+
export declare function inspectComments(file: string, source: string): JsdocFinding[];
|
|
36
|
+
/**
|
|
37
|
+
* Whether `value` is a JSDoc block (`/** … *\/`), the only comment shape a symbol may carry.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isJsdoc(value: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether `value` is a shebang, a triple-slash reference, or a tooling directive the repository
|
|
42
|
+
* keeps as the only non-JSDoc comments.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isToolingDirective(value: string): boolean;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `jsdoc` check: every comment in the app's source is a JSDoc block whose description stays
|
|
3
|
+
* within three prose lines, so an edit cannot leave a long narrative or a `//` aside beside the
|
|
4
|
+
* code it describes. Tags are left out of the line budget; `@param`, `@returns` and `@throws`
|
|
5
|
+
* stay on one line, and `@description` is refused.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from "node:fs/promises";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { tokenize } from "@sdxc/codemod";
|
|
13
|
+
import { isFailure, wrap } from "@sdxc/result";
|
|
14
|
+
import { PROJECT_FOLDERS } from "../stats.js";
|
|
15
|
+
import { passed, skipped } from "./check.js";
|
|
16
|
+
import { isAppSource, listFiles } from "./files.js";
|
|
17
|
+
/** Tags whose description must stay on the same line as the tag. */
|
|
18
|
+
const ONE_LINE_TAGS = new Set([
|
|
19
|
+
"param",
|
|
20
|
+
"arg",
|
|
21
|
+
"argument",
|
|
22
|
+
"returns",
|
|
23
|
+
"return",
|
|
24
|
+
"throws",
|
|
25
|
+
"exception",
|
|
26
|
+
]);
|
|
27
|
+
/** Tags that belong in the comment's prose, not as a block tag. */
|
|
28
|
+
const BANNED_TAGS = new Set(["description", "desc"]);
|
|
29
|
+
/**
|
|
30
|
+
* Tooling directives the repository keeps as the only non-JSDoc comments, matched on the
|
|
31
|
+
* comment body after its markers.
|
|
32
|
+
*/
|
|
33
|
+
const TOOLING = /(?:@ts-(?:expect-error|ignore|nocheck)\b|oxlint-disable(?:-next-line)?\b|biome-ignore\b|eslint-disable(?:-next-line)?\b|prettier-ignore\b|@jsxImportSource\b|@vitest-environment\b|v8 ignore\b|c8 ignore\b|istanbul ignore\b|#__PURE__\b|\/?\s*<reference\b)/;
|
|
34
|
+
/** The most prose lines a JSDoc description may hold. */
|
|
35
|
+
export const MAX_DESCRIPTION_LINES = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Warns on each non-JSDoc comment that is not a tooling directive, each description longer than
|
|
38
|
+
* three prose lines, each banned `@description`, and each `@param` / `@returns` / `@throws` that
|
|
39
|
+
* spills onto a second line.
|
|
40
|
+
*/
|
|
41
|
+
export const jsdocCheck = {
|
|
42
|
+
name: "jsdoc",
|
|
43
|
+
async run(context) {
|
|
44
|
+
let findings = [];
|
|
45
|
+
let files = 0;
|
|
46
|
+
for (let folder of PROJECT_FOLDERS) {
|
|
47
|
+
for (let file of (await listFiles(context.root, folder)).filter(isAppSource)) {
|
|
48
|
+
files += 1;
|
|
49
|
+
let source = await wrap(() => readFile(join(context.root, file), "utf8"));
|
|
50
|
+
if (isFailure(source))
|
|
51
|
+
continue;
|
|
52
|
+
for (let finding of inspectComments(file, source.data)) {
|
|
53
|
+
findings.push(`${finding.file}:${finding.line}: ${finding.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (files === 0)
|
|
58
|
+
return skipped("No app source to read for comments");
|
|
59
|
+
if (findings.length === 0) {
|
|
60
|
+
return passed("Every comment is JSDoc within three description lines");
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
status: "warn",
|
|
64
|
+
message: findings.length === 1
|
|
65
|
+
? "Found 1 comment outside the JSDoc rules"
|
|
66
|
+
: `Found ${findings.length} comments outside the JSDoc rules`,
|
|
67
|
+
findings,
|
|
68
|
+
fix: "Write comments as /** … */, keep the description to 3 lines, put @param/@returns/@throws on one line, and drop @description",
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Every rule breach in `source`, in source order. A file the scanner cannot tokenize is left
|
|
74
|
+
* alone so the type checker names the syntax error.
|
|
75
|
+
*
|
|
76
|
+
* @param file - Path reported in each finding.
|
|
77
|
+
* @param source - The module's text.
|
|
78
|
+
*/
|
|
79
|
+
export function inspectComments(file, source) {
|
|
80
|
+
let tokens = tokenize(file, source);
|
|
81
|
+
if (isFailure(tokens))
|
|
82
|
+
return [];
|
|
83
|
+
let findings = [];
|
|
84
|
+
for (let token of tokens.data) {
|
|
85
|
+
if (token.type !== "comment")
|
|
86
|
+
continue;
|
|
87
|
+
let line = lineOf(source, token.start);
|
|
88
|
+
let value = token.value;
|
|
89
|
+
if (value.startsWith("#!"))
|
|
90
|
+
continue;
|
|
91
|
+
if (isJsdoc(value)) {
|
|
92
|
+
findings.push(...inspectJsdoc(file, line, value));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (isToolingDirective(value))
|
|
96
|
+
continue;
|
|
97
|
+
let kind = value.startsWith("//") ? "//" : "/* … */";
|
|
98
|
+
findings.push({
|
|
99
|
+
file,
|
|
100
|
+
line,
|
|
101
|
+
message: `${kind} comment; write JSDoc (/** … */) or a tooling directive`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return findings;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether `value` is a JSDoc block (`/** … *\/`), the only comment shape a symbol may carry.
|
|
108
|
+
*/
|
|
109
|
+
export function isJsdoc(value) {
|
|
110
|
+
return value.startsWith("/**");
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether `value` is a shebang, a triple-slash reference, or a tooling directive the repository
|
|
114
|
+
* keeps as the only non-JSDoc comments.
|
|
115
|
+
*/
|
|
116
|
+
export function isToolingDirective(value) {
|
|
117
|
+
if (value.startsWith("#!"))
|
|
118
|
+
return true;
|
|
119
|
+
return TOOLING.test(value);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Findings inside one JSDoc block: a description longer than three prose lines, a banned
|
|
123
|
+
* `@description`, or a one-line tag that continues onto further lines.
|
|
124
|
+
*/
|
|
125
|
+
function inspectJsdoc(file, line, value) {
|
|
126
|
+
let blocks = splitBlocks(commentLines(value));
|
|
127
|
+
let findings = [];
|
|
128
|
+
let prose = (blocks[0] ?? []).filter((entry) => entry.trim() !== "");
|
|
129
|
+
if (prose.length > MAX_DESCRIPTION_LINES) {
|
|
130
|
+
findings.push({
|
|
131
|
+
file,
|
|
132
|
+
line,
|
|
133
|
+
message: `description has ${prose.length} lines; keep it to ${MAX_DESCRIPTION_LINES}`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
for (let tagLines of blocks.slice(1)) {
|
|
137
|
+
let first = tagLines[0] ?? "";
|
|
138
|
+
let match = /^@(\S+)/.exec(first);
|
|
139
|
+
let name = match?.[1] ?? "";
|
|
140
|
+
if (BANNED_TAGS.has(name)) {
|
|
141
|
+
findings.push({
|
|
142
|
+
file,
|
|
143
|
+
line,
|
|
144
|
+
message: `@${name} is not allowed; put the prose before the tags`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (ONE_LINE_TAGS.has(name) && tagLines.slice(1).some((entry) => entry.trim() !== "")) {
|
|
148
|
+
findings.push({
|
|
149
|
+
file,
|
|
150
|
+
line,
|
|
151
|
+
message: `@${name} spans ${tagLines.filter((entry) => entry.trim() !== "").length} lines; keep it on one line`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return findings;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Strip the comment markers and the per-line `*` gutter, keeping relative indentation that a
|
|
159
|
+
* fenced `@example` may need.
|
|
160
|
+
*/
|
|
161
|
+
function commentLines(raw) {
|
|
162
|
+
let text = raw.trim();
|
|
163
|
+
if (text.startsWith("/**"))
|
|
164
|
+
text = text.slice(3);
|
|
165
|
+
else if (text.startsWith("/*"))
|
|
166
|
+
text = text.slice(2);
|
|
167
|
+
if (text.endsWith("*/"))
|
|
168
|
+
text = text.slice(0, -2);
|
|
169
|
+
return text.split("\n").map((entry) => entry.replace(/^[ \t]*\*? ?/, "").trimEnd());
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Cut the lines at every block tag that starts a line outside a fenced code block, so the first
|
|
173
|
+
* group is the description and each later group is one tag.
|
|
174
|
+
*/
|
|
175
|
+
function splitBlocks(lines) {
|
|
176
|
+
let blocks = [[]];
|
|
177
|
+
let fence = null;
|
|
178
|
+
for (let line of lines) {
|
|
179
|
+
let fenced = /^\s*(```+|~~~+)/.exec(line);
|
|
180
|
+
if (fenced?.[1]) {
|
|
181
|
+
if (fence === null)
|
|
182
|
+
fence = fenced[1][0] ?? null;
|
|
183
|
+
else if (fenced[1].startsWith(fence))
|
|
184
|
+
fence = null;
|
|
185
|
+
}
|
|
186
|
+
if (fence === null && /^@\S/.test(line))
|
|
187
|
+
blocks.push([line]);
|
|
188
|
+
else
|
|
189
|
+
blocks.at(-1)?.push(line);
|
|
190
|
+
}
|
|
191
|
+
return blocks;
|
|
192
|
+
}
|
|
193
|
+
/** The 1-based line number of `offset` in `source`. */
|
|
194
|
+
function lineOf(source, offset) {
|
|
195
|
+
let line = 1;
|
|
196
|
+
for (let index = 0; index < offset; index++) {
|
|
197
|
+
if (source.charCodeAt(index) === 10)
|
|
198
|
+
line += 1;
|
|
199
|
+
}
|
|
200
|
+
return line;
|
|
201
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `layout` check: the app keeps one folder per kind of code under `app/`, and only entry
|
|
3
|
+
* points sit in `bootstrap/`, which nothing outside it imports. A folder outside the layout
|
|
4
|
+
* gives a file two possible homes, and an import of an entry point drags the whole Worker along.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/** The folders `app/` may hold, one per kind of code. */
|
|
11
|
+
export declare const APP_FOLDERS: ReadonlySet<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Warns on each folder in `app/` the layout has no kind for, and on each import of `bootstrap/`
|
|
14
|
+
* from outside it. A file the module scanner cannot read is left to the type checker.
|
|
15
|
+
*/
|
|
16
|
+
export declare const layoutCheck: Check;
|
|
17
|
+
/**
|
|
18
|
+
* Whether `specifier`, written in `file`, reaches into `bootstrap/` through the `~/bootstrap`
|
|
19
|
+
* alias or a relative path.
|
|
20
|
+
*
|
|
21
|
+
* @param file - The importing file, relative to the project root.
|
|
22
|
+
*/
|
|
23
|
+
export declare function reachesBootstrap(specifier: string, file: string): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `layout` check: the app keeps one folder per kind of code under `app/`, and only entry
|
|
3
|
+
* points sit in `bootstrap/`, which nothing outside it imports. A folder outside the layout
|
|
4
|
+
* gives a file two possible homes, and an import of an entry point drags the whole Worker along.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
10
|
+
import { dirname, join, posix } from "node:path";
|
|
11
|
+
import { findModuleReferences } from "@sdxc/codemod";
|
|
12
|
+
import { isFailure, wrap } from "@sdxc/result";
|
|
13
|
+
import { passed, skipped } from "./check.js";
|
|
14
|
+
import { isAppSource, listFiles } from "./files.js";
|
|
15
|
+
/** The folders `app/` may hold, one per kind of code. */
|
|
16
|
+
export const APP_FOLDERS = new Set([
|
|
17
|
+
"commands",
|
|
18
|
+
"emails",
|
|
19
|
+
"http",
|
|
20
|
+
"initializers",
|
|
21
|
+
"jobs",
|
|
22
|
+
"mcp",
|
|
23
|
+
"models",
|
|
24
|
+
"policies",
|
|
25
|
+
"services",
|
|
26
|
+
"test",
|
|
27
|
+
]);
|
|
28
|
+
/** The folders whose modules must reach `bootstrap/` through nothing. */
|
|
29
|
+
const IMPORTING_FOLDERS = ["app", "config", "database", "resources", "routes"];
|
|
30
|
+
/**
|
|
31
|
+
* Warns on each folder in `app/` the layout has no kind for, and on each import of `bootstrap/`
|
|
32
|
+
* from outside it. A file the module scanner cannot read is left to the type checker.
|
|
33
|
+
*/
|
|
34
|
+
export const layoutCheck = {
|
|
35
|
+
name: "layout",
|
|
36
|
+
async run(context) {
|
|
37
|
+
let entries = await wrap(() => readdir(join(context.root, "app"), { withFileTypes: true }));
|
|
38
|
+
if (isFailure(entries))
|
|
39
|
+
return skipped("No app/ folder in the project");
|
|
40
|
+
let findings = entries.data
|
|
41
|
+
.filter((entry) => entry.isDirectory() && !APP_FOLDERS.has(entry.name))
|
|
42
|
+
.map((entry) => entry.name)
|
|
43
|
+
.sort()
|
|
44
|
+
.map((name) => `app/${name}/ is a folder the app layout has no kind for`);
|
|
45
|
+
for (let folder of IMPORTING_FOLDERS) {
|
|
46
|
+
for (let file of (await listFiles(context.root, folder)).filter(isAppSource)) {
|
|
47
|
+
let source = await wrap(() => readFile(join(context.root, file), "utf8"));
|
|
48
|
+
if (isFailure(source))
|
|
49
|
+
continue;
|
|
50
|
+
let references = findModuleReferences(file, source.data);
|
|
51
|
+
if (isFailure(references))
|
|
52
|
+
continue;
|
|
53
|
+
for (let { specifier } of references.data) {
|
|
54
|
+
if (reachesBootstrap(specifier, file))
|
|
55
|
+
findings.push(`${file} imports ${specifier}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (findings.length === 0) {
|
|
60
|
+
return passed("app/ holds only the layout's folders and nothing imports bootstrap/");
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
status: "warn",
|
|
64
|
+
message: "The project strays from the app layout",
|
|
65
|
+
findings,
|
|
66
|
+
fix: "Move each file to the folder its kind has (sdxc make <kind> shows where), and import a Durable Object from its own module instead of bootstrap/",
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Whether `specifier`, written in `file`, reaches into `bootstrap/` through the `~/bootstrap`
|
|
72
|
+
* alias or a relative path.
|
|
73
|
+
*
|
|
74
|
+
* @param file - The importing file, relative to the project root.
|
|
75
|
+
*/
|
|
76
|
+
export function reachesBootstrap(specifier, file) {
|
|
77
|
+
if (specifier === "~/bootstrap" || specifier.startsWith("~/bootstrap/"))
|
|
78
|
+
return true;
|
|
79
|
+
if (!specifier.startsWith("."))
|
|
80
|
+
return false;
|
|
81
|
+
let target = posix.normalize(posix.join(dirname(file).split("\\").join("/"), specifier));
|
|
82
|
+
return target === "bootstrap" || target.startsWith("bootstrap/");
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `migrations` check: every chain in `make.migrations` replays on an empty database with
|
|
3
|
+
* double-quoted string literals disabled. A new database, a new tenant or a fresh test run
|
|
4
|
+
* replays the whole chain, so a file that only applied on top of old state breaks there first.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/**
|
|
11
|
+
* Fails on each chain whose replay stops, naming the file and SQLite's error. An error that
|
|
12
|
+
* `doctor.migrations.accept` lists is stepped past and reported as a finding, so the rest of the
|
|
13
|
+
* chain is still checked; an entry no error matches any more warns, so the list stays current.
|
|
14
|
+
* The replay code loads `node:sqlite` on first use, so a runtime without it skips this check alone.
|
|
15
|
+
*/
|
|
16
|
+
export declare const migrationsCheck: Check;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `migrations` check: every chain in `make.migrations` replays on an empty database with
|
|
3
|
+
* double-quoted string literals disabled. A new database, a new tenant or a fresh test run
|
|
4
|
+
* replays the whole chain, so a file that only applied on top of old state breaks there first.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { isFailure } from "@sdxc/result";
|
|
10
|
+
import { skipped } from "./check.js";
|
|
11
|
+
/**
|
|
12
|
+
* Fails on each chain whose replay stops, naming the file and SQLite's error. An error that
|
|
13
|
+
* `doctor.migrations.accept` lists is stepped past and reported as a finding, so the rest of the
|
|
14
|
+
* chain is still checked; an entry no error matches any more warns, so the list stays current.
|
|
15
|
+
* The replay code loads `node:sqlite` on first use, so a runtime without it skips this check alone.
|
|
16
|
+
*/
|
|
17
|
+
export const migrationsCheck = {
|
|
18
|
+
name: "migrations",
|
|
19
|
+
async run(context) {
|
|
20
|
+
let loaded = await import("../make/from-model.js").then(async (fromModel) => ({ fromModel, schema: await import("../make/schema-diff.js") }), (error) => (error instanceof Error ? error : new Error(String(error))));
|
|
21
|
+
if (loaded instanceof Error)
|
|
22
|
+
return skipped(`Could not load SQLite: ${loaded.message}`);
|
|
23
|
+
let { fromModel, schema } = loaded;
|
|
24
|
+
let entries = context.config.doctor.migrations.accept;
|
|
25
|
+
let matched = new Set();
|
|
26
|
+
let accepts = (file, message) => {
|
|
27
|
+
let entry = entries.find((item) => item.file === file && namesColumn(message, item.column));
|
|
28
|
+
if (entry === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
matched.add(entry);
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
let findings = [];
|
|
34
|
+
let accepted = [];
|
|
35
|
+
let replayed = [];
|
|
36
|
+
for (let folder of Object.values(context.config.make.migrations)) {
|
|
37
|
+
let chain = await fromModel.readChain(context.root, folder);
|
|
38
|
+
if (isFailure(chain)) {
|
|
39
|
+
findings.push(`${folder}: ${chain.error.message}`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (chain.data.length === 0)
|
|
43
|
+
continue;
|
|
44
|
+
let replay = schema.replayChain(chain.data, { accepts });
|
|
45
|
+
if (isFailure(replay)) {
|
|
46
|
+
findings.push(`${folder}/${replay.error.message}`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
replay.data.db.close();
|
|
50
|
+
for (let failure of replay.data.accepted) {
|
|
51
|
+
accepted.push(`${folder}/${failure.file} accepted: ${failure.message}`);
|
|
52
|
+
}
|
|
53
|
+
replayed.push(folder);
|
|
54
|
+
}
|
|
55
|
+
if (findings.length > 0) {
|
|
56
|
+
return {
|
|
57
|
+
status: "fail",
|
|
58
|
+
message: `${findings.length === 1 ? "A migration chain does" : `${findings.length} migration chains do`} not replay on an empty database`,
|
|
59
|
+
findings,
|
|
60
|
+
fix: "Make the named migration apply to an empty database: quote strings with single quotes, and read a column's old name in a rebuild's SELECT. A migration production already ran goes in doctor.migrations.accept instead",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let stale = entries
|
|
64
|
+
.filter((entry) => !matched.has(entry))
|
|
65
|
+
.map((entry) => `${entry.file} no longer fails on ${entry.column}`);
|
|
66
|
+
if (stale.length > 0) {
|
|
67
|
+
return {
|
|
68
|
+
status: "warn",
|
|
69
|
+
message: stale.length === 1
|
|
70
|
+
? "An accepted migration failure no longer fails"
|
|
71
|
+
: `${stale.length} accepted migration failures no longer fail`,
|
|
72
|
+
findings: [...stale, ...accepted],
|
|
73
|
+
fix: "Remove each entry named above from doctor.migrations.accept in the sdxc configuration",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (replayed.length === 0)
|
|
77
|
+
return skipped("The project has no migrations");
|
|
78
|
+
let replays = `${replayed.join(", ")} ${replayed.length === 1 ? "replays" : "replay"} on an empty database`;
|
|
79
|
+
return {
|
|
80
|
+
status: "pass",
|
|
81
|
+
message: accepted.length === 0
|
|
82
|
+
? replays
|
|
83
|
+
: `${replays} past ${accepted.length === 1 ? "an accepted failure" : `${accepted.length} accepted failures`}`,
|
|
84
|
+
findings: accepted,
|
|
85
|
+
fix: null,
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Whether SQLite's error `message` names `column`, quoted or bare, alone or qualified by its
|
|
91
|
+
* table, so an entry accepts the error it was written for and no other in the same file.
|
|
92
|
+
*/
|
|
93
|
+
function namesColumn(message, column) {
|
|
94
|
+
let named = /column(?: name)?: "?([^"\s]+)"?/.exec(message)?.[1];
|
|
95
|
+
return named === column || named?.endsWith(`.${column}`) === true;
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `models` check: every module in `app/models/` that creates a model is registered in
|
|
3
|
+
* `app/models/index.ts`, since `ctx.models` reaches only what `createModels({ … })` lists and an
|
|
4
|
+
* unregistered model is invisible to every request, job and command.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Check } from "./check.js";
|
|
10
|
+
/** The registry module `sdxc make model` adds each model to. */
|
|
11
|
+
export declare const MODELS_INDEX = "app/models/index.ts";
|
|
12
|
+
/** Warns on each model module the registry imports neither statically nor on first use. */
|
|
13
|
+
export declare const modelsCheck: Check;
|