35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""源码快照打包(原 /tmp/pack.py 丢失,重写)。"""
|
|
import hashlib
|
|
import os
|
|
import zipfile
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
ROOT = Path('/Users/macclaw/Desktop/yawan-workbench')
|
|
OUT = Path('/Users/macclaw/Desktop/私域Agent-重构版-2026-08-29.zip')
|
|
|
|
INCLUDE_DIRS = ['server/app', 'server/tests', 'web/src', 'web/dist', 'scripts', 'docs']
|
|
INCLUDE_FILES = ['server/requirements.txt', 'web/package.json', 'web/vite.config.ts',
|
|
'web/tsconfig.json', 'web/index.html', 'MIGRATION.md',
|
|
'系统功能逻辑文档.html', '用户使用手册.html']
|
|
|
|
count = 0
|
|
with zipfile.ZipFile(OUT, 'w', zipfile.ZIP_DEFLATED) as z:
|
|
for d in INCLUDE_DIRS:
|
|
base = ROOT / d
|
|
if not base.exists():
|
|
continue
|
|
for f in base.rglob('*'):
|
|
if f.is_file() and '__pycache__' not in str(f) and 'node_modules' not in str(f):
|
|
z.write(f, f'私域Agent/{d}/{f.relative_to(base)}')
|
|
count += 1
|
|
for fp in INCLUDE_FILES:
|
|
f = ROOT / fp
|
|
if f.exists() and f.is_file():
|
|
z.write(f, f'私域Agent/{fp}')
|
|
count += 1
|
|
|
|
size = OUT.stat().st_size
|
|
print(f'源码包: {count} 文件 | {size/1024:.0f} KB')
|