Files
ykxmz/_build/fix_verify_final.py
xmz7891 351171e6ea 清理对外材料里的中转管理后台 + 把规矩变成测试
用户定的新规矩:
「你对外公开的数据里不要包含那个中转站管理的页面,你就只能提官网」

用户确认的范围:只清理「我对外的公开发言」
(发布说明 / 更新日志 / 官网 / README / 我给出的汇报),
服务端 zip 里的运维文档保留(装服务器的人需要它),
源码实现保留(路径是功能本身,藏起来没法维护)。

清掉的内容:
  * CHANGELOG.md:1.8.0 条目里"管理后台重做"整段、
    "管理页显示成一屏源码"、"管理页标题被切掉";
    1.7.1 条目里**直接写出的路径 /zhongzhuanzhan**、
    "管理入口从官网上移除";1.7.0 的"管理页加图标"
  * RELEASE-1.8.0.md:第四节「中转管理后台完全重做」整节删掉,
    改成「官网重新设计」

新增 _build/test_public_clean.py(15 项)并加进套件(阶段 3b7):
  * CHANGELOG / README / docs 里不许出现
    zhongzhuanzhan、/admin、管理后台、管理页、管理入口、admin_password
  * 官网渲染出来的 HTML 逐词检查,且站内链接只允许
    指向 /download/、/shot/、首页、图标、页内锚点
  * 发布说明里不许出现安装教程类内容(用户要求只放更新内容)

  为什么写成测试:文档没人看。这一天里我因为"以为记住了"
  翻了三次车,所以把规矩变成会红的断言。

新增 docs/项目规矩.md:把用户历次明确的约束集中记下来
(发布流程、对外清洁度、版本号、产物组成、README 规则、
白色简洁设计、改完必须验、测试工具不能当干扰源),
新会话接手时先读这个。

顺带修的工程问题(今天反复踩的坑):
  * 用 PowerShell 的 @"..."@ 嵌 Python 去改 .ps1 时,
    PowerShell 会先把 $var 展开成空,写进去一堆反斜杠
    -> verify_all.ps1 被写坏,& 语法报错
    现在改 .ps1 一律用 Python 读写文件
  * re.sub 的替换串会解释反斜杠转义,
    `"\\test_public_clean.py"` 里的 \t 变成制表符,
    路径成了 "_build<TAB>est_public_clean.py"
    -> 用 lambda 替换,避开转义

验收:全量回归 34 个阶段全部通过(含新的清洁度守卫)。
2026-10-07 12:15:32 +08:00

88 lines
2.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
r'''最后一次修 verify_all.ps1 的路径。
为什么要写第三个脚本:
上一次修的时候,re.sub 把 `\t` 当成了制表符,
路径 `_build\test_public_clean.py` 变成了
`_build<TAB>est_public_clean.py` —— **连 "t" 都被吃掉了**,
所以按 `test_public_clean` 去搜是搜不到的
(实际内容是 `est_public_clean`)。
这次用宽松模式:凡是那一行里有 "public_clean" 就整体替换掉。
'''
from __future__ import annotations
import re
import sys
from pathlib import Path
VERIFY = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote"
r"\_tests\verify_all.ps1")
BOM = b"\xef\xbb\xbf"
WANT = '$stageOut = & python (Join-Path $root "_build\\test_public_clean.py") 2>&1'
def main() -> int:
text = VERIFY.read_text(encoding="utf-8-sig")
# 宽松匹配:整行里出现 public_clean 就算
pattern = re.compile(r'^.*public_clean.*$', re.M)
found = pattern.findall(text)
print(" 现场(%d 行):" % len(found))
for line in found:
print(" %r" % line)
if WANT in text and len(found) == 1 and found[0] == WANT:
print()
print(" 已经是正确写法")
return 0
if not found:
print()
print(" [失败] 整行里连 public_clean 都没有")
# 把那一带打出来看
lines = text.splitlines()
for index, line in enumerate(lines, 1):
if "3b7" in line or "对外材料" in line:
for offset in range(-3, 5):
pos = index - 1 + offset
if 0 <= pos < len(lines):
print(" %d: %r" % (pos + 1, lines[pos]))
break
return 1
# 用 lambda 替换到底,绝不碰转义
new_text, count = pattern.subn(lambda _m: WANT, text)
print()
print(" 替换 %d 行" % count)
VERIFY.write_bytes(BOM + new_text.replace("\r\n", "\n").encode("utf-8"))
check = VERIFY.read_text(encoding="utf-8-sig")
lines = [ln for ln in check.splitlines() if "public_clean" in ln]
print(" 回读 %d 行:" % len(lines))
ok = True
for line in lines:
same = line == WANT
ok = ok and same
print(" %s %r" % ("✓" if same else "✗", line))
print(" BOM: %s" % VERIFY.read_bytes().startswith(BOM))
# 顺便确认没有再出现制表符或被吃掉的痕迹
print()
print(" 那一段完整内容:")
all_lines = check.splitlines()
for index, line in enumerate(all_lines, 1):
if "3b7" in line:
for offset in range(0, 7):
if index - 1 + offset < len(all_lines):
print(" %d: %s" % (index + offset,
all_lines[index - 1 + offset]))
break
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())