34 lines
1.5 KiB
PHP
34 lines
1.5 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$out = [];
|
|
|
|
// Read playwright-check.sh
|
|
$f = "/var/www/html/api/v76-scripts/playwright-check.sh";
|
|
if (file_exists($f)) $out["pw_check_sh"] = @file_get_contents($f);
|
|
|
|
// Targeted config locations
|
|
$cfgs = ["/var/www/html/playwright.config.js", "/var/www/html/playwright.config.ts",
|
|
"/var/www/html/api/playwright.config.js", "/opt/weval-l99/playwright.config.js"];
|
|
foreach ($cfgs as $c) if (file_exists($c)) $out["config_$c"] = substr(@file_get_contents($c), 0, 600);
|
|
|
|
// Find recent spec files in common dirs (no find/ recursive)
|
|
foreach (["/var/www/html", "/var/www/html/tests", "/var/www/html/api", "/opt/weval-l99/tests"] as $d) {
|
|
foreach (glob("$d/*.spec.{js,ts}", GLOB_BRACE) as $s) $out["specs"][] = $s;
|
|
foreach (glob("$d/tests/*.spec.{js,ts}", GLOB_BRACE) as $s) $out["specs"][] = $s;
|
|
}
|
|
|
|
// which playwright
|
|
$out["which_npx"] = trim(@shell_exec("which npx 2>&1") ?: "");
|
|
$out["which_playwright"] = trim(@shell_exec("which playwright 2>&1") ?: "");
|
|
|
|
// Look for package.json with playwright
|
|
foreach (["/var/www/html/package.json", "/var/www/html/api/package.json", "/opt/weval-l99/package.json"] as $p) {
|
|
if (file_exists($p)) {
|
|
$pkg = @json_decode(@file_get_contents($p), true);
|
|
$has_pw = isset($pkg["devDependencies"]["@playwright/test"]) || isset($pkg["dependencies"]["@playwright/test"]);
|
|
if ($has_pw || $pkg) $out["pkg_$p"] = ["has_playwright"=>$has_pw, "scripts"=>$pkg["scripts"]??[]];
|
|
}
|
|
}
|
|
|
|
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|