import { readFileSync, writeFileSync } from 'node:fs'; // 用法:node .ua/add-entry.mjs <条目json文件>:把自补条目追加进 backlog(按 id 升序插到末尾) const [src] = process.argv.slice(2); const b = JSON.parse(readFileSync('.ua/backlog.json', 'utf8')); const entry = JSON.parse(readFileSync(src, 'utf8')); if (b.items.some((i) => i.id === entry.id)) throw new Error(`id 已存在:${entry.id}`); b.items.push(entry); writeFileSync('.ua/backlog.json', JSON.stringify(b, null, 2) + '\n', 'utf8'); console.log('added', entry.id, entry.title);