cursedops 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/stageLook.ts +86 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedops",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.1",
|
|
4
4
|
"description": "The build-and-ops answers this generation's apps wrote independently and identically: finding a generation's roots — and printing a command that runs when pasted — without knowing a path, the generation's whole-tree laws run over one repo from a checkout or a worktree, macOS launchd agent install/replace/remove and the live port a job serves, the check that a launchd job imports only what the LOCKED versions of its packages export (a lib-preview overlay's extra subpath or name is a job that dies at the next forced reinstall), the scaffolding and verdicts of a deployed smoke (origin probe, the smoke's own environment, a network that lies about DNS, a settled version), the static-serving helpers eight apps copied — the path-traversal guard among them — the API floor that keeps an unmatched /api/... from ever being answered with the app shell, the commit and dirty flag a checkout-served process reports, the Cloudflare Worker deploy toolkit four apps copied (the deploy sequence, exact-set secrets over a pipe, origin-first rollback, the curl edge fetch, the row-for-row D1 import proof, the billed-CPU tail check around a deploy's walk and smoke, and each app's worker:secrets and worker:smoke main as one function of its data), the relay a Worker fronts a Mac-bound app with (the Durable Object, the frames, the Mac's dialer and key rotation — lifted from station for roms — and the signed-in stage walk's skeleton and the relay app's whole worker:deploy), the Worker import-graph and await-port checks every Worker app's suite runs over its own source, and the public-surface ratchet three published libraries each carried a forked copy of. Mechanism only — no app knows its name from here. Bun, zero runtime dependencies (typescript is an optional peer, for public-surface only), ships source.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
package/src/stageLook.ts
CHANGED
|
@@ -86,6 +86,70 @@ export function brokenMediaOf(r: LookResponse): string | null {
|
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* A read of the page's OWN that the stage failed — a same-origin `/api/` answer of 5xx — as
|
|
91
|
+
* `<status> <path>`. A look shot over one is a picture of an error card or a skeleton, not of the
|
|
92
|
+
* change (forge task 3914: station's `#/deploys` read 503 "station's Mac is not connected", because a
|
|
93
|
+
* relay stage has a Mac end only while its `worker:stage-walk` runs).
|
|
94
|
+
*/
|
|
95
|
+
export function failedReadOf(r: Pick<LookResponse, "url" | "status">, origin: string): string | null {
|
|
96
|
+
const url = new URL(r.url());
|
|
97
|
+
if (url.origin !== origin || !url.pathname.startsWith("/api/") || r.status() < 500) return null;
|
|
98
|
+
return `${r.status()} ${url.pathname}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** How long the network may stay busy before the look goes on without it — a player streams for good. */
|
|
102
|
+
export const IDLE_CEILING_MS = 15_000;
|
|
103
|
+
/** How long a page's pending regions (`aria-busy="true"`, cursedbelt's skeletons) may read before the look gives up. */
|
|
104
|
+
export const SETTLE_CEILING_MS = 90_000;
|
|
105
|
+
|
|
106
|
+
/** The slice of a playwright `Page` that {@link settle} drives. */
|
|
107
|
+
export interface SettlePage {
|
|
108
|
+
waitForLoadState(state: "networkidle", options: { timeout: number }): Promise<unknown>;
|
|
109
|
+
evaluate<T>(fn: () => T): Promise<T>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface Settled {
|
|
113
|
+
/** False when the network never went quiet inside {@link IDLE_CEILING_MS} — said, never fatal. */
|
|
114
|
+
idle: boolean;
|
|
115
|
+
/** The pending regions still reading at the ceiling, by their text; empty when the page settled. */
|
|
116
|
+
busy: string[];
|
|
117
|
+
ms: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Wait until the page has DRAWN, not until the network is quiet: both of the looks that went wrong
|
|
122
|
+
* waited for `networkidle` alone. music's never came (its player keeps a stream open), so the look threw;
|
|
123
|
+
* station's `#/deploys` came while its read was still in flight, so the look shot four skeleton tiles
|
|
124
|
+
* and "Reading the apps' deploys…" (forge task 3914). So: `networkidle` with a ceiling, then every
|
|
125
|
+
* `aria-busy="true"` region gone on two reads in a row, up to {@link SETTLE_CEILING_MS} — and what is
|
|
126
|
+
* still busy then is SAID, so a look of a loading state never reads as a look of the page.
|
|
127
|
+
*/
|
|
128
|
+
export async function settle(
|
|
129
|
+
page: SettlePage,
|
|
130
|
+
options: { idleMs?: number; settleMs?: number; pollMs?: number; sleep?: (ms: number) => Promise<unknown>; now?: () => number } = {},
|
|
131
|
+
): Promise<Settled> {
|
|
132
|
+
const { idleMs = IDLE_CEILING_MS, settleMs = SETTLE_CEILING_MS, pollMs = 500, sleep = Bun.sleep, now = Date.now } = options;
|
|
133
|
+
const start = now();
|
|
134
|
+
const idle = await page.waitForLoadState("networkidle", { timeout: idleMs }).then(
|
|
135
|
+
() => true,
|
|
136
|
+
() => false,
|
|
137
|
+
);
|
|
138
|
+
const pending = () =>
|
|
139
|
+
page.evaluate(() =>
|
|
140
|
+
[...document.querySelectorAll('[aria-busy="true"]')].map((el) => (el.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, 80) || el.tagName.toLowerCase()),
|
|
141
|
+
);
|
|
142
|
+
let quiet = 0;
|
|
143
|
+
let busy: string[] = [];
|
|
144
|
+
while (true) {
|
|
145
|
+
busy = await pending();
|
|
146
|
+
quiet = busy.length === 0 ? quiet + 1 : 0;
|
|
147
|
+
if (quiet >= 2) return { idle, busy: [], ms: now() - start };
|
|
148
|
+
if (now() - start >= settleMs) return { idle, busy, ms: now() - start };
|
|
149
|
+
await sleep(pollMs);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
89
153
|
/** The slices of playwright this drives. Structural, so cursedops needs no dependency on it. */
|
|
90
154
|
interface LookRoute {
|
|
91
155
|
request(): { headers(): Record<string, string> };
|
|
@@ -188,14 +252,32 @@ async function main(argv: string[]): Promise<number> {
|
|
|
188
252
|
mkdirSync(dir, { recursive: true });
|
|
189
253
|
let bad = false;
|
|
190
254
|
for (const width of [390, 1440]) {
|
|
191
|
-
type ShotPage = LookPage & { screenshot(o: { path: string; fullPage?: boolean }): Promise<unknown>; url(): string };
|
|
255
|
+
type ShotPage = LookPage & SettlePage & { screenshot(o: { path: string; fullPage?: boolean }): Promise<unknown>; url(): string };
|
|
192
256
|
const look = await openStagePage<ShotPage>({ app, width });
|
|
193
257
|
try {
|
|
194
|
-
const
|
|
258
|
+
const failed: string[] = [];
|
|
259
|
+
look.page.on("response", (r) => {
|
|
260
|
+
const f = failedReadOf(r, look.origin);
|
|
261
|
+
if (f && !failed.includes(f)) failed.push(f);
|
|
262
|
+
});
|
|
263
|
+
const res = await look.page.goto(`${look.origin}${path}`, { waitUntil: "load" });
|
|
264
|
+
const settled = await settle(look.page);
|
|
195
265
|
const shot = join(dir, `stage-${app}-${width}.png`);
|
|
196
266
|
await look.page.screenshot({ path: shot });
|
|
197
|
-
|
|
198
|
-
|
|
267
|
+
// 🔴 `null` is not a failure: the sign-in callback already landed on `/`, so a `/#/deploys` is a
|
|
268
|
+
// same-document hash change, which playwright answers with no response (forge task 3914's `?`).
|
|
269
|
+
console.log(`${width}: ${res?.status() ?? "same document"} ${look.page.url()} → ${shot} (drawn in ${(settled.ms / 1000).toFixed(1)} s)`);
|
|
270
|
+
if (res && res.status() >= 400) bad = true;
|
|
271
|
+
if (!settled.idle) console.log(` · the network never went quiet in ${IDLE_CEILING_MS / 1000} s (a stream or a poll) — the look waited on the page's own pending regions instead`);
|
|
272
|
+
if (settled.busy.length) {
|
|
273
|
+
bad = true;
|
|
274
|
+
console.error(` 🔴 still READING after ${SETTLE_CEILING_MS / 1000} s — this shot is the loading state, not the page: ${settled.busy.slice(0, 3).join(" · ")}`);
|
|
275
|
+
}
|
|
276
|
+
if (failed.length) {
|
|
277
|
+
bad = true;
|
|
278
|
+
console.error(` 🔴 the stage failed ${failed.length} of the page's own read(s) — the shot shows what it does without them: ${failed.slice(0, 5).join(", ")}`);
|
|
279
|
+
console.error(" a 503 on a relay app's stage is often its Mac end being down — that end is up only while its `worker:stage-walk` runs");
|
|
280
|
+
}
|
|
199
281
|
const broken = look.brokenMedia();
|
|
200
282
|
if (broken.length) {
|
|
201
283
|
bad = true;
|