"""Verify an installed Art Design Pro checkout and optionally run its real build. Requires the USER's official checkout. A fixture-only installer test never counts as a successful official Vue build. """ from __future__ import annotations import argparse import json import subprocess import sys from pathlib import Path if str(Path(__file__).resolve().parents[1]) not in sys.path: sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from scripts.install_into_art_design_pro import install def verify(path: Path, build: bool = False) -> dict: root = path.expanduser().resolve() result = install(root, verify=True) manifest = root/'src/views/siteforge/.siteforge-v819.json' if not manifest.is_file(): raise ValueError('安装清单缺失,请执行安装器 --apply') data = json.loads(manifest.read_text(encoding='utf-8')) if data.get('siteforge_version') != '8.29.0-dev.1': raise ValueError('安装清单版本不匹配') result.update({'version':data['siteforge_version'],'build':'NOT_RUN'}) if build: if not (root/'node_modules').is_dir(): raise ValueError('缺少 Art Design Pro 官方 npm 依赖;在官方工程先运行 pnpm install --frozen-lockfile') command = ['pnpm','build'] try: out = subprocess.run(command, cwd=root, check=False, capture_output=True, text=True, timeout=300) except (OSError, subprocess.TimeoutExpired) as exc: raise ValueError('真实构建无法完成:'+str(exc)) from exc if out.returncode: raise ValueError(f'pnpm build 失败(退出码 {out.returncode}):'+out.stderr[-2000:]) result['build']='PASS' result['build_stdout_tail']=out.stdout[-1000:] return result if __name__=='__main__': parser=argparse.ArgumentParser() parser.add_argument('official_repo',type=Path) parser.add_argument('--build',action='store_true',help='有官方源码和 node_modules 后执行真实 pnpm build') parser.add_argument('--report',type=Path) a=parser.parse_args() try: result=verify(a.official_repo,build=a.build) if a.report: a.report.parent.mkdir(parents=True,exist_ok=True) a.report.write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8') print(json.dumps(result,ensure_ascii=False,indent=2)) except ValueError as exc: print('BLOCKED/FAILED: '+str(exc),file=sys.stderr) raise SystemExit(1)