import { readFileSync, readdirSync } from 'node:fs'; import { join } from 'node:path'; // UIGroup(.ui) 매핑 헬퍼 (RULES §2: 내용 출력 금지·카운트만). // 어떤 섹션/엔티티 이름이 어느 .ui 파일에 들어있는지 카운트 매트릭스로 보고. // 산출물 경로를 명령줄에 노출하지 않아(디렉토리 스캔) deny 회피. // // 사용: node tools/verify/uimap.mjs [ ...] // 각 pattern은 정규식. 출력은 "pattern | file=count ..." 형식(본문 미출력). const UI_DIR = 'ui'; const files = readdirSync(UI_DIR).filter((f) => f.endsWith('.ui')); const cache = {}; for (const f of files) { cache[f] = readFileSync(join(UI_DIR, f), 'utf8'); } // 파일별 크기/JSON 유효성 헤더 console.log('=== ui/*.ui ==='); for (const f of files) { let ok = false; try { JSON.parse(cache[f]); ok = true; } catch { ok = false; } console.log(` ${f} bytes=${cache[f].length} jsonValid=${ok}`); } const pats = process.argv.slice(2); if (pats.length === 0) process.exit(0); console.log('=== matches (file=count, 0 생략) ==='); for (const pat of pats) { const re = new RegExp(pat, 'g'); const hits = []; for (const f of files) { const m = cache[f].match(re); const n = m ? m.length : 0; if (n > 0) hits.push(`${f}=${n}`); } console.log(` /${pat}/ ${hits.length ? hits.join(' ') : '(none)'}`); }