@bobfrankston/mailx 1.0.160 → 1.0.162

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/again.cmd ADDED
@@ -0,0 +1,3 @@
1
+ call rebuild
2
+ ager.ts
3
+ mailx -email BobFrankston@Gmail.com
package/bin/ager.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * ager — archive .mailx to c:\temp\.mailx## and preserve OAuth tokens
3
+ *
4
+ * Moves ~/.mailx to c:\temp\.mailx01 (or next available number),
5
+ * then copies the tokens directory back so OAuth doesn't need re-consent.
6
+ *
7
+ * Usage: node ager.js
8
+ */
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ const home = process.env.USERPROFILE || process.env.HOME || ".";
12
+ const source = path.join(home, ".mailx");
13
+ const tempDir = "C:\\temp";
14
+ if (!fs.existsSync(source)) {
15
+ console.error(`No .mailx directory at ${source}`);
16
+ process.exit(1);
17
+ }
18
+ // Find next available number
19
+ fs.mkdirSync(tempDir, { recursive: true });
20
+ let num = 1;
21
+ while (fs.existsSync(path.join(tempDir, `.mailx${String(num).padStart(2, "0")}`))) {
22
+ num++;
23
+ }
24
+ const dest = path.join(tempDir, `.mailx${String(num).padStart(2, "0")}`);
25
+ // Save tokens before moving
26
+ const tokensDir = path.join(source, "tokens");
27
+ const hasTokens = fs.existsSync(tokensDir);
28
+ const tokenFiles = [];
29
+ if (hasTokens) {
30
+ const walk = (dir, base) => {
31
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
32
+ const full = path.join(dir, entry.name);
33
+ const rel = path.join(base, entry.name);
34
+ if (entry.isDirectory())
35
+ walk(full, rel);
36
+ else
37
+ tokenFiles.push({ rel, data: fs.readFileSync(full) });
38
+ }
39
+ };
40
+ walk(tokensDir, "");
41
+ console.log(` Saved ${tokenFiles.length} token file(s)`);
42
+ }
43
+ // Move .mailx to temp
44
+ fs.renameSync(source, dest);
45
+ console.log(`Moved ${source} → ${dest}`);
46
+ // Restore tokens to fresh .mailx
47
+ if (tokenFiles.length > 0) {
48
+ const newTokens = path.join(source, "tokens");
49
+ for (const { rel, data } of tokenFiles) {
50
+ const target = path.join(newTokens, rel);
51
+ fs.mkdirSync(path.dirname(target), { recursive: true });
52
+ fs.writeFileSync(target, data);
53
+ }
54
+ console.log(` Restored tokens to ${newTokens}`);
55
+ }
56
+ console.log("Ready for fresh start.");
57
+ //# sourceMappingURL=ager.js.map
package/bin/mailx.js CHANGED
@@ -748,10 +748,16 @@ async function main() {
748
748
  }
749
749
  process.on("SIGINT", () => gracefulShutdown("SIGINT"));
750
750
  process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
751
- process.on("exit", () => {
751
+ process.on("uncaughtException", (err) => {
752
+ console.error(`UNCAUGHT EXCEPTION: ${err.stack || err.message}`);
753
+ gracefulShutdown("uncaughtException");
754
+ });
755
+ process.on("unhandledRejection", (reason) => {
756
+ console.error(`UNHANDLED REJECTION: ${reason?.stack || reason?.message || reason}`);
757
+ });
758
+ process.on("exit", (code) => {
759
+ console.log(`Process exit (code ${code})`);
752
760
  if (!shuttingDown) {
753
- // Sync fallback — shutdown() is async so can't fully run here,
754
- // but at least stop timers and release semaphores
755
761
  imapManager.stopPeriodicSync();
756
762
  imapManager.stopOutboxWorker();
757
763
  db.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.160",
3
+ "version": "1.0.162",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -23,7 +23,7 @@
23
23
  "@bobfrankston/iflow": "^1.0.55",
24
24
  "@bobfrankston/miscinfo": "^1.0.7",
25
25
  "@bobfrankston/oauthsupport": "^1.0.20",
26
- "@bobfrankston/msger": "^0.1.210",
26
+ "@bobfrankston/msger": "^0.1.212",
27
27
  "@capacitor/android": "^8.3.0",
28
28
  "@capacitor/cli": "^8.3.0",
29
29
  "@capacitor/core": "^8.3.0",