Skip to content

Commit

Permalink
Add cookie-cutter template for custom nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang committed Feb 10, 2025
1 parent e7ccd50 commit 13bfd02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions comfy_cli/command/custom_nodes/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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

Check warning on line 929 in comfy_cli/command/custom_nodes/command.py

View check run for this annotation

Codecov / codecov/patch

comfy_cli/command/custom_nodes/command.py#L929

Added line #L929 was not covered by tests

try:
cookiecutter.main.cookiecutter(

Check warning on line 932 in comfy_cli/command/custom_nodes/command.py

View check run for this annotation

Codecov / codecov/patch

comfy_cli/command/custom_nodes/command.py#L931-L932

Added lines #L931 - L932 were not covered by tests
"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)

Check warning on line 939 in comfy_cli/command/custom_nodes/command.py

View check run for this annotation

Codecov / codecov/patch

comfy_cli/command/custom_nodes/command.py#L936-L939

Added lines #L936 - L939 were not covered by tests
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies = [
"websocket-client",
"ruff",
"semver~=3.0.2",
"cookiecutter",
]

[project.optional-dependencies]
Expand Down

0 comments on commit 13bfd02

Please sign in to comment.