@ultimat3/cli 31.26.0 → 31.28.0
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/CLAUDE.md +47 -37
- package/README.md +19 -8
- package/package.json +29 -29
- package/src/app-manifest.ts +6 -1
- package/src/app-mcp.ts +17 -3
- package/src/cmd-cache-spec.ts +5 -2
- package/src/cmd-db-spec.ts +2 -3
- package/src/cmd-db.ts +0 -2
- package/src/cmd-deploy-verify-sample.ts +93 -0
- package/src/cmd-deploy-verify.ts +2 -41
- package/src/cmd-dev-spec.ts +15 -1
- package/src/cmd-dev.ts +31 -4
- package/src/cmd-doctor.ts +15 -4
- package/src/cmd-exercise-spec.ts +7 -1
- package/src/cmd-exercise.ts +22 -10
- package/src/cmd-generate.ts +2 -0
- package/src/cmd-jobs-spec.ts +3 -6
- package/src/cmd-jobs.ts +1 -7
- package/src/cmd-logs-spec.ts +2 -1
- package/src/cmd-logs.ts +9 -28
- package/src/cmd-planned.ts +11 -45
- package/src/cmd-profile-frames.ts +99 -0
- package/src/cmd-profile-spec.ts +24 -0
- package/src/cmd-profile.ts +164 -0
- package/src/cmd-repro-spec.ts +13 -1
- package/src/cmd-repro.ts +37 -5
- package/src/cmd-status-sample.ts +57 -0
- package/src/cmd-status-spec.ts +30 -0
- package/src/cmd-status.ts +108 -0
- package/src/cmd-token-spec.ts +5 -2
- package/src/cmd-token.ts +7 -3
- package/src/cmd-upgrade-codemods.ts +71 -0
- package/src/cmd-upgrade-spec.ts +19 -5
- package/src/cmd-upgrade.ts +91 -34
- package/src/codemods/agents-dev-mcp.ts +50 -0
- package/src/codemods/authenticator-session-refusal.ts +214 -0
- package/src/codemods/biome-no-default-export.ts +58 -0
- package/src/codemods/bunfig-island-coverage.ts +33 -0
- package/src/codemods/chart-dashboard.ts +73 -0
- package/src/codemods/ci-e2e-browser-stock.ts +75 -0
- package/src/codemods/ci-e2e-browser.ts +63 -0
- package/src/codemods/codemod.ts +58 -0
- package/src/codemods/define-error-leaf.ts +73 -0
- package/src/codemods/docs-ci-parts.ts +65 -0
- package/src/codemods/docs-gate-prose.ts +53 -0
- package/src/codemods/docs-island-rows.ts +31 -0
- package/src/codemods/docs-shipped-guards.ts +100 -0
- package/src/codemods/docs-test-services.ts +62 -0
- package/src/codemods/engine-diff.ts +104 -0
- package/src/codemods/engine-edits.ts +111 -0
- package/src/codemods/engine-fs.ts +95 -0
- package/src/codemods/engine.ts +191 -0
- package/src/codemods/format-edited-hook-3122.ts +28 -0
- package/src/codemods/format-edited-hook.ts +152 -0
- package/src/codemods/helm-alerts-objective.ts +105 -0
- package/src/codemods/helm-alerts-stock.ts +108 -0
- package/src/codemods/index.ts +56 -0
- package/src/codemods/metrics-probe-healthz.ts +47 -0
- package/src/codemods/pending.ts +36 -0
- package/src/codemods/repro-gitignore.ts +40 -0
- package/src/codemods/runtime-pin-lines.ts +109 -0
- package/src/codemods/runtime-pin.ts +116 -0
- package/src/codemods/solid-floor.ts +63 -0
- package/src/codemods/test-ports.ts +86 -0
- package/src/codemods/test-suites.ts +37 -0
- package/src/codemods/theme-toggle-mount-over.ts +70 -0
- package/src/codemods/vendored-guards.ts +186 -0
- package/src/codemods/verify-floor-skips.ts +88 -0
- package/src/codemods/verify-floor-steps.ts +90 -0
- package/src/coverage-island.ts +121 -0
- package/src/coverage-lcov.ts +49 -5
- package/src/coverage-remap.ts +146 -0
- package/src/db-replay-engine-prepared.ts +66 -0
- package/src/db-replay-engine-template.ts +156 -0
- package/src/db-replay-engine.ts +4 -0
- package/src/db-replay-scratch-reap.ts +54 -0
- package/src/deploy-verify-flags.ts +9 -2
- package/src/deploy-verify-grade.ts +10 -3
- package/src/dev-boot.ts +14 -1
- package/src/dev-dashboard-guard.ts +57 -10
- package/src/dev-host.ts +46 -0
- package/src/dev-tls-cache.ts +103 -0
- package/src/dev-tls-der.ts +69 -0
- package/src/dev-tls.ts +120 -0
- package/src/doctor-advisory-floors.ts +113 -0
- package/src/doctor-browser.ts +60 -0
- package/src/doctor-guards.ts +39 -86
- package/src/doctor-superseded.ts +67 -0
- package/src/error-codes-doctor.ts +12 -4
- package/src/error-codes-verify.ts +47 -0
- package/src/error-codes.ts +20 -23
- package/src/exercise-database.ts +47 -9
- package/src/exercise-push-device.ts +51 -0
- package/src/exercise-route-api.ts +74 -0
- package/src/exercise-routes.ts +14 -5
- package/src/exercise-services.ts +3 -1
- package/src/exercise-shard-flag.ts +47 -0
- package/src/fix-command.ts +2 -2
- package/src/generate-factories.ts +5 -11
- package/src/generate-feature-required.ts +9 -4
- package/src/generate-files.ts +26 -7
- package/src/generate-kinds.ts +5 -1
- package/src/guards-built-in-codes.ts +36 -0
- package/src/guards-built-in-refusal.ts +25 -0
- package/src/guards-built-in.ts +134 -0
- package/src/guards-materialize.ts +42 -0
- package/src/guards-paths.ts +37 -0
- package/src/guards-shipped-names.ts +38 -0
- package/src/guards-vendored.ts +73 -0
- package/src/guards.ts +105 -34
- package/src/index.ts +10 -0
- package/src/island-bundle-options.ts +48 -0
- package/src/island-bundle.ts +18 -46
- package/src/island-link.ts +5 -0
- package/src/island-outputs.ts +5 -0
- package/src/lint-findings.ts +3 -3
- package/src/mcp-errors-verify.ts +35 -0
- package/src/mcp-errors.ts +21 -20
- package/src/mcp-host-logs.ts +121 -0
- package/src/mcp-host.ts +12 -73
- package/src/measure-scope.ts +23 -3
- package/src/messages-floor.ts +19 -0
- package/src/messages-repro.ts +16 -2
- package/src/messages-status.ts +10 -0
- package/src/messages-upgrade.ts +15 -0
- package/src/messages.ts +22 -1
- package/src/registry.ts +4 -0
- package/src/repro-archive-collect.ts +161 -0
- package/src/repro-archive-write.ts +96 -0
- package/src/repro-archive.ts +161 -0
- package/src/repro-bundle.ts +8 -16
- package/src/repro-errors.ts +14 -2
- package/src/repro-framework.ts +53 -0
- package/src/repro-parse.ts +87 -0
- package/src/repro-redact.ts +218 -0
- package/src/repro-scrub.ts +257 -0
- package/src/role-start-types.ts +7 -0
- package/src/role-start.ts +4 -0
- package/src/serve-boot.ts +7 -1
- package/src/serve-env-tls.ts +57 -0
- package/src/solid-loader.ts +27 -10
- package/src/superseded-match.ts +87 -0
- package/src/superseded.ts +84 -0
- package/src/templates/bun-image.ts +48 -0
- package/src/templates/generate-export-rows.ts +136 -0
- package/src/templates/generate-import-rows.ts +186 -0
- package/src/templates/generate-rows-slice.ts +95 -0
- package/src/templates/github/ci.yml.ts +5 -1
- package/src/templates/guard-released-forms.ts +112 -0
- package/src/templates/guard-runtime-pin-test.ts +54 -0
- package/src/templates/guard-runtime-pin.ts +189 -0
- package/src/templates/scaffold-claude-agents.ts +6 -6
- package/src/templates/scaffold-claude-commands.ts +1 -1
- package/src/templates/scaffold-claude-hook.ts +18 -8
- package/src/templates/scaffold-claude.ts +2 -2
- package/src/templates/scaffold-db-package.ts +3 -0
- package/src/templates/scaffold-docs.ts +34 -30
- package/src/templates/scaffold-guards.ts +73 -39
- package/src/templates/scaffold-repo.ts +4 -8
- package/src/templates/scaffold-site.ts +4 -1
- package/src/templates/scaffold-suites.ts +72 -0
- package/src/templates/scaffold-test-services.ts +35 -10
- package/src/templates/scaffold-verify-floor.ts +53 -31
- package/src/templates/shapes/api.ts +4 -0
- package/src/templates/slice-foundation.ts +3 -3
- package/src/unthrown-codes.ts +3 -1
- package/src/upgrade-bun-floor.ts +4 -0
- package/src/upgrade-clean-tree.ts +54 -0
- package/src/upgrade-gate-codemods-install.ts +40 -0
- package/src/upgrade-gate-codemods.ts +151 -0
- package/src/upgrade-gate.ts +44 -7
- package/src/upgrade-guards-baseline.ts +43 -0
- package/src/upgrade-guards.ts +37 -2
- package/src/upgrade-lock.ts +118 -0
- package/src/upgrade-plan.ts +2 -1
- package/src/upgrade-report-codemods.ts +54 -0
- package/src/upgrade-report.ts +55 -27
- package/src/upgrade-signals.ts +91 -0
- package/src/upgrade-unfinished.ts +61 -0
- package/src/verify-coverage-run.ts +42 -11
- package/src/verify-e2e.ts +115 -4
- package/src/verify-floor.ts +27 -0
- package/src/verify-guard-baseline.ts +109 -0
- package/src/verify-live.ts +72 -0
- package/src/verify-merge-skips.ts +51 -0
- package/src/verify-merge.ts +36 -2
- package/src/verify-run.ts +48 -7
- package/src/verify-services.ts +287 -0
- package/src/verify-skip-reason.ts +53 -0
- package/src/verify-strict.ts +108 -0
- package/src/verify-test-command.ts +129 -0
- package/src/verify-tests.ts +39 -126
- package/types/babel-modules.d.ts +2 -0
- package/wiki/CLI-Reference.md +200 -27
- package/wiki/Caching-And-Invalidation.md +1 -1
- package/wiki/Entities-And-Migrations.md +1 -1
- package/wiki/Interface-Rules.md +17 -8
- package/wiki/Jobs-And-Workflows.md +3 -3
- package/wiki/Known-Gaps.md +5 -1
- package/wiki/MCP-And-AI.md +1 -1
- package/wiki/Observability.md +1 -0
- package/wiki/PWA-And-Offline.md +1 -1
- package/wiki/Project-Layout.md +4 -4
- package/wiki/Troubleshooting.md +3 -3
- package/wiki/Tutorial-05-Deploy-Free.md +2 -2
- package/wiki/Upgrading.md +8 -0
package/src/generate-kinds.ts
CHANGED
|
@@ -19,11 +19,13 @@ export const GENERATORS = [
|
|
|
19
19
|
'action',
|
|
20
20
|
'mutator',
|
|
21
21
|
'backfill',
|
|
22
|
-
//
|
|
22
|
+
// Five primitive factories, each its one call in the feature's `jobs/`. Which factories have a
|
|
23
23
|
// generator, and why the rest have none, is `FACTORY_GENERATORS` (`generate-factories.ts`).
|
|
24
24
|
'cron-job',
|
|
25
25
|
'purge',
|
|
26
26
|
'webhook-receiver',
|
|
27
|
+
'export-rows',
|
|
28
|
+
'import-rows',
|
|
27
29
|
'job',
|
|
28
30
|
'route',
|
|
29
31
|
'policy',
|
|
@@ -291,6 +293,8 @@ const EXAMPLE_NAME: Readonly<Record<Generator, string>> = {
|
|
|
291
293
|
'cron-job': 'nightly-report',
|
|
292
294
|
purge: 'purge-retained',
|
|
293
295
|
'webhook-receiver': 'billing-events',
|
|
296
|
+
'export-rows': 'export-posts --feature post',
|
|
297
|
+
'import-rows': 'import-posts --feature post',
|
|
294
298
|
job: 'send-digest',
|
|
295
299
|
route: 'posts',
|
|
296
300
|
policy: 'post',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The codes the shipped guards raise, as `x.manifest.json` facts: a built-in guard that runs is a
|
|
2
|
+
// code this app's gate emits, exactly as a vendored copy's was, so moving the guard into the
|
|
3
|
+
// framework (`vendored-guards`) removes no code from the app's contract. Owned by `@ultimat3/cli`.
|
|
4
|
+
|
|
5
|
+
import type { ErrorCodeFact } from '@ultimat3/manifest';
|
|
6
|
+
import { planBuiltIns, readShippedConfig } from './guards-built-in';
|
|
7
|
+
import { guardPaths } from './guards-paths';
|
|
8
|
+
import { shippedGuardCode } from './guards-shipped-names';
|
|
9
|
+
|
|
10
|
+
/** The package a built-in's code is declared by: the CLI that ships and runs it. */
|
|
11
|
+
export const BUILT_IN_GUARD_PACKAGE = '@ultimat3/cli';
|
|
12
|
+
|
|
13
|
+
const byCode = (a: ErrorCodeFact, b: ErrorCodeFact): number => a.code.localeCompare(b.code);
|
|
14
|
+
|
|
15
|
+
/** Every built-in guard this app runs — any mode but `"off"`, never one it holds a copy of. */
|
|
16
|
+
export async function builtInGuardCodes(root: string): Promise<readonly ErrorCodeFact[]> {
|
|
17
|
+
const { builtIn } = planBuiltIns(
|
|
18
|
+
await guardPaths(root),
|
|
19
|
+
(await readShippedConfig(root)).severity,
|
|
20
|
+
);
|
|
21
|
+
return builtIn
|
|
22
|
+
.map(({ name }) => ({
|
|
23
|
+
code: shippedGuardCode(name),
|
|
24
|
+
package: BUILT_IN_GUARD_PACKAGE,
|
|
25
|
+
}))
|
|
26
|
+
.sort(byCode);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The app's own declarations win a code both name; the built-ins fill the rest, sorted by code. */
|
|
30
|
+
export const withBuiltInGuardCodes = (
|
|
31
|
+
app: readonly ErrorCodeFact[],
|
|
32
|
+
builtIn: readonly ErrorCodeFact[],
|
|
33
|
+
): readonly ErrorCodeFact[] => {
|
|
34
|
+
const declared = new Set(app.map(({ code }) => code));
|
|
35
|
+
return [...app, ...builtIn.filter(({ code }) => !declared.has(code))].sort(byCode);
|
|
36
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// `x g guard <shipped name>` refused: installing the framework is the one way to get a shipped
|
|
2
|
+
// guard (axiom 1), so writing a copy is a second path — and a copy runs in place of the installed
|
|
3
|
+
// guard, never receiving a fix. The refusal names the row that changes how it reports instead.
|
|
4
|
+
|
|
5
|
+
import { UltimateError } from '@ultimat3/core';
|
|
6
|
+
import { SHIPPED_GUARD_CONFIG } from './guards-built-in';
|
|
7
|
+
import { SHIPPED_GUARD_NAMES } from './templates/scaffold-guards';
|
|
8
|
+
|
|
9
|
+
/** A string here until the coordinator registers it in `error-codes.ts`. */
|
|
10
|
+
export const GUARD_BUILT_IN_CODE = 'X_GUARD_BUILT_IN';
|
|
11
|
+
|
|
12
|
+
export class GuardBuiltInError extends UltimateError {
|
|
13
|
+
constructor(name: string) {
|
|
14
|
+
super({
|
|
15
|
+
code: GUARD_BUILT_IN_CODE,
|
|
16
|
+
cause: `${name} is a guard the framework ships, and it already runs on x verify's boundaries step from the installed version — a copy in guards/ would run in its place and never receive a fix`,
|
|
17
|
+
fix: `x verify --only boundaries --json # ${name} already runs: set "${name}": "error", "warning" or "off" in ${SHIPPED_GUARD_CONFIG}, or x g guard app-${name} for a rule of your own`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Throws for a shipped name (already kebab-cased, as the generator reads it); any other is the app's. */
|
|
23
|
+
export function refuseShippedGuardName(name: string): void {
|
|
24
|
+
if (SHIPPED_GUARD_NAMES.includes(name)) throw new GuardBuiltInError(name);
|
|
25
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The shipped guards, run from the INSTALLED framework instead of from copies in the app: which
|
|
2
|
+
// ones run for this app, at what severity, and the module each is imported from. An app's
|
|
3
|
+
// `guards/` holds its own rules and `guards/shipped.json` — a severity per shipped guard, never a
|
|
4
|
+
// copy of one — so a fixed guard reaches every app on its next install, with no hand edit.
|
|
5
|
+
|
|
6
|
+
// why: Bun ships no path joiner; `guards/shipped.json` sits under the app root.
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
9
|
+
import { SHIPPED_GUARD_NAMES, type ShippedGuardName } from './guards-shipped-names';
|
|
10
|
+
import type { Finding } from './output';
|
|
11
|
+
|
|
12
|
+
/** The app's one file about shipped guards. Its presence is the opt-in: absent, an app is legacy. */
|
|
13
|
+
export const SHIPPED_GUARD_CONFIG = 'guards/shipped.json';
|
|
14
|
+
|
|
15
|
+
/** The key inside it. Named once: the problem quotes it and the fix repairs it. */
|
|
16
|
+
export const SHIPPED_SEVERITY_FIELD = 'severity';
|
|
17
|
+
|
|
18
|
+
/** Where a built-in guard says it lives, in a finding: the package that ships it, never the app. */
|
|
19
|
+
export const BUILT_IN_GUARD_PREFIX = '@ultimat3/cli/guards';
|
|
20
|
+
|
|
21
|
+
/** A vendored copy of a shipped guard. A string here until the coordinator registers it. */
|
|
22
|
+
export const GUARD_VENDORED_CODE = 'X_GUARD_VENDORED';
|
|
23
|
+
|
|
24
|
+
/** `"error"` gates, `"warning"` reports only, `"off"` does not run. Absent: the guard's own. */
|
|
25
|
+
export type ShippedSeverity = 'error' | 'warning' | 'off';
|
|
26
|
+
export type ShippedSeverities = Readonly<Record<string, ShippedSeverity>>;
|
|
27
|
+
|
|
28
|
+
const SEVERITIES: readonly string[] = ['error', 'warning', 'off'];
|
|
29
|
+
|
|
30
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
31
|
+
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `{ "severity": { "<shipped guard>": "error" | "warning" | "off" } }`, or the problems. A row
|
|
35
|
+
* naming a guard the framework does not ship is a problem, never ignored: a typo covers nothing.
|
|
36
|
+
*/
|
|
37
|
+
export function parseShippedConfig(
|
|
38
|
+
text: string,
|
|
39
|
+
names: readonly string[] = SHIPPED_GUARD_NAMES,
|
|
40
|
+
): { readonly severity: ShippedSeverities; readonly problems: readonly string[] } {
|
|
41
|
+
let payload: unknown;
|
|
42
|
+
try {
|
|
43
|
+
payload = JSON.parse(text);
|
|
44
|
+
} catch {
|
|
45
|
+
return { severity: {}, problems: ['it does not parse as JSON'] };
|
|
46
|
+
}
|
|
47
|
+
if (!isRecord(payload)) return { severity: {}, problems: ['it is not a JSON object'] };
|
|
48
|
+
const problems: string[] = Object.keys(payload)
|
|
49
|
+
.filter((key) => key !== SHIPPED_SEVERITY_FIELD)
|
|
50
|
+
.map((key) => `${JSON.stringify(key)} is not a key it reads — "${SHIPPED_SEVERITY_FIELD}" is`);
|
|
51
|
+
const raw = payload[SHIPPED_SEVERITY_FIELD];
|
|
52
|
+
if (raw === undefined) return { severity: {}, problems };
|
|
53
|
+
if (!isRecord(raw)) {
|
|
54
|
+
return {
|
|
55
|
+
severity: {},
|
|
56
|
+
problems: [...problems, `"${SHIPPED_SEVERITY_FIELD}" is not an object of guard → severity`],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const severity: Record<string, ShippedSeverity> = {};
|
|
60
|
+
for (const [name, value] of Object.entries(raw)) {
|
|
61
|
+
if (!names.includes(name)) {
|
|
62
|
+
problems.push(
|
|
63
|
+
`"${SHIPPED_SEVERITY_FIELD}" names ${JSON.stringify(name)}, not a shipped guard`,
|
|
64
|
+
);
|
|
65
|
+
} else if (typeof value !== 'string' || !SEVERITIES.includes(value)) {
|
|
66
|
+
problems.push(
|
|
67
|
+
`"${SHIPPED_SEVERITY_FIELD}" gives ${name} ${JSON.stringify(value)}, not "error", "warning" or "off"`,
|
|
68
|
+
);
|
|
69
|
+
} else severity[name] = value as ShippedSeverity;
|
|
70
|
+
}
|
|
71
|
+
return { severity, problems };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The app's config; `severity` undefined when it has none — a legacy app, not yet migrated. */
|
|
75
|
+
export async function readShippedConfig(
|
|
76
|
+
root: string,
|
|
77
|
+
): Promise<{ readonly severity?: ShippedSeverities; readonly problems: readonly string[] }> {
|
|
78
|
+
const file = Bun.file(join(root, SHIPPED_GUARD_CONFIG));
|
|
79
|
+
if (!(await file.exists())) return { problems: [] };
|
|
80
|
+
return parseShippedConfig(await file.text());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* How a built-in runs. `default`: as the guard declares itself. `error`/`warning`: the app's row
|
|
85
|
+
* over it. `legacy`: an app with no `guards/shipped.json` never had this guard gate it, so on
|
|
86
|
+
* `main` everything it says — a broken finding too — is a warning, never red.
|
|
87
|
+
*/
|
|
88
|
+
export type BuiltInMode = 'default' | 'error' | 'warning' | 'legacy';
|
|
89
|
+
|
|
90
|
+
export interface BuiltInGuard {
|
|
91
|
+
readonly name: ShippedGuardName;
|
|
92
|
+
/** What a finding names as its source when the guard does not say: the package, not a file. */
|
|
93
|
+
readonly display: string;
|
|
94
|
+
readonly mode: BuiltInMode;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A shipped name's file in the app's own directory, `.ts` or `.tsx`, or undefined. */
|
|
98
|
+
export const vendoredPath = (paths: readonly string[], name: string): string | undefined =>
|
|
99
|
+
paths.find((path) => path === `guards/${name}.ts` || path === `guards/${name}.tsx`);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The rule, pure: every shipped guard this app runs built in, and the shipped names it holds a
|
|
103
|
+
* copy of. A copy wins — the app's file runs in its place — so an app that has not upgraded keeps
|
|
104
|
+
* exactly the rule it committed; the copy is reported (`vendoredWarning`) and never run twice.
|
|
105
|
+
*/
|
|
106
|
+
export function planBuiltIns(
|
|
107
|
+
appPaths: readonly string[],
|
|
108
|
+
severity: ShippedSeverities | undefined,
|
|
109
|
+
): { readonly builtIn: readonly BuiltInGuard[]; readonly vendored: readonly string[] } {
|
|
110
|
+
const builtIn: BuiltInGuard[] = [];
|
|
111
|
+
const vendored: string[] = [];
|
|
112
|
+
for (const name of SHIPPED_GUARD_NAMES) {
|
|
113
|
+
if (vendoredPath(appPaths, name) !== undefined) {
|
|
114
|
+
vendored.push(name);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const row =
|
|
118
|
+
severity !== undefined && Object.hasOwn(severity, name) ? severity[name] : undefined;
|
|
119
|
+
if (row === 'off') continue;
|
|
120
|
+
const mode: BuiltInMode = severity === undefined ? 'legacy' : (row ?? 'default');
|
|
121
|
+
builtIn.push({ name, display: `${BUILT_IN_GUARD_PREFIX}/${name}.ts`, mode });
|
|
122
|
+
}
|
|
123
|
+
return { builtIn, vendored };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The config's own problems: red, because a row the gate cannot read covers nothing. */
|
|
127
|
+
export const shippedConfigFindings = (problems: readonly string[]): readonly Finding[] =>
|
|
128
|
+
problems.map((problem) => ({
|
|
129
|
+
code: 'X_CONFIG_INVALID',
|
|
130
|
+
cause: `${SHIPPED_GUARD_CONFIG} is not a shipped-guard config: ${problem}`,
|
|
131
|
+
fix: `x verify --only boundaries --json # then write ${SHIPPED_GUARD_CONFIG} as { "${SHIPPED_SEVERITY_FIELD}": { "<guard>": "off" } } — "error", "warning" or "off" per shipped guard: ${SHIPPED_GUARD_NAMES.join(', ')}`,
|
|
132
|
+
docs: ERROR_DOCS_URL,
|
|
133
|
+
at: SHIPPED_GUARD_CONFIG,
|
|
134
|
+
}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// A built-in guard's module on disk, so the gate can `import()` the installed framework's rule. Its
|
|
2
|
+
// own file, apart from `guards-built-in.ts`, because it reads the guard TEMPLATES — which the
|
|
3
|
+
// serving roles' graph never may, and that file is read by the manifest projection on it.
|
|
4
|
+
|
|
5
|
+
// why: Bun ships no rename, no forced remove and no path joiner; the module is written then renamed
|
|
6
|
+
// so a concurrent gate run never imports half a file.
|
|
7
|
+
import { rename, rm } from 'node:fs/promises';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { shippedGuardSource } from './templates/scaffold-guards';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The built-in's module, under the app's ignored `.x/cache/` (never a shared temp dir, where
|
|
13
|
+
* another user could plant the file first), named by its text's hash: a newer install is a new
|
|
14
|
+
* path, so a long-lived process never imports a stale copy from its module cache. Written to a temp
|
|
15
|
+
* file of its own per call — parallel calls in one process never share one — then renamed; the
|
|
16
|
+
* temp is gone either way, and so is a module an older install wrote for the same guard.
|
|
17
|
+
*/
|
|
18
|
+
export async function materializeGuard(root: string, name: string): Promise<string> {
|
|
19
|
+
const source = shippedGuardSource(name) ?? '';
|
|
20
|
+
const dir = join(root, '.x', 'cache', 'guards');
|
|
21
|
+
const file = `${name}-${Bun.hash(source).toString(36)}.ts`;
|
|
22
|
+
const path = join(dir, file);
|
|
23
|
+
const existing = Bun.file(path);
|
|
24
|
+
if ((await existing.exists()) && (await existing.text()) === source) return path;
|
|
25
|
+
const temp = `${path}.${String(process.pid)}.${crypto.randomUUID().slice(0, 8)}.tmp`;
|
|
26
|
+
try {
|
|
27
|
+
await Bun.write(temp, source);
|
|
28
|
+
await rename(temp, path);
|
|
29
|
+
} finally {
|
|
30
|
+
await rm(temp, { force: true });
|
|
31
|
+
}
|
|
32
|
+
await removeStale(dir, name, file);
|
|
33
|
+
return path;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** `<name>-<hash>.ts` an older install wrote — never `file`, never another guard sharing a prefix. */
|
|
37
|
+
async function removeStale(dir: string, name: string, file: string): Promise<void> {
|
|
38
|
+
const own = new RegExp(`^${name.replaceAll('-', '\\-')}-[0-9a-z]+\\.ts$`);
|
|
39
|
+
for await (const entry of new Bun.Glob(`${name}-*.ts`).scan({ cwd: dir })) {
|
|
40
|
+
if (entry !== file && own.test(entry)) await rm(join(dir, entry), { force: true });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Where an app's own guards are, as a leaf: the `guards/` directory and its files. Read by the gate
|
|
2
|
+
// (`guards.ts`), `x doctor` and the manifest's error-code projection, the last on the serving
|
|
3
|
+
// roles' graph — so nothing here imports a template or a runner.
|
|
4
|
+
|
|
5
|
+
// why: Bun has no synchronous stat — `statSync` answers whether `guards` is a directory.
|
|
6
|
+
import { statSync } from 'node:fs';
|
|
7
|
+
// why: Bun has no path-join primitive, and the path must carry the host's separator.
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
/** The directory IS the registration. An app-side list is a list an app can forget to add to. */
|
|
11
|
+
export const GUARD_DIR = 'guards';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Every guard file, app-root-relative and sorted, so two machines report the same findings in the
|
|
15
|
+
* same order. A `*.test.ts` beside a guard is its test, never a second guard — the generator emits
|
|
16
|
+
* one, and importing it would run the suite inside the gate.
|
|
17
|
+
*/
|
|
18
|
+
export async function guardPaths(root: string): Promise<readonly string[]> {
|
|
19
|
+
const dir = join(root, GUARD_DIR);
|
|
20
|
+
// A FILE named `guards` holds no guards — never ENOTDIR out of the gate or `x doctor`; the gate
|
|
21
|
+
// reports it (`guardDirIsFile`), so the author's rules are not silently absent.
|
|
22
|
+
if (guardDirState(root) !== 'directory') return [];
|
|
23
|
+
const paths: string[] = [];
|
|
24
|
+
for await (const entry of new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir, absolute: false })) {
|
|
25
|
+
const path = entry.split('\\').join('/');
|
|
26
|
+
if (/\.(?:test|d)\.tsx?$/.test(path)) continue;
|
|
27
|
+
paths.push(`${GUARD_DIR}/${path}`);
|
|
28
|
+
}
|
|
29
|
+
return paths.sort();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** What `guards` is in this app: the directory, nothing, or something else in its place. */
|
|
33
|
+
export function guardDirState(root: string): 'directory' | 'absent' | 'other' {
|
|
34
|
+
const stat = statSync(join(root, GUARD_DIR), { throwIfNoEntry: false });
|
|
35
|
+
if (stat === undefined) return 'absent';
|
|
36
|
+
return stat.isDirectory() ? 'directory' : 'other';
|
|
37
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The names of the guards the framework ships, as a leaf: no template, no I/O. The serving roles'
|
|
2
|
+
// graph may hold it (`x.manifest.json` lists a built-in's code), which `templates/` never may —
|
|
3
|
+
// so `templates/scaffold-guards.ts` keys its `SHIPPED` table by this list, and tsc holds them equal.
|
|
4
|
+
|
|
5
|
+
export const SHIPPED_GUARD_NAMES = [
|
|
6
|
+
'animated-layout-property',
|
|
7
|
+
'bare-error',
|
|
8
|
+
'error-declared',
|
|
9
|
+
'focus-visible',
|
|
10
|
+
'image-dimensions',
|
|
11
|
+
'island-mount-clears',
|
|
12
|
+
'island-without-states',
|
|
13
|
+
'native-confirm',
|
|
14
|
+
'raw-breakpoint',
|
|
15
|
+
'raw-colour',
|
|
16
|
+
'raw-fetch',
|
|
17
|
+
'raw-interval',
|
|
18
|
+
'raw-length',
|
|
19
|
+
'raw-motion',
|
|
20
|
+
'raw-shadow',
|
|
21
|
+
'raw-z-index',
|
|
22
|
+
'repo-await-in-loop',
|
|
23
|
+
'repo-raw-sql',
|
|
24
|
+
'repo-unbounded',
|
|
25
|
+
'runtime-pin',
|
|
26
|
+
'semantic-interactive',
|
|
27
|
+
'unbounded-fanout',
|
|
28
|
+
'undeclared-custom-property',
|
|
29
|
+
'undefined-style-class',
|
|
30
|
+
'untranslated-string',
|
|
31
|
+
'unzoned-date',
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
export type ShippedGuardName = (typeof SHIPPED_GUARD_NAMES)[number];
|
|
35
|
+
|
|
36
|
+
/** `raw-fetch` → `X_RAW_FETCH`: `templates/guard.ts`' `guardCode` over a name already kebab. */
|
|
37
|
+
export const shippedGuardCode = (name: ShippedGuardName): string =>
|
|
38
|
+
`X_${name.toUpperCase().replaceAll('-', '_')}`;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// A copy of a shipped guard still in an app's `guards/`, judged against every form the framework
|
|
2
|
+
// shipped, and the one finding that names it: an unedited copy is one delete, an edited one a rename
|
|
3
|
+
// to the app's own guard plus a `guards/shipped.json` row, with its diff — the migration, as an edit.
|
|
4
|
+
|
|
5
|
+
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
6
|
+
import { unifiedDiff } from './codemods/engine-diff';
|
|
7
|
+
import { SHIPPED_GUARD_CONFIG } from './guards-built-in';
|
|
8
|
+
import type { Finding } from './output';
|
|
9
|
+
import { RELEASED_GUARD_FORMS } from './templates/guard-released-forms';
|
|
10
|
+
import { shippedGuardForms, shippedGuardSource } from './templates/scaffold-guards';
|
|
11
|
+
|
|
12
|
+
/** A checkout on Windows may write CRLF; the rule is the same text either way. */
|
|
13
|
+
export const sameText = (a: string, b: string): boolean =>
|
|
14
|
+
a.replaceAll('\r\n', '\n') === b.replaceAll('\r\n', '\n');
|
|
15
|
+
|
|
16
|
+
/** A rule-file text's identity across checkouts: CRLF-blind, the key `RELEASED_GUARD_FORMS` holds. */
|
|
17
|
+
export const guardFormHash = (text: string): string =>
|
|
18
|
+
Bun.hash(text.replaceAll('\r\n', '\n')).toString(36);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* How a form the framework shipped reports — the current template or any released before it — or
|
|
22
|
+
* `undefined` when `text` is no such form: the app's edit.
|
|
23
|
+
*/
|
|
24
|
+
export function shippedFormSeverity(
|
|
25
|
+
name: string,
|
|
26
|
+
text: string,
|
|
27
|
+
released: Readonly<
|
|
28
|
+
Record<string, readonly (readonly [string, 'error' | 'warning'])[]>
|
|
29
|
+
> = RELEASED_GUARD_FORMS,
|
|
30
|
+
): 'error' | 'warning' | undefined {
|
|
31
|
+
const current = shippedGuardForms(name).find((form) => sameText(text, form.source));
|
|
32
|
+
if (current !== undefined) return current.severity;
|
|
33
|
+
const hash = guardFormHash(text);
|
|
34
|
+
return (Object.hasOwn(released, name) ? released[name] : undefined)?.find(
|
|
35
|
+
([known]) => known === hash,
|
|
36
|
+
)?.[1];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface VendoredCopy {
|
|
40
|
+
readonly name: string;
|
|
41
|
+
/** App-root-relative: `guards/<name>.ts` or `.tsx`. */
|
|
42
|
+
readonly path: string;
|
|
43
|
+
/** A form the framework shipped, current or released (`shippedFormSeverity`): nobody edited it. */
|
|
44
|
+
readonly identical: boolean;
|
|
45
|
+
/** The shipped guard → this copy, unified; absent when identical. */
|
|
46
|
+
readonly diff?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The copy at `path`, judged against every current form of the shipped guard `name`. */
|
|
50
|
+
export function vendoredCopy(name: string, path: string, source: string): VendoredCopy {
|
|
51
|
+
if (shippedFormSeverity(name, source) !== undefined) return { name, path, identical: true };
|
|
52
|
+
const shipped = shippedGuardSource(name) ?? '';
|
|
53
|
+
return { name, path, identical: false, diff: unifiedDiff(path, shipped, source) };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The edit that resolves a copy — what the `vendored-guards` codemod would have done to it. */
|
|
57
|
+
export function resolvingEdit({ name, path, identical }: VendoredCopy): string {
|
|
58
|
+
const test = `guards/${name}.test.ts`;
|
|
59
|
+
if (identical) return `rm -f ${path} ${test} && x verify --only boundaries --json`;
|
|
60
|
+
const kept = path.replace(`guards/${name}.`, `guards/app-${name}.`);
|
|
61
|
+
return `mv ${path} ${kept} && x verify --only boundaries --json # then "${name}": "off" in ${SHIPPED_GUARD_CONFIG} and ${test}'s import to ./app-${name} — or rm ${path} to take the shipped rule (the diff is x doctor --json's data.guards.differs)`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** One warning per copy: a copy runs in place of the installed guard and never receives a fix. */
|
|
65
|
+
export const vendoredFinding = (copy: VendoredCopy): Finding => ({
|
|
66
|
+
code: 'X_GUARD_VENDORED',
|
|
67
|
+
cause: copy.identical
|
|
68
|
+
? `${copy.path} is an unedited copy of the shipped ${copy.name} guard, which the framework now runs built in: the copy runs in its place, so a fix to it never reaches this app`
|
|
69
|
+
: `${copy.path} is an edited copy of the shipped ${copy.name} guard: it runs in place of the one the framework now runs built in, so a fix to it never reaches this app, and your edit is not yet your own guard`,
|
|
70
|
+
fix: resolvingEdit(copy),
|
|
71
|
+
docs: ERROR_DOCS_URL,
|
|
72
|
+
at: copy.path,
|
|
73
|
+
});
|
package/src/guards.ts
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
// An app's own convention, made into a build error (axiom 3). A file in `guards/` exports one
|
|
2
|
-
// `guard`; the gate discovers the directory and runs each one inside the `boundaries` step
|
|
3
|
-
//
|
|
4
|
-
// and nothing about what
|
|
5
|
-
|
|
6
|
-
// Bun ships no equivalent for either: `
|
|
7
|
-
//
|
|
8
|
-
// absolute path `import()` accepts on every host.
|
|
9
|
-
import { existsSync } from 'node:fs';
|
|
2
|
+
// `guard`; the gate discovers the directory and runs each one inside the `boundaries` step, beside
|
|
3
|
+
// every guard the framework ships (`guards-built-in.ts`). The framework decides what a guard IS —
|
|
4
|
+
// a function returning findings, held to the error contract — and nothing about what it checks.
|
|
5
|
+
|
|
6
|
+
// Bun ships no equivalent for either: `join` builds the host-separator path, and `pathToFileURL` is
|
|
7
|
+
// the only spelling of an absolute path `import()` accepts on every host.
|
|
10
8
|
import { join } from 'node:path';
|
|
11
9
|
import { pathToFileURL } from 'node:url';
|
|
12
10
|
import { ERROR_DOCS_URL, renderCauseValue, renderThrowable } from '@ultimat3/core';
|
|
13
11
|
import { fixProblem } from './error-contract';
|
|
14
12
|
import { type GuardSources, guardSources } from './guard-sources';
|
|
13
|
+
import {
|
|
14
|
+
type BuiltInMode,
|
|
15
|
+
planBuiltIns,
|
|
16
|
+
readShippedConfig,
|
|
17
|
+
shippedConfigFindings,
|
|
18
|
+
vendoredPath,
|
|
19
|
+
} from './guards-built-in';
|
|
20
|
+
import { materializeGuard } from './guards-materialize';
|
|
21
|
+
import { GUARD_DIR, guardDirState, guardPaths } from './guards-paths';
|
|
22
|
+
|
|
23
|
+
/** The app's guard directory and its files, defined in the leaf the manifest projection reads. */
|
|
24
|
+
export { GUARD_DIR, guardPaths } from './guards-paths';
|
|
25
|
+
|
|
26
|
+
import { vendoredCopy, vendoredFinding } from './guards-vendored';
|
|
15
27
|
import type { Finding } from './output';
|
|
28
|
+
import { readVerifyFloor } from './verify-floor';
|
|
29
|
+
import type { GuardBaseline } from './verify-guard-baseline';
|
|
30
|
+
import { guardNameOf, judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
const compareNames = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
33
|
+
|
|
34
|
+
/** A built-in sorts where its copy in `guards/` would have: the order an app always saw. */
|
|
35
|
+
const sortKey = (run: GuardRun): string =>
|
|
36
|
+
run.mode === undefined ? run.path : `${GUARD_DIR}/${guardNameOf(run.path)}.ts`;
|
|
19
37
|
|
|
20
38
|
export interface Guard {
|
|
21
39
|
/** What this app refuses, in one line. It names the rule when the guard itself is the problem. */
|
|
@@ -97,23 +115,6 @@ function findingOf(value: Record<string, unknown>, at: string): Finding {
|
|
|
97
115
|
};
|
|
98
116
|
}
|
|
99
117
|
|
|
100
|
-
/**
|
|
101
|
-
* Every guard file, app-root-relative and sorted, so two machines report the same findings in the
|
|
102
|
-
* same order. A `*.test.ts` beside a guard is its test, never a second guard — the generator emits
|
|
103
|
-
* one, and importing it would run the suite inside the gate.
|
|
104
|
-
*/
|
|
105
|
-
export async function guardPaths(root: string): Promise<readonly string[]> {
|
|
106
|
-
const dir = join(root, GUARD_DIR);
|
|
107
|
-
if (!existsSync(dir)) return [];
|
|
108
|
-
const paths: string[] = [];
|
|
109
|
-
for await (const entry of new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir, absolute: false })) {
|
|
110
|
-
const path = entry.split('\\').join('/');
|
|
111
|
-
if (/\.(?:test|d)\.tsx?$/.test(path)) continue;
|
|
112
|
-
paths.push(`${GUARD_DIR}/${path}`);
|
|
113
|
-
}
|
|
114
|
-
return paths.sort();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
118
|
const failed = (path: string, cause: string): Finding => ({
|
|
118
119
|
code: 'X_GUARD_FAILED',
|
|
119
120
|
cause,
|
|
@@ -146,6 +147,15 @@ const notAGuard = (path: string, exported: unknown): Finding => {
|
|
|
146
147
|
);
|
|
147
148
|
};
|
|
148
149
|
|
|
150
|
+
/** A file where `guards/` belongs: no crash, and not silence — the app's own rules are not running. */
|
|
151
|
+
const notADirectory: Finding = {
|
|
152
|
+
code: 'X_GUARD_INVALID',
|
|
153
|
+
cause: `${GUARD_DIR} is not a directory, so none of this app's own guards can run beside the shipped ones`,
|
|
154
|
+
fix: `mv ${GUARD_DIR} ${GUARD_DIR}.txt && mkdir ${GUARD_DIR} && x verify --only boundaries --json # ${GUARD_DIR}/ is the directory the gate discovers; a rule of yours goes in it as ${GUARD_DIR}/<name>.ts`,
|
|
155
|
+
docs: ERROR_DOCS_URL,
|
|
156
|
+
at: GUARD_DIR,
|
|
157
|
+
};
|
|
158
|
+
|
|
149
159
|
const findingInvalid = (path: string, cause: string): Finding => ({
|
|
150
160
|
code: 'X_GUARD_FINDING_INVALID',
|
|
151
161
|
cause: `${path} returned a finding that is not one: ${cause}`,
|
|
@@ -166,11 +176,39 @@ export interface GuardReport {
|
|
|
166
176
|
|
|
167
177
|
const refused = (finding: Finding): GuardReport => ({ findings: [finding], warnings: [] });
|
|
168
178
|
|
|
179
|
+
/** A guard to run: what findings name it by, and the module that holds it. */
|
|
180
|
+
interface GuardRun {
|
|
181
|
+
/** App-root-relative for the app's own; `@ultimat3/cli/guards/<name>.ts` for a built-in. */
|
|
182
|
+
readonly path: string;
|
|
183
|
+
/** The absolute module path `import()` reads; for a built-in, under `.x/cache/guards/`. */
|
|
184
|
+
readonly file: string;
|
|
185
|
+
/** A built-in's mode (`guards-built-in.ts`); absent for the app's own guard. */
|
|
186
|
+
readonly mode?: BuiltInMode;
|
|
187
|
+
}
|
|
188
|
+
|
|
169
189
|
/** One guard: import it, run it, and hold what it returns to the contract. Never throws. */
|
|
170
|
-
async function runGuard(
|
|
190
|
+
async function runGuard(
|
|
191
|
+
root: string,
|
|
192
|
+
run: GuardRun,
|
|
193
|
+
sources: GuardSources,
|
|
194
|
+
baseline: GuardBaseline | undefined,
|
|
195
|
+
): Promise<GuardReport> {
|
|
196
|
+
const report = await runGuardModule(root, run, sources, baseline);
|
|
197
|
+
// A legacy app never had this built-in gate it: everything it says is a warning on `main`.
|
|
198
|
+
return run.mode === 'legacy'
|
|
199
|
+
? { findings: [], warnings: [...report.findings, ...report.warnings] }
|
|
200
|
+
: report;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function runGuardModule(
|
|
204
|
+
root: string,
|
|
205
|
+
{ path, file, mode }: GuardRun,
|
|
206
|
+
sources: GuardSources,
|
|
207
|
+
baseline: GuardBaseline | undefined,
|
|
208
|
+
): Promise<GuardReport> {
|
|
171
209
|
let loaded: unknown;
|
|
172
210
|
try {
|
|
173
|
-
loaded = await import(pathToFileURL(
|
|
211
|
+
loaded = await import(pathToFileURL(file).href);
|
|
174
212
|
} catch (error) {
|
|
175
213
|
return refused(failed(path, `${path} could not be imported: ${messageOf(error)}`));
|
|
176
214
|
}
|
|
@@ -201,9 +239,13 @@ async function runGuard(root: string, path: string, sources: GuardSources): Prom
|
|
|
201
239
|
broken.push(findingInvalid(path, `it could not be read: ${messageOf(error)}`));
|
|
202
240
|
}
|
|
203
241
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
242
|
+
// The app's row (`guards/shipped.json`) over a built-in's own severity, either way.
|
|
243
|
+
const reportOnly = mode === 'warning' || (mode !== 'error' && exported.severity === 'warning');
|
|
244
|
+
if (reportOnly) return { findings: broken, warnings: held };
|
|
245
|
+
// A gating guard under its `guardBaseline` (`verify-guard-baseline.ts`): a broken finding is
|
|
246
|
+
// never counted against it — the contract fails either way.
|
|
247
|
+
const judged = judgeGuardBaseline(path, held, baseline);
|
|
248
|
+
return { findings: [...broken, ...judged.findings], warnings: judged.notices };
|
|
207
249
|
}
|
|
208
250
|
|
|
209
251
|
/**
|
|
@@ -221,11 +263,40 @@ export const guardReport = async (
|
|
|
221
263
|
const findings: Finding[] = [];
|
|
222
264
|
const warnings: Finding[] = [];
|
|
223
265
|
const sources = guardSources(root, seed);
|
|
224
|
-
|
|
225
|
-
|
|
266
|
+
// Read here, not passed in: every caller of this seam — the step, `x upgrade`'s measuring run —
|
|
267
|
+
// judges the same committed counts, and a floor problem is the `manifest` step's to report.
|
|
268
|
+
const baseline = (await readVerifyFloor(root))?.guardBaseline;
|
|
269
|
+
const paths = await guardPaths(root);
|
|
270
|
+
const config = await readShippedConfig(root);
|
|
271
|
+
const { builtIn, vendored } = planBuiltIns(paths, config.severity);
|
|
272
|
+
const runs: GuardRun[] = paths.map((path) => ({ path, file: join(root, path) }));
|
|
273
|
+
for (const guard of builtIn) {
|
|
274
|
+
runs.push({
|
|
275
|
+
path: guard.display,
|
|
276
|
+
file: await materializeGuard(root, guard.name),
|
|
277
|
+
mode: guard.mode,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
// By guard name, so an app holding every shipped copy reports in the order it always did.
|
|
281
|
+
runs.sort((a, b) => compareNames(sortKey(a), sortKey(b)));
|
|
282
|
+
for (const run of runs) {
|
|
283
|
+
const report = await runGuard(root, run, sources, baseline);
|
|
226
284
|
findings.push(...report.findings);
|
|
227
285
|
warnings.push(...report.warnings);
|
|
228
286
|
}
|
|
287
|
+
findings.push(...shippedConfigFindings(config.problems));
|
|
288
|
+
if (guardDirState(root) === 'other') findings.push(notADirectory);
|
|
289
|
+
findings.push(
|
|
290
|
+
...orphanedBaselineFindings(
|
|
291
|
+
runs.map((run) => run.path),
|
|
292
|
+
baseline,
|
|
293
|
+
),
|
|
294
|
+
);
|
|
295
|
+
for (const name of vendored) {
|
|
296
|
+
const path = vendoredPath(paths, name) ?? `${GUARD_DIR}/${name}.ts`;
|
|
297
|
+
const source = await Bun.file(join(root, path)).text();
|
|
298
|
+
warnings.push(vendoredFinding(vendoredCopy(name, path, source)));
|
|
299
|
+
}
|
|
229
300
|
return { findings, warnings };
|
|
230
301
|
};
|
|
231
302
|
|
package/src/index.ts
CHANGED
|
@@ -112,6 +112,15 @@ export { DEFAULT_ORIGIN, isPrerenderable, prerenderSite } from './prerender';
|
|
|
112
112
|
export type { PwaArtifacts } from './pwa-artifacts';
|
|
113
113
|
export { loadPwaArtifacts } from './pwa-artifacts';
|
|
114
114
|
export { cliVersion, SPECS } from './registry';
|
|
115
|
+
// What `create-ultimate repro` opens a bundle with, so the opener restates none of it.
|
|
116
|
+
export { BUNDLE_FORMAT, bundleReproducer } from './repro-archive';
|
|
117
|
+
export { ReproBundleInvalidError } from './repro-errors';
|
|
118
|
+
export {
|
|
119
|
+
frameworkCheckoutFrom,
|
|
120
|
+
frameworkOverrides,
|
|
121
|
+
isFrameworkCheckout,
|
|
122
|
+
} from './repro-framework';
|
|
123
|
+
export { parseReproSubject } from './repro-parse';
|
|
115
124
|
export type { RunningRoles, WebBinding } from './role-start';
|
|
116
125
|
export { DEV_BINDING, DEV_ROLES, startRoles } from './role-start';
|
|
117
126
|
// `shotCommand`, `prCommand` and `ciCommand` are deliberately NOT re-exported here. They reach
|
|
@@ -153,6 +162,7 @@ export { writeSiteSeo } from './site-seo-write';
|
|
|
153
162
|
export { eachSourceFile, isGenerated, isTest, SOURCE_GLOBS } from './source-files';
|
|
154
163
|
export type { SkippedRoute, StaticReport } from './static-report';
|
|
155
164
|
export { parseStaticReport } from './static-report';
|
|
165
|
+
export { PLACEHOLDER_DB_MODULE } from './templates/scaffold-db-client';
|
|
156
166
|
export type { MigratedDatabaseOptions } from './test-database';
|
|
157
167
|
export { migratedDatabase } from './test-database';
|
|
158
168
|
export { filesIn, testArgs } from './test-shards';
|