#!/usr/bin/env node import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { crawlWiki } from './lib/live-wiki.mjs'; const CAPTURE_DATE = '2026-08-02'; const SCRIPT_PATH = fileURLToPath(import.meta.url); const PROJECT_ROOT = path.resolve(path.dirname(SCRIPT_PATH), '..'); export async function runCapture({ crawlImpl = crawlWiki, logError = console.error, logInfo = console.log, } = {}) { const manifest = await crawlImpl({ capturedAt: CAPTURE_DATE, manifestPath: path.join(PROJECT_ROOT, 'to-be-studied', 'manifest.json'), outputRoot: path.join(PROJECT_ROOT, 'to-be-studied', 'live-wiki', CAPTURE_DATE), }); const pageCount = manifest.pages.length; const failureCount = manifest.failures.length; if (failureCount > 0) { logError( `Captured ${pageCount} ${pluralize('page', pageCount)} with ${failureCount} ${pluralize('failure', failureCount)}; inspect to-be-studied/manifest.json.`, ); return 1; } logInfo(`Captured ${pageCount} ${pluralize('page', pageCount)} with no failures.`); return 0; } function pluralize(noun, count) { return count === 1 ? noun : `${noun}s`; } if (process.argv[1] && path.resolve(process.argv[1]) === SCRIPT_PATH) { try { process.exitCode = await runCapture(); } catch (error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; } }