Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
from pathlib import Path
|
|
import re
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
|
|
tt = Path(r"apps/miniprogram/tt/src/data/nomadCodeBook.ts").read_text(encoding="utf-8")
|
|
src = Path(r"apps/miniprogram/weapp/src/data/nomadCodeBook.ts").read_text(encoding="utf-8")
|
|
|
|
|
|
def chapters(text: str):
|
|
contents = re.findall(r'"content":\s*"((?:\\.|[^"\\])*)"', text)
|
|
return contents
|
|
|
|
|
|
def only_qr_removed(src_c: str) -> str:
|
|
s = src_c
|
|
s = re.sub(r"> 公众号: 异度世界\\n\\n", "", s)
|
|
s = re.sub(r"> 公众号:异度世界\\n\\n", "", s)
|
|
s = re.sub(r"!\\[[^\]]*\\]\([^)]*qrcode_for_gh[^)]*\)", "", s)
|
|
s = re.sub(r"(\\n){3,}", r"\\n\\n", s)
|
|
return s
|
|
|
|
|
|
tt_c = chapters(tt)
|
|
src_c = chapters(src)
|
|
out = []
|
|
for i, (a, b) in enumerate(zip(tt_c, src_c)):
|
|
b2 = only_qr_removed(b)
|
|
if a != b2:
|
|
out.append(f"=== ch{i} tt={len(a)} expect={len(b2)} src={len(b)} ===")
|
|
# count removed placeholders
|
|
ph_src = b.count("完整图见公众号")
|
|
ph_tt = a.count("完整图见公众号")
|
|
out.append(f"placeholder count src={ph_src} tt={ph_tt}")
|
|
oa_src = b.count("公众号")
|
|
oa_tt = a.count("公众号")
|
|
out.append(f"公众号 count src={oa_src} tt={oa_tt}")
|
|
# sample diffs - find first 3 differing regions
|
|
# align by finding common prefix
|
|
j = 0
|
|
while j < min(len(a), len(b2)) and a[j] == b2[j]:
|
|
j += 1
|
|
out.append(f"first_diff@{j}")
|
|
out.append("TT: " + repr(a[max(0, j - 20) : j + 100]))
|
|
out.append("EX: " + repr(b2[max(0, j - 20) : j + 100]))
|
|
|
|
Path(r"apps/miniprogram/scripts/_cmp_book_out.txt").write_text(
|
|
"\n".join(out) or "all match only-QR", encoding="utf-8"
|
|
)
|
|
print("diffs", len(out) // 6 if out else 0)
|
|
print("wrote _cmp_book_out.txt")
|