refactor: Remove castle sync command

Sync was a bootstrap command that ran `git submodule update` and `uv tool install` for each program. Neither machine uses git submodules anymore, and the install functionality is already available as a program action (`POST /programs/{name}/install`).

Removed files:
- cli/src/castle_cli/commands/sync.py

Updated files:
- cli/src/castle_cli/main.py (removed sync subparser and dispatch)
- README.md (removed sync from Quick Start and CLI reference)
This commit is contained in:
2026-04-27 21:57:08 -07:00
parent 9fd2221e05
commit e1a9386177
3 changed files with 0 additions and 116 deletions

View File

@@ -21,9 +21,6 @@ services: {}
jobs: {} jobs: {}
EOF EOF
# Sync all projects (git submodules + dependencies)
castle sync
# See what's here # See what's here
castle list castle list
@@ -64,7 +61,6 @@ castle test [NAME] Run tests (one or all)
castle lint [NAME] Run linter (one or all) castle lint [NAME] Run linter (one or all)
castle deploy [NAME] Deploy to ~/.castle/ (spec -> runtime) castle deploy [NAME] Deploy to ~/.castle/ (spec -> runtime)
castle run NAME Run a service in the foreground castle run NAME Run a service in the foreground
castle sync Sync submodules + install deps
castle logs NAME [-f] [-n 50] View service/job logs castle logs NAME [-f] [-n 50] View service/job logs
castle gateway start|stop|reload Manage Caddy reverse proxy castle gateway start|stop|reload Manage Caddy reverse proxy
castle service enable|disable NAME Manage a systemd service castle service enable|disable NAME Manage a systemd service

View File

@@ -1,104 +0,0 @@
"""castle sync - sync submodules and install dependencies."""
from __future__ import annotations
import argparse
import shutil
import subprocess
from pathlib import Path
from castle_cli.config import ensure_dirs, load_config
def run_sync(args: argparse.Namespace) -> int:
"""Sync submodules and install dependencies in all projects."""
config = load_config()
ensure_dirs()
# Update git submodules
print("Updating git submodules...")
result = subprocess.run(
["git", "submodule", "update", "--init", "--recursive"],
cwd=config.root,
)
if result.returncode != 0:
print("Warning: git submodule update failed (may not be a git repo)")
# Sync dependencies in each component's source directory
all_ok = True
synced_dirs: set[Path] = set()
for name, comp in config.programs.items():
source_dir = comp.source_dir
if not source_dir:
continue
project_dir = config.root / source_dir
if project_dir in synced_dirs or not project_dir.is_dir():
continue
# Determine sync command based on project type
cmd = None
if (project_dir / "pyproject.toml").exists():
cmd = ["uv", "sync"]
elif (project_dir / "package.json").exists():
pm = "pnpm" if (project_dir / "pnpm-lock.yaml").exists() else "npm"
cmd = [pm, "install"]
if cmd is None:
continue
label = cmd[0]
print(f"\nSyncing {name} ({label})...")
result = subprocess.run(cmd, cwd=project_dir)
if result.returncode != 0:
print(f" Warning: sync failed for {name}")
all_ok = False
else:
print(" OK")
synced_dirs.add(project_dir)
# Install python-runner services as uv tools
uv_path = shutil.which("uv") or "uv"
installed_dirs: set[Path] = set()
for name, svc in config.services.items():
if svc.run.runner != "python":
continue
# Find source from component reference
source = None
if svc.component and svc.component in config.programs:
source = config.programs[svc.component].source_dir
if not source:
continue
source_dir = config.root / source
if source_dir in installed_dirs:
continue
if (source_dir / "pyproject.toml").exists():
print(f"\nInstalling {name}...")
prog = config.programs.get(svc.component or "") if svc.component else None
extras = prog.install_extras if prog else []
pkg_spec = str(source_dir)
if extras:
pkg_spec += "[" + ",".join(extras) + "]"
result = subprocess.run(
[uv_path, "tool", "install", "--editable", pkg_spec, "--force"],
capture_output=True,
text=True,
)
if result.returncode != 0:
if "already installed" in result.stderr.lower():
print(f" {name}: already installed")
else:
print(f" Warning: {result.stderr.strip()}")
all_ok = False
else:
print(f" {name}: OK")
installed_dirs.add(source_dir)
if all_ok:
print("\nAll projects synced.")
else:
print("\nSync completed with warnings.")
return 0

View File

@@ -59,9 +59,6 @@ def build_parser() -> argparse.ArgumentParser:
build_parser = subparsers.add_parser("build", help="Build projects") build_parser = subparsers.add_parser("build", help="Build projects")
build_parser.add_argument("project", nargs="?", help="Project to build (default: all)") build_parser.add_argument("project", nargs="?", help="Project to build (default: all)")
# castle sync
subparsers.add_parser("sync", help="Sync submodules and install dependencies")
# castle gateway # castle gateway
gateway_parser = subparsers.add_parser("gateway", help="Manage the Caddy gateway") gateway_parser = subparsers.add_parser("gateway", help="Manage the Caddy gateway")
gateway_sub = gateway_parser.add_subparsers(dest="gateway_command") gateway_sub = gateway_parser.add_subparsers(dest="gateway_command")
@@ -163,11 +160,6 @@ def main() -> int:
return run_build(args) return run_build(args)
elif args.command == "sync":
from castle_cli.commands.sync import run_sync
return run_sync(args)
elif args.command == "gateway": elif args.command == "gateway":
from castle_cli.commands.gateway import run_gateway from castle_cli.commands.gateway import run_gateway