@ultimat3/cli 31.29.0 → 31.30.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 +29 -29
- package/src/app-migrations-verdict.ts +2 -1
- package/src/cmd-db-recount.ts +38 -43
- package/src/cmd-db-spec.ts +3 -2
- package/src/cmd-db-status.ts +80 -0
- package/src/cmd-db.ts +4 -2
- package/src/db-client-displace.ts +65 -0
- package/src/db-diagnostics.ts +25 -28
- package/src/db-status.ts +185 -0
- package/src/mcp-errors.ts +3 -3
- package/src/messages-db.ts +12 -0
- package/src/runtime-queue.ts +20 -2
- package/wiki/CLI-Reference.md +2 -0
- package/wiki/Scraping.md +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/cli",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.30.0",
|
|
4
4
|
"description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -53,34 +53,34 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/core": "^8.0.9",
|
|
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.
|
|
56
|
+
"@ultimat3/action": "31.30.0",
|
|
57
|
+
"@ultimat3/admin": "31.30.0",
|
|
58
|
+
"@ultimat3/ai": "31.30.0",
|
|
59
|
+
"@ultimat3/auth": "31.30.0",
|
|
60
|
+
"@ultimat3/cache": "31.30.0",
|
|
61
|
+
"@ultimat3/core": "31.30.0",
|
|
62
|
+
"@ultimat3/db": "31.30.0",
|
|
63
|
+
"@ultimat3/entity": "31.30.0",
|
|
64
|
+
"@ultimat3/flags": "31.30.0",
|
|
65
|
+
"@ultimat3/http": "31.30.0",
|
|
66
|
+
"@ultimat3/i18n": "31.30.0",
|
|
67
|
+
"@ultimat3/jobs": "31.30.0",
|
|
68
|
+
"@ultimat3/mail": "31.30.0",
|
|
69
|
+
"@ultimat3/manifest": "31.30.0",
|
|
70
|
+
"@ultimat3/mcp": "31.30.0",
|
|
71
|
+
"@ultimat3/money": "31.30.0",
|
|
72
|
+
"@ultimat3/notify": "31.30.0",
|
|
73
|
+
"@ultimat3/policy": "31.30.0",
|
|
74
|
+
"@ultimat3/pwa": "31.30.0",
|
|
75
|
+
"@ultimat3/query": "31.30.0",
|
|
76
|
+
"@ultimat3/realtime": "31.30.0",
|
|
77
|
+
"@ultimat3/render": "31.30.0",
|
|
78
|
+
"@ultimat3/schema": "31.30.0",
|
|
79
|
+
"@ultimat3/scraping": "31.30.0",
|
|
80
|
+
"@ultimat3/seo": "31.30.0",
|
|
81
|
+
"@ultimat3/storage": "31.30.0",
|
|
82
|
+
"@ultimat3/testing": "31.30.0",
|
|
83
|
+
"@ultimat3/time": "31.30.0",
|
|
84
84
|
"babel-preset-solid": "^1.9.16"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -79,6 +79,7 @@ export function reportAppMigrationsAhead(unknown: readonly string[]): void {
|
|
|
79
79
|
logger.warn('ultimate app migrations ahead', {
|
|
80
80
|
migrations: unknown.length,
|
|
81
81
|
cause: `the database holds ${String(unknown.length)} migration(s) this build does not ship — ${named(unknown)}: a newer release migrated and this one is mid-rollout or rolled back`,
|
|
82
|
-
|
|
82
|
+
// The read that lists them beside the framework stamp, and writes nothing.
|
|
83
|
+
fix: 'x db status --json',
|
|
83
84
|
});
|
|
84
85
|
}
|
package/src/cmd-db-recount.ts
CHANGED
|
@@ -6,14 +6,11 @@
|
|
|
6
6
|
import { finiteCount } from '@ultimat3/core';
|
|
7
7
|
import type { CounterDescriptionLike, DbClient } from '@ultimat3/db';
|
|
8
8
|
import {
|
|
9
|
-
baseClient,
|
|
10
9
|
CROSS_TENANT_SETTING,
|
|
11
|
-
dbClientInstalled,
|
|
12
10
|
recountBatchSql,
|
|
13
11
|
recountDriftBatchSql,
|
|
14
12
|
recountLockSql,
|
|
15
13
|
recountWindowSql,
|
|
16
|
-
setDbClient,
|
|
17
14
|
setLocal,
|
|
18
15
|
withTransaction,
|
|
19
16
|
} from '@ultimat3/db';
|
|
@@ -21,6 +18,7 @@ import { countersOf, describeCounter, getEntity } from '@ultimat3/entity';
|
|
|
21
18
|
import { loadApp } from './app-load';
|
|
22
19
|
import { loadAppRuntime } from './app-runtime';
|
|
23
20
|
import type { CommandContext } from './command';
|
|
21
|
+
import { withOpenedDb } from './db-client-displace';
|
|
24
22
|
import { DevAlreadyRunningError, liveDevLock } from './dev-lock';
|
|
25
23
|
import { BadFlagError } from './errors';
|
|
26
24
|
import { msg } from './messages';
|
|
@@ -156,44 +154,41 @@ async function recount(ctx: CommandContext, root: string): Promise<CommandResult
|
|
|
156
154
|
});
|
|
157
155
|
}
|
|
158
156
|
}
|
|
159
|
-
// `startDb` installs its client as the process's `db()
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
await started.client.close();
|
|
197
|
-
await started.replica?.close();
|
|
198
|
-
}
|
|
157
|
+
// `startDb` installs its client as the process's `db()`; `withOpenedDb` puts back what was there
|
|
158
|
+
// (closing a lazy default it dropped) and closes both pools, as `db-diagnostics.ts` does.
|
|
159
|
+
return withOpenedDb(
|
|
160
|
+
() => startDb(services, ctx.env),
|
|
161
|
+
async (client) => {
|
|
162
|
+
const report = await recountInBatches(client, parent.$table, counter, { write });
|
|
163
|
+
const drift = report.rows;
|
|
164
|
+
return {
|
|
165
|
+
ok: findings.length === 0 && (write || report.drifted === 0),
|
|
166
|
+
command: 'db',
|
|
167
|
+
summary: msg(write ? 'cli.db.recount.repaired' : 'cli.db.recount.drift', {
|
|
168
|
+
target,
|
|
169
|
+
count: report.drifted,
|
|
170
|
+
}),
|
|
171
|
+
findings: [
|
|
172
|
+
...findings,
|
|
173
|
+
...(write || report.drifted === 0
|
|
174
|
+
? []
|
|
175
|
+
: [
|
|
176
|
+
{
|
|
177
|
+
code: 'X_LIFECYCLE_TRIGGER_MISSING',
|
|
178
|
+
cause: `${report.drifted} row(s) of ${parent.$table} hold a ${counter.column} that is not the count of ${counter.table} rows pointing at them`,
|
|
179
|
+
fix: `x db recount ${quoteArg(target)} --write --json`,
|
|
180
|
+
},
|
|
181
|
+
]),
|
|
182
|
+
],
|
|
183
|
+
lines: drift.map((row) => ` ${row.key} stored ${row.stored} actual ${row.actual}`),
|
|
184
|
+
data: {
|
|
185
|
+
target,
|
|
186
|
+
write,
|
|
187
|
+
drifted: report.drifted,
|
|
188
|
+
batches: report.batches,
|
|
189
|
+
rows: drift.map((row) => ({ ...row })),
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
);
|
|
199
194
|
}
|
package/src/cmd-db-spec.ts
CHANGED
|
@@ -13,13 +13,14 @@ export const DB_SUBCOMMANDS = [
|
|
|
13
13
|
'backfill',
|
|
14
14
|
'diagnostics',
|
|
15
15
|
'recount',
|
|
16
|
+
'status',
|
|
16
17
|
] as const;
|
|
17
18
|
|
|
18
19
|
export const dbSpec: CommandSpec = {
|
|
19
20
|
name: 'db',
|
|
20
|
-
summary: 'gen, migrate, reset, seed, branch, backfill, diagnostics, recount',
|
|
21
|
+
summary: 'gen, migrate, reset, seed, branch, backfill, diagnostics, recount, status',
|
|
21
22
|
usage:
|
|
22
|
-
'x db gen "add publish_at" [--drop-redundant] | migrate | reset | seed [<name>] [--tier reference|dev] [--dry-run] | seed --generate [--rows n] [--seed n] [--dry-run] | branch list | branch create <name> | branch delete <name> | backfill [<name>|--all] [--write] [--force] | backfill --pending | backfill --list [--name n] [--status s] [--limit n] | diagnostics [--limit n] | recount <entity>.<column> [--write]',
|
|
23
|
+
'x db gen "add publish_at" [--drop-redundant] | migrate | reset | seed [<name>] [--tier reference|dev] [--dry-run] | seed --generate [--rows n] [--seed n] [--dry-run] | branch list | branch create <name> | branch delete <name> | backfill [<name>|--all] [--write] [--force] | backfill --pending | backfill --list [--name n] [--status s] [--limit n] | diagnostics [--limit n] | recount <entity>.<column> [--write] | status',
|
|
23
24
|
requiresApp: true,
|
|
24
25
|
subcommands: DB_SUBCOMMANDS,
|
|
25
26
|
// Declared from the constant `runBranchCommand` validates against, never a second literal: it
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// `x db status`: one read of the app's database — the framework stamp and the `x_migrations`
|
|
2
|
+
// ledger — judged by `db-status.ts` against the migrations this build ships. No DDL, no ledger
|
|
3
|
+
// write, no migrate lock: `startDb`, never `startQueue` (the queue's boot applies framework
|
|
4
|
+
// tables). An embedded database never created is reported as such, never initialised to say so.
|
|
5
|
+
|
|
6
|
+
// why: Bun has no directory probe — `Bun.file().exists()` answers about a file.
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
import {
|
|
9
|
+
type DbClient,
|
|
10
|
+
isLedgerMissing,
|
|
11
|
+
pgliteDataDir,
|
|
12
|
+
ROLLBACK_ALLOW_DESTRUCTIVE_ENV,
|
|
13
|
+
readLedger,
|
|
14
|
+
} from '@ultimat3/db';
|
|
15
|
+
import type { CommandContext } from './command';
|
|
16
|
+
import { withOpenedDb } from './db-client-displace';
|
|
17
|
+
import {
|
|
18
|
+
type DbStatusRead,
|
|
19
|
+
dbStatus,
|
|
20
|
+
dbStatusFindings,
|
|
21
|
+
dbStatusJson,
|
|
22
|
+
dbStatusLines,
|
|
23
|
+
} from './db-status';
|
|
24
|
+
import { DevAlreadyRunningError, liveDevLock } from './dev-lock';
|
|
25
|
+
import { readStamp, thisBuild } from './framework-schema-apply';
|
|
26
|
+
import { msg } from './messages';
|
|
27
|
+
import { readMigrations } from './migrations';
|
|
28
|
+
import type { CommandResult } from './output';
|
|
29
|
+
import { resolveServices } from './runtime-bindings';
|
|
30
|
+
import { startDb } from './runtime-queue';
|
|
31
|
+
|
|
32
|
+
/** The stamp, then the ledger; a missing ledger (`42P01`) is a fact, every other failure throws. */
|
|
33
|
+
export async function readDbStatus(client: DbClient): Promise<DbStatusRead> {
|
|
34
|
+
const stamp = await readStamp(client);
|
|
35
|
+
try {
|
|
36
|
+
return { stamp, ledger: await readLedger(client) };
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (!isLedgerMissing(error)) throw error;
|
|
39
|
+
return { stamp, ledger: undefined };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Opens the database the way every role does, reads once, and puts the process's `db()` back. */
|
|
44
|
+
async function readFromApp(ctx: CommandContext, root: string): Promise<DbStatusRead> {
|
|
45
|
+
const services = resolveServices(root, ctx.env);
|
|
46
|
+
if (services.db.mode === 'embedded') {
|
|
47
|
+
if (!existsSync(pgliteDataDir(services.db.url))) return { stamp: null, ledger: undefined };
|
|
48
|
+
// PGlite's data directory has one writer: an `x dev` holding it is refused, as diagnostics is.
|
|
49
|
+
const holder = liveDevLock(services.stateDir);
|
|
50
|
+
if (holder !== undefined) {
|
|
51
|
+
throw new DevAlreadyRunningError({
|
|
52
|
+
lock: holder,
|
|
53
|
+
stateDir: services.stateDir,
|
|
54
|
+
embeddedDb: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return withOpenedDb(() => startDb(services, ctx.env), readDbStatus);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function runDbStatus(ctx: CommandContext, root: string): Promise<CommandResult> {
|
|
62
|
+
const migrations = await readMigrations(root);
|
|
63
|
+
const read = await readFromApp(ctx, root);
|
|
64
|
+
const status = dbStatus(read, migrations, thisBuild());
|
|
65
|
+
const findings = dbStatusFindings(status, migrations, read.ledger, {
|
|
66
|
+
allow: ctx.env[ROLLBACK_ALLOW_DESTRUCTIVE_ENV],
|
|
67
|
+
appVersion: ctx.env['APP_VERSION'],
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
ok: findings.length === 0,
|
|
71
|
+
command: 'db',
|
|
72
|
+
summary:
|
|
73
|
+
findings.length === 0
|
|
74
|
+
? msg('cli.db.status.current')
|
|
75
|
+
: msg('cli.db.status.behind', { count: findings.length }),
|
|
76
|
+
findings,
|
|
77
|
+
lines: dbStatusLines(status),
|
|
78
|
+
data: dbStatusJson(status),
|
|
79
|
+
};
|
|
80
|
+
}
|
package/src/cmd-db.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// `x db gen|migrate|reset|seed|studio|branch|backfill|diagnostics|recount` — everything that touches the
|
|
1
|
+
// `x db gen|migrate|reset|seed|studio|branch|backfill|diagnostics|recount|status` — everything that touches the
|
|
2
2
|
// database. One subcommand per line and no fall-through: a word this file does not know is refused,
|
|
3
3
|
// never re-read as an argument to the last branch. `branch` is `cmd-db-branch.ts`, `diagnostics`
|
|
4
|
-
// is `db-diagnostics.ts`.
|
|
4
|
+
// is `db-diagnostics.ts`, `status` is `cmd-db-status.ts`.
|
|
5
5
|
//
|
|
6
6
|
// Every subcommand here runs `@ultimat3/db`'s own engine, which is the engine `ROLE=migrate` runs
|
|
7
7
|
// (`serve.ts`): one `x_migrations` ledger, one checksum rule, one advisory lock, from a laptop to
|
|
@@ -20,6 +20,7 @@ import { runBackfillCommand } from './cmd-db-backfill';
|
|
|
20
20
|
import { runBranchCommand } from './cmd-db-branch';
|
|
21
21
|
import { runRecountCommand } from './cmd-db-recount';
|
|
22
22
|
import { DB_SUBCOMMANDS, dbSpec } from './cmd-db-spec';
|
|
23
|
+
import { runDbStatus } from './cmd-db-status';
|
|
23
24
|
import type { CliCommand, CommandContext } from './command';
|
|
24
25
|
import { runDiagnostics } from './db-diagnostics';
|
|
25
26
|
import { stepFinding } from './db-finding';
|
|
@@ -71,6 +72,7 @@ export const dbCommand: CliCommand = {
|
|
|
71
72
|
if (sub === 'branch') return runBranchCommand(ctx, root);
|
|
72
73
|
if (sub === 'diagnostics') return runDiagnostics(ctx, root);
|
|
73
74
|
if (sub === 'recount') return runRecountCommand(ctx, root);
|
|
75
|
+
if (sub === 'status') return runDbStatus(ctx, root);
|
|
74
76
|
|
|
75
77
|
// Never a fall-through. This used to end `return runBranch(ctx, root, argument ?? 'preview')`,
|
|
76
78
|
// so ANY subcommand the parser had not already refused was reinterpreted as a branch NAME and
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// A CLI command that opens the app's database for one run (`startDb`) and owes the process its
|
|
2
|
+
// `db()` back: an installed client as it was, a lazily built default it dropped closed — never
|
|
3
|
+
// orphaned — and both of its own pools closed whatever the run did.
|
|
4
|
+
|
|
5
|
+
import { logger, renderThrowable } from '@ultimat3/core';
|
|
6
|
+
import { ambientClient, type DbClient, dbClientInstalled, setDbClient } from '@ultimat3/db';
|
|
7
|
+
|
|
8
|
+
const closable = (client: DbClient): client is DbClient & { close(): Promise<void> } =>
|
|
9
|
+
'close' in client && typeof client.close === 'function';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Read BEFORE the command installs anything; call what it returns once it is done. `db()` is put
|
|
13
|
+
* back synchronously on the call, so a caller may settle the returned close beside its own.
|
|
14
|
+
*/
|
|
15
|
+
export function displaceAmbient(): () => Promise<void> {
|
|
16
|
+
const installed = dbClientInstalled();
|
|
17
|
+
const previous = ambientClient();
|
|
18
|
+
return async () => {
|
|
19
|
+
if (installed) {
|
|
20
|
+
setDbClient(previous);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
setDbClient(undefined);
|
|
24
|
+
if (previous !== undefined && closable(previous)) await previous.close();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Closable {
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Open, run, then put `db()` back and close every pool whatever happened. The open is inside the
|
|
34
|
+
* guarded scope (`startDb` installs before it returns); one rejected close never skips another.
|
|
35
|
+
* The run's own failure is what is thrown, a close failure beside it is logged; after a good run a
|
|
36
|
+
* close failure is thrown.
|
|
37
|
+
*/
|
|
38
|
+
export async function withOpenedDb<T>(
|
|
39
|
+
open: () => { readonly client: DbClient & Closable; readonly replica?: Closable | undefined },
|
|
40
|
+
run: (client: DbClient) => Promise<T>,
|
|
41
|
+
): Promise<T> {
|
|
42
|
+
const restore = displaceAmbient();
|
|
43
|
+
let opened: ReturnType<typeof open> | undefined;
|
|
44
|
+
let outcome: { readonly value: T } | { readonly error: unknown };
|
|
45
|
+
try {
|
|
46
|
+
opened = open();
|
|
47
|
+
outcome = { value: await run(opened.client) };
|
|
48
|
+
} catch (error) {
|
|
49
|
+
outcome = { error };
|
|
50
|
+
}
|
|
51
|
+
const closed = await Promise.allSettled([
|
|
52
|
+
restore(),
|
|
53
|
+
opened?.client.close(),
|
|
54
|
+
opened?.replica?.close(),
|
|
55
|
+
]);
|
|
56
|
+
const rejected = closed.flatMap((one) => (one.status === 'rejected' ? [one.reason] : []));
|
|
57
|
+
if ('error' in outcome) {
|
|
58
|
+
for (const reason of rejected) {
|
|
59
|
+
logger.warn('x db could not close its database', { cause: renderThrowable(reason) });
|
|
60
|
+
}
|
|
61
|
+
throw outcome.error;
|
|
62
|
+
}
|
|
63
|
+
if (rejected.length > 0) throw rejected[0];
|
|
64
|
+
return outcome.value;
|
|
65
|
+
}
|
package/src/db-diagnostics.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// `dbDiagnostics()` and renders one table per answered section. Facts, never a verdict: exit 0
|
|
3
3
|
// whatever they say, and the one failure is a connection that never opens (`X_DB_UNAVAILABLE`).
|
|
4
4
|
|
|
5
|
-
import { baseClient, dbClientInstalled, setDbClient } from '@ultimat3/db';
|
|
6
5
|
import {
|
|
7
6
|
type DbDiagnostics,
|
|
8
7
|
type DiagnosticSection,
|
|
9
8
|
dbDiagnostics,
|
|
10
9
|
} from '@ultimat3/db/diagnostics';
|
|
11
10
|
import type { CommandContext } from './command';
|
|
11
|
+
import { withOpenedDb } from './db-client-displace';
|
|
12
12
|
import { DevAlreadyRunningError, liveDevLock } from './dev-lock';
|
|
13
13
|
import { readIntFlag } from './flag-number';
|
|
14
14
|
import { msg } from './messages';
|
|
@@ -89,31 +89,28 @@ export async function runDiagnostics(ctx: CommandContext, root: string): Promise
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
// `startDb` installs its client as the process's `db()
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await started.client.close();
|
|
117
|
-
await started.replica?.close();
|
|
118
|
-
}
|
|
92
|
+
// `startDb` installs its client as the process's `db()`; `withOpenedDb` puts back what was there
|
|
93
|
+
// (closing a lazy default it dropped) and closes both pools, or every later `db()` in an
|
|
94
|
+
// embedding process reaches a dead pool.
|
|
95
|
+
return withOpenedDb(
|
|
96
|
+
() => startDb(services, ctx.env),
|
|
97
|
+
async (client) => {
|
|
98
|
+
// Embedded, the probe IS the boot — a WASM compile and an initdb, 12.6 s cold under coverage —
|
|
99
|
+
// so the 3 s probe wait answered a healthy database X_DB_UNAVAILABLE. A server keeps the default.
|
|
100
|
+
const deadlineMs =
|
|
101
|
+
services.db.mode === 'embedded' ? EMBEDDED_DIAGNOSTICS_DEADLINE_MS : undefined;
|
|
102
|
+
const report = await dbDiagnostics({ client, limit, deadlineMs });
|
|
103
|
+
const sections = Object.values(report);
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
command: 'db',
|
|
107
|
+
summary: msg('cli.db.diagnostics.done', {
|
|
108
|
+
available: sections.filter((section) => section.available).length,
|
|
109
|
+
total: sections.length,
|
|
110
|
+
}),
|
|
111
|
+
lines: renderDiagnostics(report),
|
|
112
|
+
data: diagnosticsJson(report),
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
);
|
|
119
116
|
}
|
package/src/db-status.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// `x db status`'s verdict, pure: the app migrations this build ships against the `x_migrations`
|
|
2
|
+
// ledger (`appMigrationsVerdict`, the boot's own rule), an applied migration edited since, and the
|
|
3
|
+
// framework stamp (`stampVerdict`). A finding only where a serving role would wait or `x db migrate`
|
|
4
|
+
// would refuse; the read is `cmd-db-status.ts`'s.
|
|
5
|
+
|
|
6
|
+
import type { LedgerRow, Migration } from '@ultimat3/db';
|
|
7
|
+
import {
|
|
8
|
+
auditLedger,
|
|
9
|
+
ledgerAheadOfBuild,
|
|
10
|
+
migrationChecksum,
|
|
11
|
+
runningAppVersion,
|
|
12
|
+
} from '@ultimat3/db';
|
|
13
|
+
import { AppMigrationsUnappliedError, appMigrationsVerdict } from './app-migrations-verdict';
|
|
14
|
+
import {
|
|
15
|
+
aheadByMajor,
|
|
16
|
+
FrameworkSchemaUnappliedError,
|
|
17
|
+
parseStamp,
|
|
18
|
+
type StampEntry,
|
|
19
|
+
stampVerdict,
|
|
20
|
+
} from './framework-schema-stamp';
|
|
21
|
+
import { msg } from './messages';
|
|
22
|
+
import type { Finding, JsonValue } from './output';
|
|
23
|
+
import { findingFrom } from './output';
|
|
24
|
+
|
|
25
|
+
/** The one read: the stamp comment and the ledger rows, `undefined` when `x_migrations` is absent. */
|
|
26
|
+
export interface DbStatusRead {
|
|
27
|
+
readonly stamp: string | null;
|
|
28
|
+
readonly ledger: readonly LedgerRow[] | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FrameworkStatus {
|
|
32
|
+
readonly version: string;
|
|
33
|
+
readonly schema: string;
|
|
34
|
+
readonly applied: boolean;
|
|
35
|
+
/** The newest build the stamp records, when this one is not in it. */
|
|
36
|
+
readonly newest?: StampEntry;
|
|
37
|
+
/** The newest build, when this one is applied and the newest is another major. */
|
|
38
|
+
readonly skew?: StampEntry;
|
|
39
|
+
readonly aheadByMajor: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface DbStatus {
|
|
43
|
+
readonly shipped: readonly string[];
|
|
44
|
+
/** `null` when the ledger table does not exist: no migrate step has run here. */
|
|
45
|
+
readonly applied: readonly string[] | null;
|
|
46
|
+
readonly pending: readonly string[];
|
|
47
|
+
readonly ahead: readonly string[];
|
|
48
|
+
/** Applied, and its file now hashes otherwise. */
|
|
49
|
+
readonly edited: readonly string[];
|
|
50
|
+
readonly framework: FrameworkStatus;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function dbStatus(
|
|
54
|
+
read: DbStatusRead,
|
|
55
|
+
migrations: readonly Migration[],
|
|
56
|
+
mine: StampEntry,
|
|
57
|
+
): DbStatus {
|
|
58
|
+
const shipped = migrations.map((migration) => migration.id);
|
|
59
|
+
const applied = read.ledger?.map((row) => row.id);
|
|
60
|
+
const verdict = appMigrationsVerdict(shipped, applied);
|
|
61
|
+
const files = new Map(migrations.map((migration) => [migration.id, migration]));
|
|
62
|
+
const edited = (read.ledger ?? []).flatMap((row) => {
|
|
63
|
+
const file = files.get(row.id);
|
|
64
|
+
return file !== undefined && migrationChecksum(file) !== row.checksum ? [row.id] : [];
|
|
65
|
+
});
|
|
66
|
+
const stamp = stampVerdict(parseStamp(read.stamp), mine);
|
|
67
|
+
const framework: FrameworkStatus = stamp.applied
|
|
68
|
+
? {
|
|
69
|
+
...mine,
|
|
70
|
+
applied: true,
|
|
71
|
+
...(stamp.skew === undefined ? {} : { skew: stamp.skew }),
|
|
72
|
+
aheadByMajor: false,
|
|
73
|
+
}
|
|
74
|
+
: {
|
|
75
|
+
...mine,
|
|
76
|
+
applied: false,
|
|
77
|
+
...(stamp.newest === undefined ? {} : { newest: stamp.newest }),
|
|
78
|
+
aheadByMajor: aheadByMajor(stamp.newest, mine),
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
shipped,
|
|
82
|
+
applied: applied ?? null,
|
|
83
|
+
pending: verdict.missing,
|
|
84
|
+
ahead: verdict.unknown,
|
|
85
|
+
edited,
|
|
86
|
+
framework,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The boot's refusals and the migrator's, as findings — each the error the real path throws, so the
|
|
92
|
+
* code and fix are theirs. Ahead is not one: a serving role serves it with a warning (a rollback).
|
|
93
|
+
*/
|
|
94
|
+
export function dbStatusFindings(
|
|
95
|
+
status: DbStatus,
|
|
96
|
+
migrations: readonly Migration[],
|
|
97
|
+
ledger: DbStatusRead['ledger'],
|
|
98
|
+
options: {
|
|
99
|
+
/** `ROLLBACK_ALLOW_DESTRUCTIVE` as the migrate role would read it. */
|
|
100
|
+
readonly allow?: string | undefined;
|
|
101
|
+
/** `APP_VERSION` from the command's env, as `runMigrations` hands it to `migrate()`. */
|
|
102
|
+
readonly appVersion?: string | undefined;
|
|
103
|
+
} = {},
|
|
104
|
+
): Finding[] {
|
|
105
|
+
const findings: Finding[] = [];
|
|
106
|
+
const { framework } = status;
|
|
107
|
+
if (!framework.applied) {
|
|
108
|
+
const mine = { version: framework.version, schema: framework.schema };
|
|
109
|
+
findings.push(
|
|
110
|
+
findingFrom(new FrameworkSchemaUnappliedError({ mine, newest: framework.newest })),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (status.pending.length > 0) {
|
|
114
|
+
findings.push(
|
|
115
|
+
findingFrom(
|
|
116
|
+
new AppMigrationsUnappliedError({
|
|
117
|
+
missing: status.pending,
|
|
118
|
+
ledger: status.applied !== null,
|
|
119
|
+
}),
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
if (ledger !== undefined) {
|
|
124
|
+
// `x db migrate`'s own two steps, in its order (migrate.ts): a ledger that is exactly a
|
|
125
|
+
// rollback is accepted and audited over its known rows; anything else ahead, and any applied
|
|
126
|
+
// migration edited since, is the conflict it refuses with — never a second spelling of either.
|
|
127
|
+
try {
|
|
128
|
+
const rolledBack = ledgerAheadOfBuild(ledger, migrations, { allow: options.allow });
|
|
129
|
+
// `migrate()`'s own reader of the build's name, so both commands' causes name the same one.
|
|
130
|
+
auditLedger(rolledBack?.known ?? ledger, migrations, runningAppVersion(options.appVersion));
|
|
131
|
+
} catch (error) {
|
|
132
|
+
findings.push(findingFrom(error));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return findings;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const idsOrNone = (ids: readonly string[]): string =>
|
|
139
|
+
ids.length === 0 ? msg('cli.db.status.none') : ids.join(', ');
|
|
140
|
+
|
|
141
|
+
export function dbStatusLines(status: DbStatus): readonly string[] {
|
|
142
|
+
const { framework } = status;
|
|
143
|
+
const newest = framework.newest ?? framework.skew;
|
|
144
|
+
return [
|
|
145
|
+
msg('cli.db.status.framework', {
|
|
146
|
+
verdict: msg(framework.applied ? 'cli.db.status.applied' : 'cli.db.status.unapplied'),
|
|
147
|
+
version: framework.version,
|
|
148
|
+
schema: framework.schema,
|
|
149
|
+
}),
|
|
150
|
+
...(newest === undefined
|
|
151
|
+
? []
|
|
152
|
+
: [msg('cli.db.status.newest', { version: newest.version, schema: newest.schema })]),
|
|
153
|
+
msg('cli.db.status.migrations', {
|
|
154
|
+
shipped: status.shipped.length,
|
|
155
|
+
applied:
|
|
156
|
+
status.applied === null ? msg('cli.db.status.noLedger') : String(status.applied.length),
|
|
157
|
+
}),
|
|
158
|
+
msg('cli.db.status.pending', { ids: idsOrNone(status.pending) }),
|
|
159
|
+
msg('cli.db.status.ahead', { ids: idsOrNone(status.ahead) }),
|
|
160
|
+
...(status.edited.length === 0
|
|
161
|
+
? []
|
|
162
|
+
: [msg('cli.db.status.edited', { ids: status.edited.join(', ') })]),
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The `--json` body: the same facts the lines print. */
|
|
167
|
+
export function dbStatusJson(status: DbStatus): { readonly [key: string]: JsonValue } {
|
|
168
|
+
const entry = (one: StampEntry | undefined): JsonValue =>
|
|
169
|
+
one === undefined ? null : { version: one.version, schema: one.schema };
|
|
170
|
+
return {
|
|
171
|
+
shipped: [...status.shipped],
|
|
172
|
+
applied: status.applied === null ? null : [...status.applied],
|
|
173
|
+
pending: [...status.pending],
|
|
174
|
+
ahead: [...status.ahead],
|
|
175
|
+
edited: [...status.edited],
|
|
176
|
+
framework: {
|
|
177
|
+
version: status.framework.version,
|
|
178
|
+
schema: status.framework.schema,
|
|
179
|
+
applied: status.framework.applied,
|
|
180
|
+
newest: entry(status.framework.newest),
|
|
181
|
+
skew: entry(status.framework.skew),
|
|
182
|
+
aheadByMajor: status.framework.aheadByMajor,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
package/src/mcp-errors.ts
CHANGED
|
@@ -143,9 +143,9 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
|
|
|
143
143
|
// The path, not `x dev`: the boot has already refused and rerunning it refuses again. The
|
|
144
144
|
// error's own `fix:` carries the resolved `.x/dev.lock`; this table cannot know the state dir.
|
|
145
145
|
X_DEV_LOCK_UNREADABLE: 'rm .x/dev.lock # then: x dev --json',
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
//
|
|
146
|
+
// `x doctor`, not `x db status`: generation failing is a reachability question, and `x db status`
|
|
147
|
+
// reads the migration ledger only. `x doctor` is already this table's answer for
|
|
148
|
+
// X_DB_STUDIO_FAILED.
|
|
149
149
|
X_DB_GEN_FAILED: 'x doctor --json # cause carries the Postgres error verbatim',
|
|
150
150
|
// Both directions resolve through the same command, and the CAUSE is what differs: one names a
|
|
151
151
|
// declaration the migrations never carried, the other one they carry and nothing declares. The
|
package/src/messages-db.ts
CHANGED
|
@@ -53,4 +53,16 @@ export const DB_MESSAGES = {
|
|
|
53
53
|
'cli.db.seed.dryRun': '{count} seed(s) would run — nothing written while --dry-run is set',
|
|
54
54
|
'cli.db.seed.failed': '{failed} of {count} seed(s) failed',
|
|
55
55
|
'cli.db.seed.none': 'no seed matched — nothing to run',
|
|
56
|
+
'cli.db.status.current': 'this database is at this build: every shipped migration applied',
|
|
57
|
+
'cli.db.status.behind': '{count} finding(s): this database is not at this build',
|
|
58
|
+
'cli.db.status.framework': 'framework {verdict} — this build {version} ({schema})',
|
|
59
|
+
'cli.db.status.applied': 'applied',
|
|
60
|
+
'cli.db.status.unapplied': 'NOT applied',
|
|
61
|
+
'cli.db.status.newest': 'newest {version} ({schema}) in the stamp',
|
|
62
|
+
'cli.db.status.migrations': 'migrations {shipped} shipped, {applied} applied',
|
|
63
|
+
'cli.db.status.noLedger': 'none (no x_migrations ledger)',
|
|
64
|
+
'cli.db.status.pending': 'pending {ids}',
|
|
65
|
+
'cli.db.status.ahead': 'ahead {ids}',
|
|
66
|
+
'cli.db.status.edited': 'edited {ids} (applied, the file hashes otherwise)',
|
|
67
|
+
'cli.db.status.none': '-',
|
|
56
68
|
} as const;
|
package/src/runtime-queue.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
postgresMeterStore,
|
|
11
11
|
requestDeadlineMs,
|
|
12
12
|
} from '@ultimat3/action';
|
|
13
|
+
import { logger, renderThrowable } from '@ultimat3/core';
|
|
13
14
|
import type { PgliteClient, PostgresClient } from '@ultimat3/db';
|
|
14
15
|
import {
|
|
15
16
|
baseClient,
|
|
@@ -92,7 +93,12 @@ export interface RunningQueue {
|
|
|
92
93
|
* neither reports anything. A default here is what let the caller forget; the type is what stops
|
|
93
94
|
* the next one. Exported for the test that proves which environment decides.
|
|
94
95
|
*/
|
|
95
|
-
export function startDb(
|
|
96
|
+
export function startDb(
|
|
97
|
+
services: DevServices,
|
|
98
|
+
env: ReplicaEnv,
|
|
99
|
+
// A seam for the one failure after the primary exists: the standby refused at construction.
|
|
100
|
+
attach: typeof attachReplica = attachReplica,
|
|
101
|
+
): StartedDb {
|
|
96
102
|
const binding = services.db;
|
|
97
103
|
// `DATABASE_POOL_MAX` from the env the boot was HANDED, for `env`'s reason below. Installing a
|
|
98
104
|
// client here means `defaultClient()` — the only other reader — never runs in a served role, so
|
|
@@ -112,7 +118,19 @@ export function startDb(services: DevServices, env: ReplicaEnv): StartedDb {
|
|
|
112
118
|
extensions: () => appExtensions(services.root),
|
|
113
119
|
})
|
|
114
120
|
: postgresClient({ url: binding.url, profile, env });
|
|
115
|
-
|
|
121
|
+
let attached: ReturnType<typeof attachReplica>;
|
|
122
|
+
try {
|
|
123
|
+
attached = attach(client, replicaUrlFor(binding, env), profile);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
// The primary is built and nothing will hold it: close it here, and say so if that fails too,
|
|
126
|
+
// without letting the close's answer replace the error the caller is handed.
|
|
127
|
+
client.close().catch((closeError: unknown) => {
|
|
128
|
+
logger.warn('ultimate db could not close the primary after the replica failed', {
|
|
129
|
+
cause: renderThrowable(closeError),
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
116
134
|
setDbClient(attached.client);
|
|
117
135
|
return { client, replica: attached.replica };
|
|
118
136
|
}
|
package/wiki/CLI-Reference.md
CHANGED
|
@@ -485,6 +485,7 @@ x db gen "add publish_at" | migrate | reset
|
|
|
485
485
|
| backfill --pending [--json]
|
|
486
486
|
| backfill <name>|--all [--write] [--force] [--json]
|
|
487
487
|
| diagnostics [--limit n] [--json]
|
|
488
|
+
| status [--json]
|
|
488
489
|
```
|
|
489
490
|
|
|
490
491
|
| Subcommand | Does | Notes |
|
|
@@ -501,6 +502,7 @@ x db gen "add publish_at" | migrate | reset
|
|
|
501
502
|
| `backfill <name>` / `backfill --all` | gate one sweep (or every pending one) and enqueue it | **dry run by default** — `--write` is never implied. `--write` enqueues; the workers perform the pass, because the queue is a job's execution surface. `--all` isolates per name and continues past a failure, exiting non-zero naming each |
|
|
502
503
|
| `diagnostics` | what the database is doing now: `blockers` (each waiting `pid` and the `blockedBy` pid holding it, at `data.blockers.rows[]`), `activity`, `slowQueries`, `unusedIndexes`, `invalidIndexes`, `notValidConstraints`, `deadTuples` | **facts, never a verdict: exit 0** whatever they say. The one failure is a connection that never opens, `X_DB_UNAVAILABLE`. Every section is one catalog read in its own `BEGIN READ ONLY` with a 2 s `statement_timeout`, capped at `--limit` rows (default 20, at most 1000). A section that fails is `{ available: false, code, reason, fix }` in place and the other six still answer; `slowQueries` is unavailable until an operator installs `pg_stat_statements` (never on the embedded database). No user table is read; session SQL is printed with every literal as `?`; a credential in a reason is masked. **Whoever runs it sees the redacted SQL of every session on the app's database role** (every role, when it holds `pg_read_all_stats`): statement shape and identifiers, never values. `unusedIndexes` skips unique and primary indexes and carries `statsAgeSeconds` and `replica`. Opens the database without applying the framework tables; an embedded one `x dev` holds is refused (`X_DEV_ALREADY_RUNNING`). `--json`: `data.<section>`. Arbitrary read-only SQL is `db.query` over [`x mcp serve`](MCP-And-AI) |
|
|
503
504
|
| `recount <entity>.<column>` | compare a `countedIn` counter with the true count of its child rows | **dry run by default**: lists the drifted rows (at most 50, the count whole) and exits non-zero with `X_LIFECYCLE_TRIGGER_MISSING` when any drifted. The parent is walked in windows of 1,000 keys, in key order, each window one cross-tenant transaction (`As of 31.23`). `--write` repairs each window's drift inside its transaction and exits 0. An unknown `<entity>.<column>` is `X_CLI_BAD_FLAG`. `--json`: `data` = `{ target, write, drifted, batches, rows }` |
|
|
505
|
+
| `status` | is this database at this build? The app migrations this build ships against the `x_migrations` ledger (`pending`: shipped, not applied; `ahead`: applied, not shipped; `edited`: applied, the file now hashes otherwise), and the framework stamp (`framework.applied`, the newest build it records, a major skew) | **one read, no writes**, `As of 2026-11-15`: the stamp comment and the ledger rows, judged by the rules a serving role's boot applies (`appMigrationsVerdict`, `stampVerdict`). No DDL, no ledger created, no migrate lock; an embedded database never created is reported as nothing applied without being initialised, one `x dev` holds is refused (`X_DEV_ALREADY_RUNNING`). **Non-zero exit** with the boot's own findings when behind — `X_FRAMEWORK_SCHEMA_UNAPPLIED`, `X_APP_MIGRATIONS_UNAPPLIED` (fix `x db migrate`) — and the ledger judged as `x db migrate` judges it (`ledgerAheadOfBuild`, then `auditLedger`): an edited migration, or an `ahead` row that is not exactly a rollback — one sorting before the newest migration this build ships, or beside a pending one — is `X_MIGRATION_CONFLICT`; a rollback over a row recorded destructive is `X_MIGRATION_ROLLBACK_DESTRUCTIVE` unless `ROLLBACK_ALLOW_DESTRUCTIVE` names it. An `ahead` that is exactly a rollback exits 0: `x db migrate` accepts it and a serving role serves it with a warning (a rollback, or a rollout's old pods). `--json`: `data` = `{ shipped, applied, pending, ahead, edited, framework: { version, schema, applied, newest, skew, aheadByMajor } }`, `applied` `null` when no ledger exists |
|
|
504
506
|
|
|
505
507
|
A bare `x db backfill` is `X_CLI_BAD_FLAG` naming a shape that works: the four answer four different questions, and defaulting to one of them is the ambiguity axiom 1 refuses.
|
|
506
508
|
|
package/wiki/Scraping.md
CHANGED
|
@@ -549,6 +549,26 @@ A test passes `renderer:` (any `PdfRenderer`); `chromePdfRenderer({ launch })` t
|
|
|
549
549
|
|
|
550
550
|
**The CDP launcher moved.** `findChrome`, `launchChrome`, `launchFoundChrome`, `cdpConnect`, `cdpConnectOver`, the `Cdp*Error` classes and the `CHROME_*` / `LAUNCH_*` constants live in `@ultimat3/scraping/cdp` since 31.0.0 (its own entry, importing core only), and `X_CDP_*` are registered by scraping. It is their one import path: `@ultimat3/testing` no longer re-exports them, and `E2E_BROWSER_CLOSE_MS` is `LAUNCHED_CLOSE_MS` here ([Upgrading](Upgrading) #53).
|
|
551
551
|
|
|
552
|
+
**A test launches through `launchReady`** (`As of 2026-11-15`), from the same entry: `launchChrome`, then ready once the page it was handed EXISTS — heard as `Target.targetCreated`, never polled for, so a cold start (a Windows runner) is waited for rather than read early. The test takes `launchTestMs(launchTimeoutMs)` as its deadline — `LAUNCH_TEST_MS` at the default — so the launch's own `X_CDP_LAUNCH_FAILED` is what a slow browser reports, never Bun's timeout:
|
|
553
|
+
|
|
554
|
+
```ts
|
|
555
|
+
import { test } from 'bun:test';
|
|
556
|
+
import { findChrome, LAUNCH_TEST_MS, launchReady } from '@ultimat3/scraping/cdp';
|
|
557
|
+
|
|
558
|
+
const executable = await findChrome(process.env);
|
|
559
|
+
|
|
560
|
+
test.skipIf(executable === undefined)('the page the browser was handed', async () => {
|
|
561
|
+
const browser = await launchReady({ executable: executable ?? '', timeoutMs: 20_000 });
|
|
562
|
+
try {
|
|
563
|
+
await browser.connection.send('Target.getTargets');
|
|
564
|
+
} finally {
|
|
565
|
+
await browser.close();
|
|
566
|
+
}
|
|
567
|
+
}, LAUNCH_TEST_MS);
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
`bun run scripts/launch-deadline.ts` refuses a test that awaits a launch under a deadline of its own (`X_TEST_LAUNCH_DEADLINE`).
|
|
571
|
+
|
|
552
572
|
A social card for a row published at runtime is the same shape: `page.screenshot()` of the row's
|
|
553
573
|
1200 x 630 card page, `disk().put()`, then `og: { image }` — [SEO](SEO#a-card-the-build-photographs-ogcapture)
|
|
554
574
|
covers the cards a static build takes itself. `examples/dummy`'s `runs/jobs/print-statement.ts` is
|