13 lines
865 B
Python
13 lines
865 B
Python
import pathlib,zipfile,json,hashlib
|
||
root=pathlib.Path('dist');out=pathlib.Path('artifacts/shanhe-puzzle-xhs.zip')
|
||
files=sorted(p for p in root.rglob('*') if p.is_file())
|
||
if len(files)>200:raise SystemExit(f'ZIP文件数量超过200个上限: {len(files)}')
|
||
with zipfile.ZipFile(out,'w',zipfile.ZIP_DEFLATED,compresslevel=9) as z:
|
||
for p in files:z.write(p,p.relative_to(root).as_posix())
|
||
with zipfile.ZipFile(out) as z:
|
||
assert 'index.html' in z.namelist()
|
||
assert z.testzip() is None
|
||
assert len(z.infolist())<=200
|
||
print('离线 ZIP:',out.resolve(),' | ',round(out.stat().st_size/1024),'KB')
|
||
pathlib.Path('artifacts/package-report.json').write_text(json.dumps({'file':str(out),'bytes':out.stat().st_size,'fileCount':len(files),'fileLimit':200,'sha256':hashlib.sha256(out.read_bytes()).hexdigest(),'archiveIntegrity':'passed','rootEntry':'index.html'},indent=2))
|