// `archilyzer wayback scan [--dry-run] [--max-rows N] [--full]` — a // Wayback pages channel's CDX scan into its wayback-scan.json // (controller/waybackScan.ts), in this process: no editor needed. The same // paced client the editor uses (one request at a time, 2 s apart, 429/503 // waited out) — its own instance, so with the editor running, scan through // `pnpm ops wayback-scan` instead and keep archive.org on one queue. No bodies // are fetched. Prints the run's summary; exit 1 when archive.org refused. import { isValidChannelSlug } from "../controller/channels"; import { readWaybackChannelConfig, runWaybackScan } from "../controller/waybackScan"; import { SCAN_MAX_ROWS_LIMIT } from "../lib/waybackPages/scanCdx"; import { getPaths, type Paths } from "../lib/paths"; export async function main(opts: { slug: string; dryRun: boolean; full: boolean; maxRows?: number; paths?: Paths; }): Promise { if (!isValidChannelSlug(opts.slug)) { console.error(`wayback scan: "${opts.slug}" is not a channel slug`); return 2; } if (opts.maxRows !== undefined && (!Number.isInteger(opts.maxRows) || opts.maxRows < 1 || opts.maxRows > SCAN_MAX_ROWS_LIMIT)) { console.error(`wayback scan: --max-rows must be a whole number from 1 to ${SCAN_MAX_ROWS_LIMIT}`); return 2; } const paths = opts.paths ?? getPaths(); const wayback = await readWaybackChannelConfig(paths, opts.slug); if (!wayback) { console.error(`wayback scan: ${opts.slug} is not a Wayback pages channel (its config names no wayback.targets)`); return 2; } const r = await runWaybackScan({ paths, slug: opts.slug, wayback, dryRun: opts.dryRun, full: opts.full, ...(opts.maxRows !== undefined ? { maxRows: opts.maxRows } : {}), onLog: (line) => console.log(line), }); console.log( `${r.dryRun ? "dry run: " : ""}pass ${r.pass}${r.newPass ? " (new)" : ""}: ${r.requests} requests, ${r.rowsRead} rows read, ` + `${r.added} new, ${r.totalRows} in the scan` + (r.complete ? " — every target complete" : r.stopped ? ` — stopped: ${r.stopped}` : ""), ); if (!r.ok) { console.error(`wayback scan: ${r.error}`); return 1; } return 0; }