Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

build: clean desktop output before bundling frontend assets (#13095)

mingruankejiaf7c55311a5f
diff --git a/README.md b/README.md
index 15681df9c2..eacc969817 100644
--- a/README.md
+++ b/README.md
@@ -633,6 +633,8 @@ make package
The installer will be in `src-tauri/target/release/bundle/`.
+`pnpm build` explicitly removes the previous root `dist/` directory before running Vite, so desktop packaging starts with fresh frontend output.
+
## Tech Stack
| Layer | Technology |
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 07f1e79842..cf57908811 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -587,6 +587,8 @@ make package
安装包输出在 `src-tauri/target/release/bundle/` 目录。
+`pnpm build` 会在运行 Vite 前显式清理根目录的 `dist/`,确保桌面打包使用重新生成的前端资源。
+
## 技术栈
| 层级 | 技术 |
diff --git a/package.json b/package.json
index abbc75d3ea..b9d98c7575 100644
--- a/package.json
+++ b/package.json
@@ -28,7 +28,7 @@
"check:connection-types": "node scripts/sync-connection-types.mjs --check",
"pretypecheck": "pnpm generate:connection-types",
"typecheck": "vue-tsc --noEmit --project apps/desktop/tsconfig.json",
- "build": "vite build --config apps/desktop/vite.config.ts",
+ "build": "node scripts/clean-desktop-dist.mjs && vite build --config apps/desktop/vite.config.ts",
"build:docs-export": "vite build --config apps/desktop/vite.docs-export.config.ts",
"build:checked": "pnpm typecheck && pnpm build",
"check": "node scripts/run-check.mjs",
diff --git a/scripts/clean-desktop-dist.mjs b/scripts/clean-desktop-dist.mjs
new file mode 100644
index 0000000000..19d5a33918
--- /dev/null
+++ b/scripts/clean-desktop-dist.mjs
@@ -0,0 +1,5 @@
+import { rm } from "node:fs/promises";
+import { fileURLToPath } from "node:url";
+
+const distDirectory = fileURLToPath(new URL("../dist", import.meta.url));
+await rm(distDirectory, { recursive: true, force: true });
diff --git a/scripts/clean-desktop-dist.test.mjs b/scripts/clean-desktop-dist.test.mjs
new file mode 100644
index 0000000000..a5781ffbb7
--- /dev/null
+++ b/scripts/clean-desktop-dist.test.mjs
@@ -0,0 +1,32 @@
+import assert from "node:assert/strict";
+import { execFile } from "node:child_process";
+import { access, copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { test } from "node:test";
+import { promisify } from "node:util";
+
+const execFileAsync = promisify(execFile);
+
+test("cleans only the script's desktop dist directory, even from another cwd", async (t) => {
+ const root = await mkdtemp(path.join(tmpdir(), "dbx-clean-desktop-dist-"));
+ t.after(() => rm(root, { recursive: true, force: true }));
+ const scripts = path.join(root, "scripts");
+ const dist = path.join(root, "dist");
+ const assets = path.join(dist, "assets");
+ const other = path.join(root, "other");
+ await mkdir(scripts);
+ await mkdir(assets, { recursive: true });
+ await mkdir(path.join(other, "dist"), { recursive: true });
+ await copyFile(new URL("./clean-desktop-dist.mjs", import.meta.url), path.join(scripts, "clean-desktop-dist.mjs"));
+ await writeFile(path.join(assets, "stale.js"), "stale");
+ const unrelated = path.join(other, "dist", "keep.txt");
+ await writeFile(unrelated, "keep");
+
+ const run = () => execFileAsync(process.execPath, [path.join(scripts, "clean-desktop-dist.mjs")], { cwd: other });
+ await run();
+ await assert.rejects(access(dist), { code: "ENOENT" });
+ assert.equal(await readFile(unrelated, "utf8"), "keep");
+ await run();
+ assert.equal(await readFile(unrelated, "utf8"), "keep");
+});