Skip to content

Commit 10c9ab6

Browse files
committed
fix cli electron issue
1 parent a240367 commit 10c9ab6

File tree

3 files changed

+28
-116
lines changed

3 files changed

+28
-116
lines changed

client/.github/workflows/publish.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

client/bin/interwu.js

Lines changed: 27 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { spawn } = require("child_process");
44
const path = require("path");
55
const os = require("os");
66
const fs = require("fs");
7-
const { debugLog, debugError } = require("../src/displayUtils");
87

98
// Load environment variables from .env file if it exists
109
const envPath = path.join(__dirname, "..", ".env");
@@ -82,17 +81,17 @@ env.IS_PRODUCTION = process.env.IS_PRODUCTION || "true";
8281
const electronArgs = [appPath];
8382
if (sessionCode) {
8483
electronArgs.push(`--session-code=${sessionCode}`);
85-
debugLog(`🎯 Joining session: ${sessionCode}`);
84+
//console.log(`🎯 Joining session: ${sessionCode}`);
8685
}
8786
if (customWebSocketUrl) {
8887
electronArgs.push(`--websocket-url=${customWebSocketUrl}`);
89-
debugLog(`🌐 Using WebSocket: ${customWebSocketUrl}`);
88+
//console.log(`🌐 Using WebSocket: ${customWebSocketUrl}`);
9089
}
9190

9291
// Function to try spawning electron with shell option for Windows
9392
function tryElectron(electronCmd, args, useShell = false) {
9493
return new Promise((resolve, reject) => {
95-
debugLog(`Attempting to launch: ${electronCmd} ${args.join(" ")}`);
94+
//console.log(`Attempting to launch: ${electronCmd} ${args.join(" ")}`);
9695
const child = spawn(electronCmd, args, {
9796
env,
9897
stdio: "inherit",
@@ -192,7 +191,7 @@ function findElectronExecutable() {
192191
// Check which path exists
193192
for (const electronPath of possiblePaths) {
194193
if (fs.existsSync(electronPath)) {
195-
debugLog(`Found Electron at: ${electronPath}`);
194+
//console.log(`Found Electron at: ${electronPath}`);
196195
return electronPath;
197196
}
198197
}
@@ -240,55 +239,7 @@ function findGlobalElectronInPackage() {
240239
// Check which path exists
241240
for (const electronPath of possiblePaths) {
242241
if (fs.existsSync(electronPath)) {
243-
debugLog(`Found bundled Electron at: ${electronPath}`);
244-
return electronPath;
245-
}
246-
}
247-
248-
return null;
249-
}
250-
251-
// Function to find bundled electron in global package
252-
function findGlobalElectronInPackage() {
253-
const platform = os.platform();
254-
const possiblePaths = [];
255-
256-
// Look for electron bundled with the interwu package
257-
if (platform === "win32") {
258-
possiblePaths.push(
259-
path.join(
260-
__dirname,
261-
"..",
262-
"node_modules",
263-
"electron",
264-
"dist",
265-
"electron.exe"
266-
)
267-
);
268-
} else if (platform === "darwin") {
269-
possiblePaths.push(
270-
path.join(
271-
__dirname,
272-
"..",
273-
"node_modules",
274-
"electron",
275-
"dist",
276-
"Electron.app",
277-
"Contents",
278-
"MacOS",
279-
"Electron"
280-
)
281-
);
282-
} else {
283-
possiblePaths.push(
284-
path.join(__dirname, "..", "node_modules", "electron", "dist", "electron")
285-
);
286-
}
287-
288-
// Check which path exists
289-
for (const electronPath of possiblePaths) {
290-
if (fs.existsSync(electronPath)) {
291-
debugLog(`Found bundled Electron at: ${electronPath}`);
242+
//console.log(`Found bundled Electron at: ${electronPath}`);
292243
return electronPath;
293244
}
294245
}
@@ -303,37 +254,37 @@ async function main() {
303254

304255
if (electronPath) {
305256
try {
306-
debugLog("Using local Electron installation...");
257+
//console.log("Using local Electron installation...");
307258
const exitCode = await tryElectron(electronPath, electronArgs, false);
308259
process.exit(exitCode);
309260
} catch (err) {
310-
debugError("Failed to start with local Electron:", err.message);
261+
//console.error("Failed to start with local Electron:", err.message);
311262
}
312263
}
313264

314265
// Try globally installed electron
315266
try {
316-
debugLog("Trying to use globally installed Electron...");
267+
//console.log("Trying to use globally installed Electron...");
317268
const exitCode = await tryElectron("electron", electronArgs, false);
318269
process.exit(exitCode);
319270
} catch (fallbackErr) {
320-
debugError("Failed to start with global Electron:", fallbackErr.message);
271+
//console.error("Failed to start with global Electron:", fallbackErr.message);
321272

322273
// Try npx electron as fallback
323274
try {
324-
debugLog("Trying npx electron as fallback...");
275+
//console.log("Trying npx electron as fallback...");
325276
const exitCode = await tryElectron(
326277
"npx",
327278
["electron", ...electronArgs],
328279
true
329280
);
330281
process.exit(exitCode);
331282
} catch (npxErr) {
332-
debugError("Failed with npx electron:", npxErr.message);
283+
//console.error("Failed with npx electron:", npxErr.message);
333284

334285
// Try finding bundled electron in the global package
335286
try {
336-
debugLog("Trying bundled Electron in global package...");
287+
//console.log("Trying bundled Electron in global package...");
337288
const globalElectronPath = findGlobalElectronInPackage();
338289
if (globalElectronPath) {
339290
const exitCode = await tryElectron(
@@ -346,21 +297,22 @@ async function main() {
346297
throw new Error("No bundled Electron found");
347298
} catch (bundledErr) {
348299
console.error(`
349-
❌ All Electron launch methods failed.
350-
🔧 To fix this issue, try one of the following:
351-
352-
1. Install Electron globally:
353-
npm install -g electron@latest
354-
355-
2. Clear npm cache and try again:
356-
npm cache clean --force
357-
npx interwu [code]
358-
359-
3. Use local installation:
360-
npm install interwu
361-
npx interwu [code]
300+
❌ All Electron launch methods failed.
301+
🔧 To fix this issue, try one of the following:
302+
303+
1. Install Electron globally:
304+
npm install -g electron@latest
305+
306+
2. Clear npm cache and try again:
307+
npm cache clean --force
308+
npx interwu [code]
309+
310+
3. Use local installation:
311+
npm install interwu
312+
npx interwu [code]
313+
314+
\n📝 Note: If using pnpm, replace 'npm' with 'pnpm' in the commands above.`);
362315

363-
\n📝 Note: If using pnpm, replace 'npm' with 'pnpm' in the commands above.`);
364316
process.exit(1);
365317
}
366318
}

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sr2echa/interwu",
33
"productName": "interwu",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "Client for Secure Remote Interview Monitoring.",
66
"main": "src/index.js",
77
"bin": {

0 commit comments

Comments
 (0)