Skip to content

Commit 3f0cf4f

Browse files
committed
Create validate command for ppl to test using the ruff checks
1 parent ae9b0aa commit 3f0cf4f

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

comfy_cli/command/custom_nodes/command.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,15 +693,11 @@ def deps_in_workflow(
693693
)
694694

695695

696-
@app.command("publish", help="Publish node to registry")
697-
@tracking.track_command("publish")
698-
def publish(
699-
token: Optional[str] = typer.Option(None, "--token", help="Personal Access Token for publishing", hide_input=True),
700-
):
696+
def validate_node_for_publishing():
701697
"""
702-
Publish a node with optional validation.
698+
Validates node configuration and runs security checks.
699+
Returns the validated config if successful, raises typer.Exit if validation fails.
703700
"""
704-
705701
# Perform some validation logic here
706702
typer.echo("Validating node configuration...")
707703
config = extract_node_configuration()
@@ -713,12 +709,10 @@ def publish(
713709
cmd = ["ruff", "check", ".", "-q", "--select", "S102,S307", "--exit-zero"]
714710
result = subprocess.run(cmd, capture_output=True, text=True)
715711

716-
if result.stdout: # Changed from checking returncode to checking if there's output
717-
print("[yellow]Security warnings found:[/yellow]") # Changed from red to yellow to indicate warning
712+
if result.stdout:
713+
print("[yellow]Security warnings found:[/yellow]")
718714
print(result.stdout)
719715
print("[bold yellow]We will soon disable exec and eval, so this will be an error soon.[/bold yellow]")
720-
# TODO: re-enable exit when we disable exec and eval
721-
# raise typer.Exit(code=1)
722716

723717
except FileNotFoundError:
724718
print("[red]Ruff is not installed. Please install it with 'pip install ruff'[/red]")
@@ -727,6 +721,29 @@ def publish(
727721
print(f"[red]Error running security check: {e}[/red]")
728722
raise typer.Exit(code=1)
729723

724+
return config
725+
726+
727+
@app.command("validate", help="Run validation checks for publishing")
728+
@tracking.track_command("publish")
729+
def validate():
730+
"""
731+
Run validation checks that would be performed during publishing.
732+
"""
733+
validate_node_for_publishing()
734+
print("[green]✓ All validation checks passed successfully[/green]")
735+
736+
737+
@app.command("publish", help="Publish node to registry")
738+
@tracking.track_command("publish")
739+
def publish(
740+
token: Optional[str] = typer.Option(None, "--token", help="Personal Access Token for publishing", hide_input=True),
741+
):
742+
"""
743+
Publish a node with optional validation.
744+
"""
745+
config = validate_node_for_publishing()
746+
730747
# Prompt for API Key
731748
if not token:
732749
token = typer.prompt(

0 commit comments

Comments
 (0)