Skip to content

Commit 8b819e6

Browse files
committed
refactor: use MFEMountData instead of parsin mounts
1 parent 5fd1571 commit 8b819e6

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Auto install npm dependencies in mounted MFEs during initialization. (by @Danyal-Faheem)

tutormfe/patches/dev-docker-compose-jobs-services

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
{%- set mfe_data = MFEMountData(MOUNTS) %}
33

44
{%- for app_name, app, mounts in mfe_data.mounted %}
5-
{{ app_name }}-job: # Work on this MFE for development
5+
{{ app_name }}-job:
66
image: "{{ MFE_DOCKER_IMAGE_DEV_PREFIX }}-{{ app_name }}-dev:{{ MFE_VERSION }}"
77
volumes:
88
{%- for mount in mounts %}
99
- {{ mount }}
1010
{%- endfor %}
11+
environment:
12+
- "NODE_ENV=development"
1113
{%- endfor %}

tutormfe/patches/local-docker-compose-jobs-services

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
{%- set mfe_data = MFEMountData(MOUNTS) %}
44

55
{%- for app_name, app, mounts in mfe_data.mounted %}
6-
{{ app_name }}-job: # Work on this MFE for development
6+
{{ app_name }}-job:
77
image: "{{ MFE_DOCKER_IMAGE_DEV_PREFIX }}-{{ app_name }}-dev:{{ MFE_VERSION }}"
88
volumes:
99
{%- for mount in mounts %}
1010
- {{ mount }}
1111
{%- endfor %}
12+
environment:
13+
- "NODE_ENV=production"
1214
{%- endfor %}

tutormfe/plugin.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,16 +340,12 @@ def _check_mfe_host(config: Config) -> None:
340340
@tutor_hooks.Actions.CONFIG_LOADED.add()
341341
def _run_jobs_in_mounted_mfes(config: Config) -> None:
342342

343-
344-
345343
mounts = get_typed(config, "MOUNTS", list, [])
344+
mfe_mount_data = MFEMountData(mounts)
346345

347-
if not mounts:
346+
if not mfe_mount_data.mounted:
348347
return None
349348

350-
pattern = re.compile(rf'{re.escape(REPO_PREFIX)}(\w+)')
351-
mounted_mfes = [match.group(1) for mount in mounts if (match := pattern.search(mount))]
352-
353349
mfe_npm_install_file = os.path.join(
354350
str(
355351
importlib_resources.files("tutormfe")
@@ -361,7 +357,7 @@ def _run_jobs_in_mounted_mfes(config: Config) -> None:
361357
)
362358
)
363359

364-
for mounted_mfe in mounted_mfes:
360+
for mfe, _, _ in mfe_mount_data.mounted:
365361
with tutor_hooks.Contexts.app("mfe").enter():
366362
with open(mfe_npm_install_file, encoding='utf-8') as fi:
367-
tutor_hooks.Filters.CLI_DO_INIT_TASKS.add_item((mounted_mfe , fi.read()))
363+
tutor_hooks.Filters.CLI_DO_INIT_TASKS.add_item((mfe , fi.read()))

0 commit comments

Comments
 (0)