Skip to content

Commit e67cd6a

Browse files
committed
refinements
1 parent 03e8554 commit e67cd6a

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

app/utility/plugin_manager.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,37 +106,52 @@ async def enable_plugin(self, plugin_name: str, build_gui=False) -> bool:
106106

107107
return restart_required
108108

109-
async def _build_plugin_gui_if_needed(self, plugin_name):
110-
gui_path = f"plugins/{plugin_name}/gui"
109+
async def _build_plugin_gui_if_needed(self, plugins):
110+
# allow string or list
111+
if isinstance(plugins, str):
112+
plugins = [plugins]
111113

112-
if not os.path.isdir(gui_path):
113-
return False
114+
plugins_to_build = []
115+
116+
for plugin in plugins:
117+
gui_path = f"plugins/{plugin}/gui"
118+
119+
if not os.path.isdir(gui_path):
120+
continue
121+
122+
if not glob.glob(f"{gui_path}/**/*.vue", recursive=True):
123+
continue
114124

115-
if not glob.glob(f"{gui_path}/**/*.vue", recursive=True):
125+
plugins_to_build.append(plugin)
126+
127+
if not plugins_to_build:
116128
return False
117129

118-
print(f"[plugin_manager] Building GUI for {plugin_name}")
130+
print(f"[plugin_manager] Building GUI for: {', '.join(plugins_to_build)}")
119131

120132
await asyncio.to_thread(
121133
subprocess.run,
122-
["node", "prebundle.js"],
134+
["node", "prebundle.js", *plugins_to_build],
123135
cwd="plugins/magma",
124136
check=True
125137
)
138+
126139
await asyncio.to_thread(
127140
subprocess.run,
128141
["npm", "install"],
129142
cwd="plugins/magma",
130143
check=True
131144
)
145+
132146
await asyncio.to_thread(
133147
subprocess.run,
134148
["npm", "run", "build"],
135149
cwd="plugins/magma",
136150
check=True
137151
)
152+
138153
return True
139-
154+
140155
def unload_plugin(self, plugin_name: str):
141156
"""Unload a plugin to free memory."""
142157
if plugin_name in self.loaded_plugins:

0 commit comments

Comments
 (0)