mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 12:30:44 +00:00
按用户规矩升到 1.9.0(有新内容+重构,不是只修 bug)+ 加版本号一致性检查
用户定的规矩:
只修 bug -> 最后一位 +1 1.8.2 -> 1.8.3
加新内容/重构 -> 第二位 +1,最后一位清 0 1.8.2 -> 1.9.0
这一轮既有新东西(设置窗口的中转服务器字段、允许新设备接入开关、
双击开设置窗口)又有重构(手表面板切换收成 showOnly()),
所以是 **1.9.0**,不是我之前说的 1.8.3。
== 顺手加了个「版本号一致性」检查(回归阶段 3a8)==
版本号散落在 8 个地方,靠脚本+人工替换很容易漏。实测漏了两个,
而且**漏了不报错**,只是用户看到一个对不上的版本号:
* windows/version_info.txt 写着 1.7.1
-> 用户在「文件属性 -> 详细信息」里看到的版本,错了三个版本
* docs/LICENSE.txt 写着 1.7.1
-> 安装时许可页上显示 1.7.1
第二个的根因值得记:installer/build_installer.py 会从 docs/ 里三份
文档**重新生成** license-combined.txt,所以光改生成物没用 ——
下次构建又变回去(我第一次就是这么被骗的)。改成在 build_license()
里**统一注入当前版本**,源文档写什么都不影响。
新增:
_tests/check_version_consistency.py 检查 8 处版本号一致
_build/add_verify_stage.py 给套件加阶段(不经 shell,
不会被 PowerShell 吃掉 \$ 变量)
_build/fix_license_version.py 按行精确修 license
== 另外修了两个我自己的坑 ==
1. verify_all.ps1 被 PowerShell heredoc 吃掉了 \ / \,
整个脚本语法错。**同一个坑踩了两次**(3a7 和 3a8)。
以后给 .ps1 加含 \$ 的内容一律写 Python 脚本文件再跑。
2. build_exe.ps1 被 edit 工具吃掉了 UTF-8 BOM
(PowerShell 5.1 会按 GBK 读,中文注释乱码)。
全量回归 43 个阶段全部通过。
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
r'''给 verify_all.ps1 追加阶段 —— **不能用 PowerShell heredoc**。
|
||||
|
||||
== 为什么单独写这个脚本 ==
|
||||
|
||||
我这一轮在 PowerShell 里用 `python -c @"..."@` 写 Python 代码
|
||||
去改 verify_all.ps1,结果 **`$stageOut` 和 `$root` 被 PowerShell
|
||||
当成变量给展开了**(`@"..."@` 是插值字符串),写进去变成:
|
||||
|
||||
= & python (Join-Path "_tests\check_version_consistency.py") 2>&1
|
||||
Show-Fails
|
||||
Record "版本号一致性" (0 -eq 0)
|
||||
|
||||
整个脚本直接语法错。**同一个坑踩了两次**(3a7 和 3a8)。
|
||||
|
||||
教训:凡是给 .ps1 加含 `$` 的内容,一律**写 Python 脚本文件再跑**,
|
||||
不要用 `python -c @"..."@`。
|
||||
|
||||
用法:
|
||||
python _build/add_verify_stage.py <锚点文字> <阶段号> <标题> <脚本相对路径> <Record 名>
|
||||
'''
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
SUITE = ROOT / "_tests" / "verify_all.ps1"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if len(sys.argv) < 6:
|
||||
print(__doc__)
|
||||
return 1
|
||||
anchor_text, stage_no, title, script_rel, record_name = sys.argv[1:6]
|
||||
|
||||
raw = SUITE.read_bytes()
|
||||
had_bom = raw.startswith(b"\xef\xbb\xbf")
|
||||
text = raw.decode("utf-8-sig")
|
||||
|
||||
if script_rel in text:
|
||||
print(" 已经注册过了(%s 里提到了 %s)" % (SUITE.name, script_rel))
|
||||
return 0
|
||||
|
||||
lines = text.splitlines()
|
||||
idx = None
|
||||
for i, ln in enumerate(lines):
|
||||
if ln.startswith("Record") and anchor_text in ln:
|
||||
idx = i
|
||||
break
|
||||
if idx is None:
|
||||
print(" ✗ 找不到锚点(Record 行含 %r)" % anchor_text)
|
||||
print(" 现有 Record 行:")
|
||||
for i, ln in enumerate(lines):
|
||||
if ln.startswith("Record"):
|
||||
print(" %d: %s" % (i, ln))
|
||||
return 1
|
||||
|
||||
block = [
|
||||
"",
|
||||
"# ---------------------------------------------------------------- %s"
|
||||
% stage_no,
|
||||
'Banner "%s"' % title,
|
||||
"$stageOut = & python (Join-Path $root \"%s\") 2>&1"
|
||||
% script_rel.replace("/", "\\"),
|
||||
" Show-Fails $stageOut",
|
||||
'Record "%s" ($LASTEXITCODE -eq 0)' % record_name,
|
||||
]
|
||||
lines[idx + 1:idx + 1] = block
|
||||
|
||||
out = "\n".join(lines) + "\n"
|
||||
SUITE.write_bytes((b"\xef\xbb\xbf" if had_bom else b"") + out.encode("utf-8"))
|
||||
print(" ✓ 已在「%s」后面插入阶段 %s" % (anchor_text, stage_no))
|
||||
print(" (BOM 保留:%s)" % had_bom)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -83,9 +83,27 @@ def main() -> int:
|
||||
changed += 1
|
||||
|
||||
# ---- Windows EXE 版本信息 ----
|
||||
if swap(ROOT / "windows" / "version_info.txt",
|
||||
[(f'"{OLD}.0"', f'"{NEW}.0"')],
|
||||
f"EXE 文件版本 {NEW}.0"):
|
||||
# ⚠ 原来用的是 f'"{OLD}.0"',一旦 OLD 和文件里对不上就静默跳过
|
||||
# (version_info.txt 就是这么从 1.7.1 一直漏到现在的)。
|
||||
# 改成正则匹配任意四段版本。
|
||||
import re as _re
|
||||
_vi = ROOT / "windows" / "version_info.txt"
|
||||
if _vi.is_file():
|
||||
_raw = _vi.read_bytes()
|
||||
_bom = _raw.startswith(b"\xef\xbb\xbf")
|
||||
_txt = _raw.decode("utf-8-sig")
|
||||
_new = _re.sub(
|
||||
r'(StringStruct\("(?:File|Product)Version",\\s*")\\d+\\.\\d+\\.\\d+\\.\\d+("\))',
|
||||
r'\\g<1>' + NEW + r'.0\\g<2>', _txt)
|
||||
if _new != _txt:
|
||||
_vi.write_bytes((b"\xef\xbb\xbf" if _bom else b"")
|
||||
+ _new.replace("\\r\\n", "\\n").encode("utf-8"))
|
||||
print(f" version_info.txt: EXE 文件版本 {NEW}.0")
|
||||
changed += 1
|
||||
else:
|
||||
print(" [跳过] version_info.txt")
|
||||
|
||||
if False:
|
||||
changed += 1
|
||||
|
||||
# ---- __init__ ----
|
||||
@@ -100,6 +118,22 @@ def main() -> int:
|
||||
f"VERSION={NEW}"):
|
||||
changed += 1
|
||||
|
||||
# ---- 安装包版本 ----
|
||||
# ⚠ 原来漏了这三处,导致 version_info.txt 从 1.7.1 起就一直没跟上
|
||||
# (用户在"文件属性 -> 详细信息"里看到一个错三个版本的号)。
|
||||
if swap(ROOT / "installer" / "ykxmz.iss",
|
||||
[(f'#define MyAppVersion "{OLD}"',
|
||||
f'#define MyAppVersion "{NEW}"'),
|
||||
(f'ykxmz-setup-{OLD}.exe', f'ykxmz-setup-{NEW}.exe')],
|
||||
f"安装包版本 {NEW}"):
|
||||
changed += 1
|
||||
|
||||
# ---- 安装许可页上的版本 ----
|
||||
if swap(ROOT / "installer" / "license-combined.txt",
|
||||
[(f"版本:{OLD}", f"版本:{NEW}")],
|
||||
f"许可页版本 {NEW}"):
|
||||
changed += 1
|
||||
|
||||
# ---- 三份文档 ----
|
||||
for path in sorted((ROOT / "docs").glob("*.txt")):
|
||||
raw = path.read_bytes()
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
r'''修 license-combined.txt 里那份**没过期的**协议版本号。
|
||||
|
||||
这个文件是三份文档拼起来的(许可协议 + 安装前必读 + 版本记录),
|
||||
每份都有自己的头部版本号和落款。实测第一份的头部还写着 1.7.1:
|
||||
|
||||
第 6 行: '版本:1.7.1' <- 头部,要改
|
||||
第 153 行: ' 软件:ykxmz 1.7.1' <- 落款,要改
|
||||
第 540 行: ' 1.7.1' <- **版本记录**(变更日志),
|
||||
历史条目,**不能改**
|
||||
|
||||
前两次我用的整体 replace 都不够精确:
|
||||
* 第一次 `text.replace('版本:1.7.1', ...)` 报了成功,但改完
|
||||
又被后一步覆盖掉了(顺序问题)
|
||||
* 而且整体 replace 会连带把版本记录里的历史条目也改掉
|
||||
|
||||
所以这次**按行号精确改**:只动 6 和 153。
|
||||
'''
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
FILE = ROOT / "installer" / "license-combined.txt"
|
||||
NEW = "1.9.0"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
raw = FILE.read_bytes()
|
||||
had_bom = raw.startswith(b"\xef\xbb\xbf")
|
||||
text = raw.decode("utf-8-sig")
|
||||
lines = text.splitlines()
|
||||
|
||||
changed = []
|
||||
# 按内容精确匹配,避免行号漂移
|
||||
for i, ln in enumerate(lines):
|
||||
s = ln.strip()
|
||||
# 头部:版本:X.Y.Z
|
||||
if s.startswith("版本:") and s != ("版本:" + NEW):
|
||||
old = s
|
||||
lines[i] = ln.replace(s, "版本:" + NEW)
|
||||
changed.append((i + 1, old, lines[i].strip()))
|
||||
# 落款:软件:ykxmz X.Y.Z
|
||||
elif s.startswith("软件:ykxmz ") and s != ("软件:ykxmz " + NEW):
|
||||
old = s
|
||||
lines[i] = ln.replace(s, "软件:ykxmz " + NEW)
|
||||
changed.append((i + 1, old, lines[i].strip()))
|
||||
|
||||
if not changed:
|
||||
print(" ✓ 没有要改的")
|
||||
return 0
|
||||
|
||||
print(" ── 改了这些行 ──")
|
||||
for n, old, new in changed:
|
||||
print(" 第 %3d 行: %r -> %r" % (n, old, new))
|
||||
|
||||
out = "\n".join(lines) + "\n"
|
||||
FILE.write_bytes((b"\xef\xbb\xbf" if had_bom else b"")
|
||||
+ out.encode("utf-8"))
|
||||
|
||||
# 复核:版本记录那一段不许动
|
||||
after = FILE.read_text(encoding="utf-8-sig")
|
||||
if "八、版本记录" not in after:
|
||||
print(" ✗ 版本记录那一段不见了!")
|
||||
return 1
|
||||
seg = after.split("八、版本记录", 1)[1]
|
||||
if " 1.7.1" not in seg:
|
||||
print(" ⚠ 版本记录里的历史条目 1.7.1 被改掉了 —— 那是不该动的")
|
||||
return 1
|
||||
print(" ✓ 版本记录里的历史条目(1.7.1)保持原样")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -17,7 +17,7 @@ import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
|
||||
VERSION = "1.8.2"
|
||||
VERSION = "1.9.0"
|
||||
NAME = f"ykxmz-{VERSION}"
|
||||
|
||||
AGENT_SRC = ROOT / "dist_exe" / "ykxmz"
|
||||
|
||||
Reference in New Issue
Block a user