mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-18 00:02:48 +00:00
repo: push all current workspace changes
This commit is contained in:
parent
252fbdc93b
commit
e7dfff5836
29 changed files with 577 additions and 98 deletions
|
|
@ -2,15 +2,22 @@ import { execSync } from "node:child_process";
|
|||
import { cpSync, readFileSync, writeFileSync, rmSync, existsSync } from "node:fs";
|
||||
import { resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createFoundryLogger } from "@sandbox-agent/foundry-shared";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const desktopRoot = resolve(__dirname, "..");
|
||||
const repoRoot = resolve(desktopRoot, "../../..");
|
||||
const frontendDist = resolve(desktopRoot, "../frontend/dist");
|
||||
const destDir = resolve(desktopRoot, "frontend-dist");
|
||||
const logger = createFoundryLogger({
|
||||
service: "foundry-desktop-build",
|
||||
bindings: {
|
||||
script: "build-frontend",
|
||||
},
|
||||
});
|
||||
|
||||
function run(cmd: string, opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
|
||||
console.log(`> ${cmd}`);
|
||||
logger.info({ command: cmd, cwd: opts?.cwd ?? repoRoot }, "run_command");
|
||||
execSync(cmd, {
|
||||
stdio: "inherit",
|
||||
cwd: opts?.cwd ?? repoRoot,
|
||||
|
|
@ -19,7 +26,7 @@ function run(cmd: string, opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
|
|||
}
|
||||
|
||||
// Step 1: Build the frontend with the desktop-specific backend endpoint
|
||||
console.log("\n=== Building frontend for desktop ===\n");
|
||||
logger.info("building_frontend");
|
||||
run("pnpm --filter @sandbox-agent/foundry-frontend build", {
|
||||
env: {
|
||||
VITE_HF_BACKEND_ENDPOINT: "http://127.0.0.1:7741/v1/rivet",
|
||||
|
|
@ -27,7 +34,7 @@ run("pnpm --filter @sandbox-agent/foundry-frontend build", {
|
|||
});
|
||||
|
||||
// Step 2: Copy dist to frontend-dist/
|
||||
console.log("\n=== Copying frontend build output ===\n");
|
||||
logger.info({ frontendDist, destDir }, "copying_frontend_dist");
|
||||
if (existsSync(destDir)) {
|
||||
rmSync(destDir, { recursive: true });
|
||||
}
|
||||
|
|
@ -39,4 +46,4 @@ let html = readFileSync(indexPath, "utf-8");
|
|||
html = html.replace(/<script\s+src="https:\/\/unpkg\.com\/react-scan\/dist\/auto\.global\.js"[^>]*><\/script>\s*/g, "");
|
||||
writeFileSync(indexPath, html);
|
||||
|
||||
console.log("\n=== Frontend build complete ===\n");
|
||||
logger.info({ indexPath }, "frontend_build_complete");
|
||||
|
|
|
|||
|
|
@ -2,10 +2,17 @@ import { execSync } from "node:child_process";
|
|||
import { mkdirSync, existsSync } from "node:fs";
|
||||
import { resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createFoundryLogger } from "@sandbox-agent/foundry-shared";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const desktopRoot = resolve(__dirname, "..");
|
||||
const sidecarDir = resolve(desktopRoot, "src-tauri/sidecars");
|
||||
const logger = createFoundryLogger({
|
||||
service: "foundry-desktop-build",
|
||||
bindings: {
|
||||
script: "build-sidecar",
|
||||
},
|
||||
});
|
||||
|
||||
const isDev = process.argv.includes("--dev");
|
||||
|
||||
|
|
@ -35,7 +42,7 @@ const targets: Array<{ bunTarget: string; tripleTarget: string }> = isDev
|
|||
];
|
||||
|
||||
function run(cmd: string, opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
|
||||
console.log(`> ${cmd}`);
|
||||
logger.info({ command: cmd, cwd: opts?.cwd ?? desktopRoot }, "run_command");
|
||||
execSync(cmd, {
|
||||
stdio: "inherit",
|
||||
cwd: opts?.cwd ?? desktopRoot,
|
||||
|
|
@ -44,7 +51,7 @@ function run(cmd: string, opts?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
|
|||
}
|
||||
|
||||
// Step 1: Build the backend with tsup
|
||||
console.log("\n=== Building backend with tsup ===\n");
|
||||
logger.info("building_backend");
|
||||
run("pnpm --filter @sandbox-agent/foundry-backend build", {
|
||||
cwd: resolve(desktopRoot, "../../.."),
|
||||
});
|
||||
|
|
@ -55,14 +62,14 @@ mkdirSync(sidecarDir, { recursive: true });
|
|||
const backendEntry = resolve(desktopRoot, "../backend/dist/index.js");
|
||||
|
||||
if (!existsSync(backendEntry)) {
|
||||
console.error(`Backend build output not found at ${backendEntry}`);
|
||||
logger.error({ backendEntry }, "backend_build_output_not_found");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
for (const { bunTarget, tripleTarget } of targets) {
|
||||
const outfile = resolve(sidecarDir, `foundry-backend-${tripleTarget}`);
|
||||
console.log(`\n=== Compiling sidecar for ${tripleTarget} ===\n`);
|
||||
logger.info({ bunTarget, tripleTarget, outfile }, "compiling_sidecar");
|
||||
run(`bun build --compile --target ${bunTarget} ${backendEntry} --outfile ${outfile}`);
|
||||
}
|
||||
|
||||
console.log("\n=== Sidecar build complete ===\n");
|
||||
logger.info({ targets: targets.map((target) => target.tripleTarget) }, "sidecar_build_complete");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue