#!/usr/bin/env node
// scripts/gen-expected-prom.mjs
// Regenerate tests/fixtures/expected.prom snapshot from tests/fixtures/stats-sample.jsonl.
//
// Usage:
//   node scripts/gen-expected-prom.mjs > tests/fixtures/expected.prom
//
// When the snapshot is stale (e.g. after intentional format change or new
// stats-sample row), regenerate via the command above and inspect the diff.

import { readFileSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { transformToPrometheus } from '../lib/exporters/textfile-format.mjs';

const __dirname = dirname(fileURLToPath(import.meta.url));
const SAMPLE_PATH = join(__dirname, '..', 'tests', 'fixtures', 'stats-sample.jsonl');

const text = readFileSync(SAMPLE_PATH, 'utf-8');
const records = text.trim().split('\n').filter(Boolean).map(line => JSON.parse(line));
process.stdout.write(transformToPrometheus(records));
