Skip to content

Commit 981014d

Browse files
authored
Fixed: Zip the correct files in the custom node directory. (#73)
* Improve error messages for Publishing nodes. * Fixed: Zip the correct nodes.
1 parent f96be3a commit 981014d

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

comfy_cli/command/custom_nodes/command.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,19 @@ def registry_install(node_id: str, version: Optional[str] = None):
796796
logging.info(
797797
f"Node {node_id} version {node_version.version} has been successfully installed."
798798
)
799+
800+
801+
@app.command(
802+
"pack",
803+
help="Pack the current node into a tar.gz file. Ignorining .gitignore files.",
804+
)
805+
@tracking.track_command("pack")
806+
def pack():
807+
typer.echo("Validating node configuration...")
808+
config = extract_node_configuration()
809+
if not config:
810+
raise typer.Exit(code=1)
811+
812+
zip_filename = "node.tar.gz"
813+
zip_files(zip_filename)
814+
logging.info("Node has been packed successfully.")

comfy_cli/file_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def parse_json(input_data):
4848
def download_file(
4949
url: str, local_filepath: pathlib.Path, headers: Optional[dict] = None
5050
):
51-
5251
"""Helper function to download a file."""
5352

5453
import httpx
@@ -98,10 +97,9 @@ def zip_files(zip_filename):
9897
dirs.remove(".git")
9998
for file in files:
10099
file_path = os.path.join(root, file)
101-
if not spec.match_file(file_path):
102-
zipf.write(
103-
file_path, os.path.relpath(file_path, os.path.join(root, ".."))
104-
)
100+
relative_path = os.path.relpath(file_path, start=".")
101+
if not spec.match_file(relative_path):
102+
zipf.write(file_path, relative_path)
105103

106104

107105
def upload_file_to_signed_url(signed_url: str, file_path: str):

comfy_cli/registry/config_parser.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
2+
from comfy_cli import ui
33
import tomlkit.exceptions
44
from comfy_cli.registry.types import (
55
PyProjectConfig,
@@ -8,6 +8,7 @@
88
Model,
99
ComfyConfig,
1010
)
11+
from typing import Optional
1112
import tomlkit
1213
import subprocess
1314

@@ -119,9 +120,15 @@ def initialize_project_config():
119120

120121
def extract_node_configuration(
121122
path: str = os.path.join(os.getcwd(), "pyproject.toml"),
122-
) -> PyProjectConfig:
123+
) -> Optional[PyProjectConfig]:
123124
import tomlkit
124125

126+
if not os.path.isfile(path):
127+
ui.display_error_message(
128+
"No pyproject.toml file found in the current directory."
129+
)
130+
return None
131+
125132
with open(path, "r") as file:
126133
data = tomlkit.load(file)
127134

0 commit comments

Comments
 (0)