feat(new): one description for every part, mcp servers question

This commit is contained in:
hh committed 2026-10-01 02:02:05 +02:00
1 parent 048f29f21e
commit 7bd4b48b6e
2 files changed
+13 -4

No files matched your search

+2 -2
View File
@@ -9,10 +9,10 @@ updateproject # every part
updateproject backend # one part updateproject backend # one part
``` ```
`newproject` asks for the parts, the backend language, the frontend framework and how the frontend is served, then hands over to each template's own questions. Every prompt has a flag for non-interactive use: `newproject` asks for the description, the parts, the backend language, the frontend framework, how the frontend is served and the MCP servers for `.mcp.json`, then hands over to each template's own questions. Every prompt has a flag for non-interactive use:
```sh ```sh
newproject ~/projects/my-thing --parts backend,frontend,caddy --backend python --frontend svelte --serve bun --defaults newproject ~/projects/my-thing --parts backend,frontend,caddy --backend python --frontend svelte --serve bun --mcp context7,svelte --defaults
``` ```
`other` as the backend or the frontend renders the `blank` template: the part's compose files, Makefile and `.env.example` with no code, for a stack that has no template of its own, next to any other part. `other` as the backend or the frontend renders the `blank` template: the part's compose files, Makefile and `.env.example` with no code, for a stack that has no template of its own, next to any other part.
+11 -2
View File
@@ -18,6 +18,7 @@ BLANK = "blank"
BACKENDS = {"python": "backend-python", "other": BLANK} BACKENDS = {"python": "backend-python", "other": BLANK}
FRONTENDS = {"svelte": "frontend-svelte", "other": BLANK} FRONTENDS = {"svelte": "frontend-svelte", "other": BLANK}
SERVE = ["bun", "static", "api"] SERVE = ["bun", "static", "api"]
MCP = ["context7", "svelte"]
def template(name: str) -> str: def template(name: str) -> str:
@@ -59,6 +60,7 @@ def new(args: argparse.Namespace) -> None:
dest = Path(args.dest).resolve() dest = Path(args.dest).resolve()
name = args.name or ask_text("Project name", dest.name) name = args.name or ask_text("Project name", dest.name)
slug = args.slug or ask_text("Slug", slugify(name)) slug = args.slug or ask_text("Slug", slugify(name))
description = args.description if args.description is not None else ask_text("Description", name)
parts = args.parts.split(",") if args.parts else ask_checkbox("Parts", ["backend", "frontend", "caddy"], ["backend", "frontend", "caddy"]) parts = args.parts.split(",") if args.parts else ask_checkbox("Parts", ["backend", "frontend", "caddy"], ["backend", "frontend", "caddy"])
backend = frontend = None backend = frontend = None
if "backend" in parts: if "backend" in parts:
@@ -69,6 +71,9 @@ def new(args: argparse.Namespace) -> None:
if frontend and FRONTENDS[frontend] != BLANK: if frontend and FRONTENDS[frontend] != BLANK:
options = SERVE if backend else SERVE[:-1] options = SERVE if backend else SERVE[:-1]
serve = args.serve or ask_select("Frontend served by", options, "bun") serve = args.serve or ask_select("Frontend served by", options, "bun")
mcp_default = ["svelte"] if frontend and FRONTENDS[frontend] == "frontend-svelte" else []
mcp = args.mcp.split(",") if args.mcp is not None else ask_checkbox("MCP servers", MCP, mcp_default)
mcp = [m for m in mcp if m]
stack = [p for p in ("backend", "frontend") if p in parts] stack = [p for p in ("backend", "frontend") if p in parts]
single = len(stack) == 1 single = len(stack) == 1
routes = [r for r, ok in (("api", backend), ("frontend", frontend and serve != "api")) if ok] routes = [r for r, ok in (("api", backend), ("frontend", frontend and serve != "api")) if ok]
@@ -85,10 +90,12 @@ def new(args: argparse.Namespace) -> None:
dest.mkdir(parents=True, exist_ok=True) dest.mkdir(parents=True, exist_ok=True)
identity = {"project_name": name, "project_slug": slug} identity = {"project_name": name, "project_slug": slug}
copy("infra", {"project_name": name, "layout": "single" if single else "parts", "parts": [] if single else stack}) copy("infra", {"project_name": name, "project_description": description, "layout": "single" if single else "parts",
"parts": [] if single else stack, "mcp_servers": mcp})
layout = "root" if single else "part" layout = "root" if single else "part"
if backend: if backend:
copy_part("backend", BACKENDS[backend], {"serve_spa": serve == "api", "author_name": git_config("user.name"), copy_part("backend", BACKENDS[backend], {"project_description": description, "serve_spa": serve == "api",
"author_name": git_config("user.name"),
"author_email": git_config("user.email")}) "author_email": git_config("user.email")})
if frontend: if frontend:
copy_part("frontend", FRONTENDS[frontend], {"serve": serve}) copy_part("frontend", FRONTENDS[frontend], {"serve": serve})
@@ -240,10 +247,12 @@ def main() -> None:
n.add_argument("dest") n.add_argument("dest")
n.add_argument("--name") n.add_argument("--name")
n.add_argument("--slug") n.add_argument("--slug")
n.add_argument("--description")
n.add_argument("--parts", help="comma-separated: backend,frontend,caddy") n.add_argument("--parts", help="comma-separated: backend,frontend,caddy")
n.add_argument("--backend", choices=list(BACKENDS)) n.add_argument("--backend", choices=list(BACKENDS))
n.add_argument("--frontend", choices=list(FRONTENDS)) n.add_argument("--frontend", choices=list(FRONTENDS))
n.add_argument("--serve", choices=SERVE) n.add_argument("--serve", choices=SERVE)
n.add_argument("--mcp", help="comma-separated: context7,svelte; empty for none")
n.add_argument("--defaults", action="store_true", help="accept template defaults without asking") n.add_argument("--defaults", action="store_true", help="accept template defaults without asking")
n.set_defaults(func=new) n.set_defaults(func=new)
u = sub.add_parser("update", help="Update every part from its template") u = sub.add_parser("update", help="Update every part from its template")