@ultimat3/cli 31.46.0 → 31.47.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 +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/codemods/ci-weekly-schedule.ts +61 -0
- package/src/codemods/index.ts +2 -0
- package/src/codemods/vendored-guards.ts +3 -5
- package/src/codemods/verify-floor-skips.ts +4 -6
- 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 +1 -1
- 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/scaffold-docs.ts +1 -0
- package/src/templates/shapes/overlay.ts +4 -7
- 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 +18 -5
- package/wiki/Caching-And-Invalidation.md +76 -23
- package/wiki/Client-Navigation.md +2 -0
- 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/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 +41 -4
package/src/cmd-token.ts
CHANGED
|
@@ -7,11 +7,15 @@ import type { ApiKeyStore, ApiKeySummary } from '@ultimat3/auth';
|
|
|
7
7
|
import { describeApiKey, issueApiKey, postgresAuthAdapter, revokeApiKey } from '@ultimat3/auth';
|
|
8
8
|
import { type Clock, systemClock, tryResolveEnvironment } from '@ultimat3/core';
|
|
9
9
|
import { requireAppRoot } from './app-root';
|
|
10
|
-
import { plannedSubcommand } from './cmd-planned';
|
|
11
10
|
import { TOKEN_MAX_DAYS, TOKEN_SUBCOMMANDS, tokenSpec } from './cmd-token-spec';
|
|
12
11
|
import type { CliCommand, CommandContext } from './command';
|
|
13
12
|
import { ok } from './command';
|
|
14
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
BadFlagError,
|
|
15
|
+
MissingPositionalError,
|
|
16
|
+
MissingSubcommandError,
|
|
17
|
+
UnknownCommandError,
|
|
18
|
+
} from './errors';
|
|
15
19
|
import { parseIntFlag } from './flag-number';
|
|
16
20
|
import { readsAsProduction } from './mcp-db-target';
|
|
17
21
|
import { msg } from './messages';
|
|
@@ -170,7 +174,11 @@ export const tokenCommandOver = (open: OpenToken, clock: Clock = systemClock): C
|
|
|
170
174
|
// a `ParsedArgs` built by hand.
|
|
171
175
|
if (sub === undefined)
|
|
172
176
|
throw new MissingSubcommandError({ command: 'token', known: TOKEN_SUBCOMMANDS });
|
|
173
|
-
throw
|
|
177
|
+
throw new UnknownCommandError({
|
|
178
|
+
path: `token ${sub}`,
|
|
179
|
+
known: TOKEN_SUBCOMMANDS,
|
|
180
|
+
suggestion: 'help token',
|
|
181
|
+
});
|
|
174
182
|
},
|
|
175
183
|
});
|
|
176
184
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// 31.47.0: `x new`'s ci.yml gates the default branch weekly and keeps one issue while that run is
|
|
2
|
+
// red, and its dependabot.yml leaves the Bun image to the repo's Bun pins. A workflow that already
|
|
3
|
+
// has a schedule made these decisions itself and is left alone; one that no longer holds the
|
|
4
|
+
// template's lines is reported with the diff, all or nothing.
|
|
5
|
+
|
|
6
|
+
import { CI_WORKFLOW_PATH } from '../templates/github/ci.yml';
|
|
7
|
+
import {
|
|
8
|
+
ALARM_JOB,
|
|
9
|
+
CONCURRENCY_GROUP,
|
|
10
|
+
PLAN_CONDITION,
|
|
11
|
+
scheduleTrigger,
|
|
12
|
+
} from '../templates/github/ci-schedule';
|
|
13
|
+
import { BUN_IMAGE_IGNORE, DEPENDABOT_PATH } from '../templates/github/dependabot.yml';
|
|
14
|
+
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
15
|
+
import { editSnippets, mergeResults, readText } from './engine-edits';
|
|
16
|
+
|
|
17
|
+
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
18
|
+
|
|
19
|
+
const OLD_TRIGGERS = 'on:\n push:\n pull_request:\n';
|
|
20
|
+
const OLD_GROUP = `concurrency:
|
|
21
|
+
group: ci-\${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || github.ref }}
|
|
22
|
+
`;
|
|
23
|
+
const OLD_CONDITION = ` if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
|
24
|
+
`;
|
|
25
|
+
const VERDICT_STEP = ' - run: bun run verify merge "$RUNNER_TEMP"/parts/*.json\n';
|
|
26
|
+
const POSTGRES_IGNORE = ` # A Postgres MAJOR is a planned migration (a new data directory), never a weekly bump.
|
|
27
|
+
- dependency-name: postgres
|
|
28
|
+
update-types: ['version-update:semver-major']
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
/** A `schedule:` key inside the `on:` block, never a job of that name further down. */
|
|
32
|
+
const HAS_SCHEDULE = /^["']?on["']?:[^\n]*\n(?:(?:[ \t#][^\n]*)?\n)*?[ \t]+schedule:/m;
|
|
33
|
+
/** The name `x new` wrote into the workflow's header: the cron's seed, as it was for a new app. */
|
|
34
|
+
const APP_NAME = /^# The gate for ([^\s:]+):/m;
|
|
35
|
+
|
|
36
|
+
async function carryWorkflow(app: CodemodApp): Promise<CodemodResult> {
|
|
37
|
+
const file = await readText(app, CI_WORKFLOW_PATH);
|
|
38
|
+
if (file === undefined || HAS_SCHEDULE.test(file.text)) return NOTHING;
|
|
39
|
+
const name = APP_NAME.exec(file.text)?.[1] ?? app.root;
|
|
40
|
+
return editSnippets(app, CI_WORKFLOW_PATH, [
|
|
41
|
+
{ from: OLD_TRIGGERS, to: `${OLD_TRIGGERS}${scheduleTrigger(name)}` },
|
|
42
|
+
{ from: OLD_GROUP, to: CONCURRENCY_GROUP },
|
|
43
|
+
{ from: OLD_CONDITION, to: PLAN_CONDITION },
|
|
44
|
+
{ from: VERDICT_STEP, to: `${VERDICT_STEP}${ALARM_JOB}` },
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function carryDependabot(app: CodemodApp): Promise<CodemodResult> {
|
|
49
|
+
const file = await readText(app, DEPENDABOT_PATH);
|
|
50
|
+
if (file === undefined || file.text.includes('dependency-name: oven/bun')) return NOTHING;
|
|
51
|
+
return editSnippets(app, DEPENDABOT_PATH, [
|
|
52
|
+
{ from: POSTGRES_IGNORE, to: `${POSTGRES_IGNORE}${BUN_IMAGE_IGNORE}` },
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const codemod: Codemod = {
|
|
57
|
+
id: 'ci-weekly-schedule',
|
|
58
|
+
since: '31.47.0',
|
|
59
|
+
summary: `${CI_WORKFLOW_PATH}: a weekly gate of the default branch, with one issue kept while it is red; ${DEPENDABOT_PATH}: the Bun image moves with the repo's Bun pins`,
|
|
60
|
+
run: async (app) => mergeResults([await carryWorkflow(app), await carryDependabot(app)]),
|
|
61
|
+
};
|
package/src/codemods/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { codemod as ciArtifactRetention } from './ci-artifact-retention';
|
|
|
11
11
|
import { codemod as ciE2eBrowser } from './ci-e2e-browser';
|
|
12
12
|
import { codemod as ciPinnedActions } from './ci-pinned-actions';
|
|
13
13
|
import { codemod as ciServicesEnv } from './ci-services-env';
|
|
14
|
+
import { codemod as ciWeeklySchedule } from './ci-weekly-schedule';
|
|
14
15
|
import type { Codemod } from './codemod';
|
|
15
16
|
import { codemod as defineErrorLeaf } from './define-error-leaf';
|
|
16
17
|
import { codemod as docsCiParts } from './docs-ci-parts';
|
|
@@ -67,4 +68,5 @@ export const CODEMODS: readonly Codemod[] = [
|
|
|
67
68
|
testServices,
|
|
68
69
|
ciPinnedActions,
|
|
69
70
|
ciArtifactRetention,
|
|
71
|
+
ciWeeklySchedule,
|
|
70
72
|
];
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// differs only in severity becomes a `guards/shipped.json` row; any other edit is kept as the app's
|
|
4
4
|
// own guard under a new name, the shipped one off, with the reason and the diff — never lost.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import {
|
|
7
8
|
parseShippedConfig,
|
|
8
9
|
SHIPPED_GUARD_CONFIG,
|
|
@@ -28,9 +29,6 @@ const REPORT_ONLY = /^\s*severity:\s*'warning',\s*$/m;
|
|
|
28
29
|
const withoutSeverity = (text: string): string =>
|
|
29
30
|
text.replaceAll('\r\n', '\n').replaceAll(SEVERITY_LINE, '');
|
|
30
31
|
|
|
31
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
32
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
33
|
-
|
|
34
32
|
/** What one copy becomes: deleted at a severity, or kept as the app's own guard. */
|
|
35
33
|
type Verdict =
|
|
36
34
|
| { readonly kind: 'delete'; readonly severity: 'error' | 'warning' }
|
|
@@ -78,8 +76,8 @@ const moveBaselines = async (
|
|
|
78
76
|
} catch {
|
|
79
77
|
return false;
|
|
80
78
|
}
|
|
81
|
-
const baseline =
|
|
82
|
-
if (!
|
|
79
|
+
const baseline = isJsonObject(floor) ? floor[GUARD_BASELINE_FIELD] : undefined;
|
|
80
|
+
if (!isJsonObject(floor) || !isJsonObject(baseline)) return false;
|
|
83
81
|
const moved = Object.fromEntries(
|
|
84
82
|
Object.entries(baseline).map(([key, value]) => [renamed.get(key) ?? key, value]),
|
|
85
83
|
);
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
// `skip` with its why — and sets `strict`. An older app gains the `skip` rows that hold for it
|
|
3
3
|
// (roadmap; job with no job suite; e2e with no page). `strict` is 31.28.0's (`verify-floor-steps`).
|
|
4
4
|
|
|
5
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
5
6
|
import { floorSteps } from '../templates/scaffold-verify-floor';
|
|
6
7
|
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
7
8
|
import type { Codemod, CodemodApp } from './codemod';
|
|
8
9
|
|
|
9
10
|
export type Floor = Record<string, unknown>;
|
|
10
11
|
|
|
11
|
-
export const isObject = (value: unknown): value is Floor =>
|
|
12
|
-
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
|
-
|
|
14
12
|
const any = async (app: CodemodApp, pattern: string): Promise<boolean> =>
|
|
15
13
|
(await app.glob(pattern)).length > 0;
|
|
16
14
|
|
|
@@ -39,7 +37,7 @@ async function excused(app: CodemodApp): Promise<Readonly<Record<string, string>
|
|
|
39
37
|
|
|
40
38
|
/** `floor` with `skip` merged in, placed right after `steps` as the scaffold writes it. */
|
|
41
39
|
function withSkip(floor: Floor, skip: Readonly<Record<string, string>>): Floor {
|
|
42
|
-
const merged = { ...(
|
|
40
|
+
const merged = { ...(isJsonObject(floor['skip']) ? floor['skip'] : {}), ...skip };
|
|
43
41
|
const out: Floor = {};
|
|
44
42
|
for (const [key, value] of Object.entries(floor)) {
|
|
45
43
|
if (key === 'skip') continue;
|
|
@@ -65,7 +63,7 @@ export const codemod: Codemod = {
|
|
|
65
63
|
} catch {
|
|
66
64
|
floor = undefined;
|
|
67
65
|
}
|
|
68
|
-
if (!
|
|
66
|
+
if (!isJsonObject(floor)) {
|
|
69
67
|
return {
|
|
70
68
|
changed: [],
|
|
71
69
|
skipped: [
|
|
@@ -74,7 +72,7 @@ export const codemod: Codemod = {
|
|
|
74
72
|
};
|
|
75
73
|
}
|
|
76
74
|
const steps = Array.isArray(floor['steps']) ? floor['steps'] : [];
|
|
77
|
-
const held =
|
|
75
|
+
const held = isJsonObject(floor['skip']) ? floor['skip'] : {};
|
|
78
76
|
const add = Object.fromEntries(
|
|
79
77
|
Object.entries(await excused(app)).filter(
|
|
80
78
|
([step]) => !steps.includes(step) && !(step in held),
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
// names every gate step — required or excused — `strict` goes on. Short of that, `strict: false`
|
|
4
4
|
// is written once with a note: a decision recorded, not a question asked on every upgrade.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject } from '@ultimat3/core';
|
|
6
7
|
import { floorSteps } from '../templates/scaffold-verify-floor';
|
|
7
8
|
import { VERIFY_FLOOR_FILE } from '../verify-floor';
|
|
8
9
|
import { VERIFY_STEP_NAMES } from '../verify-step';
|
|
9
10
|
import type { Codemod, CodemodResult } from './codemod';
|
|
10
11
|
import { unifiedDiff } from './engine-diff';
|
|
11
12
|
import type { Floor } from './verify-floor-skips';
|
|
12
|
-
import { floorSuites,
|
|
13
|
+
import { floorSuites, renderFloor } from './verify-floor-skips';
|
|
13
14
|
|
|
14
15
|
const NOTHING: CodemodResult = { changed: [], skipped: [] };
|
|
15
16
|
|
|
@@ -50,9 +51,9 @@ export const codemod: Codemod = {
|
|
|
50
51
|
return NOTHING;
|
|
51
52
|
}
|
|
52
53
|
// `verify-floor-skips` already reports a floor that is not a JSON object.
|
|
53
|
-
if (!
|
|
54
|
+
if (!isJsonObject(floor) || !Array.isArray(floor['steps'])) return NOTHING;
|
|
54
55
|
const held: unknown[] = floor['steps'];
|
|
55
|
-
const skip =
|
|
56
|
+
const skip = isJsonObject(floor['skip']) ? floor['skip'] : {};
|
|
56
57
|
const wanted = floorSteps(await floorSuites(app)).steps;
|
|
57
58
|
const added = wanted.filter((step) => !held.includes(step) && !(step in skip));
|
|
58
59
|
// `steps` replaced where it stands: the app's key order kept.
|
package/src/db-seed.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
// why: `node:path` for the joiner and the app-root-relative spelling every finding is keyed by; Bun
|
|
9
9
|
// exposes neither.
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
import type { Environment } from '@ultimat3/core';
|
|
12
12
|
import { UltimateError } from '@ultimat3/core';
|
|
13
13
|
import type { Driver, Seed, SeedTier } from '@ultimat3/entity';
|
|
@@ -16,6 +16,7 @@ import { BadFlagError } from './errors';
|
|
|
16
16
|
import type { Finding, JsonValue } from './output';
|
|
17
17
|
import { findingFrom } from './output';
|
|
18
18
|
import { hasPathSegment } from './path-segments';
|
|
19
|
+
import { posixRelative } from './posix-path';
|
|
19
20
|
import { quoteArg } from './shell-quote';
|
|
20
21
|
import { isTest } from './source-files';
|
|
21
22
|
import { renderTable } from './table';
|
|
@@ -104,7 +105,7 @@ export async function discoverSeeds(root: string): Promise<SeedDiscovery> {
|
|
|
104
105
|
const seen = new Set<string>();
|
|
105
106
|
for (const pattern of SEED_GLOBS) {
|
|
106
107
|
for await (const absolute of new Bun.Glob(pattern).scan({ cwd: root, absolute: true })) {
|
|
107
|
-
const file =
|
|
108
|
+
const file = posixRelative(root, absolute);
|
|
108
109
|
// Root-relative, as `loadApp` tests it: an absolute path under `my.test.app/` is no test.
|
|
109
110
|
if (hasPathSegment(absolute, 'node_modules') || isTest(file)) continue;
|
|
110
111
|
if (seen.has(absolute)) continue;
|
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
|
}
|