ework-web 0.10.12 → 0.10.13
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/package.json +1 -1
- package/src/daemon-deploy.ts +23 -1
package/package.json
CHANGED
package/src/daemon-deploy.ts
CHANGED
|
@@ -74,11 +74,16 @@ function parseEnvFile(content: string): Map<string, string> {
|
|
|
74
74
|
|
|
75
75
|
function buildEnvBlock(env: Map<string, string>, target: DeployTarget): string {
|
|
76
76
|
const lines: string[] = [];
|
|
77
|
+
const localIP = detectLocalIP();
|
|
77
78
|
for (const k of FORWARD_KEYS) {
|
|
78
79
|
const v = env.get(k);
|
|
79
80
|
if (v === undefined) continue;
|
|
80
81
|
if (k === "OPENCODE_BINARY") continue;
|
|
81
|
-
|
|
82
|
+
let val = v;
|
|
83
|
+
if (k === "GITEA_URL" && localIP && (val.includes("127.0.0.1") || val.includes("localhost"))) {
|
|
84
|
+
val = val.replace(/127\.0\.0\.1|localhost/g, localIP);
|
|
85
|
+
}
|
|
86
|
+
lines.push(`${k}=${val}`);
|
|
82
87
|
}
|
|
83
88
|
const mysqlHost = String(target.mysqlHost).replace(/:\d+$/, "");
|
|
84
89
|
lines.push(`WORK_DB_HOST=${mysqlHost}`);
|
|
@@ -88,6 +93,23 @@ function buildEnvBlock(env: Map<string, string>, target: DeployTarget): string {
|
|
|
88
93
|
return lines.join("\n");
|
|
89
94
|
}
|
|
90
95
|
|
|
96
|
+
function detectLocalIP(): string | null {
|
|
97
|
+
try {
|
|
98
|
+
const { networkInterfaces } = require("node:os");
|
|
99
|
+
const nets = networkInterfaces();
|
|
100
|
+
for (const name of Object.keys(nets)) {
|
|
101
|
+
for (const net of nets[name] ?? []) {
|
|
102
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
103
|
+
return net.address;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch {
|
|
108
|
+
// Network detection best-effort
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
91
113
|
function buildSetupScript(envBlock: string, daemonPort: number, mysqlHostRaw: string, mysqlPort: string): string {
|
|
92
114
|
const mysqlHost = mysqlHostRaw.replace(/:\d+$/, "");
|
|
93
115
|
return [
|