@bobfrankston/mailx 1.0.27 → 1.0.29
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/bin/mailx.js +21 -6
- package/launcher/builder/postinstall.js +37 -2
- package/package.json +1 -1
package/bin/mailx.js
CHANGED
|
@@ -17,14 +17,29 @@ import net from "node:net";
|
|
|
17
17
|
|
|
18
18
|
const PORT = 9333;
|
|
19
19
|
const args = process.argv.slice(2);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
// Normalize: accept both -flag and --flag
|
|
22
|
+
function hasFlag(name) { return args.includes(`-${name}`) || args.includes(`--${name}`); }
|
|
23
|
+
|
|
24
|
+
const serverMode = hasFlag("server");
|
|
25
|
+
const noBrowser = hasFlag("no-browser");
|
|
26
|
+
const verbose = hasFlag("verbose");
|
|
27
|
+
|
|
28
|
+
// Validate arguments
|
|
29
|
+
const knownFlags = ["server", "no-browser", "verbose", "external", "kill", "v", "version"];
|
|
30
|
+
for (const arg of args) {
|
|
31
|
+
const flag = arg.replace(/^--?/, "");
|
|
32
|
+
if (arg.startsWith("-") && !knownFlags.includes(flag)) {
|
|
33
|
+
console.error(`Unknown option: ${arg}`);
|
|
34
|
+
console.error("Usage: mailx [-server] [-verbose] [-kill] [-v] [-no-browser] [-external]");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
|
|
24
39
|
function log(...msg) { if (verbose) console.log("[mailx]", ...msg); }
|
|
25
40
|
|
|
26
41
|
// Kill any running mailx server
|
|
27
|
-
if (
|
|
42
|
+
if (hasFlag("kill")) {
|
|
28
43
|
log("Killing mailx processes...");
|
|
29
44
|
const { execSync } = await import("node:child_process");
|
|
30
45
|
// Kill by port
|
|
@@ -46,7 +61,7 @@ if (args.includes("--kill") || args.includes("-kill")) {
|
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
// Version
|
|
49
|
-
if (
|
|
64
|
+
if (hasFlag("v") || hasFlag("version")) {
|
|
50
65
|
const pkgPath = path.join(import.meta.dirname, "..", "package.json");
|
|
51
66
|
try {
|
|
52
67
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
@@ -89,7 +104,7 @@ async function main() {
|
|
|
89
104
|
|
|
90
105
|
console.log("Starting mailx server...");
|
|
91
106
|
log(`Loading server from: ${path.join(import.meta.dirname, "..", "packages", "mailx-server", "index.js")}`);
|
|
92
|
-
if (
|
|
107
|
+
if (hasFlag("external")) process.argv.push("--external");
|
|
93
108
|
await import("../packages/mailx-server/index.js");
|
|
94
109
|
|
|
95
110
|
if (!noBrowser) {
|
|
@@ -1,8 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* mailx postinstall
|
|
4
|
-
*
|
|
3
|
+
* mailx postinstall:
|
|
4
|
+
* 1. Link workspace packages so Node can resolve them after npm install
|
|
5
|
+
* 2. Set binary permissions on Linux/Mac
|
|
5
6
|
*/
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const root = path.join(__dirname, "..", "..");
|
|
13
|
+
|
|
14
|
+
// Link workspace packages into node_modules so imports resolve
|
|
15
|
+
const nodeModules = path.join(root, "node_modules", "@bobfrankston");
|
|
16
|
+
const packagesDir = path.join(root, "packages");
|
|
17
|
+
if (fs.existsSync(packagesDir)) {
|
|
18
|
+
fs.mkdirSync(nodeModules, { recursive: true });
|
|
19
|
+
for (const pkg of fs.readdirSync(packagesDir)) {
|
|
20
|
+
const pkgDir = path.join(packagesDir, pkg);
|
|
21
|
+
const pkgJson = path.join(pkgDir, "package.json");
|
|
22
|
+
if (!fs.existsSync(pkgJson)) continue;
|
|
23
|
+
try {
|
|
24
|
+
const meta = JSON.parse(fs.readFileSync(pkgJson, "utf-8"));
|
|
25
|
+
const name = meta.name?.replace("@bobfrankston/", "");
|
|
26
|
+
if (!name) continue;
|
|
27
|
+
const link = path.join(nodeModules, name);
|
|
28
|
+
if (!fs.existsSync(link)) {
|
|
29
|
+
// Use junction on Windows (no admin needed), symlink on Unix
|
|
30
|
+
if (process.platform === "win32") {
|
|
31
|
+
fs.symlinkSync(pkgDir, link, "junction");
|
|
32
|
+
} else {
|
|
33
|
+
fs.symlinkSync(pkgDir, link, "dir");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch { /* skip */ }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Set binary permissions
|
|
6
41
|
try {
|
|
7
42
|
const { runPostinstall } = await import("@bobfrankston/rust-builder/postinstall");
|
|
8
43
|
const path = await import("path");
|