Files
cms-SiteForge/scripts/install_into_art_design_pro.py
T
浅念 8cea7dee20 chore: baseline V8.10.0-dev.1 with v8_workflows type-mapping fix and trade-pro spec
- SiteForge Enterprise V8.10.0-dev.1 upstream source (210 tests)
- Fix: v8_workflows._mapped_input now reads both 类型/分类 columns so WXR
  imports keep post/product types instead of collapsing to page
- Docs: trade-pro theme port spec (R3) and implementation plan

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

53 lines
3.4 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_V7_REGISTERED'
V8_MARKER='// SITEFORGE_FACTORY_V8_REGISTERED'
V8_ROUTES="""
// SITEFORGE_FACTORY_V8_REGISTERED
{ path:'/siteforge/production', name:'SiteForgeV8Production', component:'/siteforge/V8Production',
meta:{title:'V8 生产控制台',icon:'ri:factory-line'} },
"""
ROUTES='''\n // SITEFORGE_FACTORY_V7_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:'企业控制'}},
{path:'editor',name:'SiteForgeEditor',component:'/siteforge/VisualEditor',meta:{title:'可视化编辑'}},
{path:'migration',name:'SiteForgeMigration',component:'/siteforge/MigrationCenter',meta:{title:'CMS 迁移'}},
{path:'releases',name:'SiteForgeReleases',component:'/siteforge/ReleaseCenter',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
if V8_MARKER not in modified:
modified,count=re.subn(pat,lambda m:m.group(1)+V8_ROUTES,modified,count=1)
if count!=1:raise ValueError('无法注册 V8 业务页面')
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)