@ultimat3/cli 31.1.0 → 31.3.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 -3
- package/package.json +29 -29
- package/src/app-load.ts +3 -2
- package/src/binding-names.ts +124 -0
- package/src/browser-transport.ts +28 -0
- package/src/cmd-doctor.ts +8 -0
- package/src/cmd-exercise.ts +13 -1
- package/src/cmd-upgrade.ts +28 -4
- package/src/dev-boot.ts +4 -5
- package/src/dev-rebuild.ts +38 -5
- package/src/doctor-typescript.ts +31 -0
- package/src/error-codes.ts +2 -0
- package/src/island-build-pool.ts +35 -0
- package/src/island-bundle.ts +137 -176
- package/src/island-cache-inputs.ts +141 -0
- package/src/island-duplicates.ts +36 -0
- package/src/island-group-cache.ts +289 -0
- package/src/island-groups.ts +117 -0
- package/src/island-outputs.ts +153 -0
- package/src/island-runtime.ts +5 -0
- package/src/island-styles.ts +68 -19
- package/src/mcp-errors-shot.ts +49 -0
- package/src/mcp-errors.ts +5 -41
- package/src/measure-scope.ts +17 -4
- package/src/messages-upgrade.ts +2 -0
- package/src/offline-ports.ts +106 -0
- package/src/prerender.ts +2 -2
- package/src/runtime-storage-boot.ts +41 -7
- package/src/templates/scaffold-repo.ts +2 -1
- package/src/templates/sign-in-oidc.ts +24 -9
- package/src/transport-calls.ts +7 -3
- package/src/transport-values.ts +59 -0
- package/src/typescript-floor.ts +83 -0
- package/src/upgrade-report.ts +8 -1
- package/src/verify-e2e.ts +17 -5
- package/wiki/Client-Data.md +14 -8
- package/wiki/Configuration.md +1 -1
- package/wiki/Deployment.md +1 -1
- package/wiki/Entities-And-Migrations.md +15 -10
- package/wiki/Storage-And-Uploads.md +1 -1
- package/wiki/Testing.md +1 -0
- package/wiki/Upgrading.md +17 -4
package/src/island-styles.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// default loader answers the asset PATH — a string — so `styles['track']` is `undefined`, every
|
|
4
4
|
// element renders unclassed, and `Bun.build` reports `success: true` with no log.
|
|
5
5
|
|
|
6
|
+
// why: Bun ships no path API; the bundler names its inputs relative to the building process's cwd.
|
|
7
|
+
import { resolve } from 'node:path';
|
|
6
8
|
import { renderThrowable, UltimateError } from '@ultimat3/core';
|
|
7
|
-
import { loadStylesheet } from '@ultimat3/render/server';
|
|
9
|
+
import { compileStylesheet, loadStylesheet, registeredStylesheets } from '@ultimat3/render/server';
|
|
8
10
|
import type { BunPlugin } from 'bun';
|
|
9
11
|
import { IslandBuildFailedError } from './errors';
|
|
10
12
|
|
|
@@ -16,6 +18,9 @@ import { IslandBuildFailedError } from './errors';
|
|
|
16
18
|
*/
|
|
17
19
|
const STYLESHEET = /\.s?css$/;
|
|
18
20
|
|
|
21
|
+
/** Whether `path` is a stylesheet by the one spelling the loader and the bundler share. */
|
|
22
|
+
export const isStylesheet = (path: string): boolean => STYLESHEET.test(path);
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* Every stylesheet an island build has loaded in this process, absolute. `x build --target docker`
|
|
21
26
|
* writes them into the island store, so a container that serves the stored chunks registers the
|
|
@@ -26,27 +31,71 @@ const islandSheets = new Set<string>();
|
|
|
26
31
|
/** Sorted, so the store index is byte-identical for identical input. */
|
|
27
32
|
export const islandStylesheets = (): readonly string[] => [...islandSheets].sort();
|
|
28
33
|
|
|
34
|
+
/** Registers one island stylesheet: what the plugin does on a load, and a cached group's hit. */
|
|
35
|
+
export function registerIslandStylesheet(path: string, source: string): string {
|
|
36
|
+
islandSheets.add(path);
|
|
37
|
+
return loadStylesheet(path, source, 'island');
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* `loadStylesheet`, not `compileStylesheet`: compiling alone answers the class names and drops the
|
|
31
42
|
* RULES on the floor, and an island is the one importer a document's own module graph never sees.
|
|
32
43
|
* Registering here is what puts them in `stylesFor(surface)` — `buildIslands` runs before the first
|
|
33
44
|
* document is rendered, in `x dev` and in `prerenderSite` alike.
|
|
45
|
+
*
|
|
46
|
+
* One plugin per `buildIslands` call, holding each sheet's answer for that call: every group's
|
|
47
|
+
* build loads the design system's sheets again, and compiling them once per group was 6.0 s of a
|
|
48
|
+
* 19.6 s build of the 159-island bench app (one CPU profile, As of 2026-11-10). Per call and never
|
|
49
|
+
* per process, so a `x dev` rebuild compiles an edited sheet — or a partial it `@use`s — afresh.
|
|
50
|
+
*/
|
|
51
|
+
/** The plugin, and the Sass partials each sheet it loaded read — what a cache entry must rehash. */
|
|
52
|
+
export interface IslandStyles extends BunPlugin {
|
|
53
|
+
dependenciesOf(sheets: readonly string[]): readonly string[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function islandStylesPlugin(): IslandStyles {
|
|
57
|
+
const compiled = new Map<string, Promise<string>>();
|
|
58
|
+
const partials = new Map<string, readonly string[]>();
|
|
59
|
+
const load = async (path: string): Promise<string> => {
|
|
60
|
+
const source = await Bun.file(path).text();
|
|
61
|
+
try {
|
|
62
|
+
const classes = registerIslandStylesheet(path, source);
|
|
63
|
+
// A partial `@use`d by the sheet moves its class hashes and is no bundler input: read off the
|
|
64
|
+
// registry the load just wrote, compiled again only for a sheet with no rules to register.
|
|
65
|
+
const held = registeredStylesheets().find((sheet) => sheet.file === path);
|
|
66
|
+
partials.set(path, held?.dependencies ?? compileStylesheet(path, source).dependencies);
|
|
67
|
+
return classes;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// A coded failure already names the file and carries a fix — re-wrapping it would bury
|
|
70
|
+
// both. Anything else is rendered through `renderThrowable`, because this is the plugin's
|
|
71
|
+
// last frame and a value that fights being read would escape a Bun plugin as a bare throw.
|
|
72
|
+
if (error instanceof UltimateError) throw error;
|
|
73
|
+
throw new IslandBuildFailedError({ file: path, logs: renderThrowable(error) });
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
name: 'ultimate-island-styles',
|
|
78
|
+
dependenciesOf: (sheets) => [...new Set(sheets.flatMap((one) => partials.get(one) ?? []))],
|
|
79
|
+
setup(build): void {
|
|
80
|
+
build.onLoad({ filter: STYLESHEET }, async ({ path }) => {
|
|
81
|
+
let contents = compiled.get(path);
|
|
82
|
+
if (contents === undefined) {
|
|
83
|
+
contents = load(path);
|
|
84
|
+
compiled.set(path, contents);
|
|
85
|
+
}
|
|
86
|
+
return { contents: await contents, loader: 'js' };
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The stylesheets among a build's metafile inputs (cwd-relative), absolute — a package's own
|
|
94
|
+
* included, which a cached group must register again exactly as the build's plugin did.
|
|
34
95
|
*/
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
islandSheets.add(path);
|
|
42
|
-
return { contents: loadStylesheet(path, source, 'island'), loader: 'js' };
|
|
43
|
-
} catch (error) {
|
|
44
|
-
// A coded failure already names the file and carries a fix — re-wrapping it would bury
|
|
45
|
-
// both. Anything else is rendered through `renderThrowable`, because this is the plugin's
|
|
46
|
-
// last frame and a value that fights being read would escape a Bun plugin as a bare throw.
|
|
47
|
-
if (error instanceof UltimateError) throw error;
|
|
48
|
-
throw new IslandBuildFailedError({ file: path, logs: renderThrowable(error) });
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
};
|
|
96
|
+
export function stylesheetsOf(inputs: readonly string[]): readonly string[] {
|
|
97
|
+
const cwd = process.cwd();
|
|
98
|
+
return [
|
|
99
|
+
...new Set(inputs.filter((one) => STYLESHEET.test(one)).map((one) => resolve(cwd, one))),
|
|
100
|
+
].sort();
|
|
101
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// `errors.explain`'s rows for `x shot` and the `ui.*` MCP tools — the capture family, split out of
|
|
2
|
+
// `mcp-errors.ts` under the 500-line ceiling. Spread into `CLI_FIXES` there, whose
|
|
3
|
+
// `Record<CliErrorCode, string>` is still what makes a code without a row a build error.
|
|
4
|
+
|
|
5
|
+
import type { CliErrorCode } from './error-codes';
|
|
6
|
+
|
|
7
|
+
export const SHOT_FIXES = {
|
|
8
|
+
X_SHOT_BROWSER_MISSING:
|
|
9
|
+
'export CHROME_PATH=/usr/bin/google-chrome # macOS: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; Windows PowerShell: $env:CHROME_PATH = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"',
|
|
10
|
+
X_UI_SHOT_ROUTE_UNKNOWN:
|
|
11
|
+
'x routes --json # then call the ui.* tool with one of its path values',
|
|
12
|
+
X_UI_SHOT_ROUTE_UNBUDGETED:
|
|
13
|
+
"x build --target static --json && x verify --only budgets --json # after declaring budget: { js: '<n>kb' } in the route file",
|
|
14
|
+
// The four `ui.interact` refusals. None can be repaired by a command — each is a change to the
|
|
15
|
+
// step list the agent sends — so each names the command that SHOWS what a valid resend needs.
|
|
16
|
+
X_UI_INTERACT_STEPS_INVALID:
|
|
17
|
+
'x help shot --json # then resend ui.interact with at most 12 one-key steps, type.text under 500 chars and wait under 5000 ms',
|
|
18
|
+
X_UI_INTERACT_SECRET_FIELD:
|
|
19
|
+
'x shot --all-islands --json # or --island <name>: a declared state renders the filled form without the secret ever being typed',
|
|
20
|
+
X_UI_INTERACT_LEFT_APP:
|
|
21
|
+
'x routes --json # then resend ui.interact with steps that stay on one of its paths',
|
|
22
|
+
X_UI_INTERACT_STEP_FAILED:
|
|
23
|
+
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
24
|
+
X_SHOT_HOST_REFUSED: 'x shot /route --allow-hosts cdn.example.com --json',
|
|
25
|
+
X_SHOT_ELEMENT_MISSING:
|
|
26
|
+
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
27
|
+
X_SHOT_ELEMENT_UNREADY:
|
|
28
|
+
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
29
|
+
X_SHOT_KEY_INVALID: 'x help shot --json # a chord is modifiers then one key: Meta+K',
|
|
30
|
+
// The three `ui.diff` codes. Every capture it can compare was written by `x shot` or a `ui.*`
|
|
31
|
+
// tool under `.x/shot/`, so the runnable half is the command that writes one there.
|
|
32
|
+
X_UI_DIFF_PATH_OUTSIDE:
|
|
33
|
+
'x shot / --json # then pass the image path it answers, relative to the app root: ui.diff reads .x/shot/ and nothing else',
|
|
34
|
+
X_UI_DIFF_FILE_MISSING:
|
|
35
|
+
'x shot / --json # then diff the image path it answers; a capture ui.shot wrote is listed in its own answer',
|
|
36
|
+
X_UI_DIFF_SIZE_MISMATCH:
|
|
37
|
+
'x shot / --json # photograph both captures at one viewport with one fullPage setting, then diff those two',
|
|
38
|
+
// The four island-capture codes. Each one's real repair is an edit to the app's own states file
|
|
39
|
+
// or component, which no command can perform — so each names the command that REPRODUCES it with
|
|
40
|
+
// the file and the reason attached, which is the runnable half.
|
|
41
|
+
X_SHOT_ISLAND_STATES_EMPTY:
|
|
42
|
+
'x help shot --json # then export the manifest from the states file the cause names',
|
|
43
|
+
X_SHOT_ISLAND_UNPHOTOGRAPHABLE:
|
|
44
|
+
'x help shot --json # the cause names the assertion that did not hold; --settle buys the slow ones more time',
|
|
45
|
+
X_SHOT_ISLAND_UNSTUBBED_REQUEST:
|
|
46
|
+
'x help shot --json # the cause lists every request the state must answer under routes',
|
|
47
|
+
X_SHOT_ISLAND_MISSING:
|
|
48
|
+
'x help shot --json # every absent picture carries its own named refusal in the run above',
|
|
49
|
+
} as const satisfies Partial<Record<CliErrorCode, string>>;
|
package/src/mcp-errors.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ErrorExplanation } from '@ultimat3/mcp';
|
|
|
7
7
|
import type { CliErrorCode } from './error-codes';
|
|
8
8
|
import { CLI_ERROR_CODES } from './error-codes';
|
|
9
9
|
import { codeFixes, codeFixScan } from './error-fixes';
|
|
10
|
+
import { SHOT_FIXES } from './mcp-errors-shot';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* One runnable command per CLI code. Typed over `CliErrorCode`, so a new code fails the build.
|
|
@@ -70,47 +71,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
70
71
|
'x verify --json # the package-shape finding carries the dependency line to add',
|
|
71
72
|
X_PACKAGE_DUPLICATED:
|
|
72
73
|
'x i18n check --json # the finding names both copies and the package.json to pin',
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
X_UI_SHOT_ROUTE_UNKNOWN:
|
|
76
|
-
'x routes --json # then call the ui.* tool with one of its path values',
|
|
77
|
-
X_UI_SHOT_ROUTE_UNBUDGETED:
|
|
78
|
-
"x build --target static --json && x verify --only budgets --json # after declaring budget: { js: '<n>kb' } in the route file",
|
|
79
|
-
// The four `ui.interact` refusals. None can be repaired by a command — each is a change to the
|
|
80
|
-
// step list the agent sends — so each names the command that SHOWS what a valid resend needs.
|
|
81
|
-
X_UI_INTERACT_STEPS_INVALID:
|
|
82
|
-
'x help shot --json # then resend ui.interact with at most 12 one-key steps, type.text under 500 chars and wait under 5000 ms',
|
|
83
|
-
X_UI_INTERACT_SECRET_FIELD:
|
|
84
|
-
'x shot --all-islands --json # or --island <name>: a declared state renders the filled form without the secret ever being typed',
|
|
85
|
-
X_UI_INTERACT_LEFT_APP:
|
|
86
|
-
'x routes --json # then resend ui.interact with steps that stay on one of its paths',
|
|
87
|
-
X_UI_INTERACT_STEP_FAILED:
|
|
88
|
-
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
89
|
-
X_SHOT_HOST_REFUSED: 'x shot /route --allow-hosts cdn.example.com --json',
|
|
90
|
-
X_SHOT_ELEMENT_MISSING:
|
|
91
|
-
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
92
|
-
X_SHOT_ELEMENT_UNREADY:
|
|
93
|
-
'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
|
|
94
|
-
X_SHOT_KEY_INVALID: 'x help shot --json # a chord is modifiers then one key: Meta+K',
|
|
95
|
-
// The three `ui.diff` codes. Every capture it can compare was written by `x shot` or a `ui.*`
|
|
96
|
-
// tool under `.x/shot/`, so the runnable half is the command that writes one there.
|
|
97
|
-
X_UI_DIFF_PATH_OUTSIDE:
|
|
98
|
-
'x shot / --json # then pass the image path it answers, relative to the app root: ui.diff reads .x/shot/ and nothing else',
|
|
99
|
-
X_UI_DIFF_FILE_MISSING:
|
|
100
|
-
'x shot / --json # then diff the image path it answers; a capture ui.shot wrote is listed in its own answer',
|
|
101
|
-
X_UI_DIFF_SIZE_MISMATCH:
|
|
102
|
-
'x shot / --json # photograph both captures at one viewport with one fullPage setting, then diff those two',
|
|
103
|
-
// The four island-capture codes. Each one's real repair is an edit to the app's own states file
|
|
104
|
-
// or component, which no command can perform — so each names the command that REPRODUCES it with
|
|
105
|
-
// the file and the reason attached, which is the runnable half.
|
|
106
|
-
X_SHOT_ISLAND_STATES_EMPTY:
|
|
107
|
-
'x help shot --json # then export the manifest from the states file the cause names',
|
|
108
|
-
X_SHOT_ISLAND_UNPHOTOGRAPHABLE:
|
|
109
|
-
'x help shot --json # the cause names the assertion that did not hold; --settle buys the slow ones more time',
|
|
110
|
-
X_SHOT_ISLAND_UNSTUBBED_REQUEST:
|
|
111
|
-
'x help shot --json # the cause lists every request the state must answer under routes',
|
|
112
|
-
X_SHOT_ISLAND_MISSING:
|
|
113
|
-
'x help shot --json # every absent picture carries its own named refusal in the run above',
|
|
74
|
+
// `x shot` and the `ui.*` tools: their own family, in `mcp-errors-shot.ts`.
|
|
75
|
+
...SHOT_FIXES,
|
|
114
76
|
X_GH_UNAVAILABLE: 'gh auth login # install first from https://cli.github.com',
|
|
115
77
|
X_GH_NOT_AUTHENTICATED: 'gh auth login',
|
|
116
78
|
X_GH_COMMAND_FAILED: 'x ci --json # the finding carries the gh invocation that failed',
|
|
@@ -410,6 +372,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
410
372
|
'export const api = defineApi({ actions: [yourActions], queries: [yourQueries] }); # in apps/web/api/index.ts — list the module there, then delete the loader import',
|
|
411
373
|
X_WORKSPACE_EXTERNAL_DEP_UNDECLARED:
|
|
412
374
|
'x verify --only package-shape --json # each finding carries its own `bun add <package> --cwd <workspace>` line',
|
|
375
|
+
X_TYPESCRIPT_VERSION:
|
|
376
|
+
'x doctor --json # each X_TYPESCRIPT_VERSION finding names its manifest and the bun add that moves it',
|
|
413
377
|
};
|
|
414
378
|
|
|
415
379
|
const isCliCode = (code: string): code is CliErrorCode =>
|
package/src/measure-scope.ts
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
// context (`useRequestHeader('cookie')` throws X_NO_REQUEST outside one), an actor the app chose
|
|
5
5
|
// (`defineMeasurementActor()` in `app.config.ts`, core's `measurementActor()` otherwise), and a
|
|
6
6
|
// server to answer — the app's own API pipeline, dispatched IN PROCESS through core's
|
|
7
|
-
// `withInProcessFetch`, because no server is listening during a build (plan 101 slice 11 m)
|
|
7
|
+
// `withInProcessFetch`, because no server is listening during a build (plan 101 slice 11 m) — and
|
|
8
|
+
// `runtime.ts`'s ports as `offline-ports.ts` decides them, for every render the build runs.
|
|
8
9
|
|
|
9
10
|
import type { Actor, Ctx } from '@ultimat3/core';
|
|
10
11
|
import { actorLabel, measurementActor, runWithContext, withInProcessFetch } from '@ultimat3/core';
|
|
11
12
|
import { defineHttpConfig, httpPipeline, httpRouter, requestContext } from '@ultimat3/http';
|
|
12
13
|
import { apiRoutes } from './api-routes';
|
|
14
|
+
import { installOfflinePorts } from './offline-ports';
|
|
13
15
|
|
|
14
|
-
/** One build's measurement scope: its actor,
|
|
16
|
+
/** One build's measurement scope: its actor, a runner that renders inside it, and its release. */
|
|
15
17
|
export interface MeasureScope {
|
|
16
18
|
readonly actor: Actor;
|
|
17
19
|
run<T>(fn: () => T): T;
|
|
20
|
+
/** Releases the ports `measureScope` installed. Once, when the build's renders are done. */
|
|
21
|
+
close(): Promise<void>;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/** A scope's in-process API: the app's own table, as `actor` — or, `null`, as nobody. */
|
|
@@ -45,15 +49,24 @@ function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () =>
|
|
|
45
49
|
return <T>(fn: () => T): T => withInProcessFetch(dispatch, () => runWithContext(request, fn));
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
/** A measurement scope's input: the app at `root`, whose `runtime.ts` the build honours. */
|
|
53
|
+
interface MeasureInput extends ScopeInput {
|
|
54
|
+
readonly root: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
/**
|
|
49
58
|
* The scope for `origin`. The pipeline is the app's API table and nothing else: a page's data
|
|
50
59
|
* comes from its actions and queries, and a route the render reaches that is not one of them
|
|
51
60
|
* answers 404 — which the render reports, and the route is filed unmeasured with that reason.
|
|
52
61
|
* For a render that is WEIGHED and discarded only: its output is never published.
|
|
53
62
|
*/
|
|
54
|
-
export async function measureScope(input:
|
|
63
|
+
export async function measureScope(input: MeasureInput): Promise<MeasureScope> {
|
|
55
64
|
const actor = await measurementActor();
|
|
56
|
-
|
|
65
|
+
// Installed here rather than per render: the published (`site/`) renders read the same ports, and
|
|
66
|
+
// a page whose `load` calls an `audit: true` query was unmeasured with `X_AUDIT_SINK_MISSING`
|
|
67
|
+
// for an app that declared its sink in `runtime.ts`, as upgrade entry 43 says to.
|
|
68
|
+
const close = await installOfflinePorts(input.root);
|
|
69
|
+
return { actor, run: inProcessRunner(input, actor), close };
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
/**
|
package/src/messages-upgrade.ts
CHANGED
|
@@ -26,6 +26,8 @@ export const UPGRADE_MESSAGES = {
|
|
|
26
26
|
'AGENTS.md: differs from CLAUDE.md, left alone. Merge what only AGENTS.md says into CLAUDE.md, then: ln -sf CLAUDE.md AGENTS.md',
|
|
27
27
|
'cli.upgrade.bunEdited': 'bun floor: {path} {from} -> {to}',
|
|
28
28
|
'cli.upgrade.bunManual': 'bun floor, by hand: {path}:{line} — {why}',
|
|
29
|
+
'cli.upgrade.typescript':
|
|
30
|
+
'typescript, by hand: {file} declares {from}, below the {to} the framework is checked with — run: {fix}',
|
|
29
31
|
'cli.upgrade.done': '{from} -> {to}: the gate is green',
|
|
30
32
|
'cli.upgrade.dryRun': '{from} -> {to}: nothing written, no gate run',
|
|
31
33
|
'cli.upgrade.guard': 'guard, yours to take or leave: {fix}',
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// `apps/<app>/runtime.ts` for the two paths that run the app's primitives with no server — `x build`'s
|
|
2
|
+
// renders and `x exercise`'s pass — read and installed by the boot's own reader and loop, with
|
|
3
|
+
// every port first decided by `OFFLINE_PORTS`: a memory double, or the package default.
|
|
4
|
+
|
|
5
|
+
// Why a table and not the app's values: neither path may reach a deployment's backend. A port with
|
|
6
|
+
// no row is a build error (TS2741 on `OfflinePortTable`).
|
|
7
|
+
|
|
8
|
+
import { memoryAuditSink } from '@ultimat3/action';
|
|
9
|
+
import { loadAppRuntime } from './app-runtime';
|
|
10
|
+
import type { PortValues, RuntimeOverrides } from './runtime-overrides';
|
|
11
|
+
import { PORT_BINDINGS } from './runtime-port-bindings';
|
|
12
|
+
import type { ChosenPorts, WiredPort } from './runtime-ports';
|
|
13
|
+
import { installPorts } from './runtime-ports';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What an offline path does with a port `runtime.ts` supplied. `double`: install this stand-in in
|
|
17
|
+
* the app's place — the port's presence is what the primitive asks, and the app's own backend may
|
|
18
|
+
* be production's. `default`: install nothing, so the package's own default answers; `why` says so.
|
|
19
|
+
*/
|
|
20
|
+
export type OfflineChoice<P extends WiredPort> =
|
|
21
|
+
| { readonly use: 'double'; readonly double: () => PortValues[P] }
|
|
22
|
+
| { readonly use: 'default'; readonly why: string };
|
|
23
|
+
|
|
24
|
+
export type OfflinePortTable = { readonly [P in WiredPort]: OfflineChoice<P> };
|
|
25
|
+
|
|
26
|
+
const remote = (why: string) => ({ use: 'default', why }) as const;
|
|
27
|
+
const NETWORK = remote('a remote backend; the package default (memory or a refusal) answers');
|
|
28
|
+
const POOL = remote('Postgres over the ambient pool by default: the scratch or measure database');
|
|
29
|
+
const BOOT = remote('a boot-phase port; the offline paths keep the process their command set up');
|
|
30
|
+
const SERVED = remote('read by the serving boot only; no request is served offline');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* One row per wired port. Only `services`-phase ports can be doubles: `installPorts` installs that
|
|
34
|
+
* phase alone (`offline-ports.test.ts` holds it).
|
|
35
|
+
*/
|
|
36
|
+
export const OFFLINE_PORTS: OfflinePortTable = {
|
|
37
|
+
aiGateway: NETWORK,
|
|
38
|
+
// Its presence is the contract: `audit: true` is refused without one (`X_AUDIT_SINK_MISSING`), so
|
|
39
|
+
// an app that declared one runs; where the records go is the deployment's, never a build's.
|
|
40
|
+
auditSink: { use: 'double', double: () => memoryAuditSink() },
|
|
41
|
+
authLimiter: POOL,
|
|
42
|
+
authServerStore: POOL,
|
|
43
|
+
cacheTiers: SERVED,
|
|
44
|
+
clock: BOOT,
|
|
45
|
+
embedder: NETWORK,
|
|
46
|
+
errorReporter: remote('an offline failure is the command`s finding, never a production report'),
|
|
47
|
+
eventBus: POOL,
|
|
48
|
+
failureStore: SERVED,
|
|
49
|
+
idempotencyStore: POOL,
|
|
50
|
+
images: SERVED,
|
|
51
|
+
isrStore: SERVED,
|
|
52
|
+
jobs: POOL,
|
|
53
|
+
mail: NETWORK,
|
|
54
|
+
mcpConfirmationStore: POOL,
|
|
55
|
+
meterStore: POOL,
|
|
56
|
+
notifyStores: POOL,
|
|
57
|
+
outboxStore: POOL,
|
|
58
|
+
purge: NETWORK,
|
|
59
|
+
pushSubscriptionStore: POOL,
|
|
60
|
+
rateLimitStore: POOL,
|
|
61
|
+
scrapeDriver: NETWORK,
|
|
62
|
+
searchIndex: POOL,
|
|
63
|
+
secretSource: BOOT,
|
|
64
|
+
semanticCache: NETWORK,
|
|
65
|
+
smsTransport: NETWORK,
|
|
66
|
+
storage: remote('`x exercise` stands in a memory disk (`exercise-services.ts`)'),
|
|
67
|
+
totpReplay: POOL,
|
|
68
|
+
transport: NETWORK,
|
|
69
|
+
uploadScanner: NETWORK,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** The doubles for the ports `runtime` supplied; an absent port stays absent, as at a real boot. */
|
|
73
|
+
export function offlineChosen(
|
|
74
|
+
runtime: RuntimeOverrides | undefined,
|
|
75
|
+
table: OfflinePortTable = OFFLINE_PORTS,
|
|
76
|
+
): ChosenPorts {
|
|
77
|
+
const chosen: { [P in WiredPort]?: PortValues[P] } = {};
|
|
78
|
+
const pick = <P extends WiredPort>(port: P): void => {
|
|
79
|
+
const choice: OfflineChoice<P> = table[port];
|
|
80
|
+
if (choice.use === 'double' && runtime?.[port] !== undefined) chosen[port] = choice.double();
|
|
81
|
+
};
|
|
82
|
+
for (const port of Object.keys(table) as WiredPort[]) pick(port);
|
|
83
|
+
return chosen;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Install the offline ports for the app at `root`; answers the release, newest first. */
|
|
87
|
+
export async function installOfflinePorts(root: string): Promise<() => Promise<void>> {
|
|
88
|
+
const releases = await installPorts(
|
|
89
|
+
PORT_BINDINGS,
|
|
90
|
+
'services',
|
|
91
|
+
offlineChosen(await loadAppRuntime(root)),
|
|
92
|
+
);
|
|
93
|
+
return async () => {
|
|
94
|
+
for (const release of releases.toReversed()) await release();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** `work` with the offline ports installed, released however it ends. */
|
|
99
|
+
export async function withOfflinePorts<T>(root: string, work: () => Promise<T>): Promise<T> {
|
|
100
|
+
const release = await installOfflinePorts(root);
|
|
101
|
+
try {
|
|
102
|
+
return await work();
|
|
103
|
+
} finally {
|
|
104
|
+
await release();
|
|
105
|
+
}
|
|
106
|
+
}
|
package/src/prerender.ts
CHANGED
|
@@ -265,7 +265,7 @@ export async function prerenderSite(options: PrerenderOptions): Promise<Prerende
|
|
|
265
265
|
// and no server is listening during a build. `renderStatic` keeps `ctx`: its output is a
|
|
266
266
|
// published file, and a `site/` load a policy refuses must fail the build, never render another
|
|
267
267
|
// actor's rows into it. `published` authenticates nobody: sitemap and llms.txt reads run in it.
|
|
268
|
-
const measure = await measureScope({ origin, buildId });
|
|
268
|
+
const measure = await measureScope({ origin, buildId, root: options.root });
|
|
269
269
|
const published = publicScope({ origin, buildId });
|
|
270
270
|
// Started on the first route that needs weighing, and released however the loop ends.
|
|
271
271
|
const database = measureDatabase(options.root);
|
|
@@ -436,7 +436,7 @@ export async function prerenderSite(options: PrerenderOptions): Promise<Prerende
|
|
|
436
436
|
}));
|
|
437
437
|
} finally {
|
|
438
438
|
capture.close();
|
|
439
|
-
await database.close();
|
|
439
|
+
await Promise.all([database.close(), measure.close()]);
|
|
440
440
|
}
|
|
441
441
|
// The variants and cards the exported documents name, before the worker precaches them.
|
|
442
442
|
await capture.write(pages);
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// Single responsibility: the storage disk a boot installs — s3 when `S3_ENDPOINT` names one, the
|
|
2
|
-
// embedded local disk otherwise
|
|
3
|
-
// rather than after it. Split from `runtime-services.ts
|
|
2
|
+
// embedded local disk otherwise, NONE when the app already declared its own — and the two refusals
|
|
3
|
+
// that must come before the first upload rather than after it. Split from `runtime-services.ts`.
|
|
4
4
|
|
|
5
5
|
// why: Bun has no `mkdir`; the embedded root must exist before the disk is handed out.
|
|
6
6
|
import { mkdirSync } from 'node:fs';
|
|
7
7
|
import { isLocal, renderThrowable, resolveEnvironment } from '@ultimat3/core';
|
|
8
8
|
import { configuredHttp, defineHttpConfig } from '@ultimat3/http';
|
|
9
|
-
import type { Storage } from '@ultimat3/storage';
|
|
10
|
-
import {
|
|
9
|
+
import type { Storage, StorageConfig } from '@ultimat3/storage';
|
|
10
|
+
import {
|
|
11
|
+
definedStorage,
|
|
12
|
+
defineStorage,
|
|
13
|
+
localDriver,
|
|
14
|
+
s3Driver,
|
|
15
|
+
usesDevStorageSecret,
|
|
16
|
+
} from '@ultimat3/storage';
|
|
11
17
|
import type { StorageDriver } from '@ultimat3/storage/adapter';
|
|
12
18
|
import { LocalDiskUnsafeError, StorageUnwritableError } from './errors';
|
|
13
19
|
import type { DevServices, Env } from './runtime-bindings';
|
|
@@ -15,6 +21,30 @@ import { s3PathStyleOf } from './runtime-s3-path-style';
|
|
|
15
21
|
|
|
16
22
|
const FILE_SCHEME = 'file://';
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Every registry a boot in this process installed. `definedStorage()` holding one of these is a
|
|
26
|
+
* previous boot's default (a second `startServices` in one process), replaced; holding anything
|
|
27
|
+
* else is the app's own `defineStorage()`, kept.
|
|
28
|
+
*/
|
|
29
|
+
const bootInstalled = new WeakSet<Storage>();
|
|
30
|
+
|
|
31
|
+
function bootDefine(config: StorageConfig): Storage {
|
|
32
|
+
const installed = defineStorage(config);
|
|
33
|
+
bootInstalled.add(installed);
|
|
34
|
+
return installed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The registry an app module declared before this boot ran, or `undefined`. `runtime.ts` is
|
|
39
|
+
* imported before `startServices`, and an app module it reaches that calls
|
|
40
|
+
* `defineStorage({ disks: { uploads, evidence } })` has already run: the boot's one-disk
|
|
41
|
+
* `defineStorage` replaced it, and every disk but the boot's was `X_STORAGE_DISK_UNKNOWN`.
|
|
42
|
+
*/
|
|
43
|
+
function appDeclared(): Storage | undefined {
|
|
44
|
+
const current = definedStorage();
|
|
45
|
+
return current === undefined || bootInstalled.has(current) ? undefined : current;
|
|
46
|
+
}
|
|
47
|
+
|
|
18
48
|
/**
|
|
19
49
|
* The most one request to this server carries — `http.maxRequestBodyBytes` as the server resolves
|
|
20
50
|
* it, read at each signing because the boot builds its disk before the app's `configureHttp` runs.
|
|
@@ -39,11 +69,15 @@ export const servedRequestCeiling = (): number =>
|
|
|
39
69
|
* to run a container, so this reports what to do instead of what went wrong.
|
|
40
70
|
*/
|
|
41
71
|
export function startStorage(services: DevServices, env: Env, override?: StorageDriver): Storage {
|
|
72
|
+
// Before every arm, the override included: "several disks are the app's `defineStorage()`, which
|
|
73
|
+
// wins" (`PortValues.storage`). The app's disks carry their own refusals (`localDriver`'s).
|
|
74
|
+
const declared = appDeclared();
|
|
75
|
+
if (declared !== undefined) return declared;
|
|
42
76
|
// First arm, not a branch beside the two below: `runtime.ts` handing the boot a driver has
|
|
43
77
|
// already answered "which disk", and re-deriving one from `S3_ENDPOINT` would be a second answer.
|
|
44
78
|
// Registered under the driver's own name — its signed URLs hang off that key (`defineStorage`).
|
|
45
79
|
if (override !== undefined) {
|
|
46
|
-
return
|
|
80
|
+
return bootDefine({ disks: { [override.name]: override }, default: override.name });
|
|
47
81
|
}
|
|
48
82
|
const binding = services.storage;
|
|
49
83
|
|
|
@@ -55,7 +89,7 @@ export function startStorage(services: DevServices, env: Env, override?: Storage
|
|
|
55
89
|
'set S3_BUCKET to the bucket name, or unset S3_ENDPOINT to use the embedded disk',
|
|
56
90
|
);
|
|
57
91
|
}
|
|
58
|
-
return
|
|
92
|
+
return bootDefine({
|
|
59
93
|
disks: {
|
|
60
94
|
object: s3Driver({
|
|
61
95
|
bucket,
|
|
@@ -107,5 +141,5 @@ export function startStorage(services: DevServices, env: Env, override?: Storage
|
|
|
107
141
|
// `maxRequestBytes`: a signed PUT lands on THIS server, so a grant it could never accept in one
|
|
108
142
|
// request is refused at signing, naming the multipart grant.
|
|
109
143
|
const disk = localDriver({ root, env, maxRequestBytes: servedRequestCeiling });
|
|
110
|
-
return
|
|
144
|
+
return bootDefine({ disks: { local: disk }, default: 'local' });
|
|
111
145
|
}
|
|
@@ -38,8 +38,9 @@ const BIOME_VERSION = '2.6.3';
|
|
|
38
38
|
* constant and TypeScript's was a literal buried in a dependency block, so the framework moved to
|
|
39
39
|
* 7.x and every `x new` kept scaffolding `^6.0.3`. `scaffold-repo.test.ts` now pins this against
|
|
40
40
|
* the repo's own root `package.json`, so the next bump cannot leave the scaffold behind in silence.
|
|
41
|
+
* Exported for `typescript-floor.ts`: `x upgrade` and `x doctor` hold an EXISTING app to it.
|
|
41
42
|
*/
|
|
42
|
-
const TYPESCRIPT_VERSION = '^7.0.2';
|
|
43
|
+
export const TYPESCRIPT_VERSION = '^7.0.2';
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* The Solid runtime every island and `@ultimat3/ui` component renders with, exact for the reason
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
defineAuth,
|
|
47
47
|
discoverOAuthProvider,
|
|
48
48
|
hasOAuthProvider,
|
|
49
|
+
OAUTH_CALLBACK_ROUTE_PATH,
|
|
49
50
|
type OAuthLoginRoutes,
|
|
50
51
|
oauthLogin,
|
|
51
52
|
oauthStartPath,
|
|
@@ -58,6 +59,13 @@ export const OIDC_PROVIDER = '${provider}';
|
|
|
58
59
|
export const OIDC_ISSUER_ENV = '${oidcEnvPrefix(provider)}_ISSUER';
|
|
59
60
|
/** Where the sign-in page sends a browser: the start leg, \`${oauthStartPath(provider)}\`. */
|
|
60
61
|
export const OIDC_START_PATH = oauthStartPath(OIDC_PROVIDER);
|
|
62
|
+
/**
|
|
63
|
+
* The callback leg's mount AND the \`redirect_uri\` the issuer must have registered: one value,
|
|
64
|
+
* handed to \`oauthLogin({ callbackPath })\` below and mounted by \`sign-in-routes.ts\`. The
|
|
65
|
+
* framework's default; set it (e.g. \`'/auth/oauth/:provider/callback'\`) to keep a URI an IdP
|
|
66
|
+
* already holds, and both move together.
|
|
67
|
+
*/
|
|
68
|
+
export const OIDC_CALLBACK_PATH: string = OAUTH_CALLBACK_ROUTE_PATH;
|
|
61
69
|
|
|
62
70
|
type Env = Readonly<Record<string, string | undefined>>;
|
|
63
71
|
|
|
@@ -77,7 +85,10 @@ export const oidcLegs = (env: Env = process.env): Promise<OAuthLoginRoutes> => {
|
|
|
77
85
|
if (!hasOAuthProvider(OIDC_PROVIDER)) {
|
|
78
86
|
registerOAuthProvider(await discoverOAuthProvider({ id: OIDC_PROVIDER, issuer }));
|
|
79
87
|
}
|
|
80
|
-
return oauthLogin(signInAuth(), {
|
|
88
|
+
return oauthLogin(signInAuth(), {
|
|
89
|
+
successPath: AFTER_SIGN_IN,
|
|
90
|
+
callbackPath: OIDC_CALLBACK_PATH,
|
|
91
|
+
});
|
|
81
92
|
})().catch((error: unknown) => {
|
|
82
93
|
legs = undefined;
|
|
83
94
|
throw error;
|
|
@@ -111,10 +122,12 @@ unitTest('a discovery that fails is refused, and the next sign-in tries again',
|
|
|
111
122
|
|
|
112
123
|
const routesSource =
|
|
113
124
|
(): string => `// The two OIDC legs as plain HTTP routes — \`runtime.ts\` hands them to both boots. Plain routes,
|
|
114
|
-
// not actions: the callback is a redirect protocol whose shape the provider fixes.
|
|
115
|
-
|
|
125
|
+
// not actions: the callback is a redirect protocol whose shape the provider fixes. The callback is
|
|
126
|
+
// mounted at \`OIDC_CALLBACK_PATH\` — the \`callbackPath\` \`oauthLogin\` was handed, so its
|
|
127
|
+
// \`callback.path\` — never at a constant of its own: the mount and the \`redirect_uri\` move together.
|
|
128
|
+
import { OAUTH_START_ROUTE_PATH } from '@ultimat3/auth';
|
|
116
129
|
import type { Route } from '@ultimat3/http';
|
|
117
|
-
import { oidcLegs } from './oidc';
|
|
130
|
+
import { OIDC_CALLBACK_PATH, oidcLegs } from './oidc';
|
|
118
131
|
|
|
119
132
|
const leg = (name: 'start' | 'callback', path: string): Route => ({
|
|
120
133
|
method: 'GET',
|
|
@@ -126,20 +139,22 @@ const leg = (name: 'start' | 'callback', path: string): Route => ({
|
|
|
126
139
|
|
|
127
140
|
export const signInRoutes: readonly Route[] = [
|
|
128
141
|
leg('start', OAUTH_START_ROUTE_PATH),
|
|
129
|
-
leg('callback',
|
|
142
|
+
leg('callback', OIDC_CALLBACK_PATH),
|
|
130
143
|
];
|
|
131
144
|
`;
|
|
132
145
|
|
|
133
146
|
const routesTest =
|
|
134
|
-
(): string => `// Both legs are mounted, public
|
|
135
|
-
|
|
147
|
+
(): string => `// Both legs are mounted, public: the start leg at the framework's path, the callback at the one
|
|
148
|
+
// \`oauthLogin\` is handed as \`callbackPath\` — so the mount is the \`redirect_uri\` the IdP holds.
|
|
149
|
+
import { OAUTH_START_ROUTE_PATH } from '@ultimat3/auth';
|
|
136
150
|
import { expect, unitTest } from '@ultimat3/testing';
|
|
151
|
+
import { OIDC_CALLBACK_PATH } from './oidc';
|
|
137
152
|
import { signInRoutes } from './sign-in-routes';
|
|
138
153
|
|
|
139
|
-
unitTest('the start and callback legs are public GET routes at the
|
|
154
|
+
unitTest('the start and callback legs are public GET routes at the paths oauthLogin serves', () => {
|
|
140
155
|
expect(signInRoutes.map((route) => [route.method, route.path, route.meta.auth])).toEqual([
|
|
141
156
|
['GET', OAUTH_START_ROUTE_PATH, 'public'],
|
|
142
|
-
['GET',
|
|
157
|
+
['GET', OIDC_CALLBACK_PATH, 'public'],
|
|
143
158
|
]);
|
|
144
159
|
});
|
|
145
160
|
`;
|
package/src/transport-calls.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// rule has to leave alone is a fixture string. Which file may hold which shape is the caller's.
|
|
4
4
|
|
|
5
5
|
import { maskLiterals } from '@ultimat3/core';
|
|
6
|
+
import { destructuredNames } from './binding-names';
|
|
6
7
|
import { lineIndex } from './ts-scan';
|
|
7
8
|
|
|
8
9
|
export type TransportShape = 'fetch' | 'websocket' | 'xhr' | 'eventsource';
|
|
@@ -30,7 +31,7 @@ const FETCH = new RegExp(String.raw`(?<![\w$.])(${GLOBAL}?)fetch\s*\(`, 'g');
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Whether the file binds `fetch` itself — a `const`/`let`/`var`/`function`, an import, a
|
|
33
|
-
*
|
|
34
|
+
* destructuring that binds that NAME (`binding-names.ts`) or a parameter — which makes a BARE `fetch(` its own function, not the
|
|
34
35
|
* page's. `packages/action/src/idempotency-postgres.ts` calls a local `fetch(key)`. Per file, not
|
|
35
36
|
* per scope: a floor, and the one direction it errs is silence on a file that shadows the global
|
|
36
37
|
* AND calls it bare. `globalThis.fetch(` is reported regardless.
|
|
@@ -38,8 +39,11 @@ const FETCH = new RegExp(String.raw`(?<![\w$.])(${GLOBAL}?)fetch\s*\(`, 'g');
|
|
|
38
39
|
export function bindsFetch(code: string): boolean {
|
|
39
40
|
return (
|
|
40
41
|
/\b(?:const|let|var|function)\s+fetch\b/.test(code) ||
|
|
41
|
-
|
|
42
|
-
/\
|
|
42
|
+
// `import { fetch }` and `import { f as fetch }` bind it; `import { fetch as f }` binds `f`.
|
|
43
|
+
/\bimport\s+[^;]*(?<!\bas\s+)\bfetch\b(?!\s+as\b)[^;]*\bfrom\b/.test(code) ||
|
|
44
|
+
/\bimport\s+[^;]*\bas\s+fetch\b[^;]*\bfrom\b/.test(code) ||
|
|
45
|
+
// By the NAME a pattern binds: `{ fetch: f }` reads the property and binds `f`.
|
|
46
|
+
destructuredNames(code).has('fetch') ||
|
|
43
47
|
/\(\s*(?:[\w$]+\s*(?::[^,()]+)?,\s*)*fetch\s*[?:,)=][^()]*\)\s*(?::[^={;]+)?(?:=>|\{)/.test(
|
|
44
48
|
code,
|
|
45
49
|
)
|