diff --git a/server.py b/server.py index b420c6045..2c2d0702d 100644 --- a/server.py +++ b/server.py @@ -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) @@ -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(