bookworm-smart-assistant/scripts/poc/poc-h2-worker.js
Bookworm Admin b7a8e29d21 release: v6.7.0 - OTA E2E test release
- VERSION file as authoritative version source
- export.mjs reads VERSION with package.json fallback
- bw-ota.ps1 DryRun mode for safe testing
- auto-setup.ps1 bumped to v3.2.0 (Phase 8 OTA)
2026-04-27 17:59:44 +08:00

27 lines
775 B
JavaScript

'use strict';
const fs = require('fs');
const mode = process.argv[2]; // 'jsonl' | 'json-full'
const target = process.argv[3];
const workerId = process.argv[4];
const count = Number(process.argv[5]) || 100;
function writeJsonlRecord() {
for (let i = 0; i < count; i++) {
const rec = JSON.stringify({ worker: workerId, i, ts: Date.now() }) + '\n';
fs.appendFileSync(target, rec);
}
}
function writeJsonFullRewrite() {
for (let i = 0; i < count; i++) {
let arr = [];
try { arr = JSON.parse(fs.readFileSync(target, 'utf8') || '[]'); } catch { arr = []; }
arr.push({ worker: workerId, i, ts: Date.now() });
fs.writeFileSync(target, JSON.stringify(arr), 'utf8');
}
}
if (mode === 'jsonl') writeJsonlRecord();
else writeJsonFullRewrite();