feat(web): auto-install emsdk and set default caddy port

- Clone and install emsdk automatically if not present
- Configure caddy to listen on port 8547 by default
This commit is contained in:
2025-12-29 00:43:34 -06:00
parent fc349c45c5
commit d320f2b01b
2 changed files with 34 additions and 5 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ samply:
web *args:
bun run pacman/web.build.ts {{args}}
bun run --cwd web build
caddy file-server --root web/dist/client
caddy file-server --root web/dist/client --listen :8547
# Fix linting errors & formatting
fix:
+31 -2
View File
@@ -147,13 +147,42 @@ async function activateEmsdk(
return { vars: null };
}
// Check if the emsdk directory exists
// Check if the emsdk directory exists, clone and install if not
if (!(await fs.exists(emsdkDir))) {
logger.info("Emscripten SDK not found, cloning and installing...");
// Clone the emsdk repository
logger.debug("Cloning emsdk repository...");
const cloneResult =
await $`git clone https://github.com/emscripten-core/emsdk.git ${emsdkDir}`.quiet();
if (cloneResult.exitCode !== 0) {
return {
err: `Emscripten SDK directory not found at ${emsdkDir}. Please install or clone 'emsdk' and try again.`,
err: `Failed to clone emsdk: ${cloneResult.stderr.toString()}`,
};
}
// Install latest version
logger.debug("Installing latest Emscripten version...");
const emsdkBinary = join(emsdkDir, os.type === "windows" ? "emsdk.bat" : "emsdk");
const installResult = await $`${emsdkBinary} install latest`.quiet();
if (installResult.exitCode !== 0) {
return {
err: `Failed to install emsdk: ${installResult.stderr.toString()}`,
};
}
// Activate latest version
logger.debug("Activating latest Emscripten version...");
const activateResult = await $`${emsdkBinary} activate latest`.quiet();
if (activateResult.exitCode !== 0) {
return {
err: `Failed to activate emsdk: ${activateResult.stderr.toString()}`,
};
}
logger.info("Emscripten SDK installed and activated successfully");
}
// Check if the emsdk directory is activated/installed properly for the current OS
match({
os: os,