/**
 * 在 Windows 上通过 start cmd 打开独立终端窗口分别启动各服务
 */
const { exec } = require('child_process')

const services = [
  {
    name: '后端',
    title: 'GPU Guard - 后端 (8003)',
    command: 'pnpm --filter @gpu-guard/backend dev'
  },
  {
    name: '前端',
    title: 'GPU Guard - 前端 (9001)',
    command: 'pnpm --filter @gpu-guard/frontend dev'
  },
  {
    name: '桌面端',
    title: 'GPU Guard - 桌面端 (Tauri)',
    command: 'pnpm --filter @gpu-guard/desktop dev'
  }
]

console.log('🚀 启动 AI Flow 服务...\n')
console.log('各服务将在独立终端窗口中运行：')
console.log('  - 后端: http://localhost:8003')
console.log('  - 前端: http://localhost:9001')
console.log('   - 桌面端: Tauri 窗口\n')

for (const service of services) {
  // 使用 Windows start 命令在新窗口中运行，/k 保持窗口不关闭
  const cmd = `start cmd /k "title ${service.title} && ${service.command}"`
  console.log(`📦 启动 ${service.name}...`)
  exec(cmd, { shell: 'cmd.exe' })
}

console.log('✅ 所有服务已在新窗口中启动！\n')
