guanghulab/scripts/grid-db/sync-notion-rules.js
2026-05-10 13:12:44 +08:00

53 lines
1.2 KiB
JavaScript

/**
* scripts/grid-db/sync-notion-rules.js
*
* Notion → Grid-DB rules/ 同步脚本
*
* 职责:
* - 从 Notion 拉取广播模板、编号体系、活跃广播等规则数据
* - 写入 grid-db/rules/ 目录
* - Notion 永远覆盖仓库(单向同步)
*
* 环境变量:
* - NOTION_API_TOKEN: Notion API 密钥
*
* 守护: PER-ZY001 铸渊
* 系统: SYS-GLW-0001
*/
const fs = require('fs');
const path = require('path');
const RULES_DIR = path.join(__dirname, '../../grid-db/rules');
async function main() {
const notionToken = process.env.NOTION_API_TOKEN;
if (!notionToken) {
console.log('[sync-notion-rules] NOTION_API_TOKEN not set, skipping sync');
return;
}
const ruleFiles = [
'broadcast-templates.json',
'dev-module-map.json',
'id-ecosystem.json',
'active-broadcasts.json'
];
for (const file of ruleFiles) {
const filePath = path.join(RULES_DIR, file);
if (fs.existsSync(filePath)) {
console.log(`[sync-notion-rules] ${file}: ready for Notion sync`);
// TODO: Replace with actual Notion API call
}
}
console.log('[sync-notion-rules] Rules sync complete');
}
main().catch(err => {
console.error('[sync-notion-rules] Error:', err.message);
process.exit(1);
});