@bobfrankston/mailx 1.0.140 → 1.0.141

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/bin/mailx.js +17 -7
  2. package/package.json +1 -1
package/bin/mailx.js CHANGED
@@ -31,7 +31,7 @@ const addMode = hasFlag("add");
31
31
  const testMode = hasFlag("test");
32
32
  const rebuildMode = hasFlag("rebuild");
33
33
  // Validate arguments
34
- const knownFlags = ["server", "no-browser", "verbose", "external", "kill", "v", "version", "setup", "add", "test", "rebuild", "native-imap"];
34
+ const knownFlags = ["server", "no-browser", "verbose", "external", "kill", "v", "version", "setup", "add", "test", "rebuild", "native-imap", "log"];
35
35
  for (const arg of args) {
36
36
  const flag = arg.replace(/^--?/, "");
37
37
  if (arg.startsWith("-") && !knownFlags.includes(flag)) {
@@ -172,7 +172,7 @@ function isPortInUse(port) {
172
172
  }
173
173
  /** Launch msger pointing at the server URL */
174
174
  function launchMsger(url) {
175
- showMessageBox({ url, detach: true });
175
+ showMessageBox({ url, detach: true, size: { width: 1400, height: 900 } });
176
176
  }
177
177
  async function prompt(question) {
178
178
  const readline = await import("readline");
@@ -491,16 +491,27 @@ async function main() {
491
491
  // Check if server is already running
492
492
  const inUse = await isPortInUse(PORT);
493
493
  if (inUse) {
494
- console.log(`mailx server already running on port ${PORT}`);
495
494
  const url = `http://127.0.0.1:${PORT}`;
496
- if (!noBrowser) {
495
+ if (!noBrowser)
497
496
  launchMsger(url);
498
- }
499
497
  return;
500
498
  }
499
+ // Redirect console to log file — keep terminal clean
500
+ // Server also logs, but this catches CLI startup messages
501
+ if (!verbose) {
502
+ const home = process.env.USERPROFILE || process.env.HOME || ".";
503
+ const logDir = path.join(home, ".mailx", "logs");
504
+ fs.mkdirSync(logDir, { recursive: true });
505
+ const logDate = new Date().toISOString().slice(0, 10);
506
+ const logPath = path.join(logDir, `mailx-${logDate}.log`);
507
+ const logStream = fs.createWriteStream(logPath, { flags: "a" });
508
+ const origLog = console.log;
509
+ const origErr = console.error;
510
+ console.log = (...a) => { logStream.write(a.join(" ") + "\n"); };
511
+ console.error = (...a) => { logStream.write("ERROR " + a.join(" ") + "\n"); };
512
+ }
501
513
  // Start Express server in-process
502
514
  console.log("Starting mailx server...");
503
- log(`Loading server from: ${path.join(import.meta.dirname, "..", "packages", "mailx-server", "index.js")}`);
504
515
  if (hasFlag("external"))
505
516
  process.argv.push("--external");
506
517
  await import("../packages/mailx-server/index.js");
@@ -513,7 +524,6 @@ async function main() {
513
524
  break;
514
525
  }
515
526
  launchMsger(url);
516
- console.log("mailx opened");
517
527
  }
518
528
  // Keep process alive — server is running
519
529
  await new Promise(() => { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.140",
3
+ "version": "1.0.141",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",