Files
37duAutomation/plugins/XQ0001-0100/XQ0021 酒店报表导出/_pack.py
T
puddy 1664821117 restore: 恢复 11-06~11-09 本地未提交改动
- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto
- controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图
- electron-shell: 插件同步、注册表、runner 调整
- plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新
- tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
2026-11-09 17:27:10 +08:00

49 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 -*-
"""XQ0021 酒店报表导出 插件打包脚本(统一规范版)。
打包产物统一输出到仓库根 dist-plugin/<id>_v<版本>.zip(目录不入库),
zip 根含 plugin.json,可被 agent_cli publish 直接发布。
用法(任意 cwd 均可):
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0021 酒店报表导出\\_pack.py"
"""
import json
import sys
import zipfile
from pathlib import Path
_HERE = Path(__file__).resolve().parent
_REPO_ROOT = _HERE.parents[2]
_OUT_DIR = _REPO_ROOT / "dist-plugin"
_EXCLUDE_DIRS = {"ui-src", "__pycache__", ".git", ".idea", "debug", ".sessions"}
_EXCLUDE_FILES = {"_pack.py"}
_EXCLUDE_SUFFIXES = (".pyc", ".pyo")
def main():
manifest = json.loads((_HERE / "plugin.json").read_text(encoding="utf-8"))
pid = manifest["id"]
ver = manifest["version"]
if manifest.get("ui") and not (_HERE / "ui" / "index.html").is_file():
sys.exit(f"插件 {pid} 声明 ui=true 但缺少 ui/index.html:请先在 ui-src 下执行 npm install && npm run build")
if not manifest.get("requires", {}).get("sdks"):
print(f"提示:插件 {pid} 未声明 requires.sdks,将不挂载任何 SDK")
_OUT_DIR.mkdir(exist_ok=True)
out = _OUT_DIR / f"{pid}_v{ver}.zip"
count = 0
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 in _EXCLUDE_SUFFIXES:
continue
if p.is_file():
zf.write(p, str(rel))
count += 1
print(f"已打包: {out}({count} 个文件,{out.stat().st_size / 1024:.0f} KB)")
if __name__ == "__main__":
main()