2784c5b36f
Previous fix injected base target=_top but the sandbox attribute lacked allow-top-navigation, so the browser blocked link clicks and the user had to Ctrl+Click as a workaround. Fix: sandbox allow-same-origin allow-popups + base target=_blank. Links now open in new tab (better UX, no content loss). Also fix deploy/rebuild.ps1 to read jar from target/ instead of deleted deploy/baota/. Add agent_test/ scripts: create_7_test_projects, upload_test_html, manual_package.
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""Manually package the deploy zip (workaround for PowerShell encoding issues)."""
|
|
import shutil
|
|
import os
|
|
import zipfile
|
|
from datetime import datetime
|
|
|
|
PROJECT_ROOT = r"D:\Idea Project\publish"
|
|
TMP = os.path.join(os.environ["TEMP"], f"publish_deploy_{datetime.now().strftime('%Y%m%d_%H%M%S')}")
|
|
FRONTEND_DIR = os.path.join(TMP, "frontend")
|
|
JAR_SRC = os.path.join(PROJECT_ROOT, "target", "daily-report-distribution-1.0.0.jar")
|
|
ZIP_OUT = os.path.join(PROJECT_ROOT, "deploy", "publish_deploy.zip")
|
|
|
|
# Verify inputs
|
|
assert os.path.exists(JAR_SRC), f"Missing jar: {JAR_SRC}"
|
|
assert os.path.exists(os.path.join(PROJECT_ROOT, "dist", "index.html")), "Missing dist/index.html"
|
|
assert os.path.exists(os.path.join(PROJECT_ROOT, "server.js")), "Missing server.js"
|
|
|
|
# Clean & create
|
|
shutil.rmtree(TMP, ignore_errors=True)
|
|
os.makedirs(FRONTEND_DIR)
|
|
|
|
# Copy frontend build
|
|
shutil.copy2(os.path.join(PROJECT_ROOT, "dist", "index.html"), FRONTEND_DIR)
|
|
shutil.copytree(os.path.join(PROJECT_ROOT, "dist", "assets"),
|
|
os.path.join(FRONTEND_DIR, "assets"))
|
|
shutil.copy2(os.path.join(PROJECT_ROOT, "server.js"), FRONTEND_DIR)
|
|
print(" [OK] Frontend files staged")
|
|
|
|
# Copy backend jar
|
|
shutil.copy2(JAR_SRC, os.path.join(TMP, "app.jar"))
|
|
print(" [OK] Backend jar staged")
|
|
|
|
# Zip
|
|
if os.path.exists(ZIP_OUT):
|
|
os.remove(ZIP_OUT)
|
|
with zipfile.ZipFile(ZIP_OUT, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
for root, dirs, files in os.walk(TMP):
|
|
for f in files:
|
|
full = os.path.join(root, f)
|
|
arc = os.path.relpath(full, TMP)
|
|
zf.write(full, arc)
|
|
|
|
size_mb = os.path.getsize(ZIP_OUT) / 1024 / 1024
|
|
print(f" [OK] Packaged: {size_mb:.1f} MB")
|
|
|
|
# Cleanup
|
|
shutil.rmtree(TMP, ignore_errors=True)
|
|
print(f"\nDone. Output: {ZIP_OUT}")
|