From 817a91b30e0d4e6edc9a1e5872bbbaf39b27784b Mon Sep 17 00:00:00 2001 From: rgthree Date: Sat, 2 Dec 2023 00:11:26 -0500 Subject: [PATCH] Switch to WEB_DIRECTORY pattern. Fixes #63 --- .gitignore | 3 ++- __init__.py | 29 ++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 813279a..ebe3afb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ wildcards/** .vscode/ .idea/ node_modules/ -rgthree_config.json \ No newline at end of file +rgthree_config.json +web/rgthree_config.js \ No newline at end of file diff --git a/__init__.py b/__init__.py index f241a92..dcce56f 100644 --- a/__init__.py +++ b/__init__.py @@ -52,25 +52,20 @@ NODE_CLASS_MAPPINGS = { } -# This doesn't import correctly.. -# WEB_DIRECTORY = "./web" +WEB_DIRECTORY = "./web" THIS_DIR = os.path.dirname(os.path.abspath(__file__)) -DIR_DEV_WEB = os.path.abspath(f'{THIS_DIR}/web/') +DIR_WEB = os.path.abspath(f'{THIS_DIR}/web/') DIR_PY = os.path.abspath(f'{THIS_DIR}/py') -# remove old directory. -OLD_DIR_WEB = os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree') -if os.path.exists(OLD_DIR_WEB): - shutil.rmtree(OLD_DIR_WEB) - -DIR_WEB = os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree-comfy') -if os.path.exists(DIR_WEB): - shutil.rmtree(DIR_WEB) -os.makedirs(DIR_WEB) - -shutil.copytree(DIR_DEV_WEB, DIR_WEB, dirs_exist_ok=True) - +# remove old directories +OLD_DIRS = [ + os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree'), + os.path.abspath(f'{THIS_DIR}/../../web/extensions/rgthree-comfy'), +] +for old_dir in OLD_DIRS: + if os.path.exists(old_dir): + shutil.rmtree(old_dir) def extend_config(default_config, user_config): cfg = {} @@ -92,10 +87,10 @@ with open(os.path.join(DIR_WEB, 'rgthree_config.js'), 'w', encoding = 'UTF-8') a NOT_NODES = ['constants', 'log', 'utils', 'rgthree'] -__all__ = ['NODE_CLASS_MAPPINGS'] +__all__ = ['NODE_CLASS_MAPPINGS', 'WEB_DIRECTORY'] nodes = [] -for file in glob.glob(os.path.join(DIR_PY, '*.py')) + glob.glob(os.path.join(DIR_DEV_WEB, 'js', '*.js')): +for file in glob.glob(os.path.join(DIR_PY, '*.py')) + glob.glob(os.path.join(DIR_WEB, 'js', '*.js')): name = os.path.splitext(file)[0] if name not in nodes and name not in NOT_NODES and not name.startswith( '_') and not name.startswith('base') and not 'utils' in name: