From 13bfd02ca61d3a417cce74edf14b6a5e28f2ea87 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Mon, 10 Feb 2025 15:34:26 -0800 Subject: [PATCH] Add cookie-cutter template for custom nodes. --- comfy_cli/command/custom_nodes/command.py | 19 +++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 20 insertions(+) diff --git a/comfy_cli/command/custom_nodes/command.py b/comfy_cli/command/custom_nodes/command.py index b536eaa..dd12869 100644 --- a/comfy_cli/command/custom_nodes/command.py +++ b/comfy_cli/command/custom_nodes/command.py @@ -8,6 +8,7 @@ import typer from rich import print +from rich.console import Console from typing_extensions import Annotated, List from comfy_cli import logging, tracking, ui, utils @@ -28,6 +29,7 @@ ) from comfy_cli.workspace_manager import WorkspaceManager +console = Console() app = typer.Typer() app.add_typer(bisect_app, name="bisect", help="Bisect custom nodes for culprit node.") manager_app = typer.Typer() @@ -918,3 +920,20 @@ def pack(): zip_files(zip_filename) typer.echo(f"Created zip file: {NODE_ZIP_FILENAME}") logging.info("Node has been packed successfully.") + + +@app.command("scaffold", help="Create a new ComfyUI custom node project using cookiecutter") +@tracking.track_command("node") +def scaffold_cookiecutter(): + """Create a new ComfyUI custom node project using cookiecutter.""" + import cookiecutter.main + + try: + cookiecutter.main.cookiecutter( + "https://github.com/Comfy-Org/cookiecutter-comfy-extension.git", + overwrite_if_exists=True, + ) + console.print("[bold green]✓ Custom node project created successfully![/bold green]") + except Exception as e: + console.print(f"[bold red]Error creating project: {str(e)}[/bold red]") + raise typer.Exit(code=1) diff --git a/pyproject.toml b/pyproject.toml index 7dabe97..328c087 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,7 @@ dependencies = [ "websocket-client", "ruff", "semver~=3.0.2", + "cookiecutter", ] [project.optional-dependencies]