- sites/spiders: Haidan/HDDolby/RousiPro/SunnyPT/TNode/TorrentLeech/Yema (+mTorrent wrapper), specialized SiteAdapter, indirect download resolved at download time - sites/user-parsers: SiteParserBase + all 20 MP SiteSchema parsers (lxml XPath via xpath+xmldom), refreshSiteUserData with schema fallback - sites/definitions: zod SiteDefinition schemas, 23 MovieClaw v0.27.0 (MIT) definitions via scripts/mp-sync/movieclaw-import.mjs, registry getSiteDefinition/listSiteDefinitions, NOTICE - scripts/mp-sync: ledger.json (upstream sha256), check.mjs, build-ledger.mjs; docs/porting/mp-sync-ledger.md - license-and-provenance: add copied-mit kind, re-anchor MovieClaw rows to v0.27.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
67 lines
3.0 KiB
JavaScript
67 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* 比较 ledger.json 与 MoviePilot 目标提交,列出需要跟随移植的上游变化。
|
|
*
|
|
* node scripts/mp-sync/check.mjs [--mp <MP 仓库路径>] [--to <目标提交,默认 HEAD>] [--json]
|
|
*
|
|
* 输出:已变更 / 已删除 / 未变化 的 ledger 文件,监视目录(spider/、parser/)中 ledger 未收录的新文件,
|
|
* 以及逐文件 `git diff` 命令。存在变化时退出码为 1(可用于 CI 或定时提醒)。
|
|
* 浅克隆需要先取目标提交:git -C <mp> fetch --depth=1 origin <commit>(或 fetch --unshallow)。
|
|
*/
|
|
import { readFileSync } from "node:fs";
|
|
import { DEFAULT_MP_REPO, LEDGER_PATH, listUpstreamDir, parseArgs, resolveCommit, upstreamHash } from "./lib.mjs";
|
|
|
|
const args = parseArgs(process.argv.slice(2));
|
|
const repo = args.mp ?? DEFAULT_MP_REPO;
|
|
const target = resolveCommit(repo, args.to ?? "HEAD");
|
|
const ledger = JSON.parse(readFileSync(args.ledger ?? LEDGER_PATH, "utf8"));
|
|
|
|
const changed = [];
|
|
const deleted = [];
|
|
const unchanged = [];
|
|
for (const e of ledger.entries) {
|
|
const h = upstreamHash(repo, target, e.upstream);
|
|
if (h === null) deleted.push(e);
|
|
else if (h !== e.sha256) changed.push({ ...e, newSha256: h });
|
|
else unchanged.push(e);
|
|
}
|
|
const known = new Set(ledger.entries.map((e) => e.upstream));
|
|
const added = [];
|
|
for (const dir of ledger.watchDirs ?? []) {
|
|
for (const f of listUpstreamDir(repo, target, dir)) if (!known.has(f)) added.push(f);
|
|
}
|
|
|
|
const short = (c) => c.slice(0, 7);
|
|
if (args.json) {
|
|
console.log(JSON.stringify({ target, changed, deleted, added, unchanged: unchanged.length }, null, 2));
|
|
} else {
|
|
console.log(`MoviePilot 目标提交 ${short(target)}(ledger ${ledger.entries.length} 个文件)\n`);
|
|
const section = (title, list, fmt) => {
|
|
console.log(`## ${title}(${list.length})`);
|
|
for (const x of list) console.log(fmt(x));
|
|
console.log("");
|
|
};
|
|
section("已变更", changed, (e) =>
|
|
[
|
|
`- ${e.upstream} (${short(e.commit)} → ${short(target)})`,
|
|
` 本项目:${e.ours.join(", ")}`,
|
|
` git -C ${repo} diff ${short(e.commit)} ${short(target)} -- ${e.upstream}`,
|
|
].join("\n"),
|
|
);
|
|
section("已删除 / 改名", deleted, (e) =>
|
|
[
|
|
`- ${e.upstream}(本项目:${e.ours.join(", ")})`,
|
|
` git -C ${repo} log --oneline --follow ${short(e.commit)}..${short(target)} -- ${e.upstream}`,
|
|
` git -C ${repo} diff --stat -M ${short(e.commit)} ${short(target)} -- ${e.upstream.replace(/\/[^/]+$/, "/")}`,
|
|
].join("\n"),
|
|
);
|
|
section("监视目录新增(ledger 未收录)", added, (f) => `- ${f}\n git -C ${repo} show ${short(target)}:${f}`);
|
|
console.log(`未变化:${unchanged.length}`);
|
|
if (changed.length || deleted.length || added.length) {
|
|
console.log(
|
|
"\n处理流程:按 diff 增量移植 → 把对应源码文件头 `@mp-source ... @ <提交>` 改为新提交(新文件新增标签)→ node scripts/mp-sync/build-ledger.mjs --commit <新提交> → 测试。",
|
|
);
|
|
}
|
|
}
|
|
process.exit(changed.length || deleted.length || added.length ? 1 : 0);
|