#!/usr/bin/env node // Emits the events between two `docs/web-features-map.json` snapshots as JSON lines on // stdout, oldest concern first: input changes, then the totals, then one line per // feature whose status or counts moved, in feature-id order. Event format: // `docs/web-features-map.md` -> "Events". // // Usage: node oracle/suites/web-features-diff.mjs BEFORE AFTER // BEFORE may be an empty or missing file, meaning no earlier snapshot. import { existsSync, readFileSync } from 'node:fs'; import { diffSnapshots } from './web-features-map-lib.mjs'; const [beforePath, afterPath] = process.argv.slice(2); if (!beforePath || !afterPath) { console.error('usage: web-features-diff.mjs BEFORE AFTER'); process.exit(2); } const read = (p) => { const text = existsSync(p) ? readFileSync(p, 'utf8') : ''; return text.trim() ? JSON.parse(text) : null; }; const after = read(afterPath); if (!after) { console.error(`${afterPath}: no snapshot`); process.exit(2); } for (const e of diffSnapshots(read(beforePath), after)) process.stdout.write(`${JSON.stringify(e)}\n`);