Files
37duAutomation/plugins/XQ0001-0100/XQ0047 微盟数据导出/_pack.py
T
puddy 01b21551c4 feat(XQ0047): 微盟数据导出插件 v1.0.2 版本更新,拆分合并单元格并优化导出
新增合并单元格拆分逻辑,将微盟导出Excel中同一订单的纵向合并单元格值填充到区域内每一行,使每行数据自包含便于筛选统计
更新插件版本号、打包脚本及需求文档中的版本信息
2026-10-21 16:16:34 +08:00

45 lines
1.8 KiB
Python
Raw 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 -*-
"""发布打包辅助(开发工具,`_` 前缀运行时不会被插件扫描加载)。
把本插件压成 dist-plugin/xq0047_v<版本>.zip,
包根布局:plugin.json / 各 .py / ui / requirements.txt 直接位于 zip 根。
排除项:ui-src、__pycache__、debug、.sessions、本脚本、*.pyc。
用法(仓库根下执行):
.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0047 微盟数据导出\\_pack.py"
随后发布(desktop/ 下执行,见 docs/插件/发版规范.md):
.venv\\Scripts\\python.exe -m controlplane.tools.agent_cli publish \\
dist-plugin/xq0047_v1.0.2.zip --id xq0047 --version 1.0.2
"""
import json
import zipfile
from pathlib import Path
_HERE = Path(__file__).resolve().parent
# 仓库根 = plugins/XQ0001-0100/<插件目录>/ 的 parents[2],统一出包位置
_OUT_DIR = _HERE.parents[2] / "dist-plugin"
_EXCLUDE_DIRS = {"ui-src", "__pycache__", "debug", ".sessions"}
_EXCLUDE_FILES = {"_pack.py"}
def main():
manifest = json.loads((_HERE / "plugin.json").read_text(encoding="utf-8"))
pid, ver = manifest["id"], manifest["version"]
ui_index = _HERE / "ui" / "index.html"
if not ui_index.exists():
raise SystemExit(f"缺少构建产物 {ui_index}:请先在 ui-src 下 npm run build")
_OUT_DIR.mkdir(exist_ok=True)
out = _OUT_DIR / f"{pid}_v{ver}.zip"
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as zf:
for p in sorted(_HERE.rglob("*")):
rel = p.relative_to(_HERE)
if set(rel.parts) & _EXCLUDE_DIRS or p.name in _EXCLUDE_FILES or p.suffix == ".pyc":
continue
if p.is_file():
zf.write(p, str(rel))
print(f"已打包: {out}({out.stat().st_size / 1024:.0f} KB)")
if __name__ == "__main__":
main()