Add backend-only deployment option

This commit is contained in:
王鹏
2026-10-09 09:40:30 +08:00
parent 414218c0bd
commit eb5a276f44
5 changed files with 67 additions and 3 deletions

View File

@@ -421,6 +421,47 @@ class DeployerTests(unittest.TestCase):
self.assertIn("用户端: http://localhost:8082/", combined)
self.assertIn("管理端: http://localhost:8081/", combined)
def test_backend_only_plan_keeps_sql_and_skips_all_frontend_steps(self):
with TemporaryDirectory() as temp:
root = Path(temp)
backend = root / "server"
frontend = root / "web"
database = root / "db"
(backend / "target").mkdir(parents=True)
(backend / "target" / "app.jar").write_text("jar", encoding="utf-8")
frontend.mkdir()
(frontend / "package.json").write_text(
'{"scripts":{"serve":"vue-cli-service serve"}}', encoding="utf-8"
)
database.mkdir()
sql_file = database / "schema.sql"
sql_file.write_text("CREATE TABLE demo(id INT);", encoding="utf-8")
scan = ScanResult(
root=root,
backend=ProjectComponent("Spring Boot", backend, "Maven project"),
frontend=ProjectComponent("Vue", frontend, "Vue project"),
sql_files=[sql_file],
)
plan = build_deployment_plan(
scan,
DeploymentConfig(
backend_only=True,
mysql_database="demo",
output_dir=root / "deploy",
tool_search_roots=[root / "missing"],
),
)
kinds = [step.kind for step in plan]
self.assertEqual(
kinds,
["backend_build_skip", "sql_import", "backend_start", "deployment_summary"],
)
self.assertFalse(any(kind.startswith("frontend_") for kind in kinds))
self.assertEqual(plan[-1].description.count("http://"), 1)
self.assertIn("后端:", plan[-1].description)
def test_plan_uses_executable_steps_without_shell_placeholders(self):
with TemporaryDirectory() as temp:
root = Path(temp)