|
|
|
|
|
# Windows BAT 部署启动器 Implementation Plan
|
|
|
|
|
|
|
|
|
|
|
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
|
|
|
|
|
|
|
|
|
|
**Goal:** 为现有 PowerShell 部署流程提供可双击运行的 Windows BAT 启动器。
|
|
|
|
|
|
|
|
|
|
|
|
**Architecture:** 每个 BAT 以 `%~dp0` 切换到部署目录,使用系统 `powershell.exe` 调用对应 PS1,保存退出码并暂停显示结果。
|
|
|
|
|
|
|
|
|
|
|
|
**Tech Stack:** Windows CMD、BAT、Windows PowerShell 5.1。
|
|
|
|
|
|
|
|
|
|
|
|
## Global Constraints
|
|
|
|
|
|
|
|
|
|
|
|
- 文件位置固定为 `E:\workspace\dianshang\deploy\automation`。
|
|
|
|
|
|
- 不修改现有 PS1 逻辑,不保存或显示任何密码、私钥或数据库配置。
|
|
|
|
|
|
- 三个 BAT 分别调用 `Initialize-SshKey.ps1`、`deploy.ps1 -InitializeOnly` 和 `deploy.ps1`。
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
### Task 1: 创建并验证 BAT 启动器
|
|
|
|
|
|
|
|
|
|
|
|
**Files:**
|
|
|
|
|
|
- Create: `E:\workspace\dianshang\deploy\automation\01_setup_ssh.bat`
|
|
|
|
|
|
- Create: `E:\workspace\dianshang\deploy\automation\02_initialize_server.bat`
|
|
|
|
|
|
- Create: `E:\workspace\dianshang\deploy\automation\03_deploy.bat`
|
|
|
|
|
|
|
|
|
|
|
|
**Interfaces:**
|
|
|
|
|
|
- Consumes: 同目录的 `Initialize-SshKey.ps1` 与 `deploy.ps1`。
|
|
|
|
|
|
- Produces: 可在 CMD 中执行或通过资源管理器双击运行的入口文件。
|
|
|
|
|
|
|
|
|
|
|
|
- [ ] **Step 1: 写入失败验证命令**
|
|
|
|
|
|
|
|
|
|
|
|
```bat
|
|
|
|
|
|
cmd.exe /d /c "E:\workspace\dianshang\deploy\automation\01_setup_ssh.bat"
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Expected: FAIL,因为 BAT 尚不存在。
|
|
|
|
|
|
|
|
|
|
|
|
- [ ] **Step 2: 创建三个最小 BAT 文件**
|
|
|
|
|
|
|
|
|
|
|
|
每个文件采用以下固定结构,其中 `<ps1-and-arguments>` 分别替换为 `Initialize-SshKey.ps1`、`deploy.ps1 -InitializeOnly`、`deploy.ps1`:
|
|
|
|
|
|
|
|
|
|
|
|
```bat
|
|
|
|
|
|
@echo off
|
|
|
|
|
|
setlocal
|
|
|
|
|
|
cd /d "%~dp0"
|
|
|
|
|
|
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0<ps1-and-arguments>"
|
|
|
|
|
|
set "exitCode=%ERRORLEVEL%"
|
|
|
|
|
|
echo.
|
|
|
|
|
|
if not "%exitCode%"=="0" echo Failed with exit code %exitCode%.
|
|
|
|
|
|
pause
|
|
|
|
|
|
exit /b %exitCode%
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
- [ ] **Step 3: 验证 BAT 会启动预期 PowerShell 文件**
|
|
|
|
|
|
|
|
|
|
|
|
Run: `cmd.exe /d /c "E:\workspace\dianshang\deploy\automation\02_initialize_server.bat"`
|
|
|
|
|
|
|
|
|
|
|
|
Expected: 由于尚未建立 SSH 密钥或本地配置,PowerShell 报出缺失配置或连接错误;CMD 不出现“选择一个应用以打开此 .ps1 文件”。
|
|
|
|
|
|
|
|
|
|
|
|
- [ ] **Step 4: 检查每个 BAT 的命令解释与退出码传递**
|
|
|
|
|
|
|
|
|
|
|
|
Run: `for %f in (01_setup_ssh.bat 02_initialize_server.bat 03_deploy.bat) do @cmd.exe /d /c "type E:\workspace\dianshang\deploy\automation\%f"`
|
|
|
|
|
|
|
|
|
|
|
|
Expected: 每个文件包含 `cd /d "%~dp0"`、`powershell.exe`、`set "exitCode=%ERRORLEVEL%"` 与 `exit /b %exitCode%`。
|