mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-01 02:06:41 +00:00
feat: embed WebUI in binary with proxy flags (#19299)
Co-authored-by: BlankParticle <blankparticle@gmail.com>
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user