Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,21 @@ def list_str(values):
app_svc.register_subapp("/api/v2", app.api.v2.make_app(app_svc.get_services()))
init_swagger_documentation(app_svc.application)
if args.uiDevHost:
if not os.path.exists(f"{MAGMA_PATH}/dist"):
if not os.path.exists(f"{MAGMA_PATH}/dist") and (os.path.exists(f"{MAGMA_PATH}") and len(os.listdir(MAGMA_PATH)) > 0):
logging.info("Building VueJS front-end.")
subprocess.run(["npm", "run", "build"], cwd=MAGMA_PATH, check=True)
logging.info("VueJS front-end build complete.")
else:
logging.warning(
f"[bright_yellow]The `--uidev` flag was supplied, but the Caldera v5 Vue UI is not present."
f" The Vue UI should be located in {MAGMA_PATH}. Use `--recursive` when cloning Caldera."
f" Flag ignored; continuing with default server startup.[/bright_yellow]"
)
args.uiDevHost = False
app_svc.application.on_response_prepare.append(enable_cors)

if args.build:
if len(os.listdir(MAGMA_PATH)) > 0:
if os.path.exists(f"{MAGMA_PATH}") and len(os.listdir(MAGMA_PATH)) > 0:
logging.info("Building VueJS front-end.")
subprocess.run(["npm", "install"], cwd=MAGMA_PATH, check=True)
subprocess.run(["npm", "run", "build"], cwd=MAGMA_PATH, check=True)
Expand All @@ -287,12 +294,18 @@ def list_str(values):
f" The Vue UI should be located in {MAGMA_PATH}. Use `--recursive` when cloning Caldera.[/bright_yellow]"
)
else:
if not os.path.exists(f"{MAGMA_PATH}/dist"):
if os.path.exists(f"{MAGMA_PATH}") and len(os.listdir(MAGMA_PATH)) > 0 and not os.path.exists(f"{MAGMA_PATH}/dist"):
logging.warning(
"[bright_yellow]Built Caldera v5 Vue components not detected, and `--build` flag not supplied."
" If attempting to start Caldera v5 for the first time, the `--build` flag must be"
"[bright_yellow]Caldera v5 Vue UI source detected, but not built components, and `--build` flag not supplied."
" If attempting to start Caldera v5 with the UI for the first time, the `--build` flag must be"
" supplied to trigger the building of the Vue source components.[/bright_yellow]"
)
elif not os.path.exists(f"{MAGMA_PATH}/dist"):
logging.warning(
f"[bright_yellow]Built Caldera v5 Vue components not detected, and `--build` flag not supplied."
f" If attempting to start Caldera v5 with the UI for the first time, the `--build` flag and"
f" Magma plugin (located in {MAGMA_PATH}) must be supplied to trigger the building of the Vue source components.[/bright_yellow]"
)

if args.fresh:
logging.info(
Expand Down