Files
37duAutomation/plugins/XQ0001-0100/XQ0078 金色湖畔小程序数据导出/_pack.py
T
puddy 6b9102ba6c feat(xq0078): 新增金色湖畔小程序数据导出插件(1.0.4)
- 金贵微信端管理平台(vip6.wechat.goldenyun.cn)门票使用统计导出:接口登录 → 搜索接口取核销明细 → 调平台导出接口生成 xlsx

- 核销时间日期段界面可选(默认昨天 00:00:00 ~ 今天 23:59:59);导出接口异常时按同一份数据本地生成同列序 xlsx 兜底
2026-11-06 15:52:15 +08:00

48 lines
1.9 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/xq0078_v<版本>.zip,
包根布局:plugin.json / 各 .py / config / data / logic / ui 直接位于 zip 根。
排除项:ui-src、__pycache__、debug、.sessions、本脚本、*.pyc。
用法(仓库根下执行):
.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0078 金色湖畔小程序数据导出\\_pack.py"
随后发布(见 docs/插件/发版规范.md,测试通道 → 人工验证 → 转正):
.venv\\Scripts\\python.exe tools\\agent_cli.py publish \\
dist-plugin/xq0078_v1.0.0.zip --id xq0078 --version 1.0.0
"""
import json
import sys
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"]
if manifest.get("ui") and not (_HERE / "ui" / "index.html").is_file():
print("插件声明 ui=true 但缺少 ui/index.html:请先在 ui-src 下 npm run build")
return 1
_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)")
return 0
if __name__ == "__main__":
sys.exit(main())