Files
ykxmz/_build/fix_verify_ps1.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

85 lines
2.9 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 里被转义吃掉的那两行。
事故:
我用 PowerShell 的 @"..."@ 里嵌 Python 去改 verify_all.ps1,
PowerShell 先把 $stageOut / $root 当自己的变量展开成空,
写进去的代码就变成了 `\ = & python (Join-Path \ "...")`,
PowerShell 直接语法报错 & is not allowed。
这个坑今天踩了十几次了。**改 .ps1 一律用 Python 读写文件,
不要把代码嵌在 PowerShell 字符串里。**
补丁内容:把损坏的两行换成和其他阶段一致的写法。
'''
from __future__ import annotations
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"
# 损坏的两行(用正则宽松匹配,因为损坏后的具体字符可能不同)
import re # noqa: E402
BROKEN = re.compile(
r"^.*= & python \(Join-Path .*test_public_clean\.py.*\) 2>&1\s*\n"
r"\s*Show-Fails Record \"对外材料清洁度\".*$",
re.M)
FIXED = (
'$stageOut = & python (Join-Path $root '
'"_build\\test_public_clean.py") 2>&1\n'
' Show-Fails $stageOut\n'
'Record "对外材料清洁度" ($LASTEXITCODE -eq 0)'
)
def main() -> int:
raw = VERIFY.read_bytes()
had_bom = raw.startswith(BOM)
text = raw.decode("utf-8-sig")
if "test_public_clean" not in text:
print(" [失败] 找不到那个阶段")
return 1
# 检查是否已经正确
if '$stageOut = & python (Join-Path $root "_build\\test_public_clean.py") 2>&1' in text:
print(" 已经是正确写法了")
else:
new_text, count = BROKEN.subn(FIXED, text)
if count == 0:
print(" [失败] 正则没匹配到损坏的行")
# 打印现场
for index, line in enumerate(text.splitlines(), 1):
if "test_public_clean" in line or "对外材料清洁度" in line:
print(" %d: %r" % (index, line))
return 1
text = new_text
print(" 修好了 %d 处" % count)
VERIFY.write_bytes(BOM + text.replace("\r\n", "\n").encode("utf-8")
if not had_bom else
BOM + text.replace("\r\n", "\n").encode("utf-8"))
print(" BOM: %s" % VERIFY.read_bytes().startswith(BOM))
# 回读确认
print()
print(" 修复后的那一段:")
lines = VERIFY.read_text(encoding="utf-8-sig").splitlines()
for index, line in enumerate(lines, 1):
if "3b7" in line:
for offset in range(0, 7):
if index - 1 + offset < len(lines):
print(" %d: %s" % (index + offset,
lines[index - 1 + offset]))
break
return 0
if __name__ == "__main__":
sys.exit(main())