From dac6bb16432154c8a0bd0f5097b68d3fe482beb2 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Sun, 8 Feb 2026 20:48:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=91=BD=E4=BB=A4=E4=B8=BA=20dist=20=E4=BD=93?= =?UTF-8?q?=E7=B3=BB=EF=BC=8Cbuild=20=E4=BB=85=E7=BC=96=E8=AF=91=E4=B8=8D?= =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - build:linux/mac/win → dist/dist:linux/dist:mac/dist:win - Turbo 任务依赖:desktop#dist:* → server#compile → server#build - 根目录 bun dist 一条命令完成完整打包流水线 - 更新 AGENTS.md 文档同步命令变更 --- AGENTS.md | 12 +++++++++--- apps/desktop/AGENTS.md | 20 +++++++++++++------- apps/desktop/package.json | 7 ++++--- apps/server/AGENTS.md | 3 ++- package.json | 4 ++++ turbo.json | 16 ++++++++++++++++ 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c0e75d1..1bad0f6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,6 +20,11 @@ Guidelines for AI agents working in this Bun monorepo. ```bash bun dev # Start all apps in dev mode bun build # Build all apps +bun compile # Compile server to standalone binary (depends on build) +bun dist # Full packaging pipeline: server build → compile → desktop distributable (current platform) +bun dist:linux # Full pipeline → Linux distributable +bun dist:mac # Full pipeline → macOS distributable +bun dist:win # Full pipeline → Windows distributable bun fix # Lint + format (Biome auto-fix) bun typecheck # TypeScript check across monorepo ``` @@ -43,9 +48,10 @@ bun db:studio # Open Drizzle Studio ```bash bun dev # electron-vite dev mode (requires server dev running) bun build # electron-vite build (main + preload) -bun build:win # Build + package for Windows -bun build:mac # Build + package for macOS -bun build:linux # Build + package for Linux +bun dist # Build + package for current platform +bun dist:linux # Build + package for Linux +bun dist:mac # Build + package for macOS +bun dist:win # Build + package for Windows bun fix # Biome auto-fix bun typecheck # TypeScript check ``` diff --git a/apps/desktop/AGENTS.md b/apps/desktop/AGENTS.md index e42c8d5..59fc762 100644 --- a/apps/desktop/AGENTS.md +++ b/apps/desktop/AGENTS.md @@ -24,9 +24,10 @@ Thin Electron shell hosting the fullstack server app. ```bash bun dev # electron-vite dev (requires server dev running) bun build # electron-vite build (main + preload) -bun build:win # Build + package for Windows -bun build:mac # Build + package for macOS -bun build:linux # Build + package for Linux +bun dist # Build + package for current platform +bun dist:linux # Build + package for Linux +bun dist:mac # Build + package for macOS +bun dist:win # Build + package for Windows bun fix # Biome auto-fix bun typecheck # TypeScript check ``` @@ -57,10 +58,15 @@ bun typecheck # TypeScript check ## Production Build Workflow -1. **Build server**: `bun build` in `apps/server` → `.output/` -2. **Compile server**: `bun compile` in `apps/server` → `out/server-{platform}` -3. **Copy binary**: Copy the platform-appropriate binary to `apps/desktop/resources/server` -4. **Package desktop**: `bun build:linux` (or `:mac` / `:win`) in `apps/desktop` +From monorepo root, run `bun dist` to execute the full pipeline automatically (via Turbo task dependencies): + +1. **Build server**: `apps/server` → `vite build` → `.output/` +2. **Compile server**: `apps/server` → `bun compile.ts` → `out/server-{platform}` +3. **Package desktop**: `apps/desktop` → `electron-vite build` + `electron-builder` → distributable + +The `electron-builder.yml` `extraResources` config reads binaries directly from `../server/out/`, no manual copy needed. + +To build for a specific platform explicitly, use `bun dist:linux` / `bun dist:mac` / `bun dist:win` in `apps/desktop`. ## Critical Rules diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 43c50dc..81dd48c 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -9,10 +9,11 @@ "main": "out/main/index.js", "scripts": { "build": "electron-vite build", - "build:linux": "electron-vite build && electron-builder --linux --config", - "build:mac": "electron-vite build && electron-builder --mac --config", - "build:win": "electron-vite build && electron-builder --win --config", "dev": "electron-vite dev", + "dist": "bun run build && electron-builder --config", + "dist:linux": "bun run build && electron-builder --linux --config", + "dist:mac": "bun run build && electron-builder --mac --config", + "dist:win": "bun run build && electron-builder --win --config", "fix": "biome check --write", "typecheck": "tsc --noEmit" }, diff --git a/apps/server/AGENTS.md b/apps/server/AGENTS.md index 8844eb8..355dac3 100644 --- a/apps/server/AGENTS.md +++ b/apps/server/AGENTS.md @@ -25,7 +25,8 @@ bun db:studio # Drizzle Studio GUI # Build bun build # Production build → .output/ -bun compile # Compile to standalone binary +bun compile # Compile to standalone binary (depends on build) + # Also triggered automatically by root `bun dist` # Code Quality bun fix # Biome auto-fix diff --git a/package.json b/package.json index 5f8f858..0131ea9 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ "build": "turbo run build", "compile": "turbo run compile", "dev": "turbo run dev", + "dist": "turbo run dist", + "dist:linux": "turbo run dist:linux", + "dist:mac": "turbo run dist:mac", + "dist:win": "turbo run dist:win", "fix": "turbo run fix", "typecheck": "turbo run typecheck" }, diff --git a/turbo.json b/turbo.json index 862cb35..86ef30e 100644 --- a/turbo.json +++ b/turbo.json @@ -9,6 +9,22 @@ "compile": { "dependsOn": ["build"] }, + "dist": {}, + "dist:linux": {}, + "dist:mac": {}, + "dist:win": {}, + "@furtherverse/desktop#dist": { + "dependsOn": ["@furtherverse/server#compile"] + }, + "@furtherverse/desktop#dist:linux": { + "dependsOn": ["@furtherverse/server#compile"] + }, + "@furtherverse/desktop#dist:mac": { + "dependsOn": ["@furtherverse/server#compile"] + }, + "@furtherverse/desktop#dist:win": { + "dependsOn": ["@furtherverse/server#compile"] + }, "dev": { "cache": false, "persistent": true