"""Build all delivery phase 10.2-10.8 files."""
from __future__ import annotations

import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))

FILES: dict[str, str] = {}


def register(rel: str, content: str) -> None:
    FILES[rel] = content.rstrip() + "\n"


def main() -> None:
    _register_repositories()
    _register_specifications()
    _register_validators()
    _register_policies()
    _register_services()
    _register_commands_queries()
    _register_api()
    _register_migrations()
    _register_tests()
    _register_updates()

    for rel, content in sorted(FILES.items()):
        path = ROOT / rel
        path.parent.mkdir(parents=True, exist_ok=True)
        path.write_text(content, encoding="utf-8")
        print(f"wrote {rel}")
    print(f"total: {len(FILES)} files")


if __name__ == "__main__":
    main()
