fix(check): stabilize pnpm check on Windows

This commit is contained in:
林剑凛 2026-06-26 17:55:58 +08:00 committed by GitHub
parent d024ac3bf4
commit bebed75265
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 39 additions and 14 deletions

3
.gitattributes vendored Normal file
View File

@ -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

View File

@ -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<Record<string, unknown>> {
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: "<project><version>0.1.10</version></project>",
manifestJson: '{ "version": "0.1.10" }',
});

View File

@ -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<Record<string, unknown>> {
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(

View File

@ -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");
}
}

View File

@ -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 {

View File

@ -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 });
}
});