Files
cms-SiteForge/scripts/install_into_art_design_pro.py
T
浅念 3c57c167f2 chore: import SiteForge Factory V5 source (baseline)
导入 SiteForge Factory V5 基线源码:
- FastAPI + SQLite + Docker Compose(Web + Worker)架构
- 四套商业主题 × 14 页面模板(1.1.0,含历史版本快照)
- 四种建站模式骨架 + 迁移审计 + 发布门禁
- 52 项 pytest 测试
- 补全计划主文档 docs/superpowers/plans/

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-22 10:42:19 +08:00

41 lines
2.6 KiB
Python

"""Offline installer for SiteForge components into a user-provided official Art Design Pro checkout.
Run with --dry-run first. It does NOT download, modify auth schemes, or
pretend to have compiled the official repository in this sandbox.
"""
import argparse,shutil,re
from pathlib import Path
SOURCE=Path(__file__).resolve().parents[1]/'integrations'/'art-design-pro'/'src'/'views'/'siteforge'
MARKER='// SITEFORGE_FACTORY_V2_REGISTERED'
ROUTES='''\n // SITEFORGE_FACTORY_V2_REGISTERED\n {\n path: '/siteforge', name: 'SiteForge', component: '/index/index',\n meta: {title:'网站工厂',icon:'ri:layout-grid-line'},\n children: [\n {path:'factory',name:'SiteForgeFactory',component:'/siteforge/WebsiteFactory',meta:{title:'网站项目'}},\n {path:'themes',name:'SiteForgeThemes',component:'/siteforge/ThemeCenter',meta:{title:'主题与版本'}},\n {path:'enterprise',name:'SiteForgeEnterprise',component:'/siteforge/EnterpriseCenter',meta:{title:'迁移与交付'}},\n ]\n },\n'''
def install(root:Path,dry_run:bool):
base=root/'src'/'router'/'routes'/'asyncRoutes.ts'
target=root/'src'/'views'/'siteforge'
if not base.is_file() or not (root/'package.json').is_file():raise ValueError('不是受支持的 Art Design Pro 源码目录')
original=base.read_text(encoding='utf-8')
pat=r'(export\s+const\s+asyncRoutes\s*:[^=]*=\s*\[)'
if MARKER not in original:
modified,count=re.subn(pat,lambda m:m.group(1)+ROUTES,original,count=1)
if count!=1:raise ValueError('无法定位 asyncRoutes 定义;该官方版本的路由结构可能不同,请人工集成')
else:modified=original
print(f'官方工程: {root}\n文件目标: {target}\n待复制页面: {len(list(SOURCE.glob("*.vue")))}\n路由需要更新: {original!=modified}')
if dry_run:return
target.mkdir(parents=True,exist_ok=True)
for src in SOURCE.glob('*.vue'):
dest=target/src.name
if dest.exists():shutil.copy2(dest,dest.with_suffix('.vue.siteforge-backup'))
shutil.copy2(src,dest)
if modified!=original:
shutil.copy2(base,base.with_suffix('.ts.siteforge-backup'))
base.write_text(modified,encoding='utf-8')
print('业务页面与菜单已写入;下一步请配置 /api、/editor、/preview 代理并执行 pnpm build 完成验收。')
if __name__=='__main__':
parser=argparse.ArgumentParser()
parser.add_argument('official_repo',type=Path)
parser.add_argument('--apply',action='store_true',help='执行源代码变更;不传则只检查')
args=parser.parse_args()
install(args.official_repo.resolve(),dry_run=not args.apply)