Files
story/scripts/sync-device-fleet-docs.cjs
T

13 lines
999 B
JavaScript
Raw Normal View History

// Mechanical sync of the maintained MQTT/OTA contract into the existing handoff.
const fs = require('node:fs'), path = require('node:path');
const root = path.resolve(__dirname, '..');
const target = path.join(root, 'docs/embedded-device-business-guide-20260914.md');
const source = fs.readFileSync(path.join(root, 'docs/device-mqtt-ota.md'), 'utf8');
let md = fs.readFileSync(target, 'utf8');
const start=md.indexOf('## 8.'),end=md.indexOf('## 附录 A.');
if(start<0||end<start)throw new Error('Expected handoff sections not found');
md=md.slice(0,start)+source.slice(source.indexOf('## 8.'))+'\n\n'+md.slice(end);
md=md.replace(/^第 1–7 节.*$/m,'第 1–7 节保留现有蓝牙绑定与平台代注册火山流程。第 8–12 节已按本次实现更新;最终硬件按协议对接,本次不修改或烧录 EchoEar。线上发布与验证状态见 `device-fleet-delivery.md`。');
fs.writeFileSync(target,md);
console.log('Updated MQTT/OTA business contract in the embedded handoff.');