atprotoTrial
uses node:path
tcm's AT Protocol flows against Bluesky's own software, locally and offline, before a release: dev-env's PDS (its
OAuth server and consent pages) and PLC directory, with a stand-in for Jetstream and a relay fed by the PDS's own
firehose (tcmts.dev.devenv.run says what it checks). pnpm tcm run tcmts.dev.atprotoTrial [tcm.js] [dir]: the
tcm given (default the known-good one), in dir (default a directory in the system's temp, kept, so dev-env is
installed there once; not as tcm's dependency). Needs Chrome.
import { codebaseDir, repository, shAsync } from "#codebase/tcmts/dev"; import { bridge, net, page, run, "scope-probe" as scope_probe, visitor, yes } from "#codebase/tcmts/dev/devenv"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; export async function atprotoTrial(tcm?: string, dir?: string): Promise<void> { const bin = path.resolve( tcm ?? path.join(repository(), "dist", "known-good", "node_modules", "tcm-ts", "bin", "tcm.js"), ); if (!fs.existsSync(bin)) throw new Error(`no tcm at ${bin}: give one, or \`pnpm verify\` makes the known-good one`); const at = path.resolve(dir ?? path.join(os.tmpdir(), "tcm-atproto-trial")); fs.mkdirSync(at, { recursive: true }); const files: Record<string, string> = { "net.mjs": net, "bridge.mjs": bridge, "yes.mjs": yes, "page.mjs": page, "visitor.mjs": visitor, "scope-probe.mjs": scope_probe, "run.sh": run, }; for (const [name, text] of Object.entries(files)) fs.writeFileSync(path.join(at, name), text); console.log(`running tcm's AT Protocol flows with ${bin}, in ${at}`); // (publishing lexicons runs from tcm's codebase, on the branch this runs on) const env = { ...process.env, TCM_TRIAL_CODEBASE: codebaseDir(), TCM_TRIAL_BRANCH: process.env.TCM_BRANCH ?? "", }; const r = await shAsync("bash", [path.join(at, "run.sh"), bin], at, env, (line) => console.log(line), ); if (!r.ok) throw new Error( `the trial failed (what each service said is in ${at}/*.log):\n${r.out.split("\n").slice(-20).join("\n")}`, ); }