Files

44 lines
1.3 KiB
Python
Executable File
Raw Permalink 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.
#!/usr/bin/env python3
"""太初统一部署入口:自动识别当前系统,调用对应的一键部署脚本,无需人为选择。
用法(任选其一,效果相同):
任何系统:python deploy.py
Windows:双击 deploy.bat
macOS/Linux:bash deploy.sh
"""
from __future__ import annotations
import platform
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
def detect_target(system: str | None = None):
"""系统名 → 部署脚本目标;无法识别返回 None。"""
s = (system or platform.system()).lower()
if s == "windows":
return "windows"
if s == "darwin":
return "macos"
if s == "linux":
return "linux"
return None
def main() -> int:
target = detect_target()
if target is None:
print(f"[错误] 无法识别的系统:{platform.system()}。")
print("请手动运行 scripts/ 下对应脚本,或参考 docs/03-部署指南/DEPLOY.md。")
return 1
print(f"检测到系统:{platform.system()} → 自动使用 {target} 一键部署脚本")
if target == "windows":
return subprocess.call(["cmd", "/c", str(ROOT / "scripts" / "deploy_windows.bat")])
return subprocess.call(["bash", str(ROOT / "scripts" / f"deploy_{target}.sh")])
if __name__ == "__main__":
sys.exit(main())