From c31f0b241fdebf119e2d34bf96b87b8c0dfc90c6 Mon Sep 17 00:00:00 2001 From: h Date: Tue, 8 Sep 2026 20:40:21 +0200 Subject: [PATCH] TEMPLATES_REF for template development --- README.md | 2 +- templates.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6dea8f8..a2c3ba2 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,6 @@ updateproject backend # one part newproject ~/projects/my-thing --parts backend,frontend,caddy --backend python --frontend svelte --serve bun --defaults ``` -One part alone is rendered at the root of the project; two parts live in `backend/` and `frontend/`. Templates are cloned from `https://git.kotikot.com/templates` unless `TEMPLATES_DIR` points at a directory with local checkouts. +One part alone is rendered at the root of the project; two parts live in `backend/` and `frontend/`. Templates are cloned from `https://git.kotikot.com/templates` unless `TEMPLATES_DIR` points at a directory with local checkouts; `TEMPLATES_REF=HEAD` renders their working trees instead of the latest tag. Requires `uv`; `bun`, `docker` and `pre-commit` are used by the generated projects. diff --git a/templates.py b/templates.py index 7892007..96d528e 100644 --- a/templates.py +++ b/templates.py @@ -13,6 +13,7 @@ import questionary from copier import run_copy, run_update SOURCE = os.environ.get("TEMPLATES_DIR", "https://git.kotikot.com/templates") +REF = os.environ.get("TEMPLATES_REF") BACKENDS = {"python": "backend-python"} FRONTENDS = {"svelte": "frontend-svelte"} SERVE = ["bun", "static", "api"] @@ -72,7 +73,7 @@ def new(args: argparse.Namespace) -> None: routes = [r for r, ok in (("api", backend), ("frontend", frontend and serve != "api")) if ok] def copy(name: str, data: dict) -> None: - run_copy(template(name), dest, data=data, unsafe=True, defaults=args.defaults) + run_copy(template(name), dest, data=data, unsafe=True, defaults=args.defaults, vcs_ref=REF) dest.mkdir(parents=True, exist_ok=True) copy("infra", {"layout": "single" if single else "parts", "parts": [] if single else stack})