diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..9cac1c097 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Keep formatter-sensitive source files consistent across platforms. +apps/desktop/src/**/*.ts text eol=lf +apps/desktop/src/**/*.vue text eol=lf diff --git a/packages/app-tests/jdbcPluginRelease.test.ts b/packages/app-tests/jdbcPluginRelease.test.ts index bafa8ca11..3e90b5a97 100644 --- a/packages/app-tests/jdbcPluginRelease.test.ts +++ b/packages/app-tests/jdbcPluginRelease.test.ts @@ -1,8 +1,16 @@ import { strict as assert } from "node:assert"; +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; import { test } from "vitest"; -import { evaluateJdbcPluginReleaseBump } from "../../.github/scripts/bump-jdbc-plugin-version.mjs"; -import { evaluateJdbcPluginVersionChange } from "../../.github/scripts/check-jdbc-plugin-version.mjs"; -import { augmentLatestJsonWithJdbcPlugin } from "../../.github/scripts/augment-latest-json-jdbc-plugin.mjs"; + +const { evaluateJdbcPluginReleaseBump } = await importScript(".github/scripts/bump-jdbc-plugin-version.mjs"); +const { evaluateJdbcPluginVersionChange } = await importScript(".github/scripts/check-jdbc-plugin-version.mjs"); +const { augmentLatestJsonWithJdbcPlugin } = await importScript(".github/scripts/augment-latest-json-jdbc-plugin.mjs"); + +function importScript(path: string): Promise> { + const source = readFileSync(resolve(path), "utf8").replace(/^#!.*\r?\n/, ""); + return import(`data:text/javascript;base64,${Buffer.from(source).toString("base64")}`); +} test("allows JDBC plugin runtime changes without a manual version bump before release", () => { assert.deepEqual( @@ -72,11 +80,7 @@ test("auto bumps JDBC plugin patch version when runtime files changed for releas test("does not auto bump JDBC plugin again when release range already includes a version bump", () => { const result = evaluateJdbcPluginReleaseBump({ - changedFiles: [ - "plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java", - "plugins/jdbc/pom.xml", - "plugins/jdbc/manifest.json", - ], + changedFiles: ["plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java", "plugins/jdbc/pom.xml", "plugins/jdbc/manifest.json"], pomXml: "0.1.10", manifestJson: '{ "version": "0.1.10" }', }); diff --git a/packages/app-tests/syncChangelog.test.ts b/packages/app-tests/syncChangelog.test.ts index 90e5b24ff..c88ed54fb 100644 --- a/packages/app-tests/syncChangelog.test.ts +++ b/packages/app-tests/syncChangelog.test.ts @@ -1,7 +1,16 @@ import { strict as assert } from "node:assert"; +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; import { test } from "vitest"; -const syncChangelog = await import("../../.github/scripts/sync-changelog.mjs"); +const syncChangelog = await importScript(".github/scripts/sync-changelog.mjs"); + +function importScript(path: string): Promise> { + const source = readFileSync(resolve(path), "utf8") + .replace(/^#!.*\r?\n/, "") + .replace("if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1]))", "if (false)"); + return import(`data:text/javascript;base64,${Buffer.from(source).toString("base64")}`); +} test("translateToEnglish reuses cached release translations when source hash is unchanged", async () => { const cnJson = syncChangelog.buildReleasesJson( diff --git a/packages/node-core/src/paths.ts b/packages/node-core/src/paths.ts index 959ef60fd..1edcd6578 100644 --- a/packages/node-core/src/paths.ts +++ b/packages/node-core/src/paths.ts @@ -1,5 +1,5 @@ import { homedir, platform } from "node:os"; -import { join } from "node:path"; +import { join, posix, win32 } from "node:path"; export function appDataDir(): string { // 支持 DBX_DATA_DIR 环境变量(与 Rust 侧 data_dir.rs 保持一致) @@ -18,11 +18,11 @@ export function appDataDirFromInputs(options: { platform: NodeJS.Platform; home: switch (options.platform) { case "darwin": - return join(options.home, "Library", "Application Support", "com.dbx.app"); + return posix.join(options.home, "Library", "Application Support", "com.dbx.app"); case "win32": - return join(options.appData || join(options.home, "AppData", "Roaming"), "com.dbx.app"); + return win32.join(options.appData || win32.join(options.home, "AppData", "Roaming"), "com.dbx.app"); default: - return join(options.home, ".local", "share", "com.dbx.app"); + return posix.join(options.home, ".local", "share", "com.dbx.app"); } } diff --git a/packages/node-core/tests/entrypoint.test.ts b/packages/node-core/tests/entrypoint.test.ts index fa07918ff..d62419454 100644 --- a/packages/node-core/tests/entrypoint.test.ts +++ b/packages/node-core/tests/entrypoint.test.ts @@ -25,7 +25,12 @@ test("matches a module invoked through an npm-style symlink", async () => { const bin = join(dir, "dbx"); await mkdir(join(dir, "dist")); await writeFile(entry, "", "utf-8"); - await symlink(entry, bin); + try { + await symlink(entry, bin); + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== "EPERM") throw error; + return; + } assert.equal(isMainModule(pathToFileURL(entry).href, bin), true); } finally { diff --git a/packages/node-core/tests/sqlite-direct.test.ts b/packages/node-core/tests/sqlite-direct.test.ts index a9a796773..9c529fc0f 100644 --- a/packages/node-core/tests/sqlite-direct.test.ts +++ b/packages/node-core/tests/sqlite-direct.test.ts @@ -113,7 +113,9 @@ test("lists and describes SQLite tables without the DBX bridge", async () => { test("routes SSH transport layer connections through the DBX bridge", async () => { const dir = mkdtempSync(join(tmpdir(), "dbx-mcp-bridge-home-")); const originalHome = process.env.HOME; + const originalDbxDataDir = process.env.DBX_DATA_DIR; process.env.HOME = dir; + process.env.DBX_DATA_DIR = dir; try { await assert.rejects(() => executeQuery(mysqlSshConfig(), "select 1"), /DBX desktop app is not running/); @@ -122,6 +124,8 @@ test("routes SSH transport layer connections through the DBX bridge", async () = } finally { if (originalHome === undefined) delete process.env.HOME; else process.env.HOME = originalHome; + if (originalDbxDataDir === undefined) delete process.env.DBX_DATA_DIR; + else process.env.DBX_DATA_DIR = originalDbxDataDir; rmSync(dir, { recursive: true, force: true }); } });