fix prod running on linux
This commit is contained in:
@@ -9,6 +9,30 @@ import type { BuildStream } from "../build/types";
|
|||||||
import { ALLOWED_PLATFORMS } from "./validation-constants";
|
import { ALLOWED_PLATFORMS } from "./validation-constants";
|
||||||
import { resolveRuntimeRoot } from "./runtime-paths";
|
import { resolveRuntimeRoot } from "./runtime-paths";
|
||||||
|
|
||||||
|
function isClientModuleDir(dir: string): boolean {
|
||||||
|
return (
|
||||||
|
fs.existsSync(path.join(dir, "go.mod")) &&
|
||||||
|
fs.existsSync(path.join(dir, "cmd", "agent"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveClientModuleDir(rootDir: string): string | null {
|
||||||
|
const candidates = [
|
||||||
|
path.join(rootDir, "dist", "Overlord-Client"),
|
||||||
|
path.join(rootDir, "dist", "Overlord-Client", "Overlord-Client"),
|
||||||
|
path.join(rootDir, "Overlord-Client"),
|
||||||
|
path.join(rootDir, "..", "Overlord-Client"),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const dir of candidates) {
|
||||||
|
if (isClientModuleDir(dir)) {
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
type BuildProcessConfig = {
|
type BuildProcessConfig = {
|
||||||
platforms: string[];
|
platforms: string[];
|
||||||
serverUrl?: string;
|
serverUrl?: string;
|
||||||
@@ -102,14 +126,17 @@ export async function startBuildProcess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rootDir = resolveRuntimeRoot();
|
const rootDir = resolveRuntimeRoot();
|
||||||
const distClientDir = path.join(rootDir, "dist", "Overlord-Client");
|
const clientDir = resolveClientModuleDir(rootDir);
|
||||||
const clientDir = fs.existsSync(distClientDir)
|
if (!clientDir) {
|
||||||
? distClientDir
|
throw new Error(
|
||||||
: path.join(rootDir, "Overlord-Client");
|
`Overlord-Client source not found (missing go.mod). Checked: ${path.join(rootDir, "dist", "Overlord-Client")}, ${path.join(rootDir, "Overlord-Client")}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
const outDir = path.join(rootDir, "dist-clients");
|
const outDir = path.join(rootDir, "dist-clients");
|
||||||
|
|
||||||
await Bun.$`mkdir -p ${outDir}`.quiet();
|
await Bun.$`mkdir -p ${outDir}`.quiet();
|
||||||
sendToStream({ type: "output", text: `Build directory: ${outDir}\n`, level: "info" });
|
sendToStream({ type: "output", text: `Build directory: ${outDir}\n`, level: "info" });
|
||||||
|
sendToStream({ type: "output", text: `Client source: ${clientDir}\n`, level: "info" });
|
||||||
|
|
||||||
const platformsToBuild = (config.platforms || []).filter((p) => ALLOWED_PLATFORMS.has(p));
|
const platformsToBuild = (config.platforms || []).filter((p) => ALLOWED_PLATFORMS.has(p));
|
||||||
if (platformsToBuild.length !== (config.platforms || []).length) {
|
if (platformsToBuild.length !== (config.platforms || []).length) {
|
||||||
|
|||||||
+5
-1
@@ -26,7 +26,11 @@ echo "[build] compiling Linux production executable..."
|
|||||||
echo "[build] copying Overlord-Client source for runtime builds..."
|
echo "[build] copying Overlord-Client source for runtime builds..."
|
||||||
mkdir -p "$SERVER_DIR/dist/Overlord-Client"
|
mkdir -p "$SERVER_DIR/dist/Overlord-Client"
|
||||||
rsync -a --exclude='build' --exclude='.git' --exclude='.vscode' "$ROOT/Overlord-Client/" "$SERVER_DIR/dist/Overlord-Client/" 2>/dev/null \
|
rsync -a --exclude='build' --exclude='.git' --exclude='.vscode' "$ROOT/Overlord-Client/" "$SERVER_DIR/dist/Overlord-Client/" 2>/dev/null \
|
||||||
|| { cp -a "$ROOT/Overlord-Client" "$SERVER_DIR/dist/Overlord-Client" && rm -rf "$SERVER_DIR/dist/Overlord-Client/build" "$SERVER_DIR/dist/Overlord-Client/.git" "$SERVER_DIR/dist/Overlord-Client/.vscode"; }
|
|| {
|
||||||
|
rm -rf "$SERVER_DIR/dist/Overlord-Client"
|
||||||
|
cp -a "$ROOT/Overlord-Client" "$SERVER_DIR/dist/Overlord-Client"
|
||||||
|
rm -rf "$SERVER_DIR/dist/Overlord-Client/build" "$SERVER_DIR/dist/Overlord-Client/.git" "$SERVER_DIR/dist/Overlord-Client/.vscode"
|
||||||
|
}
|
||||||
|
|
||||||
echo "[server] starting compiled executable..."
|
echo "[server] starting compiled executable..."
|
||||||
PORT="${PORT:-5173}" \
|
PORT="${PORT:-5173}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user