s
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import importlib.util
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
@@ -25,6 +26,21 @@ def _local_ips() -> list[str]:
|
||||
return out[:4]
|
||||
|
||||
|
||||
def _node_major() -> tuple[int | None, str | None]:
|
||||
node = shutil.which("node")
|
||||
if not node:
|
||||
return None, None
|
||||
try:
|
||||
raw = subprocess.check_output([node, "-v"], stderr=subprocess.STDOUT, text=True).strip()
|
||||
except Exception:
|
||||
return None, node
|
||||
try:
|
||||
major = int(raw.lstrip("v").split(".", 1)[0])
|
||||
except Exception:
|
||||
major = None
|
||||
return major, f"{node} ({raw})"
|
||||
|
||||
|
||||
def print_env_report(
|
||||
*,
|
||||
dev: bool,
|
||||
@@ -60,12 +76,25 @@ def print_env_report(
|
||||
print("│ ⚠ 未找到 ffplay(HDMI 全屏播放需要完整 ffmpeg 套件)")
|
||||
|
||||
if need_npm:
|
||||
major, node_desc = _node_major()
|
||||
npm = shutil.which("npm")
|
||||
docker = shutil.which("docker")
|
||||
if node_desc:
|
||||
if major is not None and major < 18:
|
||||
print(f"│ ⚠ Node: {node_desc}(Next.js 推荐 Node 18+;可自动尝试 Docker 兜底)")
|
||||
else:
|
||||
print(f"│ ✓ Node: {node_desc}")
|
||||
else:
|
||||
print("│ ✕ 未找到 Node.js(Next.js 构建/开发需要 Node 18+ 或 Docker 兜底)")
|
||||
ok = False
|
||||
if npm:
|
||||
print(f"│ ✓ npm: {npm}")
|
||||
else:
|
||||
print("│ ✕ 未找到 npm(构建/开发前端需要安装 Node.js)")
|
||||
ok = False
|
||||
print("│ ⚠ 未找到 npm(若有 Node 18+ 通常可用;否则请安装完整 Node 或启用 Docker)")
|
||||
if docker:
|
||||
print(f"│ ✓ Docker: {docker}")
|
||||
elif major is None or (major is not None and major < 18):
|
||||
print("│ ⚠ 无 Docker 时,Node 过低会依赖本机升级才能构建前端")
|
||||
|
||||
print("│")
|
||||
print("│ 同机端口提示(若冲突请在 config/runtime.env 修改 PORT):")
|
||||
|
||||
Reference in New Issue
Block a user