@ultimat3/cli 31.49.0 → 31.50.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/package.json +30 -30
- package/src/api-registration.ts +18 -1
- package/src/api-routes.ts +1 -0
- package/src/app-load.ts +1 -2
- package/src/app-openapi.ts +7 -1
- package/src/budgets.ts +2 -1
- package/src/cmd-i18n.ts +33 -1
- package/src/codemods/engine-fs.ts +9 -2
- package/src/codemods/merge-drivers.ts +85 -4
- package/src/exercise-services.ts +13 -3
- package/src/framework-schema.ts +15 -5
- package/src/guard-sources.ts +1 -2
- package/src/messages-upgrade.ts +4 -0
- package/src/page-navigation.ts +5 -2
- package/src/pwa-artifacts.ts +1 -1
- package/src/retained-assets-boot.ts +1 -1
- package/src/runtime-assets-site.ts +2 -2
- package/src/runtime-assets.ts +1 -1
- package/src/runtime-render-document.ts +1 -2
- package/src/site-asset-routes.ts +2 -2
- package/src/site-assets.ts +5 -158
- package/src/sw-precache-plan.ts +1 -1
- package/src/templates/guard-raw-motion.ts +96 -0
- package/src/templates/guard-released-forms.ts +4 -1
- package/src/templates/scaffold-repo.ts +1 -1
- package/src/test-only-shipped.ts +29 -2
- package/src/test-shards.ts +20 -8
- package/src/upgrade-coverage-ratchet.ts +95 -0
- package/src/upgrade-gate.ts +31 -11
- package/src/upgrade-report.ts +14 -0
- package/src/verify-e2e.ts +21 -3
- package/src/workspace-checks.ts +4 -1
- package/wiki/Actions.md +64 -2
- package/wiki/Auth.md +6 -2
- package/wiki/CLI-Reference.md +8 -2
- package/wiki/Client-Navigation.md +34 -4
- package/wiki/Configuration.md +2 -1
- package/wiki/Entities-And-Migrations.md +12 -2
- package/wiki/Home.md +2 -2
- package/wiki/I18n.md +1 -1
- package/wiki/Interface-Rules.md +3 -1
- package/wiki/Known-Gaps.md +1 -1
- package/wiki/MCP-And-AI.md +41 -9
- package/wiki/Notify.md +4 -2
- package/wiki/Outbound-HTTP.md +53 -2
- package/wiki/Policies-And-Authz.md +1 -1
- package/wiki/Realtime.md +14 -6
- package/wiki/Routes-And-Render-Modes.md +1 -1
- package/wiki/Static-Assets.md +5 -3
- package/wiki/Testing.md +57 -3
- package/wiki/Theming.md +6 -3
- package/wiki/UI-Components.md +1 -0
- package/wiki/Upgrading.md +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.50.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -52,35 +52,35 @@
|
|
|
52
52
|
"dev": "bun run src/bin.ts dev"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@babel/core": "^8.0
|
|
56
|
-
"@ultimat3/action": "31.
|
|
57
|
-
"@ultimat3/admin": "31.
|
|
58
|
-
"@ultimat3/ai": "31.
|
|
59
|
-
"@ultimat3/auth": "31.
|
|
60
|
-
"@ultimat3/cache": "31.
|
|
61
|
-
"@ultimat3/core": "31.
|
|
62
|
-
"@ultimat3/db": "31.
|
|
63
|
-
"@ultimat3/entity": "31.
|
|
64
|
-
"@ultimat3/flags": "31.
|
|
65
|
-
"@ultimat3/http": "31.
|
|
66
|
-
"@ultimat3/i18n": "31.
|
|
67
|
-
"@ultimat3/jobs": "31.
|
|
68
|
-
"@ultimat3/mail": "31.
|
|
69
|
-
"@ultimat3/manifest": "31.
|
|
70
|
-
"@ultimat3/mcp": "31.
|
|
71
|
-
"@ultimat3/money": "31.
|
|
72
|
-
"@ultimat3/notify": "31.
|
|
73
|
-
"@ultimat3/policy": "31.
|
|
74
|
-
"@ultimat3/pwa": "31.
|
|
75
|
-
"@ultimat3/query": "31.
|
|
76
|
-
"@ultimat3/realtime": "31.
|
|
77
|
-
"@ultimat3/render": "31.
|
|
78
|
-
"@ultimat3/schema": "31.
|
|
79
|
-
"@ultimat3/scraping": "31.
|
|
80
|
-
"@ultimat3/seo": "31.
|
|
81
|
-
"@ultimat3/storage": "31.
|
|
82
|
-
"@ultimat3/testing": "31.
|
|
83
|
-
"@ultimat3/time": "31.
|
|
55
|
+
"@babel/core": "^8.1.0",
|
|
56
|
+
"@ultimat3/action": "31.50.0",
|
|
57
|
+
"@ultimat3/admin": "31.50.0",
|
|
58
|
+
"@ultimat3/ai": "31.50.0",
|
|
59
|
+
"@ultimat3/auth": "31.50.0",
|
|
60
|
+
"@ultimat3/cache": "31.50.0",
|
|
61
|
+
"@ultimat3/core": "31.50.0",
|
|
62
|
+
"@ultimat3/db": "31.50.0",
|
|
63
|
+
"@ultimat3/entity": "31.50.0",
|
|
64
|
+
"@ultimat3/flags": "31.50.0",
|
|
65
|
+
"@ultimat3/http": "31.50.0",
|
|
66
|
+
"@ultimat3/i18n": "31.50.0",
|
|
67
|
+
"@ultimat3/jobs": "31.50.0",
|
|
68
|
+
"@ultimat3/mail": "31.50.0",
|
|
69
|
+
"@ultimat3/manifest": "31.50.0",
|
|
70
|
+
"@ultimat3/mcp": "31.50.0",
|
|
71
|
+
"@ultimat3/money": "31.50.0",
|
|
72
|
+
"@ultimat3/notify": "31.50.0",
|
|
73
|
+
"@ultimat3/policy": "31.50.0",
|
|
74
|
+
"@ultimat3/pwa": "31.50.0",
|
|
75
|
+
"@ultimat3/query": "31.50.0",
|
|
76
|
+
"@ultimat3/realtime": "31.50.0",
|
|
77
|
+
"@ultimat3/render": "31.50.0",
|
|
78
|
+
"@ultimat3/schema": "31.50.0",
|
|
79
|
+
"@ultimat3/scraping": "31.50.0",
|
|
80
|
+
"@ultimat3/seo": "31.50.0",
|
|
81
|
+
"@ultimat3/storage": "31.50.0",
|
|
82
|
+
"@ultimat3/testing": "31.50.0",
|
|
83
|
+
"@ultimat3/time": "31.50.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/api-registration.ts
CHANGED
|
@@ -81,6 +81,23 @@ export const apiListsOf = (
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Whether the `defineApi({ ... })` call names `key` in ANY form — `key: [...]`, `key: value`, the
|
|
86
|
+
* shorthand `key,`. `readProperties` sees only `key:`; a shorthand `queries,` read as absent, and
|
|
87
|
+
* 31.49.0's merge-drivers codemod added `queries: []` beside it: a duplicate key, TS1117.
|
|
88
|
+
*/
|
|
89
|
+
function apiDeclares(source: string, key: string): boolean {
|
|
90
|
+
const masked = maskOf(source);
|
|
91
|
+
const call = /\bdefineApi\(\s*\{/.exec(masked);
|
|
92
|
+
if (call === null) return false;
|
|
93
|
+
const object = readList(source, masked, call.index + call[0].length - 1);
|
|
94
|
+
const named = new RegExp(`^(?:${key}|'${key}'|"${key}")\\s*(?::|$)`);
|
|
95
|
+
// The SOURCE text, not the masked: masking blanks a string's contents, so `'jobs':` read as absent.
|
|
96
|
+
return (object?.entries ?? []).some((entry) =>
|
|
97
|
+
named.test(source.slice(entry.start, entry.end).trim()),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
84
101
|
/**
|
|
85
102
|
* `source` with `key: value,` added as a property, on its own row: in the order `x new` writes —
|
|
86
103
|
* actions, queries, jobs, tasks — so after the nearest list before it the call already holds, which
|
|
@@ -94,7 +111,7 @@ export function insertApiList(
|
|
|
94
111
|
): string | undefined {
|
|
95
112
|
const listOf = apiListsOf(source);
|
|
96
113
|
const actions = listOf?.('actions');
|
|
97
|
-
if (listOf === undefined || actions === undefined) return undefined;
|
|
114
|
+
if (listOf === undefined || actions === undefined || apiDeclares(source, key)) return undefined;
|
|
98
115
|
const earlier = LIST_ORDER.slice(0, LIST_ORDER.indexOf(key))
|
|
99
116
|
.map((name) => listOf(name))
|
|
100
117
|
.findLast((found) => found !== undefined);
|
package/src/api-routes.ts
CHANGED
|
@@ -38,6 +38,7 @@ export function apiMountRoutes(store?: RateLimitStore): readonly Route[] {
|
|
|
38
38
|
scopes: mount.scopes,
|
|
39
39
|
resolveToken: mount.resolveToken,
|
|
40
40
|
...(mount.rateLimit === undefined ? {} : { rateLimit: mount.rateLimit }),
|
|
41
|
+
...(mount.tenant === undefined ? {} : { tenant: mount.tenant }),
|
|
41
42
|
...(store === undefined ? {} : { rateLimitStore: store }),
|
|
42
43
|
}),
|
|
43
44
|
);
|
package/src/app-load.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { routeEntries, setAssetResolver } from '@ultimat3/render';
|
|
|
21
21
|
// here is six hops through `error-contract` → `fix-command` → the command registry, which is an
|
|
22
22
|
// accident one refactor away from compiling every app's `.tsx` to `React.createElement`. The named
|
|
23
23
|
// import is a value import, so the side effect holds without the bare line it replaced.
|
|
24
|
-
import { setStylesheetRoot } from '@ultimat3/render/server';
|
|
24
|
+
import { setStylesheetRoot, siteAssetTable } from '@ultimat3/render/server';
|
|
25
25
|
import { asyncModules } from './app-load-async';
|
|
26
26
|
import { importInOrder } from './app-load-batch';
|
|
27
27
|
import { isFirstPass, registeredAny, registerModule } from './app-load-register';
|
|
@@ -33,7 +33,6 @@ import type { Finding } from './output';
|
|
|
33
33
|
import { findingFrom } from './output';
|
|
34
34
|
import { hasPathSegment } from './path-segments';
|
|
35
35
|
import { posixRelative, toPosix } from './posix-path';
|
|
36
|
-
import { siteAssetTable } from './site-assets';
|
|
37
36
|
import { isTest } from './source-files';
|
|
38
37
|
|
|
39
38
|
/** Every place an app keeps code the framework has to see. */
|
package/src/app-openapi.ts
CHANGED
|
@@ -72,7 +72,13 @@ export const openApiArtifacts = (manifest: Manifest): readonly OpenApiArtifact[]
|
|
|
72
72
|
const merged = mergedDocument(manifest);
|
|
73
73
|
const routes = apiRoutes();
|
|
74
74
|
for (const mount of mounts) {
|
|
75
|
-
bearerMount({
|
|
75
|
+
bearerMount({
|
|
76
|
+
prefix: mount.prefix,
|
|
77
|
+
routes,
|
|
78
|
+
scopes: mount.scopes,
|
|
79
|
+
resolveToken: () => null,
|
|
80
|
+
...(mount.tenant === undefined ? {} : { tenant: mount.tenant }),
|
|
81
|
+
});
|
|
76
82
|
artifacts.push({
|
|
77
83
|
file: mount.openapi ?? OPENAPI_FILE,
|
|
78
84
|
text: serializeOpenApi(
|
package/src/budgets.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { join } from 'node:path';
|
|
|
11
11
|
import { ERROR_DOCS_URL, formatBytes } from '@ultimat3/core';
|
|
12
12
|
import type { Manifest, RouteFact } from '@ultimat3/manifest';
|
|
13
13
|
import { describePages, parseByteBudget, themeScriptBody } from '@ultimat3/render';
|
|
14
|
+
import { MANIFEST_FILE } from './app-root';
|
|
14
15
|
import type { ChargedFile } from './budgets-charged';
|
|
15
16
|
import { chargedClause, chargedMeta, heaviestFirst } from './budgets-charged';
|
|
16
17
|
import type { RouteRequests } from './budgets-requests';
|
|
@@ -115,7 +116,7 @@ const KB = 1024;
|
|
|
115
116
|
function exceededJsFix(url: string, file: string | undefined, bytes: number): string {
|
|
116
117
|
const where = file ?? `the file declaring ${url}`;
|
|
117
118
|
const kb = Math.ceil(bytes / KB);
|
|
118
|
-
return `edit ${where} — set budget: { js: '${String(kb)}kb' } with // measured: ${String(bytes)} B (x build --target static) — why: <the function it buys> directly above it; or x routes --json for the chain and move the heavy import behind hydrate: 'interaction'`;
|
|
119
|
+
return `edit ${where} — set budget: { js: '${String(kb)}kb' } with // measured: ${String(bytes)} B (x build --target static) — why: <the function it buys> directly above it, then x manifest (${MANIFEST_FILE} carries the budget); or x routes --json for the chain and move the heavy import behind hydrate: 'interaction'`;
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
/**
|
package/src/cmd-i18n.ts
CHANGED
|
@@ -308,6 +308,32 @@ async function adminCatalog(locale: string, seeded: boolean): Promise<Catalog> {
|
|
|
308
308
|
return Object.fromEntries(keys.map((key) => [key, label(key)]));
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* The admin keys just written to a second locale that the default locale's FILE lacks, written
|
|
313
|
+
* there too. The default locale answers them already — the framework's own `en` holds the admin
|
|
314
|
+
* chrome (`admin.brand.name`, `admin.x_jobs.title`), so its registry is green with no such key in
|
|
315
|
+
* the app's catalog — and syncing only the second locale left the app's catalogs with two key sets,
|
|
316
|
+
* the scaffold's own "same keys as the default" test red on the command the gate prescribed. The
|
|
317
|
+
* value is the string the default locale already renders, never a marker, so its page is unchanged.
|
|
318
|
+
*/
|
|
319
|
+
async function backfillDefault(
|
|
320
|
+
root: string,
|
|
321
|
+
catalogs: Readonly<Record<string, Catalog>>,
|
|
322
|
+
from: string,
|
|
323
|
+
adminKeys: readonly string[],
|
|
324
|
+
): Promise<readonly string[]> {
|
|
325
|
+
const target = catalogs[from] ?? {};
|
|
326
|
+
const rendered = catalogFor(from);
|
|
327
|
+
const real = (key: string): string => {
|
|
328
|
+
const value = rendered[key];
|
|
329
|
+
return value === undefined || isLoudMiss(value) ? adminKeyLabel(key) : value;
|
|
330
|
+
};
|
|
331
|
+
const source = Object.fromEntries(adminKeys.map((key) => [key, real(key)]));
|
|
332
|
+
const { merged, added } = syncCatalog(target, source);
|
|
333
|
+
if (added.length > 0) await Bun.write(join(root, catalogPath(from)), serializeCatalog(merged));
|
|
334
|
+
return added;
|
|
335
|
+
}
|
|
336
|
+
|
|
311
337
|
async function runSync(root: string, ctx: CommandContext): Promise<CommandResult> {
|
|
312
338
|
const locale = resolveOneLocale(ctx, 'sync');
|
|
313
339
|
const catalogs = await loadCatalogs(root);
|
|
@@ -330,14 +356,17 @@ async function runSync(root: string, ctx: CommandContext): Promise<CommandResult
|
|
|
330
356
|
const seeded = from === undefined || from === locale;
|
|
331
357
|
// The admin's keys first, so a value the default locale already carries for one (copied, marked)
|
|
332
358
|
// wins over a label read off the key.
|
|
359
|
+
const admin = await adminCatalog(locale, seeded);
|
|
333
360
|
const source = {
|
|
334
|
-
...
|
|
361
|
+
...admin,
|
|
335
362
|
...(seeded
|
|
336
363
|
? placeholderCatalog(await untranslatedKeys(root, catalogs, locale))
|
|
337
364
|
: seedCatalog(catalogs[from] ?? {})),
|
|
338
365
|
};
|
|
339
366
|
const { merged, added } = syncCatalog(target, source);
|
|
340
367
|
if (added.length > 0) await Bun.write(join(root, catalogPath(locale)), serializeCatalog(merged));
|
|
368
|
+
const adminAdded = added.filter((key) => Object.hasOwn(admin, key));
|
|
369
|
+
const defaultAdded = seeded ? [] : await backfillDefault(root, catalogs, from, adminAdded);
|
|
341
370
|
// Unconditional, and not only when keys moved: a catalog that reached disk some other way — a
|
|
342
371
|
// hand-created file, a `git merge` — is exactly the unregistered locale the gate refuses, and
|
|
343
372
|
// this is the command its `fix:` names. Re-deriving an index that is already correct writes the
|
|
@@ -367,6 +396,9 @@ async function runSync(root: string, ctx: CommandContext): Promise<CommandResult
|
|
|
367
396
|
// both are what `x i18n check` counts as missing until replaced, so `--json` never reports a
|
|
368
397
|
// copy as a translation.
|
|
369
398
|
placeholders: added.filter((key) => isLoudMiss(merged[key])),
|
|
399
|
+
// The admin keys also written to the default locale's catalog, so every app catalog keeps one
|
|
400
|
+
// key set (`backfillDefault`). Empty when the default locale is the one synced.
|
|
401
|
+
defaultAdded,
|
|
370
402
|
},
|
|
371
403
|
};
|
|
372
404
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
// why: Bun has no file-removal, rename, lstat or realpath primitive; `rm` with `force` makes a
|
|
6
6
|
// removal of nothing no error, `rename` lands a write whole, and only `realpath` answers where a
|
|
7
|
-
// symlinked component really points.
|
|
8
|
-
import { lstat, realpath, rename, rm } from 'node:fs/promises';
|
|
7
|
+
// symlinked component really points; `stat`/`chmod` carry a rewritten file's mode across the rename.
|
|
8
|
+
import { chmod, lstat, realpath, rename, rm, stat } from 'node:fs/promises';
|
|
9
9
|
// why: Bun exposes no path-resolve primitive; containment is decided on the resolved path.
|
|
10
10
|
import { dirname, resolve, sep } from 'node:path';
|
|
11
11
|
import { ScaffoldPathEscapeError } from '../errors';
|
|
@@ -60,8 +60,15 @@ export async function landFile(
|
|
|
60
60
|
move: (from: string, to: string) => Promise<void> = rename,
|
|
61
61
|
): Promise<void> {
|
|
62
62
|
const temp = `${target}.x-codemod-${String(process.pid)}-${crypto.randomUUID()}.tmp`;
|
|
63
|
+
// The temp file is born 0644: without the target's mode carried over, the rename drops `+x` —
|
|
64
|
+
// 31.49.0's merge-drivers codemod turned an app's executable `bin/setup.ts` into a plain file.
|
|
65
|
+
const mode = await stat(target).then(
|
|
66
|
+
(found) => found.mode,
|
|
67
|
+
() => undefined,
|
|
68
|
+
);
|
|
63
69
|
await Bun.write(temp, source);
|
|
64
70
|
try {
|
|
71
|
+
if (mode !== undefined) await chmod(temp, mode);
|
|
65
72
|
await move(temp, target);
|
|
66
73
|
} catch (error) {
|
|
67
74
|
await rm(temp, { force: true });
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
// 31.49.0: two branches that each generate a feature merge without a hand edit. An existing app
|
|
2
2
|
// gains the `.gitattributes` rules, the `bun run setup` step that installs the drivers, and its
|
|
3
|
-
// registries one entry per line
|
|
4
|
-
//
|
|
3
|
+
// registries one entry per line, the spread `api/index.ts` with a test that loads it. Additive: a
|
|
4
|
+
// list or a setup this cannot restate is left alone and reported; it only keeps merging by hand.
|
|
5
5
|
|
|
6
|
+
import { isJsonObject, stringField } from '@ultimat3/core';
|
|
7
|
+
import { API_INDEX } from '../app-root';
|
|
6
8
|
import { REGISTRY_FILES, withRegistryLines } from '../registry-lines';
|
|
7
9
|
import { BIN_SCRIPTS } from '../templates/scaffold-bin';
|
|
8
10
|
import { MERGE_ATTRIBUTES, ROOT_GITATTRIBUTES_PATH } from '../templates/scaffold-gitattributes';
|
|
9
|
-
import type { Codemod, CodemodApp, CodemodResult } from './codemod';
|
|
11
|
+
import type { Codemod, CodemodApp, CodemodResult, CodemodSkip } from './codemod';
|
|
10
12
|
|
|
11
13
|
const INSTALL_ANCHOR = "await bun('install');\n";
|
|
12
14
|
export const INSTALL_STEP = "await x('merge-driver', 'install');\n";
|
|
15
|
+
/** The same step for a setup script that is not `bin/setup.ts`: a shell line, pasted by hand. */
|
|
16
|
+
export const SHELL_INSTALL_STEP = 'bunx x merge-driver install';
|
|
13
17
|
|
|
14
18
|
const withAttributes = (held: string | undefined): string | undefined => {
|
|
15
19
|
if (held?.includes('merge=x-registry') === true) return undefined;
|
|
@@ -17,6 +21,69 @@ const withAttributes = (held: string | undefined): string | undefined => {
|
|
|
17
21
|
return `${held.endsWith('\n') ? held : `${held}\n`}\n${MERGE_ATTRIBUTES}`;
|
|
18
22
|
};
|
|
19
23
|
|
|
24
|
+
export const API_INDEX_TEST = API_INDEX.replace(/\.ts$/, '.test.ts');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The registration test, for an app `x new` wrote before it shipped `api/index.test.ts`. One row
|
|
28
|
+
* per entry is more lines, and an index no unit test loads weighs every one of them at 0% against
|
|
29
|
+
* the coverage floor — an upgrade that changed no behaviour went red. Generic on purpose: it reads
|
|
30
|
+
* the lists back, so it holds for any app's registrations.
|
|
31
|
+
*/
|
|
32
|
+
export const apiIndexTest =
|
|
33
|
+
(): string => `// The registration, read back: importing the index runs \`defineApi\`, and every primitive it
|
|
34
|
+
// lists is registered under the export name it was handed over as.
|
|
35
|
+
import { expect, unitTest } from '@ultimat3/testing';
|
|
36
|
+
import { api } from './index';
|
|
37
|
+
|
|
38
|
+
unitTest('every listed primitive is registered under its export name', () => {
|
|
39
|
+
const lists: readonly object[] = [api.actions, api.queries, api.jobs, api.tasks];
|
|
40
|
+
for (const list of lists) {
|
|
41
|
+
for (const [name, primitive] of Object.entries(list)) {
|
|
42
|
+
expect(primitive).toHaveProperty('name', name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
/** The index declares `api`, so the generic test has something to import; else it is reported. */
|
|
49
|
+
const EXPORTS_API = /^export const api = defineApi\(/m;
|
|
50
|
+
|
|
51
|
+
/** `scripts.setup` from the app's package.json, when it declares one. */
|
|
52
|
+
const setupCommand = (manifest: string | undefined): string | undefined => {
|
|
53
|
+
if (manifest === undefined) return undefined;
|
|
54
|
+
let parsed: unknown;
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(manifest);
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const scripts = isJsonObject(parsed) ? parsed['scripts'] : undefined;
|
|
61
|
+
return isJsonObject(scripts) ? stringField(scripts, 'setup') : undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A setup that is not `bin/setup.ts` (a bash `bin/setup`, a Makefile) is never edited — a shell
|
|
66
|
+
* script has no anchor this can trust — but it is always reported, naming the file `bun run setup`
|
|
67
|
+
* runs when the app holds it, else `package.json`, unless that file already installs the drivers.
|
|
68
|
+
*/
|
|
69
|
+
async function foreignSetup(app: CodemodApp): Promise<CodemodSkip | undefined> {
|
|
70
|
+
const command = setupCommand(await app.read('package.json'));
|
|
71
|
+
for (const token of command?.split(/\s+/) ?? []) {
|
|
72
|
+
const path = token.replace(/^\.\//, '');
|
|
73
|
+
const held = path === '' ? undefined : await app.read(path);
|
|
74
|
+
if (held === undefined) continue;
|
|
75
|
+
if (held.includes('merge-driver install')) return undefined;
|
|
76
|
+
return {
|
|
77
|
+
path,
|
|
78
|
+
reason: `bun run setup runs ${path}, not ${BIN_SCRIPTS.setup}; add the line ${SHELL_INSTALL_STEP} after its install step`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
path: 'package.json',
|
|
83
|
+
reason: `no ${BIN_SCRIPTS.setup} and no setup script file in the app; add ${SHELL_INSTALL_STEP} to whatever bun run setup runs, after its install step`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
20
87
|
async function edit(
|
|
21
88
|
app: CodemodApp,
|
|
22
89
|
path: string,
|
|
@@ -44,7 +111,10 @@ export const codemod: Codemod = {
|
|
|
44
111
|
changed.push(ROOT_GITATTRIBUTES_PATH);
|
|
45
112
|
}
|
|
46
113
|
const setup = await app.read(BIN_SCRIPTS.setup);
|
|
47
|
-
if (setup
|
|
114
|
+
if (setup === undefined) {
|
|
115
|
+
const skip = await foreignSetup(app);
|
|
116
|
+
if (skip !== undefined) skipped.push(skip);
|
|
117
|
+
} else if (!setup.includes(INSTALL_STEP)) {
|
|
48
118
|
if (setup.includes(INSTALL_ANCHOR)) {
|
|
49
119
|
await app.write(
|
|
50
120
|
BIN_SCRIPTS.setup,
|
|
@@ -61,6 +131,17 @@ export const codemod: Codemod = {
|
|
|
61
131
|
for (const path of REGISTRY_FILES) {
|
|
62
132
|
await edit(app, path, (held) => withRegistryLines(path, held), changed);
|
|
63
133
|
}
|
|
134
|
+
if (changed.includes(API_INDEX) && !(await app.exists(API_INDEX_TEST))) {
|
|
135
|
+
if (EXPORTS_API.test((await app.read(API_INDEX)) ?? '')) {
|
|
136
|
+
await app.write(API_INDEX_TEST, apiIndexTest());
|
|
137
|
+
changed.push(API_INDEX_TEST);
|
|
138
|
+
} else {
|
|
139
|
+
skipped.push({
|
|
140
|
+
path: API_INDEX_TEST,
|
|
141
|
+
reason: `${API_INDEX} now lists one entry per line and no unit test loads it, so its lines count at 0% against the coverage floor; write a test that imports it`,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
64
145
|
return { changed, skipped };
|
|
65
146
|
},
|
|
66
147
|
};
|
package/src/exercise-services.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// The runtime services a server's boot installs (`runtime-services.ts`) that `x exercise` stands in
|
|
2
|
-
// for: a storage disk, a fleet-wide rate-limit store
|
|
3
|
-
// scratch database. Without them every primitive reading one stopped on a boot-only refusal and
|
|
2
|
+
// for: a storage disk, a fleet-wide rate-limit store, the fleet-wide auth limiter and the Web Push
|
|
3
|
+
// runtime, over the pass's scratch database. Without them every primitive reading one stopped on a boot-only refusal and
|
|
4
4
|
// the app had to declare `{ off }` for it — the pass's job, not the app's.
|
|
5
5
|
|
|
6
|
+
import { postgresAuthLimiter } from '@ultimat3/auth';
|
|
7
|
+
import { installAuthLimiters } from '@ultimat3/auth/adapter';
|
|
6
8
|
import type { AppConfig, PgExecutor } from '@ultimat3/core';
|
|
7
|
-
import { ENVIRONMENT_KEY } from '@ultimat3/core';
|
|
9
|
+
import { ENVIRONMENT_KEY, systemClock } from '@ultimat3/core';
|
|
8
10
|
import { postgresRateLimitStore } from '@ultimat3/http';
|
|
9
11
|
import { installRateLimitStore } from '@ultimat3/http/adapter';
|
|
10
12
|
import {
|
|
@@ -76,6 +78,14 @@ export async function installExerciseServices(inputs: ExerciseServiceInputs): Pr
|
|
|
76
78
|
// `scope: 'shared'`, as the boot's: a `rateLimit: { scope: 'shared' }` declaration is judged
|
|
77
79
|
// against the installed store, and one process' memory refused it with X_RATE_LIMIT_NOT_SHARED.
|
|
78
80
|
released.push(installRateLimitStore(postgresRateLimitStore({ executor: inputs.executor })));
|
|
81
|
+
// The boot's auth limiter for the same reason: `defineAuth({ rateLimit: { scope: 'shared' } })`
|
|
82
|
+
// judged against one process' memory refused every action that reserves an attempt with
|
|
83
|
+
// X_AUTH_LIMITER_NOT_SHARED. Built per declared policy, over the scratch `x_auth_lockouts`.
|
|
84
|
+
released.push(
|
|
85
|
+
installAuthLimiters((policy) =>
|
|
86
|
+
postgresAuthLimiter({ executor: inputs.executor, clock: systemClock, policy }),
|
|
87
|
+
),
|
|
88
|
+
);
|
|
79
89
|
// Last, and the one that can refuse (a half VAPID pair): what is already in is undone first.
|
|
80
90
|
released.push(await installPush(inputs));
|
|
81
91
|
} catch (error) {
|
package/src/framework-schema.ts
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
// A framework table an app has to install by hand is a table that will be missing in production on
|
|
7
7
|
// the one code path that needs it, and it surfaces as a Postgres `42P01` from inside a worker.
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
SQL_AUDIT_TABLE,
|
|
11
|
+
SQL_IDEMPOTENCY_TABLE,
|
|
12
|
+
SQL_METER_KEY_TABLE,
|
|
13
|
+
SQL_METER_TABLE,
|
|
14
|
+
} from '@ultimat3/action';
|
|
10
15
|
import {
|
|
11
16
|
ADMIN_AUDIT_TABLE,
|
|
12
17
|
ERROR_GROUPS_TABLE,
|
|
@@ -100,12 +105,17 @@ export const FRAMEWORK_SCHEMA: readonly FrameworkSchema[] = Object.freeze([
|
|
|
100
105
|
tables: Object.freeze(['x_audit']),
|
|
101
106
|
ddl: Object.freeze([SQL_AUDIT_TABLE]),
|
|
102
107
|
}),
|
|
103
|
-
// The counters behind `meter
|
|
104
|
-
// place, so it ships no purge: the table is bounded by its subjects, never by
|
|
108
|
+
// The counters behind `meter:` and `drawMeter`. One row per tenant × meter × period declaration,
|
|
109
|
+
// rolled over in place, so it ships no purge: the table is bounded by its subjects, never by
|
|
110
|
+
// time. `x_meter_key` holds one row per counted keyed draw, about two periods of them per active
|
|
111
|
+
// counter: a keyed draw that counts prunes its counter's older rows, and an idle counter keeps
|
|
112
|
+
// its last rows until its next one.
|
|
113
|
+
// `SQL_METER_KEY_TABLE` also creates `x_meter_key_counted`, the function a refused keyed draw
|
|
114
|
+
// reads its key through: not a table, so it is in no `tables` list.
|
|
105
115
|
Object.freeze({
|
|
106
116
|
pkg: '@ultimat3/action',
|
|
107
|
-
tables: Object.freeze(['x_meter']),
|
|
108
|
-
ddl: Object.freeze([SQL_METER_TABLE]),
|
|
117
|
+
tables: Object.freeze(['x_meter', 'x_meter_key']),
|
|
118
|
+
ddl: Object.freeze([SQL_METER_TABLE, SQL_METER_KEY_TABLE]),
|
|
109
119
|
}),
|
|
110
120
|
Object.freeze({
|
|
111
121
|
pkg: '@ultimat3/http',
|
package/src/guard-sources.ts
CHANGED
|
@@ -90,9 +90,8 @@ export function guardSources(
|
|
|
90
90
|
const source = await textOf(path);
|
|
91
91
|
// Imported here, not at the top: Sass loads on the first compile, and a gate run whose
|
|
92
92
|
// guards compile nothing must not pay for the compiler (`sass-lazy.test.ts`).
|
|
93
|
-
const { compileStylesheet } = await import('@ultimat3/render/server');
|
|
93
|
+
const { compileStylesheet, siteAssetTable } = await import('@ultimat3/render/server');
|
|
94
94
|
const { setAssetResolver } = await import('@ultimat3/render');
|
|
95
|
-
const { siteAssetTable } = await import('./site-assets');
|
|
96
95
|
// A sheet's `asset()` resolves through the table `loadApp` installs for the build — the same
|
|
97
96
|
// table, so a file the app holds compiles and one it does not is `X_ASSET_MISSING`. Installed
|
|
98
97
|
// around the one synchronous compile and handed back after: no await runs in between, so no
|
package/src/messages-upgrade.ts
CHANGED
|
@@ -46,6 +46,10 @@ export const UPGRADE_MESSAGES = {
|
|
|
46
46
|
'guard not installed, its findings could not be counted — yours to take: {fix}',
|
|
47
47
|
'cli.upgrade.coverage':
|
|
48
48
|
'coverage floor: {file} {fromLines} / {fromFuncs} -> {toLines} / {toFuncs}, measured {lines}% / {funcs}% after the Bun floor moved — review the why',
|
|
49
|
+
'cli.upgrade.coverageRaised':
|
|
50
|
+
"coverage floor raised: {file} {fromLines} / {fromFuncs} -> {toLines} / {toFuncs}, measured {lines}% / {funcs}% by this hop's unit run (X_COVERAGE_FLOOR_STALE) — it may only rise",
|
|
51
|
+
'cli.upgrade.coverageRejudged':
|
|
52
|
+
'{summary}; the coverage floor rose to what unit measured, and unit re-run: {unit}',
|
|
49
53
|
'cli.upgrade.exerciseFloor':
|
|
50
54
|
'exercise floor: {file} "exercise" {figures}, measured by this hop\'s x exercise — it may only fall',
|
|
51
55
|
'cli.upgrade.coverage.unpinned': 'no engines.bun',
|
package/src/page-navigation.ts
CHANGED
|
@@ -75,7 +75,9 @@ export async function loadNavigation(root: string): Promise<NavigationDeclaratio
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* A page declaring `navigation` on a surface with no client navigation says something no process
|
|
78
|
-
* can honour — refused at boot, before a single request, for every route in the table.
|
|
78
|
+
* can honour — refused at boot, before a single request, for every route in the table. Except
|
|
79
|
+
* `'document'`: it asks for a real document load, which is what every page of such a surface
|
|
80
|
+
* already gets, so it is honoured there as declared.
|
|
79
81
|
*/
|
|
80
82
|
export function assertRouteNavigation(
|
|
81
83
|
surfaces: readonly NavigationSurface[],
|
|
@@ -83,7 +85,8 @@ export function assertRouteNavigation(
|
|
|
83
85
|
): void {
|
|
84
86
|
for (const entry of entries) {
|
|
85
87
|
const mode = navigationModeOf(entry.config.navigation);
|
|
86
|
-
if (mode === undefined ||
|
|
88
|
+
if (mode === undefined || mode === 'document') continue;
|
|
89
|
+
if (surfaces.some((surface) => surface === entry.surface)) continue;
|
|
87
90
|
throw new RouteNavigationInvalidError(
|
|
88
91
|
`${entry.file} declares navigation: '${mode}', and its surface (${entry.surface}) is not in app.config.ts navigation.client`,
|
|
89
92
|
);
|
package/src/pwa-artifacts.ts
CHANGED
|
@@ -30,12 +30,12 @@ import {
|
|
|
30
30
|
} from '@ultimat3/pwa';
|
|
31
31
|
import type { AssetPath } from '@ultimat3/render';
|
|
32
32
|
import { assetPathProblem } from '@ultimat3/render';
|
|
33
|
+
import { parseHashedAssetUrl, siteAssetTable } from '@ultimat3/render/server';
|
|
33
34
|
import { loadAppConfig } from './app-config-load';
|
|
34
35
|
import { assetRouteMeta } from './asset-route-meta';
|
|
35
36
|
import { hasSourceIcon, iconPlan, iconRenderer } from './icon-assets';
|
|
36
37
|
import type { AppLocales } from './pwa-manifest-locales';
|
|
37
38
|
import { appLocales, localeMembers, spellIn } from './pwa-manifest-locales';
|
|
38
|
-
import { parseHashedAssetUrl, siteAssetTable } from './site-assets';
|
|
39
39
|
|
|
40
40
|
/** What a browser fetches from `<link rel="manifest">`. The spec's own extension, not `.json`. */
|
|
41
41
|
export const WEB_MANIFEST_PATH = '/manifest.webmanifest';
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
renderFixLiteral,
|
|
11
11
|
UltimateError,
|
|
12
12
|
} from '@ultimat3/core';
|
|
13
|
+
import { siteAssetTable } from '@ultimat3/render/server';
|
|
13
14
|
import type { Storage } from '@ultimat3/storage';
|
|
14
15
|
import type { IslandBundle } from './island-bundle';
|
|
15
16
|
import type { BuildAsset, PublishReport, RetainLog } from './retained-assets';
|
|
@@ -18,7 +19,6 @@ import { retainedPrefix } from './retained-assets-layout';
|
|
|
18
19
|
import type { RetainedAssets } from './retained-assets-read';
|
|
19
20
|
import { retainedAssets } from './retained-assets-read';
|
|
20
21
|
import { retainedBuildOnce } from './runtime-boot-warnings';
|
|
21
|
-
import { siteAssetTable } from './site-assets';
|
|
22
22
|
import type { StyleBundle } from './style-bundle';
|
|
23
23
|
import type { FrameworkScript } from './worker-bundle';
|
|
24
24
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { finiteCount, probeImage, sniffImageFormat } from '@ultimat3/core';
|
|
7
7
|
import type { Route, UltimateRequest } from '@ultimat3/http';
|
|
8
8
|
import { applyCacheHeaders, jsonResponse } from '@ultimat3/http';
|
|
9
|
+
import type { SiteAsset, SiteAssetTable } from '@ultimat3/render/server';
|
|
10
|
+
import { parseHashedAssetUrl } from '@ultimat3/render/server';
|
|
9
11
|
import type { ImageQuery, ImageTransformDriver } from '@ultimat3/seo';
|
|
10
12
|
import {
|
|
11
13
|
builtinImageDriver,
|
|
@@ -16,8 +18,6 @@ import {
|
|
|
16
18
|
} from '@ultimat3/seo';
|
|
17
19
|
import { variantLru } from './runtime-assets-site-cache';
|
|
18
20
|
import { SITE_ASSET_CACHE, siteAssetRoutes } from './site-asset-routes';
|
|
19
|
-
import type { SiteAsset, SiteAssetTable } from './site-assets';
|
|
20
|
-
import { parseHashedAssetUrl } from './site-assets';
|
|
21
21
|
|
|
22
22
|
/** What one process holds of decoded variants. Bounded: an edited asset in `x dev` adds entries. */
|
|
23
23
|
export const SITE_VARIANT_CACHE_BYTES = 64 * 1024 * 1024;
|
package/src/runtime-assets.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { probeImage } from '@ultimat3/core';
|
|
11
11
|
import type { ObjectSource, RequestContext, Route, UltimateRequest } from '@ultimat3/http';
|
|
12
12
|
import { applyCacheHeaders, notModified, objectResponse } from '@ultimat3/http';
|
|
13
|
+
import { siteAssetTable } from '@ultimat3/render/server';
|
|
13
14
|
import type { ImageQuery, ImageTransformDriver } from '@ultimat3/seo';
|
|
14
15
|
import { builtinImageDriver, DEFAULT_WIDTHS, parseImageQuery, usableWidths } from '@ultimat3/seo';
|
|
15
16
|
import type { ImageTransform, Storage, StorageObject, VariantFormat } from '@ultimat3/storage';
|
|
@@ -40,7 +41,6 @@ import {
|
|
|
40
41
|
readStorageObject,
|
|
41
42
|
STORAGE_READ_PERMISSION,
|
|
42
43
|
} from './runtime-storage';
|
|
43
|
-
import { siteAssetTable } from './site-assets';
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Storage-backed images. `responsiveImage({ src: '/media/<key>' })` mints its variants under it.
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
seoRenderers,
|
|
21
21
|
} from '@ultimat3/render';
|
|
22
22
|
import type { HoleSink } from '@ultimat3/render/server';
|
|
23
|
-
import { ROOT_ELEMENT_ID, renderComponent } from '@ultimat3/render/server';
|
|
23
|
+
import { ROOT_ELEMENT_ID, renderComponent, siteAssetTable } from '@ultimat3/render/server';
|
|
24
24
|
import { loadAppConfig } from './app-config-load';
|
|
25
25
|
import type { DocumentOptions } from './document-options';
|
|
26
26
|
import { routeQuery } from './isr-query-guard';
|
|
@@ -28,7 +28,6 @@ import { navigationTagsOf } from './page-navigation';
|
|
|
28
28
|
import { servedPins } from './page-pins';
|
|
29
29
|
import { bootScript, collectorFor } from './route-islands';
|
|
30
30
|
import { linkHeader, preloadTagsOf, preloadUrls } from './route-islands-preload';
|
|
31
|
-
import { siteAssetTable } from './site-assets';
|
|
32
31
|
import { styleBundle } from './style-bundle';
|
|
33
32
|
|
|
34
33
|
/**
|
package/src/site-asset-routes.ts
CHANGED
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
parseByteRange,
|
|
13
13
|
RANGE_UNSATISFIABLE,
|
|
14
14
|
} from '@ultimat3/http';
|
|
15
|
+
import type { SiteAsset, SiteAssetTable } from '@ultimat3/render/server';
|
|
16
|
+
import { parseHashedAssetUrl, SITE_ASSET_BASE_PATH } from '@ultimat3/render/server';
|
|
15
17
|
import { assetRouteMeta } from './asset-route-meta';
|
|
16
|
-
import type { SiteAsset, SiteAssetTable } from './site-assets';
|
|
17
|
-
import { parseHashedAssetUrl, SITE_ASSET_BASE_PATH } from './site-assets';
|
|
18
18
|
|
|
19
19
|
/** The URL is the content, so the answer is `public, max-age=31536000, immutable`. */
|
|
20
20
|
export const SITE_ASSET_CACHE: CacheHint = { mode: 'immutable' };
|