refactor: Separate runtime from build. Enhance configuration and registry management, migrate to registry-based component handling

This commit is contained in:
2026-02-22 23:19:16 -08:00
parent 033a76ccfd
commit d52d8829ba
37 changed files with 1271 additions and 414 deletions

View File

@@ -18,10 +18,12 @@ def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
"components": {
"test-svc": {
"description": "Test service",
"source": "test-svc",
"run": {
"runner": "python_uv_tool",
"tool": "test-svc",
"working_dir": "test-svc",
},
"defaults": {
"env": {"TEST_SVC_DATA_DIR": str(tmp_path / "data" / "test-svc")},
},
"expose": {

View File

@@ -15,9 +15,10 @@ class TestCreateCommand:
def test_create_service(self, castle_root: Path) -> None:
"""Create a new service project."""
with patch("castle_cli.commands.create.load_config") as mock_load, patch(
"castle_cli.commands.create.save_config"
) as mock_save:
with (
patch("castle_cli.commands.create.load_config") as mock_load,
patch("castle_cli.commands.create.save_config") as mock_save,
):
config = load_config(castle_root)
mock_load.return_value = config
@@ -50,17 +51,16 @@ class TestCreateCommand:
def test_create_tool(self, castle_root: Path) -> None:
"""Create a new tool project."""
with patch("castle_cli.commands.create.load_config") as mock_load, patch(
"castle_cli.commands.create.save_config"
with (
patch("castle_cli.commands.create.load_config") as mock_load,
patch("castle_cli.commands.create.save_config"),
):
config = load_config(castle_root)
mock_load.return_value = config
from castle_cli.commands.create import run_create
args = Namespace(
name="my-tool", type="tool", description="My tool", port=None
)
args = Namespace(name="my-tool", type="tool", description="My tool", port=None)
result = run_create(args)
assert result == 0
@@ -74,17 +74,16 @@ class TestCreateCommand:
def test_create_library(self, castle_root: Path) -> None:
"""Create a new library project."""
with patch("castle_cli.commands.create.load_config") as mock_load, patch(
"castle_cli.commands.create.save_config"
with (
patch("castle_cli.commands.create.load_config") as mock_load,
patch("castle_cli.commands.create.save_config"),
):
config = load_config(castle_root)
mock_load.return_value = config
from castle_cli.commands.create import run_create
args = Namespace(
name="my-lib", type="library", description="My library", port=None
)
args = Namespace(name="my-lib", type="library", description="My library", port=None)
result = run_create(args)
assert result == 0
@@ -114,8 +113,9 @@ class TestCreateCommand:
def test_create_auto_port(self, castle_root: Path) -> None:
"""Service creation auto-assigns next available port."""
with patch("castle_cli.commands.create.load_config") as mock_load, patch(
"castle_cli.commands.create.save_config"
with (
patch("castle_cli.commands.create.load_config") as mock_load,
patch("castle_cli.commands.create.save_config"),
):
config = load_config(castle_root)
mock_load.return_value = config