From a9c74351eebc62dff52c6b83dbd5874740ccfb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 24 Oct 2025 09:36:03 +0200 Subject: [PATCH] remove bash -lc --- npm_install.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/npm_install.py b/npm_install.py index 125e70a..f578763 100644 --- a/npm_install.py +++ b/npm_install.py @@ -584,15 +584,33 @@ def install_node_and_yarn(node_pkg: str): os.symlink("/usr/bin/yarnpkg","/usr/bin/yarn") def _build_frontend(src_frontend: Path, dest_frontend: Path): + def _which(cmd: str) -> bool: + import shutil as _s + return _s.which(cmd) is not None + + yarn = "yarn" if _which("yarn") else ("yarnpkg" if _which("yarnpkg") else "") + if not yarn: + run(["corepack", "enable"], check=False) + run(["corepack", "prepare", "yarn@stable", "--activate"], check=False) + yarn = "yarn" if _which("yarn") else ("yarnpkg" if _which("yarnpkg") else "") + if not yarn: + raise RuntimeError("Brak Yarn. Zainstaluj: npm i -g yarn (lub użyj corepack).") + with step("Installing frontend dependencies (yarn)"): os.environ["NODE_ENV"] = "development" os.chdir(src_frontend) - run(["yarn", "cache", "clean", "--all"]) - run(["yarn", "install"]) + cache_dir = (run_out([yarn, "cache", "dir"], check=False) or "").strip() + if cache_dir and not Path(cache_dir).exists(): + Path(cache_dir).mkdir(parents=True, exist_ok=True) + run([yarn, "cache", "clean"], check=False) + + run([yarn, "install"]) + with step("Building frontend (yarn build)"): env = os.environ.copy() env["NODE_OPTIONS"] = "--openssl-legacy-provider" - run(["yarn", "build"], env=env) + run([yarn, "build"], env=env) + with step("Copying frontend artifacts"): shutil.copytree(src_frontend / "dist", dest_frontend, dirs_exist_ok=True) if (src_frontend / "app-images").exists():