feat: add versioned release packaging

This commit is contained in:
chengma
2026-07-07 14:21:30 +08:00
parent 148c4a73eb
commit 7838554c3d
14 changed files with 407 additions and 113 deletions
+56 -17
View File
@@ -1272,22 +1272,6 @@
- 边界:只改显示层和文档层;`cmshopee` 继续作为仓库、包名、exe、数据库、日志、配置、回写后缀和兼容标识符保留;未改任何文件名、schema、AI、Excel、DB、CDP 或 Shopee 更新流程。
- 验证:`python -m py_compile app\gui\main_window.py app\gui\__init__.py tests\test_gui.py` 通过;`python -m unittest discover -s tests -p test_gui.py` 通过(95 tests);`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过;`git diff --check` 通过。
## 【2026-07-07】T-541 文档 · 打包版窗口左上角显示不全
- 现象:运行打包后的 `dist/cmshopee/cmshopee.exe` / release 包时,Windows 10 虚拟机或小分辨率环境可能出现主窗口贴到屏幕左上角、左边和标题栏显示不全,用户看不到品牌标题且无法拖动窗口到中间。
- 原因:`MainWindow.__init__()` 当前只 `resize(1180, 760)`,没有读取 `QApplication.primaryScreen().availableGeometry()` 限制初始尺寸、居中显示,也没有保证窗口标题栏完整落在可用屏幕内。
- 文档:`docs/06-tasks.md` 新增 T-541;`docs/troubleshooting.md` 增加临时处理(`Alt+Space` → `M` → 方向键移动)和正式修复方案;`docs/packaging.md` 打包验收清单新增标题栏完整可见/可拖动检查;`docs/current-state.md` 记录 T-541 修复口径。
- 方案:后续代码在主窗口启动时根据屏幕可用区域限制尺寸并居中,保证标题栏可见;小屏继续适配,不保存坏的历史窗口坐标。
- 边界:本轮只更新文档,未改 GUI 代码、打包脚本、业务逻辑、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-541 完成 · 打包版主窗口初始位置与小屏适配
- 状态:DONE
- 代码:`app/gui/main_window.py` 新增 `_fit_and_center_window()`,启动时读取 `QApplication.primaryScreen().availableGeometry()`,将主窗口尺寸限制在可用屏幕范围内并居中;首次 `showEvent` 后再应用一次,避免打包版在 Windows 10 VM/小分辨率环境标题栏出屏。
- 文档:`docs/06-tasks.md` 将 T-541 标记为 DONE;`docs/troubleshooting.md`、`docs/packaging.md`、`docs/current-state.md` 更新为当前修复与打包验收口径。
- 测试:`tests/test_gui.py` 新增小屏和大屏 mock geometry 单测,覆盖尺寸限制与居中位置;`scripts/build_exe.ps1` 已重新构建 release,确认 T-541 合入后仍可打包。
- 边界:不保存/恢复窗口历史坐标;未改业务流程、DB、AI、Excel、CDP/Shopee、打包产物结构或用户数据路径。
## 【2026-07-07】T-538 完成 · 打包产物用户数据收进 data/
- 状态:DONE
@@ -1296,7 +1280,7 @@
- 打包:`.gitignore` 新增 `data/`;`scripts/build_exe.ps1` 发布目录校验禁止带出 `data/`;更新方式改为覆盖发布包里的程序文件和依赖文件并保留 `data/`。当前 PyInstaller 5.13.2 为扁平 onedir,不要求存在 `_internal/`。
- 文档:`docs/06-tasks.md` 将 T-538 标记为 DONE;同步 `docs/packaging.md`、架构/技术栈/API/排障/路由/current-state 和 UI 线框图里的数据路径说明。
- 边界:未改 DB schema、AI HTTP 协议、Excel、账号、CDP 或 Shopee 页面操作流程;旧 DB 已存图片路径继续按原路径读取。
- 验证:`python -m py_compile app\appconfig.py app\diagnostics.py app\prompts.py app\editor.py app\gui\__init__.py app\gui\main_window.py app\gui\tabs\generate.py app\gui\tabs\settings.py app\gui\widgets.py main.py tests\test_appconfig.py tests\test_packaging.py tests\test_gui.py` 通过;`python -m unittest discover -s tests -p test_appconfig.py` 通过;`python -m unittest discover -s tests -p test_packaging.py` 通过;`python -m unittest discover -s tests -p test_gui.py` 通过;`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过;`git diff --check` 通过。
- 验证:`python -m py_compile app\appconfig.py app\diagnostics.py app\prompts.py app\editor.py app\gui\__init__.py app\gui\main_window.py app\gui\tabs\generate.py app\gui\tabs\settings.py app\gui\widgets.py main.py tests\test_appconfig.py tests\test_packaging.py tests\test_gui.py` 通过;`python -m unittest discover -s tests -p test_appconfig.py` 通过(14 tests);`python -m unittest discover -s tests -p test_packaging.py` 通过(3 tests);`python -m unittest discover -s tests -p test_gui.py` 通过(95 tests);`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(217 tests);`git diff --check` 通过。
## 【2026-07-07】T-538 修正 · 区分数据迁移冲突和目录不可写
@@ -1312,3 +1296,58 @@
- 文档:`docs/packaging.md`、`docs/03-tech-stack.md`、`docs/06-tasks.md`、`docs/current-state.md` 已改为发布整个 `dist/cmshopee` 文件夹,验证重点是不得带出 `data/` 和用户本地数据。
- 代码:`scripts/build_exe.ps1` 打包成功后会提示当前依赖布局;无 `_internal/` 时明确说明扁平结构正常,并提醒发布整个 `dist/cmshopee` 目录。
- 边界:未升级 PyInstaller,未改变 spec 产物布局,未改运行时路径、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-540 文档 · 打包版本号与 release 产物命名统一
- 需求:参考 `D:\chengma\cmbot` 的打包版本控制方式,解决当前 `cmshopee` 没有统一版本源、发布目录不带版本号、GUI 标题和构建产物无法一致追踪的问题。
- 文档:`docs/packaging.md` 新增“版本号与发布目录(T-540 方案)”,定义 `app/version.py` 为唯一版本源、`release\cmshopee-<APP_VERSION>\` 发布目录、`cmshopee-<APP_VERSION>-portable.zip` 便携包、`version.txt` 和中文 README;`docs/06-tasks.md` 新增 T-540;`docs/current-state.md` 记录后续任务口径。
- 决策:本阶段只做手动发版版本号一致性,不搬 `cmbot` 的 `Launcher.exe`、`manifest.json`、SHA-256 下载校验、强制更新或在线更新机制。
- 边界:本轮只更新文档,未改代码、构建脚本、测试、运行时路径、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-540 完成 · 打包版本号与 release 产物命名统一
- 状态:DONE
- 代码:新增 `app/version.py`,统一维护 `APP_NAME`、`APP_CODE_NAME`、`APP_VERSION` 和 `display_name()`;GUI 主窗口标题改为 `蝦皮圈優化助手 v<APP_VERSION>`,PySide6 缺失提示继续读取统一品牌名。
- 打包:`scripts/build_exe.ps1` 从 `app/version.py` 读取版本,最低支持 Python 3.7.9,低于 3.7.9 直接失败;PyInstaller 仍输出 `dist\cmshopee`,随后组装 `release\cmshopee-<APP_VERSION>\`,写入 `version.txt`、中文 `README.txt`,并生成 `release\cmshopee-<APP_VERSION>-portable.zip`;`release/` 已加入 `.gitignore`。
- 兼容:脚本源码保持 ASCII,中文构建提示和 README 文案用 UTF-8 base64 在运行时解码,避免 Windows PowerShell 5.1 误读 UTF-8 无 BOM 导致解析失败。
- 测试:`tests/test_packaging.py` 覆盖版本源、release 命名、zip、`version.txt`、Python 3.7.9 最低版本校验和数据排除脚本逻辑;`tests/test_gui.py` 改为断言窗口标题读取统一版本源。
- 边界:不做 Launcher、manifest、sha256 下载校验、在线更新、强制更新或自动替换程序目录;未改 DB schema、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-540 修正 · 打包兼容 Python 3.7.9
- 需求:用户确认当前项目在 Python 3.7.9 环境可运行,打包文档与脚本不应继续要求 Python 3.10+。
- 代码:`scripts/build_exe.ps1` 的最低版本校验改为 Python 3.7.9;低于 3.7.9 才失败。
- 文档:`docs/packaging.md`、`docs/03-tech-stack.md`、`docs/06-tasks.md`、`docs/current-state.md` 改为当前发布构建兼容 Python 3.7.9+,CI 继续使用 Python 3.11。
- 测试:`tests/test_packaging.py` 改为断言构建脚本包含 Python 3.7.9 最低版本校验,并防止重新写回 Python 3.10+ 阻断。
- 边界:只改打包版本要求、文档和测试;未改运行依赖版本、业务逻辑、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-540 修正 · 打包固定使用 Python 3.10
- 需求:用户已安装 Python 3.10,正式打包需要固定使用 Python 3.10,避免 PATH 上的 Python 3.7.9 或其他版本参与发布构建。
- 代码:`scripts/build_exe.ps1` 改为固定调用 Windows Python Launcher 的 `py -3.10`,读取到的版本必须是 `3.10.x`;`python -m PyInstaller` 改为 `py -3.10 -m PyInstaller`,并在 PyInstaller 退出码非 0 时直接失败。
- 文档:`docs/packaging.md`、`docs/03-tech-stack.md`、`docs/06-tasks.md`、`docs/current-state.md` 改为正式打包固定 Python 3.10;安装打包依赖命令改为 `py -3.10 -m pip install -r requirements-build.txt`。
- 测试:`tests/test_packaging.py` 改为断言构建脚本固定 `py -3.10`,且不再使用裸 `python -m PyInstaller` 或 3.7.9 最低版本口径。
- 验证:`py -3.10 -m pip install -r requirements-build.txt` 成功;`py -3.10 -m compileall app main.py` 通过;`py -3.10 -m unittest discover -s tests` 通过(219 tests);`powershell -ExecutionPolicy Bypass -File scripts\build_exe.ps1` 成功,输出显示 `使用 Python 3.10: 3.10.11` 并生成 `release\cmshopee-0.1.0-portable.zip`。
- 边界:只改正式打包解释器选择、文档和测试;未改运行依赖版本、业务逻辑、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-541 文档 · 打包版窗口左上角显示不全
- 现象:运行打包后的 `dist/cmshopee/cmshopee.exe` / release 包时,Windows 10 虚拟机或小分辨率环境可能出现主窗口贴到屏幕左上角、左边和标题栏显示不全,用户看不到品牌标题且无法拖动窗口到中间。
- 原因:`MainWindow.__init__()` 当前只 `resize(1180, 760)`,没有读取 `QApplication.primaryScreen().availableGeometry()` 限制初始尺寸、居中显示,也没有保证窗口 frame/title bar 完整落在可用屏幕内。
- 文档:`docs/06-tasks.md` 新增 T-541;`docs/troubleshooting.md` 增加临时处理(`Alt+Space` → `M` → 方向键移动)和正式修复方案;`docs/packaging.md` 打包验收清单新增标题栏完整可见/可拖动检查;`docs/current-state.md` 记录 T-541 为下一步优先修复。
- 方案:后续代码在主窗口启动时根据屏幕可用区域限制尺寸并居中,保证标题栏可见;小屏继续适配,不保存坏的历史窗口坐标。
- 边界:本轮只更新文档,未改 GUI 代码、打包脚本、业务逻辑、DB、AI、Excel、CDP 或 Shopee 流程。
## 【2026-07-07】T-541 完成 · 打包版主窗口初始位置与小屏适配
- 状态:DONE
- 代码:`app/gui/main_window.py` 新增 `_fit_and_center_window()`,启动时读取 `QApplication.primaryScreen().availableGeometry()`,将主窗口尺寸限制在可用屏幕范围内并居中;首次 `showEvent` 后再应用一次,避免打包版在 Windows 10 VM/小分辨率环境标题栏出屏。
- 文档:`docs/06-tasks.md` 将 T-541 标记为 DONE;`docs/troubleshooting.md`、`docs/packaging.md`、`docs/current-state.md` 更新为当前修复与打包验收口径。
- 测试:`tests/test_gui.py` 新增小屏和大屏 mock geometry 单测,覆盖尺寸限制与居中位置;`scripts/build_exe.ps1` 已重新构建 release,确认 T-541 合入后仍可打包。
- 边界:不保存/恢复窗口历史坐标;未改业务流程、DB、AI、Excel、CDP/Shopee、打包产物结构或用户数据路径。
## 【2026-07-07】T-540 修正 · 当前打包布局统一为 PyInstaller 6
- 现象:T-540 代码和 `requirements-build.txt` 已固定 PyInstaller 6.11.1,构建脚本也会校验 `_internal/`,但 `docs/packaging.md`、`docs/03-tech-stack.md`、`docs/06-tasks.md`、`docs/current-state.md` 仍有当前 PyInstaller 5.13.2 扁平 onedir 的表述。
- 文档:已把当前打包口径统一为 PyInstaller 6.11.1,产物必须包含 `cmshopee.exe` + `_internal/`;用户升级说明改为整体覆盖新版程序文件、`_internal/`、`version.txt`、`README.txt`,并保留旧目录 `data/`。
- 边界:只修正文档一致性;历史 T-538 流水仍保留当时 PyInstaller 5 的记录;未改业务流程、DB、AI、Excel、CDP/Shopee 或用户数据路径。