diff --git a/dev/breeze/src/airflow_breeze/commands/testing_commands.py b/dev/breeze/src/airflow_breeze/commands/testing_commands.py index ec672cd2a02d4..52d178d71bbde 100644 --- a/dev/breeze/src/airflow_breeze/commands/testing_commands.py +++ b/dev/breeze/src/airflow_breeze/commands/testing_commands.py @@ -1471,11 +1471,13 @@ def ui_e2e_tests( from pathlib import Path from airflow_breeze.utils.console import get_console - from airflow_breeze.utils.run_utils import run_command + from airflow_breeze.utils.run_utils import check_pnpm_installed, run_command from airflow_breeze.utils.shared_options import get_dry_run, get_verbose perform_environment_checks() + check_pnpm_installed() + airflow_root = Path(__file__).resolve().parents[5] ui_dir = airflow_root / "airflow-core" / "src" / "airflow" / "ui" diff --git a/dev/breeze/src/airflow_breeze/utils/run_utils.py b/dev/breeze/src/airflow_breeze/utils/run_utils.py index 8c34f1e8a16f5..7a5374f3466db 100644 --- a/dev/breeze/src/airflow_breeze/utils/run_utils.py +++ b/dev/breeze/src/airflow_breeze/utils/run_utils.py @@ -260,6 +260,42 @@ def assert_prek_installed(): sys.exit(1) +def check_pnpm_installed(): + """ + Check if pnpm is installed and install it if npm is available. + """ + if shutil.which("pnpm"): + return + + get_console().print("[warning]pnpm is not installed. Installing pnpm...[/]") + + # Check if npm is available (required to install pnpm) + if not shutil.which("npm"): + get_console().print("[error]npm is not installed. Please install Node.js and npm first.[/]") + get_console().print("[warning]Visit: https://nodejs.org/[/]") + sys.exit(1) + + try: + get_console().print("[info]Installing pnpm using npm...[/]") + result = run_command( + ["npm", "install", "-g", "pnpm"], + no_output_dump_on_exception=True, + capture_output=True, + text=True, + check=False, + ) + if result.returncode == 0: + get_console().print("[success]pnpm has been installed successfully![/]") + else: + get_console().print(f"[error]Failed to install pnpm: {result.stderr}[/]") + get_console().print("[warning]Please install pnpm manually: https://pnpm.io/installation[/]") + sys.exit(1) + except Exception as e: + get_console().print(f"[error]Failed to install pnpm: {e}[/]") + get_console().print("[warning]Please install pnpm manually: https://pnpm.io/installation[/]") + sys.exit(1) + + def get_filesystem_type(filepath: str): """ Determine the type of filesystem used - we might want to use different parameters if tmpfs is used.