@ultimat3/cli 31.27.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 +3 -1
- package/README.md +14 -4
- package/package.json +29 -29
- package/src/app-manifest.ts +6 -1
- package/src/cmd-doctor.ts +11 -3
- package/src/cmd-repro-spec.ts +13 -1
- package/src/cmd-repro.ts +37 -5
- 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/doctor-advisory-floors.ts +113 -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.ts +6 -0
- package/src/exercise-database.ts +7 -2
- package/src/generate-files.ts +6 -5
- 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 +90 -34
- package/src/index.ts +10 -0
- package/src/lint-findings.ts +3 -3
- package/src/mcp-errors.ts +11 -1
- package/src/measure-scope.ts +23 -3
- package/src/messages-repro.ts +16 -2
- package/src/messages-upgrade.ts +15 -0
- package/src/messages.ts +1 -1
- 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/superseded-match.ts +87 -0
- package/src/superseded.ts +84 -0
- package/src/templates/bun-image.ts +48 -0
- package/src/templates/github/ci.yml.ts +1 -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-docs.ts +26 -24
- package/src/templates/scaffold-guards.ts +73 -39
- package/src/templates/scaffold-repo.ts +2 -1
- package/src/unthrown-codes.ts +2 -0
- 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 +38 -6
- 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 +52 -27
- package/src/upgrade-signals.ts +91 -0
- package/src/upgrade-unfinished.ts +61 -0
- package/wiki/CLI-Reference.md +58 -4
- package/wiki/Interface-Rules.md +17 -8
- package/wiki/Observability.md +1 -0
- package/wiki/Project-Layout.md +4 -4
- package/wiki/Upgrading.md +5 -0
|
@@ -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,24 +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';
|
|
16
28
|
import { readVerifyFloor } from './verify-floor';
|
|
17
29
|
import type { GuardBaseline } from './verify-guard-baseline';
|
|
18
|
-
import { judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
|
|
30
|
+
import { guardNameOf, judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
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`;
|
|
22
37
|
|
|
23
38
|
export interface Guard {
|
|
24
39
|
/** What this app refuses, in one line. It names the rule when the guard itself is the problem. */
|
|
@@ -100,23 +115,6 @@ function findingOf(value: Record<string, unknown>, at: string): Finding {
|
|
|
100
115
|
};
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
/**
|
|
104
|
-
* Every guard file, app-root-relative and sorted, so two machines report the same findings in the
|
|
105
|
-
* same order. A `*.test.ts` beside a guard is its test, never a second guard — the generator emits
|
|
106
|
-
* one, and importing it would run the suite inside the gate.
|
|
107
|
-
*/
|
|
108
|
-
export async function guardPaths(root: string): Promise<readonly string[]> {
|
|
109
|
-
const dir = join(root, GUARD_DIR);
|
|
110
|
-
if (!existsSync(dir)) return [];
|
|
111
|
-
const paths: string[] = [];
|
|
112
|
-
for await (const entry of new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir, absolute: false })) {
|
|
113
|
-
const path = entry.split('\\').join('/');
|
|
114
|
-
if (/\.(?:test|d)\.tsx?$/.test(path)) continue;
|
|
115
|
-
paths.push(`${GUARD_DIR}/${path}`);
|
|
116
|
-
}
|
|
117
|
-
return paths.sort();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
118
|
const failed = (path: string, cause: string): Finding => ({
|
|
121
119
|
code: 'X_GUARD_FAILED',
|
|
122
120
|
cause,
|
|
@@ -149,6 +147,15 @@ const notAGuard = (path: string, exported: unknown): Finding => {
|
|
|
149
147
|
);
|
|
150
148
|
};
|
|
151
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
|
+
|
|
152
159
|
const findingInvalid = (path: string, cause: string): Finding => ({
|
|
153
160
|
code: 'X_GUARD_FINDING_INVALID',
|
|
154
161
|
cause: `${path} returned a finding that is not one: ${cause}`,
|
|
@@ -169,16 +176,39 @@ export interface GuardReport {
|
|
|
169
176
|
|
|
170
177
|
const refused = (finding: Finding): GuardReport => ({ findings: [finding], warnings: [] });
|
|
171
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
|
+
|
|
172
189
|
/** One guard: import it, run it, and hold what it returns to the contract. Never throws. */
|
|
173
190
|
async function runGuard(
|
|
174
191
|
root: string,
|
|
175
|
-
|
|
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,
|
|
176
206
|
sources: GuardSources,
|
|
177
207
|
baseline: GuardBaseline | undefined,
|
|
178
208
|
): Promise<GuardReport> {
|
|
179
209
|
let loaded: unknown;
|
|
180
210
|
try {
|
|
181
|
-
loaded = await import(pathToFileURL(
|
|
211
|
+
loaded = await import(pathToFileURL(file).href);
|
|
182
212
|
} catch (error) {
|
|
183
213
|
return refused(failed(path, `${path} could not be imported: ${messageOf(error)}`));
|
|
184
214
|
}
|
|
@@ -209,7 +239,9 @@ async function runGuard(
|
|
|
209
239
|
broken.push(findingInvalid(path, `it could not be read: ${messageOf(error)}`));
|
|
210
240
|
}
|
|
211
241
|
}
|
|
212
|
-
|
|
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 };
|
|
213
245
|
// A gating guard under its `guardBaseline` (`verify-guard-baseline.ts`): a broken finding is
|
|
214
246
|
// never counted against it — the contract fails either way.
|
|
215
247
|
const judged = judgeGuardBaseline(path, held, baseline);
|
|
@@ -235,12 +267,36 @@ export const guardReport = async (
|
|
|
235
267
|
// judges the same committed counts, and a floor problem is the `manifest` step's to report.
|
|
236
268
|
const baseline = (await readVerifyFloor(root))?.guardBaseline;
|
|
237
269
|
const paths = await guardPaths(root);
|
|
238
|
-
|
|
239
|
-
|
|
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);
|
|
240
284
|
findings.push(...report.findings);
|
|
241
285
|
warnings.push(...report.warnings);
|
|
242
286
|
}
|
|
243
|
-
findings.push(...
|
|
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
|
+
}
|
|
244
300
|
return { findings, warnings };
|
|
245
301
|
};
|
|
246
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';
|
package/src/lint-findings.ts
CHANGED
|
@@ -64,7 +64,7 @@ const editFinding = (diagnostic: Diagnostic): Finding => {
|
|
|
64
64
|
return {
|
|
65
65
|
code: 'X_LINT_FAILED',
|
|
66
66
|
cause: `${place} ${category}: ${message}`,
|
|
67
|
-
fix: `bunx biome check ${quoteArg(path)} # ${category}: edit ${commentSafe(place)}, ${commentSafe(message)}`,
|
|
67
|
+
fix: `bunx @biomejs/biome check ${quoteArg(path)} # ${category}: edit ${commentSafe(place)}, ${commentSafe(message)}`,
|
|
68
68
|
docs: ERROR_DOCS_URL,
|
|
69
69
|
at: path,
|
|
70
70
|
};
|
|
@@ -78,7 +78,7 @@ const writeFinding = (diagnostics: readonly Diagnostic[]): Finding => {
|
|
|
78
78
|
code: 'X_LINT_FAILED',
|
|
79
79
|
cause: places.join('; '),
|
|
80
80
|
// Each path through `quoteArg`, joined after: one command, every file one argument.
|
|
81
|
-
fix: ['bunx biome check --write', ...paths.map(quoteArg)].join(' '),
|
|
81
|
+
fix: ['bunx @biomejs/biome check --write', ...paths.map(quoteArg)].join(' '),
|
|
82
82
|
docs: ERROR_DOCS_URL,
|
|
83
83
|
...(paths.length === 1 ? { at: paths[0] } : {}),
|
|
84
84
|
};
|
|
@@ -119,7 +119,7 @@ export function lintOutcome(result: ExecResult): StepOutcome {
|
|
|
119
119
|
{
|
|
120
120
|
code: 'X_LINT_FAILED',
|
|
121
121
|
cause: 'biome exited red and reported no diagnostic to read',
|
|
122
|
-
fix: 'bunx biome check .',
|
|
122
|
+
fix: 'bunx @biomejs/biome check .',
|
|
123
123
|
docs: ERROR_DOCS_URL,
|
|
124
124
|
},
|
|
125
125
|
],
|
package/src/mcp-errors.ts
CHANGED
|
@@ -79,7 +79,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
79
79
|
X_CLI_UNEXPECTED: 'x doctor --json',
|
|
80
80
|
// `-p .`: an app root has no `references`, so the gate's own step runs this form (#450).
|
|
81
81
|
X_TYPECHECK_FAILED: 'bunx tsc -p . --pretty false',
|
|
82
|
-
X_LINT_FAILED: 'bunx biome check .',
|
|
82
|
+
X_LINT_FAILED: 'bunx @biomejs/biome check .',
|
|
83
83
|
X_TEST_FAILED: 'x test --json # the finding carries the exact bun test invocation that failed',
|
|
84
84
|
X_FILE_TOO_LONG: 'x verify --json # the finding names the file to split',
|
|
85
85
|
X_PACKAGE_SHAPE: 'bun run verify --json # every finding carries its own new-package.ts command',
|
|
@@ -393,6 +393,16 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
393
393
|
X_PROFILE_ROUTE_FAILED: 'x routes --json',
|
|
394
394
|
X_ROWS_SLICE_ENTITY:
|
|
395
395
|
'x help g --json # then generate a job with the name and feature the finding names, and declare exportRows/importRows in it over the table that entity.ts declares',
|
|
396
|
+
X_SUPERSEDED_WORKAROUND:
|
|
397
|
+
'x doctor --json # each finding names the file, the release that retired the workaround and its replacement',
|
|
398
|
+
X_GUARD_VENDORED: 'x upgrade --json',
|
|
399
|
+
X_GUARD_BUILT_IN:
|
|
400
|
+
'x verify --only boundaries --json # set its severity in guards/shipped.json, or generate an app guard under another name',
|
|
401
|
+
X_REPRO_BUNDLE_INVALID:
|
|
402
|
+
'x repro --json # lists the failing jobs and error groups; then run it again with one id and --bundle, and attach the file it writes',
|
|
403
|
+
X_ADVISORY_FLOOR_UNMET: 'bun update source-map-js immutable',
|
|
404
|
+
X_UPGRADE_CODEMODS_PENDING: 'x upgrade --json',
|
|
405
|
+
X_UPGRADE_LOCKED: 'cat .x/upgrade.lock',
|
|
396
406
|
};
|
|
397
407
|
|
|
398
408
|
const isCliCode = (code: string): code is CliErrorCode =>
|
package/src/measure-scope.ts
CHANGED
|
@@ -27,6 +27,23 @@ interface ScopeInput {
|
|
|
27
27
|
readonly buildId: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const originOf = (url: string | undefined): string | undefined =>
|
|
31
|
+
url !== undefined && URL.canParse(url) ? new URL(url).origin : undefined;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether `url` is the app's own: the build's origin, or the `APP_URL` its typed client posts to
|
|
35
|
+
* (read at the call — `withAppUrl` may set it after the scope is built). Any other host is a call
|
|
36
|
+
* out the page makes in production too — a CMS, a vendor API — and reaches the network: answered by
|
|
37
|
+
* the app's pipeline it was a 404, and the route was filed unmeasured for a fetch it never made.
|
|
38
|
+
*/
|
|
39
|
+
function ownedBy(origin: string): (url: string) => boolean {
|
|
40
|
+
return (url) => {
|
|
41
|
+
const target = originOf(url);
|
|
42
|
+
if (target === undefined) return false;
|
|
43
|
+
return target === originOf(origin) || target === originOf(process.env['APP_URL'] || undefined);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () => T) => T {
|
|
31
48
|
// No rate limit: every request here is this build's own render, and a limiter would need a
|
|
32
49
|
// deployment scope a build does not have (`X_RATE_LIMIT_SCOPE_UNSET`).
|
|
@@ -46,7 +63,9 @@ function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () =>
|
|
|
46
63
|
const dispatch = (url: string, init: RequestInit): Promise<Response> =>
|
|
47
64
|
pipeline.handle(new Request(url, init), { role: 'web' });
|
|
48
65
|
const request: Ctx = ctx;
|
|
49
|
-
|
|
66
|
+
const owns = ownedBy(input.origin);
|
|
67
|
+
return <T>(fn: () => T): T =>
|
|
68
|
+
withInProcessFetch(dispatch, () => runWithContext(request, fn), owns);
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
/** A measurement scope's input: the app at `root`, whose `runtime.ts` the build honours. */
|
|
@@ -56,8 +75,9 @@ interface MeasureInput extends ScopeInput {
|
|
|
56
75
|
|
|
57
76
|
/**
|
|
58
77
|
* The scope for `origin`. The pipeline is the app's API table and nothing else: a page's data
|
|
59
|
-
* comes from its actions and queries, and a route the render reaches that is
|
|
60
|
-
* answers 404 — which the render reports, and the route is filed unmeasured with
|
|
78
|
+
* comes from its actions and queries, and a route on the app's origin the render reaches that is
|
|
79
|
+
* not one of them answers 404 — which the render reports, and the route is filed unmeasured with
|
|
80
|
+
* that reason. Another host's url is not the app's (`ownedBy`), and reaches the network.
|
|
61
81
|
* For a render that is WEIGHED and discarded only: its output is never published.
|
|
62
82
|
*/
|
|
63
83
|
export async function measureScope(input: MeasureInput): Promise<MeasureScope> {
|