#!/usr/bin/env node // Same crawl as the service, from a laptop or CI — prints the result as JSON. // node cli.mjs [--pages 20] [--accept '[data-ipal="accept"]'] [--wait 3000] // Exit code: 0 = nothing stored before consent but the consent cookie, 1 = something else was, 2 = setup problem. // The verdict per cookie needs the site's categories: the panel's "Crawl site" does that. import { crawlSite } from './crawl.mjs' const args = process.argv.slice(2) const opt = (name, def) => (args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : def) if (!args[0] || args[0].startsWith('--')) { console.error('Usage: node cli.mjs [--pages N] [--accept selector] [--wait ms]') process.exit(2) } let chromium try { ;({ chromium } = await import('playwright')) } catch { console.error('Playwright not found: npm install (in services/cookie-crawler) && npx playwright install chromium') process.exit(2) } const result = await crawlSite({ acceptSelector: opt('accept', '[data-ipal="accept"]'), chromium, maxPages: Number(opt('pages', 20)), siteUrl: args[0], waitMs: Number(opt('wait', 3000)), }) console.log(JSON.stringify(result, null, 2)) const early = result.observations.filter((o) => o.before && o.name !== 'cookie-consent') if (early.length) {console.error(`Stored before consent: ${early.map((o) => o.name).join(', ')} — classify them in the panel.`)} process.exit(early.length ? 1 : 0)