mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 12:17:45 +02:00
[eric] apps: link node_modules on import so imported backend apps boot first time, no restart
This commit is contained in:
@@ -374,7 +374,7 @@ def p_try_link_dir(src: str, target: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def p_link_node_modules(workspace_dir: str) -> None:
|
||||
def link_node_modules(workspace_dir: str) -> None:
|
||||
"""After copytree, point the workspace's frontend/node_modules at
|
||||
the warm-cache directory. Safe fallback; if the cache isn't ready,
|
||||
the workspace's run.sh will fall through to its own install path."""
|
||||
@@ -570,7 +570,7 @@ def seed_webapp_template_workspace(workspace_dir: str, frontend_port: int) -> No
|
||||
dirs_exist_ok=True,
|
||||
)
|
||||
# Symlink the workspace's frontend/node_modules at the warm cache so `npm install` can be skipped entirely by the workspace run.sh.
|
||||
p_link_node_modules(workspace_dir)
|
||||
link_node_modules(workspace_dir)
|
||||
env_path = os.path.join(workspace_dir, ".env")
|
||||
env_example_path = os.path.join(workspace_dir, ".env.example")
|
||||
src_example = os.path.join(WEBAPP_TEMPLATE_DIR, ".env.example")
|
||||
|
||||
@@ -146,6 +146,7 @@ def p_localize_env(folder: str) -> None:
|
||||
from backend.apps.outputs.view_builder_templates import (
|
||||
DEBUGGER_PATH,
|
||||
TEMPLATE_BACKEND_PATH,
|
||||
link_node_modules,
|
||||
patch_env_port,
|
||||
warm_venv_dir,
|
||||
)
|
||||
@@ -158,3 +159,8 @@ def p_localize_env(folder: str) -> None:
|
||||
patch_env_port(env_path, "OPENSWARM_BACKEND_VENV_CACHE", warm_venv_dir())
|
||||
except Exception:
|
||||
pass
|
||||
# Imported apps arrive WITHOUT node_modules (export drops the warm-cache symlink), so relink it here like seed does; without it the first runtime boot npm-installs while the preview races onto a not-yet-bound port, so the app stays blank until a full restart.
|
||||
try:
|
||||
link_node_modules(folder)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user