Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support more debians distros #1875

Merged
merged 2 commits into from
Jan 5, 2025
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
64 changes: 55 additions & 9 deletions packages/plugin-node/scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,64 @@
import os from "os";
import fs from "fs";
import { execSync } from "child_process";

const platform = os.platform();
const rel = os.release();

if (platform !== "linux") {
console.log("Skipping playwright installation: non-Linux platform detected:", platform);
process.exit(0);
}

function getDistroName() {
try {
const osReleaseContent = fs.readFileSync("/etc/os-release", "utf8");
const lines = osReleaseContent.split("\n");
const info = {};
for (const line of lines) {
const [key, value] = line.split("=");
if (key && value) {
info[key.toLowerCase()] = value.replace(/"/g, "").toLowerCase().trim();
}
}
return info["id"] || info["id_like"] || null;
} catch (err) {
console.error("Error reading /etc/os-release:", err.message);
}
return null;
}

if (
platform === "linux" &&
!(os.release().includes("ubuntu") || os.release().includes("debian"))
) {
// DO NOT CHANGE THIS TO ELIZALOGGER, this file cannot depends on any workspace otherwise we can't build the workspace
const distro = getDistroName();
console.log("Detected Linux distribution:", distro || "unknown");

const supportedDistros = [
"ubuntu",
"debian",
"pve",
"raspbian",
"pop",
"zorin",
"linuxmint",
"elementary",
"pureos",
"kali"
];

if (!distro || !supportedDistros.some((name) => distro.includes(name))) {
console.log(
"Skipping playwright installation on unsupported platform:",
platform
platform,
rel,
distro || "unknown distro"
);
} else {
const { execSync } = await import("child_process");
process.exit(0);
}

try {
execSync("npx playwright install-deps && npx playwright install", {
stdio: "inherit",
stdio: "inherit"
});
} catch (err) {
console.error("Failed to install Playwright dependencies:", err.message);
process.exit(1);
}
Loading