remove bash -lc

This commit is contained in:
Mateusz Gruszczyński
2025-10-24 09:40:14 +02:00
parent 09f7b84d61
commit c37af244dc

View File

@@ -584,43 +584,41 @@ def install_node_and_yarn(node_pkg: str):
os.symlink("/usr/bin/yarnpkg","/usr/bin/yarn") os.symlink("/usr/bin/yarnpkg","/usr/bin/yarn")
def _build_frontend(src_frontend: Path, dest_frontend: Path): def _build_frontend(src_frontend: Path, dest_frontend: Path):
def _which(cmd: str) -> bool:
import shutil as _s def _semver(s: str) -> bool:
return _s.which(cmd) is not None return bool(re.match(r"^\d+(?:\.\d+){1,3}$", (s or "").strip()))
def _good_yarn(cmd: str) -> bool: def _good_yarn(cmd: str) -> bool:
out = (run_out([cmd, "--version"], check=False) or "").strip() v = (run_out([cmd, "--version"], check=False) or "").strip()
return bool(re.match(r"^\d+(?:\.\d+){1,3}$", out)) return _semver(v)
yarn = None yarn_cmd = None
for cand in ("yarn", "yarnpkg"): if shutil.which("yarn") and _good_yarn("yarn"):
if _which(cand) and _good_yarn(cand): yarn_cmd = ["yarn"]
yarn = cand elif shutil.which("yarnpkg") and _good_yarn("yarnpkg"):
break yarn_cmd = ["yarnpkg"]
if not yarn: elif shutil.which("npm"):
run(["corepack", "enable"], check=False) if (run_out(["npm", "--version"], check=False) or "").strip():
run(["corepack", "prepare", "yarn@stable", "--activate"], check=False) yarn_cmd = ["npm", "exec", "--yes", "yarn@stable"]
for cand in ("yarn", "yarnpkg"): if not yarn_cmd:
if _which(cand) and _good_yarn(cand):
yarn = cand
break
if not yarn:
raise RuntimeError("No yarn in system") raise RuntimeError("No yarn in system")
with step("Installing frontend dependencies (yarn)"): with step("Installing frontend dependencies (yarn)"):
os.environ["NODE_ENV"] = "development" os.environ["NODE_ENV"] = "development"
os.chdir(src_frontend) os.chdir(src_frontend)
cache_dir = (run_out([yarn, "cache", "dir"], check=False) or "").strip()
cache_dir = (run_out(yarn_cmd + ["cache", "dir"], check=False) or "").strip()
if cache_dir and not Path(cache_dir).exists(): if cache_dir and not Path(cache_dir).exists():
Path(cache_dir).mkdir(parents=True, exist_ok=True) Path(cache_dir).mkdir(parents=True, exist_ok=True)
run([yarn, "cache", "clean"], check=False) run(yarn_cmd + ["cache", "clean"], check=False)
run([yarn, "install"])
run(yarn_cmd + ["install"])
with step("Building frontend (yarn build)"): with step("Building frontend (yarn build)"):
env = os.environ.copy() env = os.environ.copy()
env["NODE_OPTIONS"] = "--openssl-legacy-provider" env["NODE_OPTIONS"] = "--openssl-legacy-provider"
run([yarn, "build"], env=env) run(yarn_cmd + ["build"], env=env)
with step("Copying frontend artifacts"): with step("Copying frontend artifacts"):
shutil.copytree(src_frontend / "dist", dest_frontend, dirs_exist_ok=True) shutil.copytree(src_frontend / "dist", dest_frontend, dirs_exist_ok=True)