@ultimat3/cli 31.46.0 → 31.47.1
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 +1 -1
- package/README.md +1 -1
- package/package.json +29 -29
- package/src/affected.ts +3 -2
- package/src/app-config-load.ts +8 -5
- package/src/app-mcp.ts +2 -5
- package/src/app-runtime.ts +4 -4
- package/src/cmd-cache.ts +8 -4
- package/src/cmd-deploy-compose.ts +11 -12
- package/src/cmd-deploy-helm.ts +5 -8
- package/src/cmd-exercise-spec.ts +2 -2
- package/src/cmd-exercise.ts +7 -19
- package/src/cmd-new.ts +4 -3
- package/src/cmd-planned.ts +11 -76
- package/src/cmd-shot-matrix.ts +3 -2
- package/src/cmd-token.ts +11 -3
- package/src/cmd-upgrade.ts +5 -7
- package/src/codemods/ci-weekly-schedule.ts +61 -0
- package/src/codemods/e2e-suite-floor.ts +42 -0
- package/src/codemods/e2e-suite.ts +71 -0
- package/src/codemods/index.ts +4 -0
- package/src/codemods/pending.ts +2 -2
- package/src/codemods/test-ports.ts +40 -33
- package/src/codemods/test-suites.ts +11 -22
- package/src/codemods/vendored-guards.ts +3 -5
- package/src/codemods/verify-floor-skips.ts +22 -12
- package/src/codemods/verify-floor-steps.ts +4 -3
- package/src/db-seed.ts +3 -2
- package/src/dispatch.ts +2 -11
- package/src/duplicate-packages.ts +4 -4
- package/src/exercise-findings.ts +4 -3
- package/src/exercise-floor.ts +1 -1
- package/src/exercise-seed.ts +34 -0
- package/src/fix-command.ts +2 -3
- package/src/flag-reads.ts +6 -3
- package/src/generate-files.ts +10 -6
- package/src/gitignore.ts +4 -3
- package/src/guards-built-in.ts +3 -6
- package/src/guards.ts +5 -8
- package/src/island-bundle.ts +3 -2
- package/src/island-sources.ts +4 -3
- package/src/island-states-load.ts +4 -3
- package/src/island-store.ts +3 -2
- package/src/json-merge.ts +8 -6
- package/src/lint-findings.ts +4 -7
- package/src/mcp-errors.ts +2 -2
- package/src/messages.ts +1 -0
- package/src/prerender-out.ts +4 -3
- package/src/publish-closure.ts +4 -6
- package/src/pwa-manifest-locales.ts +5 -8
- package/src/registry.ts +0 -7
- package/src/root-env.ts +3 -2
- package/src/runtime-admin.ts +2 -4
- package/src/runtime-keys.ts +5 -2
- package/src/static-report.ts +5 -8
- package/src/templates/github/ci-schedule.ts +86 -0
- package/src/templates/github/ci.yml.ts +6 -8
- package/src/templates/github/dependabot.yml.ts +6 -1
- package/src/templates/guard-released-forms.ts +30 -8
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/scaffold-suites.ts +22 -0
- package/src/templates/shapes/overlay.ts +4 -7
- package/src/upgrade-gate-codemods.ts +1 -18
- package/src/upgrade-guards-baseline.ts +3 -5
- package/src/verify-merge-skips.ts +2 -4
- package/src/verify-merge.ts +13 -8
- package/src/verify-part-step.ts +5 -7
- package/src/worker-bundle.ts +4 -2
- package/wiki/Actions.md +69 -5
- package/wiki/Agents.md +13 -0
- package/wiki/Auth.md +4 -0
- package/wiki/Batching-And-Preloading.md +77 -3
- package/wiki/CLI-Reference.md +19 -6
- package/wiki/Caching-And-Invalidation.md +76 -23
- package/wiki/Client-Navigation.md +2 -0
- package/wiki/Compared.md +13 -11
- package/wiki/Configuration.md +17 -4
- package/wiki/Entities-And-Migrations.md +168 -6
- package/wiki/FAQ.md +1 -1
- package/wiki/Feature-Flags.md +3 -0
- package/wiki/Getting-Started.md +27 -1
- package/wiki/Jobs-And-Workflows.md +70 -13
- package/wiki/Known-Gaps.md +58 -49
- package/wiki/MCP-And-AI.md +43 -3
- package/wiki/Mail.md +6 -0
- package/wiki/Migrations-And-Backfills.md +13 -0
- package/wiki/Money.md +20 -1
- package/wiki/N-Plus-One-Detection.md +31 -1
- package/wiki/Notify.md +13 -2
- package/wiki/PWA-And-Offline.md +34 -4
- package/wiki/Policies-And-Authz.md +27 -5
- package/wiki/Queries-And-Live-Queries.md +41 -4
- package/wiki/Realtime.md +22 -0
- package/wiki/Resource-Management.md +6 -1
- package/wiki/Routes-And-Render-Modes.md +54 -6
- package/wiki/SEO.md +24 -2
- package/wiki/Scheduled-Tasks.md +29 -11
- package/wiki/Scraping.md +33 -2
- package/wiki/Stability.md +1 -1
- package/wiki/Static-Assets.md +1 -0
- package/wiki/Storage-And-Uploads.md +8 -1
- package/wiki/Testing.md +120 -13
- package/wiki/The-Eight-Primitives.md +125 -6
- package/wiki/Timezones-And-Dates.md +13 -5
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-02-First-Feature.md +6 -0
- package/wiki/Tutorial-03-Auth-And-Admin.md +8 -0
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +40 -2
- package/wiki/Tutorial-06-Growing-Up.md +1 -2
- package/wiki/UI-Components.md +14 -5
- package/wiki/Upgrading.md +43 -5
package/src/dispatch.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
|
8
8
|
import { currentLogStream, setLogStream } from '@ultimat3/core';
|
|
9
9
|
import { requireAppRoot, requireBunVersion } from './app-root';
|
|
10
10
|
import { createHelpCommand } from './cmd-help';
|
|
11
|
-
import { plannedCommandError, plannedCommandFor } from './cmd-planned';
|
|
12
11
|
import type { CommandContext } from './command';
|
|
13
12
|
import { UnknownCommandError } from './errors';
|
|
14
13
|
import type { Runner } from './exec';
|
|
@@ -97,7 +96,7 @@ const errorResult = (command: string, error: unknown): CommandResult => ({
|
|
|
97
96
|
export async function dispatch(options: DispatchOptions): Promise<number> {
|
|
98
97
|
const earlyReader = readerFor(options.cwd, options.invocation);
|
|
99
98
|
// Its own branch, ahead of the parse: an unsupported Bun is a fact about the environment and
|
|
100
|
-
// outranks anything argv says
|
|
99
|
+
// outranks anything argv says.
|
|
101
100
|
try {
|
|
102
101
|
requireBunVersion(options.bunVersion);
|
|
103
102
|
} catch (error) {
|
|
@@ -110,17 +109,9 @@ export async function dispatch(options: DispatchOptions): Promise<number> {
|
|
|
110
109
|
try {
|
|
111
110
|
args = parseArgs(options.argv, SPECS);
|
|
112
111
|
} catch (error) {
|
|
113
|
-
// A PLANNED command is not built, so every invocation of one must say that and nothing else.
|
|
114
|
-
// The parser refuses an undeclared flag before any `run` is reached and a planned command
|
|
115
|
-
// declares only the four globals, so `x logs tail --follow` reported X_CLI_BAD_FLAG — a flag
|
|
116
|
-
// list for a command that does not exist yet — while `x logs tail` reported the honest
|
|
117
|
-
// X_NOT_IMPLEMENTED with a runnable fix. Substituted here rather than in `parse.ts`, which is
|
|
118
|
-
// pure and knows nothing about what a command means; the precedent is the help swap below.
|
|
119
|
-
const planned = plannedCommandFor(commandFor(options.argv[0] ?? '')?.spec.name);
|
|
120
|
-
const failure = planned === undefined ? error : plannedCommandError(planned);
|
|
121
112
|
// `wantsJson`, not `includes('--json')`: a typo'd flag or a typo'd command is exactly the case
|
|
122
113
|
// an agent hits while always passing `-j`, and the short form rendered prose it then parsed.
|
|
123
|
-
const result = errorResult(
|
|
114
|
+
const result = errorResult('x', error);
|
|
124
115
|
sinkFor(result, options)(render(result, wantsJson(options.argv), false, earlyReader));
|
|
125
116
|
return 1;
|
|
126
117
|
}
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
// version are still two — and `dirname`/`join` walk a resolved entry up to the package that owns it.
|
|
16
16
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
17
17
|
// why: Bun exposes no path API — `dirname` walks a resolved entry up to the package that owns it,
|
|
18
|
-
// `join` reaches its manifest
|
|
19
|
-
|
|
20
|
-
import { dirname, join, relative } from 'node:path';
|
|
18
|
+
// `join` reaches its manifest.
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
21
20
|
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
22
21
|
import type { Finding } from './output';
|
|
22
|
+
import { posixRelative } from './posix-path';
|
|
23
23
|
import { readWorkspaceGraph } from './workspace-graph';
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -212,7 +212,7 @@ export type DuplicateProbe = (
|
|
|
212
212
|
|
|
213
213
|
/** `<dir>@<version> (resolved from ., packages/i18n)` — one clause per copy. */
|
|
214
214
|
const renderCopy = (root: string, copy: DuplicateCopy): string => {
|
|
215
|
-
const shown =
|
|
215
|
+
const shown = posixRelative(root, copy.dir);
|
|
216
216
|
const dir = shown === '' || shown.startsWith('..') ? copy.dir : shown;
|
|
217
217
|
return `${dir}@${copy.version} (resolved from ${copy.from.join(', ')})`;
|
|
218
218
|
};
|
package/src/exercise-findings.ts
CHANGED
|
@@ -117,7 +117,8 @@ export interface ExercisePhases extends ExercisePhaseMs {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export interface ExerciseReport {
|
|
120
|
-
|
|
120
|
+
/** What the pass ran on: `x exercise --seed <this>` replays it. */
|
|
121
|
+
readonly seed: number;
|
|
121
122
|
readonly counts: ExerciseCounts;
|
|
122
123
|
/** Milliseconds per phase: absent only when the pass threw before it could say. */
|
|
123
124
|
readonly phases?: ExercisePhases;
|
|
@@ -126,10 +127,10 @@ export interface ExerciseReport {
|
|
|
126
127
|
|
|
127
128
|
export const exerciseReport = (
|
|
128
129
|
records: readonly ExerciseRecord[],
|
|
129
|
-
seed: number
|
|
130
|
+
seed: number,
|
|
130
131
|
phases?: ExercisePhases,
|
|
131
132
|
): ExerciseReport => ({
|
|
132
|
-
seed
|
|
133
|
+
seed,
|
|
133
134
|
counts: exerciseCounts(records),
|
|
134
135
|
...(phases === undefined ? {} : { phases }),
|
|
135
136
|
records,
|
package/src/exercise-floor.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function judgeUnproven(
|
|
|
139
139
|
{
|
|
140
140
|
code: 'X_EXERCISE_UNPROVEN_ABOVE_FLOOR',
|
|
141
141
|
cause: `exercise left ${count} unproven, ${String(tally.figure)} of the reached; x.verify.json "${EXERCISE_FIELD}.unprovenMax" allows ${String(max)}: ${named}`,
|
|
142
|
-
fix: 'x exercise --json # each unproven record in .x/exercise.json names the proof and its reason: fix the seed or
|
|
142
|
+
fix: 'x exercise --json # re-measures at the constant seed the gate runs (a floor from before 31.47.0 was measured under random seeds); each unproven record in .x/exercise.json names the proof and its reason: fix the seed helper or override it names, assuming no order between sized calls; the floor only falls',
|
|
143
143
|
docs: ERROR_DOCS_URL,
|
|
144
144
|
at: 'x.verify.json',
|
|
145
145
|
},
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Which seed `x exercise` runs on. One constant unless told otherwise: row ids follow the seed and
|
|
2
|
+
// an app's helpers can pick rows by id, so a drawn seed made one tree's gate verdict change run to
|
|
3
|
+
// run. Every pass has a scratch database of its own, so repeating a seed collides with nothing.
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_SEED } from '@ultimat3/testing';
|
|
6
|
+
import type { IntFlag } from './flag-number';
|
|
7
|
+
import { parseIntFlag } from './flag-number';
|
|
8
|
+
import type { ParsedArgs } from './parse';
|
|
9
|
+
import { flagString } from './parse';
|
|
10
|
+
|
|
11
|
+
/** The largest `--seed`: a drawn seed stays under it, so the report's figure always replays. */
|
|
12
|
+
export const EXERCISE_SEED_MAX = 2_147_483_647;
|
|
13
|
+
|
|
14
|
+
/** `--seed random`: explore a seed the gate never runs, named in the report for its replay. */
|
|
15
|
+
export const RANDOM_EXERCISE_SEED = 'random';
|
|
16
|
+
|
|
17
|
+
const SEED_FLAG: IntFlag = {
|
|
18
|
+
name: 'seed',
|
|
19
|
+
command: 'exercise',
|
|
20
|
+
min: 0,
|
|
21
|
+
max: EXERCISE_SEED_MAX,
|
|
22
|
+
example: 'x exercise --seed 1 --json',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Not `Math.random`: the frozen RNG answers the same sequence in every process.
|
|
26
|
+
const drawSeed = (): number =>
|
|
27
|
+
(crypto.getRandomValues(new Uint32Array(1))[0] as number) & EXERCISE_SEED_MAX;
|
|
28
|
+
|
|
29
|
+
/** `--seed n`, `--seed random`, or the constant. `X_CLI_BAD_FLAG` on anything else. */
|
|
30
|
+
export function readExerciseSeed(args: ParsedArgs, draw: () => number = drawSeed): number {
|
|
31
|
+
const raw = flagString(args, SEED_FLAG.name);
|
|
32
|
+
if (raw === undefined) return DEFAULT_SEED;
|
|
33
|
+
return raw === RANDOM_EXERCISE_SEED ? draw() : parseIntFlag(raw, SEED_FLAG);
|
|
34
|
+
}
|
package/src/fix-command.ts
CHANGED
|
@@ -228,9 +228,8 @@ function positionalFault(spec: CommandSpec, sub: string, word: string): Citation
|
|
|
228
228
|
* parses, so a resolution that only asked "is this a known name" would accept `x logs tail` — the
|
|
229
229
|
* exact citation that throws `X_NOT_IMPLEMENTED` at the reader.
|
|
230
230
|
*
|
|
231
|
-
* Flags are NOT judged on a planned command
|
|
232
|
-
*
|
|
233
|
-
* would read as unknown — while the real refusal is `X_NOT_IMPLEMENTED` one level up.
|
|
231
|
+
* Flags are NOT judged on a planned command: a `CommandCatalog` row names it and declares no flags,
|
|
232
|
+
* so every flag would read as unknown — while the real refusal is `X_NOT_IMPLEMENTED` one level up.
|
|
234
233
|
*/
|
|
235
234
|
export function citationFault(
|
|
236
235
|
citation: FixCitation,
|
package/src/flag-reads.ts
CHANGED
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
// plan JSON, where nothing read the field; that flag is deleted rather than wired, and a second
|
|
8
8
|
// one of its shape would pass here too.
|
|
9
9
|
|
|
10
|
-
// why: `join
|
|
11
|
-
import { join,
|
|
10
|
+
// why: `join` is `node:`-only by necessity: Bun exposes no path-join primitive.
|
|
11
|
+
import { join, posix } from 'node:path';
|
|
12
12
|
import { ERROR_DOCS_URL, stripComments } from '@ultimat3/core';
|
|
13
13
|
import type { Finding } from './output';
|
|
14
14
|
import type { CommandSpec, FlagSpec } from './parse';
|
|
15
15
|
import { GLOBAL_FLAGS } from './parse';
|
|
16
|
+
import { posixRelative, toPosix } from './posix-path';
|
|
16
17
|
|
|
17
18
|
/** A flag as declared, with the command that declares it. */
|
|
18
19
|
export interface DeclaredFlag {
|
|
@@ -110,7 +111,9 @@ export async function checkFlagReads(
|
|
|
110
111
|
const name = declared.flag.name;
|
|
111
112
|
if ([...texts.values()].some((text) => readsFlag(text, name))) continue;
|
|
112
113
|
const declaringFile = [...texts].find(([, text]) => declaresFlag(text, name))?.[0];
|
|
113
|
-
findings.push(
|
|
114
|
+
findings.push(
|
|
115
|
+
unreadFinding(declared, posix.join(posixRelative('', srcDir), toPosix(declaringFile ?? ''))),
|
|
116
|
+
);
|
|
114
117
|
}
|
|
115
118
|
return findings;
|
|
116
119
|
}
|
package/src/generate-files.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// `cmd-generate.ts` so a generator's output can be asserted on — by the generator tests, the
|
|
3
3
|
// scaffold fixture and `x new` — without a command line, an app root or a filesystem.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { BadFlagError } from './errors';
|
|
5
|
+
import { BadFlagError, UnknownCommandError } from './errors';
|
|
7
6
|
import type { Generator } from './generate-kinds';
|
|
8
7
|
import { assertLiveSupported, assertSurfaceSupported, GENERATORS } from './generate-kinds';
|
|
9
8
|
import type { SignInMode } from './generate-sign-in-mode';
|
|
@@ -332,10 +331,15 @@ export function generate(options: GenerateOptions): readonly GeneratedFile[] {
|
|
|
332
331
|
...(options.catalogModule === undefined ? {} : { catalogModule: options.catalogModule }),
|
|
333
332
|
}),
|
|
334
333
|
);
|
|
335
|
-
default:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
334
|
+
default: {
|
|
335
|
+
// `never`: a generator added to GENERATORS without a case here stops compiling. At runtime
|
|
336
|
+
// only a JavaScript caller of this public function arrives, with a word that is no generator.
|
|
337
|
+
const unknown: never = options.kind;
|
|
338
|
+
throw new UnknownCommandError({
|
|
339
|
+
path: `g ${String(unknown)}`,
|
|
340
|
+
known: GENERATORS,
|
|
341
|
+
suggestion: 'help g',
|
|
339
342
|
});
|
|
343
|
+
}
|
|
340
344
|
}
|
|
341
345
|
}
|
package/src/gitignore.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
// `Bun.file(p).text()` is async, and the ignore set is rebuilt inside an `fs.watch` callback where
|
|
8
8
|
// an await opens a window for the next event. Delete when Bun ships sync equivalents.
|
|
9
9
|
import { existsSync, readFileSync } from 'node:fs';
|
|
10
|
-
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
// why: Bun exposes no path-join or dirname primitive. The same necessity `fix-path.ts`
|
|
11
12
|
// already records for `join`.
|
|
12
|
-
import {
|
|
13
|
+
import { posixRelative } from './posix-path';
|
|
13
14
|
|
|
14
15
|
/** One line of a `.gitignore`, read for what it states rather than for what a reader assumes. */
|
|
15
16
|
export interface IgnorePattern {
|
|
@@ -94,7 +95,7 @@ function globFor(pattern: string): Bun.Glob {
|
|
|
94
95
|
|
|
95
96
|
/** The path relative to `base`, POSIX-separated, or `undefined` when it is not under it. */
|
|
96
97
|
function relativeUnder(base: string, path: string): string | undefined {
|
|
97
|
-
const rel =
|
|
98
|
+
const rel = posixRelative(base, path);
|
|
98
99
|
return rel === '' || rel.startsWith('../') || rel === '..' ? undefined : rel;
|
|
99
100
|
}
|
|
100
101
|
|
package/src/guards-built-in.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// why: Bun ships no path joiner; `guards/shipped.json` sits under the app root.
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
8
|
+
import { ERROR_DOCS_URL, isJsonObject } from '@ultimat3/core';
|
|
9
9
|
import { SHIPPED_GUARD_NAMES, type ShippedGuardName } from './guards-shipped-names';
|
|
10
10
|
import type { Finding } from './output';
|
|
11
11
|
|
|
@@ -27,9 +27,6 @@ export type ShippedSeverities = Readonly<Record<string, ShippedSeverity>>;
|
|
|
27
27
|
|
|
28
28
|
const SEVERITIES: readonly string[] = ['error', 'warning', 'off'];
|
|
29
29
|
|
|
30
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
31
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
32
|
-
|
|
33
30
|
/**
|
|
34
31
|
* `{ "severity": { "<shipped guard>": "error" | "warning" | "off" } }`, or the problems. A row
|
|
35
32
|
* naming a guard the framework does not ship is a problem, never ignored: a typo covers nothing.
|
|
@@ -44,13 +41,13 @@ export function parseShippedConfig(
|
|
|
44
41
|
} catch {
|
|
45
42
|
return { severity: {}, problems: ['it does not parse as JSON'] };
|
|
46
43
|
}
|
|
47
|
-
if (!
|
|
44
|
+
if (!isJsonObject(payload)) return { severity: {}, problems: ['it is not a JSON object'] };
|
|
48
45
|
const problems: string[] = Object.keys(payload)
|
|
49
46
|
.filter((key) => key !== SHIPPED_SEVERITY_FIELD)
|
|
50
47
|
.map((key) => `${JSON.stringify(key)} is not a key it reads — "${SHIPPED_SEVERITY_FIELD}" is`);
|
|
51
48
|
const raw = payload[SHIPPED_SEVERITY_FIELD];
|
|
52
49
|
if (raw === undefined) return { severity: {}, problems };
|
|
53
|
-
if (!
|
|
50
|
+
if (!isJsonObject(raw)) {
|
|
54
51
|
return {
|
|
55
52
|
severity: {},
|
|
56
53
|
problems: [...problems, `"${SHIPPED_SEVERITY_FIELD}" is not an object of guard → severity`],
|
package/src/guards.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// `pathToFileURL` is the only spelling of an absolute path `import()` accepts on every host.
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
import { pathToFileURL } from 'node:url';
|
|
10
|
-
import { ERROR_DOCS_URL, renderCauseValue, renderThrowable } from '@ultimat3/core';
|
|
10
|
+
import { ERROR_DOCS_URL, isJsonObject, renderCauseValue, renderThrowable } from '@ultimat3/core';
|
|
11
11
|
import { fixProblem } from './error-contract';
|
|
12
12
|
import { type GuardSources, guardSources } from './guard-sources';
|
|
13
13
|
import {
|
|
@@ -59,11 +59,8 @@ export interface Guard {
|
|
|
59
59
|
readonly severity?: 'warning';
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
63
|
-
typeof value === 'object' && value !== null;
|
|
64
|
-
|
|
65
62
|
const isGuard = (value: unknown): value is Guard =>
|
|
66
|
-
|
|
63
|
+
isJsonObject(value) &&
|
|
67
64
|
typeof value['summary'] === 'string' &&
|
|
68
65
|
value['summary'].trim() !== '' &&
|
|
69
66
|
typeof value['check'] === 'function' &&
|
|
@@ -91,7 +88,7 @@ const shown = (value: unknown): string =>
|
|
|
91
88
|
* static scan cannot reach: a `fix` assembled at run time has no literal to read.
|
|
92
89
|
*/
|
|
93
90
|
export function findingProblem(value: unknown): string | undefined {
|
|
94
|
-
if (!
|
|
91
|
+
if (!isJsonObject(value)) return `${shown(value)} is not a finding object`;
|
|
95
92
|
const code = value['code'];
|
|
96
93
|
if (typeof code !== 'string' || !CODE.test(code)) {
|
|
97
94
|
return `${shown(code)} is not an X_SCREAMING_SNAKE code, so nothing can explain it`;
|
|
@@ -139,7 +136,7 @@ const notAGuard = (path: string, exported: unknown): Finding => {
|
|
|
139
136
|
`${path} exports no \`guard\`, so a file in ${GUARD_DIR}/ enforces nothing`,
|
|
140
137
|
);
|
|
141
138
|
}
|
|
142
|
-
const severity =
|
|
139
|
+
const severity = isJsonObject(exported) ? exported['severity'] : undefined;
|
|
143
140
|
return invalid(
|
|
144
141
|
path,
|
|
145
142
|
severity !== undefined && severity !== 'warning'
|
|
@@ -213,7 +210,7 @@ async function runGuardModule(
|
|
|
213
210
|
} catch (error) {
|
|
214
211
|
return refused(failed(path, `${path} could not be imported: ${messageOf(error)}`));
|
|
215
212
|
}
|
|
216
|
-
const exported =
|
|
213
|
+
const exported = isJsonObject(loaded) ? loaded['guard'] : undefined;
|
|
217
214
|
if (!isGuard(exported)) return refused(notAGuard(path, exported));
|
|
218
215
|
let returned: unknown;
|
|
219
216
|
try {
|
package/src/island-bundle.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
// why: Bun ships no path API. `posix` does the specifier arithmetic (an app-relative route file is
|
|
22
22
|
// POSIX by construction), `join`/`basename` the filesystem side.
|
|
23
|
-
import { join, posix
|
|
23
|
+
import { join, posix } from 'node:path';
|
|
24
24
|
import type { IslandsConfig } from '@ultimat3/core';
|
|
25
25
|
import { logger, renderThrowable } from '@ultimat3/core';
|
|
26
26
|
import { ISLAND_EXTENSION } from '@ultimat3/render';
|
|
@@ -63,6 +63,7 @@ import { islandStylesPlugin, stylesheetsOf } from './island-styles';
|
|
|
63
63
|
import type { Vendors } from './island-vendor';
|
|
64
64
|
import { loadingVendor, vendorBuilder, vendorExternalPlugin, vendorShared } from './island-vendor';
|
|
65
65
|
import { hasPathSegment } from './path-segments';
|
|
66
|
+
import { posixRelative } from './posix-path';
|
|
66
67
|
import { solidJsxCoveragePlugin, solidJsxPlugin } from './solid-loader';
|
|
67
68
|
|
|
68
69
|
// `dev-rebuild.ts` names the options type here, where it lived before the split.
|
|
@@ -142,7 +143,7 @@ export async function discoverIslands(root: string): Promise<readonly string[]>
|
|
|
142
143
|
for await (const absolute of new Bun.Glob(ISLAND_GLOB).scan({ cwd: root, absolute: true })) {
|
|
143
144
|
// Root-relative, as `isScannedModule` tests it: an app under `<anything>/node_modules/<app>`
|
|
144
145
|
// holds the segment in every absolute path, and found no island at all.
|
|
145
|
-
const file =
|
|
146
|
+
const file = posixRelative(root, absolute);
|
|
146
147
|
if (!hasPathSegment(file, 'node_modules')) files.push(file);
|
|
147
148
|
}
|
|
148
149
|
return files.sort();
|
package/src/island-sources.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// prebuilt store (`island-store.ts`) verified only its own chunk bytes, so a source edited after
|
|
3
3
|
// `x build --target prebuilt` still verified and a boot served the chunk built from the old one.
|
|
4
4
|
|
|
5
|
-
// why: Bun ships no path join/resolve
|
|
6
|
-
import { isAbsolute, join, posix,
|
|
5
|
+
// why: Bun ships no path join/resolve primitive.
|
|
6
|
+
import { isAbsolute, join, posix, resolve } from 'node:path';
|
|
7
7
|
import { contentHash } from '@ultimat3/render/server';
|
|
8
8
|
import { hasPathSegment } from './path-segments';
|
|
9
|
+
import { posixRelative } from './posix-path';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* App-root-relative POSIX paths of the files an output was built from — its source map's
|
|
@@ -49,7 +50,7 @@ export async function sourcesOnDisk(root: string, map: unknown): Promise<SourceP
|
|
|
49
50
|
const cwd = process.cwd();
|
|
50
51
|
const paths = (Array.isArray(listed) ? listed : [])
|
|
51
52
|
.filter((one): one is string => typeof one === 'string')
|
|
52
|
-
.map((one) =>
|
|
53
|
+
.map((one) => posixRelative(root, resolve(cwd, one)))
|
|
53
54
|
.filter(isRecordableSource);
|
|
54
55
|
const present = await Promise.all(paths.map((one) => Bun.file(join(root, one)).exists()));
|
|
55
56
|
return [...new Set(paths.filter((_, index) => present[index]))].sort();
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// dev server on purpose — the complete expected picture list has to exist before a capture starts,
|
|
4
4
|
// or "produced nothing and exited 0" is a result nobody can tell from success.
|
|
5
5
|
|
|
6
|
-
// why: no Bun native joins a path
|
|
7
|
-
import { join
|
|
6
|
+
// why: no Bun native joins a path; `Bun.file` and `import()` both take one joined.
|
|
7
|
+
import { join } from 'node:path';
|
|
8
8
|
import { ISLAND_EXTENSION } from '@ultimat3/render';
|
|
9
9
|
import type { IslandStatesManifest } from '@ultimat3/testing';
|
|
10
10
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { ISLAND_GLOB } from './island-bundle';
|
|
18
18
|
import { IslandStatesFileEmptyError } from './island-shot-errors';
|
|
19
19
|
import { hasPathSegment } from './path-segments';
|
|
20
|
+
import { posixRelative } from './posix-path';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* `.island.states.ts`, built from the two constants that own its halves and restated as neither:
|
|
@@ -39,7 +40,7 @@ export async function discoverIslandStates(root: string): Promise<readonly strin
|
|
|
39
40
|
const scan = new Bun.Glob(ISLAND_STATES_GLOB).scan({ cwd: root, absolute: true });
|
|
40
41
|
for await (const absolute of scan) {
|
|
41
42
|
if (hasPathSegment(absolute, 'node_modules')) continue;
|
|
42
|
-
files.push(
|
|
43
|
+
files.push(posixRelative(root, absolute));
|
|
43
44
|
}
|
|
44
45
|
return files.sort();
|
|
45
46
|
}
|
package/src/island-store.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// that names a different set of islands than the app has, or a chunk whose bytes do not hash to
|
|
8
8
|
// what the index recorded is refused, and the boot builds instead — and says so.
|
|
9
9
|
|
|
10
|
-
import { join
|
|
10
|
+
import { join } from 'node:path'; // why: Bun ships no path-join primitive.
|
|
11
11
|
import { frameworkVersion } from '@ultimat3/core';
|
|
12
12
|
import { contentHash, loadStylesheet } from '@ultimat3/render/server';
|
|
13
13
|
import { IslandBuildFailedError } from './errors';
|
|
@@ -17,6 +17,7 @@ import type { IslandRealtime } from './island-realtime-state';
|
|
|
17
17
|
import type { SourceDigester, SourceStamp } from './island-sources';
|
|
18
18
|
import { changedSource, isRecordableSource, sourceDigester, stampSources } from './island-sources';
|
|
19
19
|
import { islandStylesheets } from './island-styles';
|
|
20
|
+
import { posixRelative } from './posix-path';
|
|
20
21
|
import { PREBUILT_ISLANDS_DIR } from './serve-prebuilt-paths';
|
|
21
22
|
|
|
22
23
|
/** App-root-relative, inside the image's prebuilt store (`serve-prebuilt-paths.ts` says why there). */
|
|
@@ -118,7 +119,7 @@ export async function writeIslandStore(
|
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
121
|
const stylesheets = islandStylesheets()
|
|
121
|
-
.map((path) =>
|
|
122
|
+
.map((path) => posixRelative(root, path))
|
|
122
123
|
.filter((path) => !path.startsWith('..'))
|
|
123
124
|
.sort();
|
|
124
125
|
const index: StoreIndex = {
|
package/src/json-merge.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
// nested (`{ site: { home: { title } } }`) — a shallow spread of two generators' contributions
|
|
3
3
|
// under the same top-level key drops one of them entirely, and neither generator can see the other.
|
|
4
4
|
|
|
5
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
|
+
|
|
5
7
|
/** A parsed JSON object: the only shape a `merge: 'json'` file is ever allowed to hold. */
|
|
6
8
|
export type JsonObject = Record<string, unknown>;
|
|
7
9
|
|
|
8
|
-
const isObject = (value: unknown): value is JsonObject =>
|
|
9
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* `incoming` merged under `held`, leaf by leaf. `held` always wins — on disk it is the file a
|
|
13
12
|
* human may have translated, and in `dedupe` it is the contribution that got there first — so a
|
|
@@ -30,7 +29,7 @@ export function mergeJsonDeep(
|
|
|
30
29
|
continue;
|
|
31
30
|
}
|
|
32
31
|
const current = held[key];
|
|
33
|
-
if (!
|
|
32
|
+
if (!isJsonObject(current) || !isJsonObject(value)) continue;
|
|
34
33
|
const nested = mergeJsonDeep(current, value);
|
|
35
34
|
if (!nested.gained) continue;
|
|
36
35
|
merged[key] = nested.merged;
|
|
@@ -48,7 +47,7 @@ const isSorted = (keys: readonly string[]): boolean =>
|
|
|
48
47
|
/** Every key of every level, sorted — the order a generator's own fresh output is written in. */
|
|
49
48
|
export function sortJsonDeep(value: unknown): unknown {
|
|
50
49
|
if (Array.isArray(value)) return value.map(sortJsonDeep);
|
|
51
|
-
if (!
|
|
50
|
+
if (!isJsonObject(value)) return value;
|
|
52
51
|
return Object.fromEntries(
|
|
53
52
|
Object.keys(value)
|
|
54
53
|
.sort(byCodeUnit)
|
|
@@ -80,7 +79,10 @@ export function mergeJsonInPlace(held: JsonObject, incoming: JsonObject): JsonOb
|
|
|
80
79
|
if (!Object.hasOwn(held, key)) return [key, sortJsonDeep(incoming[key])];
|
|
81
80
|
const current = held[key];
|
|
82
81
|
const next = incoming[key];
|
|
83
|
-
return [
|
|
82
|
+
return [
|
|
83
|
+
key,
|
|
84
|
+
isJsonObject(current) && isJsonObject(next) ? mergeJsonInPlace(current, next) : current,
|
|
85
|
+
];
|
|
84
86
|
}),
|
|
85
87
|
);
|
|
86
88
|
}
|
package/src/lint-findings.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// said `bunx biome check --write .`, which exits "Skipped 1 suggested fixes", still red; a finding
|
|
4
4
|
// per formatted file was twenty commands for one keystroke's worth of work (plan 101 19b, Y1).
|
|
5
5
|
|
|
6
|
-
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
6
|
+
import { ERROR_DOCS_URL, isJsonObject } from '@ultimat3/core';
|
|
7
7
|
import { commentSafe } from './comment-safe';
|
|
8
8
|
import type { ExecResult } from './exec';
|
|
9
9
|
import { execOutput } from './exec';
|
|
@@ -27,12 +27,9 @@ interface Diagnostic {
|
|
|
27
27
|
readonly line: number;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
31
|
-
typeof value === 'object' && value !== null;
|
|
32
|
-
|
|
33
30
|
/** Only what fails the step. `info` and `warning` exit 0, so they cannot be why it is red. */
|
|
34
31
|
const diagnosticFrom = (value: unknown): Diagnostic | undefined => {
|
|
35
|
-
if (!
|
|
32
|
+
if (!isJsonObject(value) || !isJsonObject(value['location'])) return undefined;
|
|
36
33
|
const { severity, category, message, location } = value as {
|
|
37
34
|
severity?: unknown;
|
|
38
35
|
category?: unknown;
|
|
@@ -42,7 +39,7 @@ const diagnosticFrom = (value: unknown): Diagnostic | undefined => {
|
|
|
42
39
|
if (severity !== 'error' && severity !== 'fatal') return undefined;
|
|
43
40
|
const { path, start } = location;
|
|
44
41
|
if (typeof category !== 'string' || typeof path !== 'string') return undefined;
|
|
45
|
-
const line =
|
|
42
|
+
const line = isJsonObject(start) && typeof start['line'] === 'number' ? start['line'] : 0;
|
|
46
43
|
return { category, message: typeof message === 'string' ? message : category, path, line };
|
|
47
44
|
};
|
|
48
45
|
|
|
@@ -92,7 +89,7 @@ export function lintFindings(stdout: string): readonly Finding[] | undefined {
|
|
|
92
89
|
} catch {
|
|
93
90
|
return undefined;
|
|
94
91
|
}
|
|
95
|
-
if (!
|
|
92
|
+
if (!isJsonObject(report) || !Array.isArray(report['diagnostics'])) return undefined;
|
|
96
93
|
const diagnostics = report['diagnostics'].flatMap((value) => {
|
|
97
94
|
const diagnostic = diagnosticFrom(value);
|
|
98
95
|
return diagnostic === undefined ? [] : [diagnostic];
|
package/src/mcp-errors.ts
CHANGED
|
@@ -369,7 +369,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
369
369
|
X_ASSET_RETAIN_UNDECLARED:
|
|
370
370
|
"edit app.config.ts: add assets: { retain: { disk: 'assets', builds: 3 } }, naming a disk your defineStorage({ disks }) declares that every web pod reads",
|
|
371
371
|
X_EXERCISE_UNPROVEN_ABOVE_FLOOR:
|
|
372
|
-
'x exercise --json # each unproven record in .x/exercise.json names the proof and its reason: fix the seed or
|
|
372
|
+
'x exercise --json # re-measures at the constant seed the gate runs (a floor from before 31.47.0 was measured under random seeds); each unproven record in .x/exercise.json names the proof and its reason: fix the seed helper or override it names, assuming no order between sized calls; the floor only falls',
|
|
373
373
|
X_ENV_NAME_RESERVED:
|
|
374
374
|
'edit app.config.ts: add an APP_ prefix to the envSchema name the finding cites (or delete it where the value is meant for the framework); then: x env example --json && x doctor --json',
|
|
375
375
|
X_FRAMEWORK_PIN_RANGE:
|
|
@@ -401,7 +401,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
401
401
|
X_REPRO_BUNDLE_INVALID:
|
|
402
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
403
|
X_ADVISORY_FLOOR_UNMET: 'bun update source-map-js immutable',
|
|
404
|
-
X_UPGRADE_CODEMODS_PENDING: 'x upgrade --json',
|
|
404
|
+
X_UPGRADE_CODEMODS_PENDING: 'x upgrade codemods --from 0.0.0 --json',
|
|
405
405
|
X_UPGRADE_LOCKED: 'cat .x/upgrade.lock',
|
|
406
406
|
X_APP_MIGRATIONS_UNAPPLIED: 'x db migrate --json',
|
|
407
407
|
};
|
package/src/messages.ts
CHANGED
|
@@ -137,6 +137,7 @@ const CATALOG = {
|
|
|
137
137
|
'cli.exercise.none': 'this app registers no action, query or job: nothing to exercise',
|
|
138
138
|
'cli.exercise.summary':
|
|
139
139
|
'{total} primitive(s): {reached} reached, {refused} refused, {off} off, {unreached} unreached — {file}',
|
|
140
|
+
'cli.exercise.seed': 'seed {seed} — replay this pass: x exercise --seed {seed} --json',
|
|
140
141
|
'cli.exercise.phases': 'took {total} ms — {phases} — slowest: {slowest}',
|
|
141
142
|
'cli.exercise.slowest': 'slowest: {primitive} · {proof} {ms} ms',
|
|
142
143
|
// One rendering of "this file was written", for every command that writes files — `x g`, its
|
package/src/prerender-out.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// `--out apps` deleted the app's pages and `--out .x` its embedded dev database.
|
|
5
5
|
|
|
6
6
|
import { lstat, readdir, rm } from 'node:fs/promises'; // why: Bun has no recursive delete or readdir.
|
|
7
|
-
import { isAbsolute, join,
|
|
7
|
+
import { isAbsolute, join, resolve } from 'node:path'; // why: Bun ships no path resolve.
|
|
8
8
|
import { UltimateError } from '@ultimat3/core';
|
|
9
|
+
import { posixRelative } from './posix-path';
|
|
9
10
|
|
|
10
11
|
/** Written into every export directory a build empties: the proof the next build may empty it. */
|
|
11
12
|
export const EXPORT_MARKER = '.x-export';
|
|
@@ -21,8 +22,8 @@ const MARKER_TEXT =
|
|
|
21
22
|
|
|
22
23
|
/** True when `dir` is `root` itself or one of its ancestors. */
|
|
23
24
|
const containsRoot = (dir: string, root: string): boolean => {
|
|
24
|
-
const up =
|
|
25
|
-
return up === '' || (up !== '..' && !up.startsWith(
|
|
25
|
+
const up = posixRelative(resolve(dir), resolve(root));
|
|
26
|
+
return up === '' || (up !== '..' && !up.startsWith('../') && !isAbsolute(up));
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
/** Why `out` is not the build's to empty, or `undefined` when it is. */
|
package/src/publish-closure.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// `src/**/*-fixture.ts`, so a module an entry reaches under that suffix is a published package
|
|
4
4
|
// that fails on import — and the defect is the name, not the exclusion.
|
|
5
5
|
|
|
6
|
-
import { ERROR_DOCS_URL } from '@ultimat3/core';
|
|
6
|
+
import { ERROR_DOCS_URL, isJsonObject } from '@ultimat3/core';
|
|
7
7
|
import type { ClosureHost } from './import-closure';
|
|
8
8
|
import { importClosure } from './import-closure';
|
|
9
9
|
import type { Finding } from './output';
|
|
@@ -15,13 +15,11 @@ export const FIXTURE_SUFFIX = '-fixture.ts';
|
|
|
15
15
|
/** A package directory, read by package-relative POSIX path. */
|
|
16
16
|
export type PackageReader = Pick<ClosureHost, 'read'>;
|
|
17
17
|
|
|
18
|
-
const isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>
|
|
19
|
-
typeof value === 'object' && value !== null;
|
|
20
|
-
|
|
21
18
|
/** Every string under `exports` / `bin`, whatever the nesting: a condition map is still a file. */
|
|
22
19
|
const targetsOf = (value: unknown): readonly string[] => {
|
|
23
20
|
if (typeof value === 'string') return [value];
|
|
24
|
-
|
|
21
|
+
// An array is walked too: `exports` allows a fallback list (`".": ["./a.js", { … }]`).
|
|
22
|
+
return Array.isArray(value) || isJsonObject(value) ? Object.values(value).flatMap(targetsOf) : [];
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
/**
|
|
@@ -30,7 +28,7 @@ const targetsOf = (value: unknown): readonly string[] => {
|
|
|
30
28
|
* entry to walk from.
|
|
31
29
|
*/
|
|
32
30
|
export function entryFilesOf(manifest: unknown): readonly string[] {
|
|
33
|
-
if (!
|
|
31
|
+
if (!isJsonObject(manifest)) return [];
|
|
34
32
|
const targets = [...targetsOf(manifest['exports']), ...targetsOf(manifest['bin'])];
|
|
35
33
|
const files = targets
|
|
36
34
|
.map((target) => target.replace(/^\.\//, ''))
|