muagqa 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/playwrightInstaller.js +27 -7
package/package.json
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
|
+
import path from "path";
|
|
2
3
|
import chalk from "chalk";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export function ensurePlaywrightInstalled() {
|
|
5
6
|
try {
|
|
6
|
-
console.log(chalk.
|
|
7
|
+
console.log(chalk.cyan("🔍 Checking Playwright installation..."));
|
|
7
8
|
|
|
9
|
+
// Try running playwright --version
|
|
8
10
|
execSync("npx playwright --version", { stdio: "ignore" });
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
return;
|
|
12
|
-
} catch {
|
|
13
|
-
console.log(chalk.
|
|
14
|
-
|
|
12
|
+
console.log(chalk.green("✔ Playwright is already installed globally."));
|
|
13
|
+
return true;
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.log(chalk.yellow("⚠ Playwright not found globally. Installing..."));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
// 1️⃣ Determine global CLI install folder
|
|
20
|
+
const globalRoot = execSync("npm root -g").toString().trim();
|
|
21
|
+
|
|
22
|
+
const cliPath = path.join(globalRoot, "muagqa");
|
|
23
|
+
|
|
24
|
+
console.log(chalk.cyan(`📂 Installing Playwright inside: ${cliPath}`));
|
|
25
|
+
|
|
26
|
+
// 2️⃣ Install Playwright inside the global muagqa folder
|
|
27
|
+
execSync(`cd "${cliPath}" && npm install playwright`, { stdio: "inherit" });
|
|
28
|
+
|
|
29
|
+
console.log(chalk.green("✔ Playwright installed successfully!"));
|
|
30
|
+
return true;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.log(chalk.red("❌ Failed to install Playwright globally."));
|
|
33
|
+
console.error(e);
|
|
34
|
+
return false;
|
|
15
35
|
}
|
|
16
36
|
}
|