From 358a6e7eb9e8491ddb12165eaf305a392123d6e1 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 18 Sep 2025 14:12:41 +0200 Subject: [PATCH 1/3] fix: unused test --- crates/pgt_hover/tests/hover_integration_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/pgt_hover/tests/hover_integration_tests.rs b/crates/pgt_hover/tests/hover_integration_tests.rs index 9882e6b6b..344d33dff 100644 --- a/crates/pgt_hover/tests/hover_integration_tests.rs +++ b/crates/pgt_hover/tests/hover_integration_tests.rs @@ -443,6 +443,7 @@ async fn test_column_hover_with_quoted_column_name_with_table(test_db: PgPool) { .await; } +#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] async fn test_policy_table_hover(test_db: PgPool) { let setup = r#" create table users ( From 0c78d7f3dd78f40a905ed4b5e2b19070a10a6557 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 18 Sep 2025 14:26:47 +0200 Subject: [PATCH 2/3] fix(backendjsonrpc): fix command --- .../backend-jsonrpc/src/command.ts | 96 +++++++++++++------ 1 file changed, 67 insertions(+), 29 deletions(-) diff --git a/packages/@postgrestools/backend-jsonrpc/src/command.ts b/packages/@postgrestools/backend-jsonrpc/src/command.ts index 1f3ef398f..881f6d7ba 100644 --- a/packages/@postgrestools/backend-jsonrpc/src/command.ts +++ b/packages/@postgrestools/backend-jsonrpc/src/command.ts @@ -1,36 +1,74 @@ +import { execSync } from "node:child_process"; + /** * Gets the path of the binary for the current platform * * @returns Filesystem path to the binary, or null if no prebuilt distribution exists for the current platform */ export function getCommand(): string | null { - const { platform, arch } = process; - - type PlatformPaths = { - [P in NodeJS.Platform]?: { - [A in NodeJS.Architecture]?: string; - }; - }; - - const PLATFORMS: PlatformPaths = { - win32: { - x64: "@postgrestools/cli-win32-x64/postgrestools.exe", - arm64: "@postgrestools/cli-win32-arm64/postgrestools.exe", - }, - darwin: { - x64: "@postgrestools/cli-darwin-x64/postgrestools", - arm64: "@postgrestools/cli-darwin-arm64/postgrestools", - }, - linux: { - x64: "@postgrestools/cli-linux-x64/postgrestools", - arm64: "@postgrestools/cli-linux-arm64/postgrestools", - }, - }; - - const binPath = PLATFORMS?.[platform]?.[arch]; - if (!binPath) { - return null; - } - - return require.resolve(binPath); + const { platform, arch } = process; + + const PLATFORMS: Partial< + Record< + NodeJS.Platform | "linux-musl", + Partial> + > + > = { + win32: { + x64: "@postgrestools/cli-x86_64-windows-msvc/postgrestools.exe", + arm64: "@postgrestools/cli-aarch64-windows-msvc/postgrestools.exe", + }, + darwin: { + x64: "@postgrestools/cli-x86_64-apple-darwin/postgrestools", + arm64: "@postgrestools/cli-aarch64-apple-darwin/postgrestools", + }, + linux: { + x64: "@postgrestools/cli-x86_64-linux-gnu/postgrestools", + arm64: "@postgrestools/cli-aarch64-linux-gnu/postgrestools", + }, + "linux-musl": { + x64: "@postgrestools/cli-x86_64-linux-musl/postgrestools", + // no arm64 build for musl + }, + }; + + function isMusl() { + let stderr = ""; + try { + stderr = execSync("ldd --version", { + stdio: [ + "ignore", // stdin + "pipe", // stdout – glibc systems print here + "pipe", // stderr – musl systems print here + ], + }).toString(); + } catch (err: unknown) { + if (hasStdErr(err)) { + stderr = err.stderr; + } + } + if (stderr.indexOf("musl") > -1) { + return true; + } + return false; + } + + function getPlatform(): NodeJS.Platform | "linux-musl" { + if (platform === "linux") { + return isMusl() ? "linux-musl" : "linux"; + } + + return platform; + } + + const binPath = PLATFORMS?.[getPlatform()]?.[arch]; + if (!binPath) { + return null; + } + + return require.resolve(binPath); +} + +function hasStdErr(err: unknown): err is { stderr: string } { + return !!(err as any)?.stderr; } From 9c33bfab00b529ae4854550de60f81239fd7dac3 Mon Sep 17 00:00:00 2001 From: Julian Domke <68325451+juleswritescode@users.noreply.github.com> Date: Thu, 18 Sep 2025 14:28:20 +0200 Subject: [PATCH 3/3] Update crates/pgt_hover/tests/hover_integration_tests.rs --- crates/pgt_hover/tests/hover_integration_tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/pgt_hover/tests/hover_integration_tests.rs b/crates/pgt_hover/tests/hover_integration_tests.rs index 344d33dff..9882e6b6b 100644 --- a/crates/pgt_hover/tests/hover_integration_tests.rs +++ b/crates/pgt_hover/tests/hover_integration_tests.rs @@ -443,7 +443,6 @@ async fn test_column_hover_with_quoted_column_name_with_table(test_db: PgPool) { .await; } -#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] async fn test_policy_table_hover(test_db: PgPool) { let setup = r#" create table users (