@commandgarden/cli 1.2.0 → 1.2.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.
Files changed (2) hide show
  1. package/dist/main.js +19 -7
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -17244,7 +17244,7 @@ async function executeGuiStart(baseUrl, cgHome, appScript, opts) {
17244
17244
  const pid = parseInt(readFileSync7(pidPath, "utf-8").trim(), 10);
17245
17245
  if (isProcessAlive(pid)) {
17246
17246
  const message = "GUI is already running.";
17247
- if (!opts.noOpen) openBrowser(`http://127.0.0.1:${appPort}`);
17247
+ if (!opts.noOpen) openBrowser(`http://127.0.0.1:${appPort}`, cgHome);
17248
17248
  return opts.background ? { status: "already-running", message } : message;
17249
17249
  }
17250
17250
  unlinkSync3(pidPath);
@@ -17286,7 +17286,7 @@ async function executeGuiStart(baseUrl, cgHome, appScript, opts) {
17286
17286
  intervalMs: 500
17287
17287
  });
17288
17288
  if (outcome === "ready") {
17289
- openBrowser(appUrl);
17289
+ openBrowser(appUrl, cgHome);
17290
17290
  return { status: "started", message: `GUI started (PID: ${child2.pid ?? "unknown"}).`, pid: child2.pid };
17291
17291
  }
17292
17292
  if (child2.pid) try {
@@ -17303,7 +17303,7 @@ async function executeGuiStart(baseUrl, cgHome, appScript, opts) {
17303
17303
  if (!opts.noOpen) {
17304
17304
  const appUrl = `http://127.0.0.1:${appPort}`;
17305
17305
  const ready = await waitForServer(appUrl, child);
17306
- if (ready) openBrowser(appUrl);
17306
+ if (ready) openBrowser(appUrl, cgHome);
17307
17307
  }
17308
17308
  await new Promise((resolve2) => child.on("exit", () => resolve2()));
17309
17309
  return "GUI stopped.";
@@ -17348,11 +17348,23 @@ async function waitForServer(url, child) {
17348
17348
  }
17349
17349
  return false;
17350
17350
  }
17351
- function openBrowser(url) {
17351
+ function openBrowser(url, cgHome) {
17352
17352
  console.error("Opening browser...");
17353
- const child = process.platform === "darwin" ? spawn2("open", [url], { stdio: "ignore" }) : process.platform === "win32" ? spawn2("cmd", ["/c", "start", "", url], { stdio: "ignore" }) : spawn2("xdg-open", [url], { stdio: "ignore" });
17354
- child.on("error", () => {
17355
- });
17353
+ const logPath = join3(cgHome, "browser.log");
17354
+ const log = (line) => {
17355
+ try {
17356
+ writeFileSync3(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${line}
17357
+ `, { flag: "a" });
17358
+ } catch {
17359
+ }
17360
+ };
17361
+ const [command, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
17362
+ log(`platform=${process.platform} spawning: ${command} ${JSON.stringify(args)}`);
17363
+ const child = spawn2(command, args, { stdio: "ignore", detached: true });
17364
+ log(`spawned pid=${child.pid ?? "unknown"}`);
17365
+ child.on("spawn", () => log("event: spawn (process launched)"));
17366
+ child.on("error", (err) => log(`event: error ${err instanceof Error ? err.stack ?? err.message : String(err)}`));
17367
+ child.on("exit", (code, signal) => log(`event: exit code=${code} signal=${signal}`));
17356
17368
  child.unref();
17357
17369
  }
17358
17370
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commandgarden/cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Enterprise browser automation CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",