feat: embed WebUI in binary with proxy flags (#19299)

Co-authored-by: BlankParticle <blankparticle@gmail.com>
This commit is contained in:
Dax
2026-03-26 10:43:56 -04:00
committed by GitHub
parent 83ed1c4414
commit ec20efc11a
3 changed files with 63 additions and 17 deletions

View File

@@ -63,6 +63,26 @@ console.log(`Loaded ${migrations.length} migrations`)
const singleFlag = process.argv.includes("--single")
const baselineFlag = process.argv.includes("--baseline")
const skipInstall = process.argv.includes("--skip-install")
const skipEmbedWebUi = process.argv.includes("--skip-embed-web-ui")
const createEmbeddedWebUIBundle = async()=>{
console.log(`Building Web UI to embed in the binary`);
const appDir = path.join(import.meta.dirname, "../../app")
await $`bun run --cwd ${appDir} build`;
const allFiles = await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: path.join(appDir, "dist")}));
const fileMap = `
// Import all files as file_$i with type: "file"
${allFiles.map((filePath, i) => `import file_${i} from "${path.join(appDir, "dist", filePath)}" with { type: "file" };`).join("\n")}
// Export with original mappings
export default {
${allFiles.map((filePath, i)=>`"${filePath}": file_${i},`).join("\n")}
}
`.trim()
return fileMap;
}
const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle();
const allTargets: {
os: string
@@ -192,7 +212,10 @@ for (const item of targets) {
execArgv: [`--user-agent=opencode/${Script.version}`, "--use-system-ca", "--"],
windows: {},
},
entrypoints: ["./src/index.ts", parserWorker, workerPath],
files: {
...(embeddedFileMap ? { "opencode-web-ui.gen.ts": embeddedFileMap } : {}),
},
entrypoints: ["./src/index.ts", parserWorker, workerPath, ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : [])],
define: {
OPENCODE_VERSION: `'${Script.version}'`,
OPENCODE_MIGRATIONS: JSON.stringify(migrations),