Initial commit: add AutoDeploy project

This commit is contained in:
wangpeng
2026-07-14 16:30:36 +08:00
commit 2d7b6216ba
23 changed files with 3615 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
# Deploy Tool Workbench Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Build a Python tkinter workbench for detecting and deploying Spring Boot + Vue separated projects.
**Architecture:** Core logic lives in testable modules for scanning, environment checks, and deployment planning. The GUI imports those modules and presents their results in a left-nav workbench with dashboard cards, settings, and logs.
**Tech Stack:** Python 3 standard library, tkinter/ttk, unittest.
---
### Task 1: Core Project Scanner
**Files:**
- Create: `deploy_tool/scanner.py`
- Test: `tests/test_scanner.py`
- [ ] Write tests for detecting backend, frontend, and SQL files from temporary folders.
- [ ] Run `python -m unittest tests.test_scanner` and verify tests fail because the module does not exist.
- [ ] Implement scanner dataclasses and `scan_project`.
- [ ] Run `python -m unittest tests.test_scanner` and verify pass.
### Task 2: Environment Checks
**Files:**
- Create: `deploy_tool/environment.py`
- Test: `tests/test_environment.py`
- [ ] Write tests using an injected command runner for installed and missing commands.
- [ ] Run `python -m unittest tests.test_environment` and verify tests fail because the module does not exist.
- [ ] Implement environment check result types and command checks.
- [ ] Run `python -m unittest tests.test_environment` and verify pass.
### Task 3: Deployment Plan
**Files:**
- Create: `deploy_tool/deployer.py`
- Test: `tests/test_deployer.py`
- [ ] Write tests that generate backend, frontend, and SQL deployment command steps.
- [ ] Run `python -m unittest tests.test_deployer` and verify tests fail because the module does not exist.
- [ ] Implement `build_deployment_plan`.
- [ ] Run `python -m unittest tests.test_deployer` and verify pass.
### Task 4: Workbench GUI
**Files:**
- Create: `deploy_tool/gui.py`
- Create: `main.py`
- [ ] Implement tkinter layout with sidebar, top action bar, dashboard cards, config form, and log output.
- [ ] Wire folder selection, scan, environment check, and deployment plan preview.
- [ ] Keep long operations on background threads and push messages to the UI queue.
### Task 5: Documentation and Verification
**Files:**
- Create: `README.md`
- [ ] Document usage, features, and current local-only deployment scope.
- [ ] Run `python -m unittest`.
- [ ] Run `python -m py_compile main.py deploy_tool/*.py`.

View File

@@ -0,0 +1,44 @@
# Local Auto Deploy Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Turn the local deployment flow from a partly executable command preview into an automatic local deploy runner.
**Architecture:** Keep plan generation in `deploy_tool/deployer.py`, but make deployment steps typed so commands that need runtime context can run without shell placeholders. The runner will build backend and frontend, copy frontend artifacts to the output directory, import SQL through stdin, locate the built jar, and start the backend process.
**Tech Stack:** Python standard library, `unittest`, `subprocess`, `pathlib`, `shutil`.
---
### Task 1: Deployment Step Model
**Files:**
- Modify: `deploy_tool/deployer.py`
- Test: `tests/test_deployer.py`
- [x] Add tests showing SQL import steps no longer contain shell redirection and backend start no longer contains jar placeholders.
- [x] Add fields to `DeploymentStep` for `kind` and optional artifact metadata.
- [x] Update `build_deployment_plan` to emit executable step metadata.
- [x] Run `python -m unittest tests.test_deployer`.
### Task 2: Automatic Runner
**Files:**
- Modify: `deploy_tool/deployer.py`
- Test: `tests/test_deployer.py`
- [x] Add tests for latest jar discovery under `target` or `build/libs`.
- [x] Add tests for frontend artifact copy from `dist` or `build`.
- [x] Add tests with an injected process runner to verify SQL stdin and backend startup command.
- [x] Implement helper functions and dependency injection points for process execution.
- [x] Run `python -m unittest tests.test_deployer`.
### Task 3: GUI Wording and Verification
**Files:**
- Modify: `deploy_tool/gui.py`
- Test: `python -m unittest discover -s tests`
- [x] Update the confirmation text from partial execution to automatic local deployment.
- [x] Run `python -m unittest discover -s tests`.
- [x] Run `python -m py_compile main.py @((Get-ChildItem -LiteralPath .\deploy_tool -Filter *.py).FullName)`.

View File

@@ -0,0 +1,62 @@
# Backend Restart and Health Check Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Restart the process occupying the configured backend port and report deployment success only after the replacement backend is listening.
**Architecture:** Add testable process/port helpers to `deploy_tool/deployer.py`, then compose them in the existing background runner. Add a main-thread deployment state guard to `deploy_tool/gui.py` so both deploy buttons share one running state.
**Tech Stack:** Python standard library, `unittest`, Tkinter, Windows `netstat` and `taskkill`.
---
### Task 1: Listener discovery and process replacement
**Files:**
- Modify: `tests/test_deployer.py`
- Modify: `deploy_tool/deployer.py`
- [ ] Add failing tests for server-port extraction and parsing IPv4/IPv6 `netstat` listener rows.
- [ ] Run the targeted tests and confirm they fail because the helpers do not exist.
- [ ] Implement `_extract_server_port()` and `_parse_windows_listening_pids()`.
- [ ] Run the targeted tests and confirm they pass.
- [ ] Add a failing test proving listener PIDs are terminated and the port must become free before launch.
- [ ] Implement listener lookup, process-tree termination, and bounded port-release polling.
- [ ] Run all deployer tests.
### Task 2: Backend startup readiness
**Files:**
- Modify: `tests/test_deployer.py`
- Modify: `deploy_tool/deployer.py`
- [ ] Add failing tests for early child exit, startup timeout cleanup, and successful readiness.
- [ ] Run the targeted tests and confirm the current immediate-success behavior fails them.
- [ ] Refactor the background runner behind injectable `_restart_backend()` dependencies.
- [ ] Add Windows detached-process creation flags and a timestamped log separator.
- [ ] Poll child state and TCP readiness; return non-zero on early exit or timeout.
- [ ] Run all deployer tests.
### Task 3: Duplicate GUI deployment guard
**Files:**
- Modify: `tests/test_gui_navigation.py`
- Modify: `deploy_tool/gui.py`
- [ ] Add failing tests that a running deployment ignores another invocation and that button state is updated together.
- [ ] Run the targeted tests and confirm failure.
- [ ] Store both deployment button instances, add `deployment_running`, and centralize button state changes.
- [ ] Set the guard before the worker starts and clear it when `deploy_done` is handled.
- [ ] Run GUI tests.
### Task 4: Verification
**Files:**
- Verify: `deploy_tool/deployer.py`
- Verify: `deploy_tool/gui.py`
- Verify: `tests/test_deployer.py`
- Verify: `tests/test_gui_navigation.py`
- [ ] Run `python -m unittest discover -s tests -p 'test_*.py' -v` and require zero failures.
- [ ] Run `python -m compileall -q deploy_tool main.py tests` and require exit code 0.
- [ ] Inspect `git diff --check` and the final diff for unrelated changes.