From 60bb4003e07b279fc6010387889178625f0755eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Andr=C3=A9?= Date: Wed, 10 Jun 2026 20:12:01 +0200 Subject: [PATCH 1/3] fix(den-api): build on Windows --- ee/apps/den-api/scripts/build.mjs | 16 ++++++++++++++-- ee/apps/den-api/src/generated/app-version.ts | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ee/apps/den-api/scripts/build.mjs b/ee/apps/den-api/scripts/build.mjs index 5fe9bab9b9..4cd48ac232 100644 --- a/ee/apps/den-api/scripts/build.mjs +++ b/ee/apps/den-api/scripts/build.mjs @@ -8,7 +8,8 @@ const serviceDir = path.resolve(scriptDir, "..") const repoRoot = path.resolve(serviceDir, "..", "..", "..") const desktopPackagePath = path.join(repoRoot, "apps", "desktop", "package.json") const generatedVersionPath = path.join(serviceDir, "src", "generated", "app-version.ts") -const pnpmCommand = process.platform === "win32" ? "pnpm.cmd" : "pnpm" +const pnpmCommand = "pnpm" +const useShellForPnpm = process.platform === "win32" const fallbackAppVersion = "0.0.0" function readDesktopVersion() { @@ -40,13 +41,24 @@ function writeGeneratedVersionFile(latestAppVersion) { ) } +function quoteShellArg(value) { + return `"${String(value).replace(/"/g, '\\"')}"` +} + function run(command, args) { - const result = spawnSync(command, args, { + const shellCommand = [command, ...args.map(quoteShellArg)].join(" ") + const result = spawnSync(useShellForPnpm ? shellCommand : command, useShellForPnpm ? [] : args, { cwd: serviceDir, env: process.env, stdio: "inherit", + shell: useShellForPnpm, }) + if (result.error) { + console.error(result.error) + process.exit(1) + } + if (result.status !== 0) { process.exit(result.status ?? 1) } diff --git a/ee/apps/den-api/src/generated/app-version.ts b/ee/apps/den-api/src/generated/app-version.ts index 9a4e741eab..97880ec70e 100644 --- a/ee/apps/den-api/src/generated/app-version.ts +++ b/ee/apps/den-api/src/generated/app-version.ts @@ -1 +1 @@ -export const BUILD_LATEST_APP_VERSION = "0.13.8" as const +export const BUILD_LATEST_APP_VERSION = "0.15.3" as const From 3d8af2e5ac5343bf70d888b78a9cda20d6f9fcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Andr=C3=A9?= Date: Thu, 11 Jun 2026 04:34:17 +0200 Subject: [PATCH 2/3] fix(den): cover Windows build shell invocation --- ee/apps/den-api/scripts/build.mjs | 36 ++++++++++++++------ ee/apps/den-api/src/generated/app-version.ts | 2 +- ee/apps/den-api/test/build-script.test.ts | 25 ++++++++++++++ 3 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 ee/apps/den-api/test/build-script.test.ts diff --git a/ee/apps/den-api/scripts/build.mjs b/ee/apps/den-api/scripts/build.mjs index 4cd48ac232..badbcfa730 100644 --- a/ee/apps/den-api/scripts/build.mjs +++ b/ee/apps/den-api/scripts/build.mjs @@ -1,7 +1,7 @@ import { spawnSync } from "node:child_process" import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs" import path from "node:path" -import { fileURLToPath } from "node:url" +import { fileURLToPath, pathToFileURL } from "node:url" const scriptDir = path.dirname(fileURLToPath(import.meta.url)) const serviceDir = path.resolve(scriptDir, "..") @@ -9,7 +9,6 @@ const repoRoot = path.resolve(serviceDir, "..", "..", "..") const desktopPackagePath = path.join(repoRoot, "apps", "desktop", "package.json") const generatedVersionPath = path.join(serviceDir, "src", "generated", "app-version.ts") const pnpmCommand = "pnpm" -const useShellForPnpm = process.platform === "win32" const fallbackAppVersion = "0.0.0" function readDesktopVersion() { @@ -41,17 +40,26 @@ function writeGeneratedVersionFile(latestAppVersion) { ) } -function quoteShellArg(value) { +export function quoteShellArg(value) { return `"${String(value).replace(/"/g, '\\"')}"` } +export function createPnpmSpawnInput(command, args, platform = process.platform) { + const useShell = platform === "win32" + return { + command: useShell ? [command, ...args].map(quoteShellArg).join(" ") : command, + args: useShell ? [] : args, + shell: useShell, + } +} + function run(command, args) { - const shellCommand = [command, ...args.map(quoteShellArg)].join(" ") - const result = spawnSync(useShellForPnpm ? shellCommand : command, useShellForPnpm ? [] : args, { + const input = createPnpmSpawnInput(command, args) + const result = spawnSync(input.command, input.args, { cwd: serviceDir, env: process.env, stdio: "inherit", - shell: useShellForPnpm, + shell: input.shell, }) if (result.error) { @@ -64,9 +72,15 @@ function run(command, args) { } } -process.env.DEN_API_LATEST_APP_VERSION = process.env.DEN_API_LATEST_APP_VERSION || readDesktopVersion() -writeGeneratedVersionFile(process.env.DEN_API_LATEST_APP_VERSION) +function main() { + process.env.DEN_API_LATEST_APP_VERSION = process.env.DEN_API_LATEST_APP_VERSION || readDesktopVersion() + writeGeneratedVersionFile(process.env.DEN_API_LATEST_APP_VERSION) -run(pnpmCommand, ["run", "build:email"]) -run(pnpmCommand, ["run", "build:den-db"]) -run(pnpmCommand, ["exec", "tsc", "-p", "tsconfig.json"]) + run(pnpmCommand, ["run", "build:email"]) + run(pnpmCommand, ["run", "build:den-db"]) + run(pnpmCommand, ["exec", "tsc", "-p", "tsconfig.json"]) +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + main() +} diff --git a/ee/apps/den-api/src/generated/app-version.ts b/ee/apps/den-api/src/generated/app-version.ts index 97880ec70e..b9fc2681e1 100644 --- a/ee/apps/den-api/src/generated/app-version.ts +++ b/ee/apps/den-api/src/generated/app-version.ts @@ -1 +1 @@ -export const BUILD_LATEST_APP_VERSION = "0.15.3" as const +export const BUILD_LATEST_APP_VERSION = "0.15.4" as const diff --git a/ee/apps/den-api/test/build-script.test.ts b/ee/apps/den-api/test/build-script.test.ts new file mode 100644 index 0000000000..ccccb22e67 --- /dev/null +++ b/ee/apps/den-api/test/build-script.test.ts @@ -0,0 +1,25 @@ +import { describe, expect, test } from "bun:test" +import { createPnpmSpawnInput } from "../scripts/build.mjs" + +describe("den-api build script", () => { + test("quotes the pnpm command when Windows shell mode is required", () => { + const input = createPnpmSpawnInput("C:\\Program Files\\pnpm (den)\\pnpm.cmd", ["exec", "tsc", "-p", "tsconfig.json"], "win32") + + expect(input).toEqual({ + command: '"C:\\Program Files\\pnpm (den)\\pnpm.cmd" "exec" "tsc" "-p" "tsconfig.json"', + args: [], + shell: true, + }) + }) + + test("keeps direct argv spawning on non-Windows platforms", () => { + const args = ["exec", "tsc", "-p", "tsconfig.json"] + const input = createPnpmSpawnInput("pnpm", args, "linux") + + expect(input).toEqual({ + command: "pnpm", + args, + shell: false, + }) + }) +}) From af462de004e7fe196c3d318030467b9c42795857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Andr=C3=A9?= Date: Fri, 12 Jun 2026 12:18:09 +0200 Subject: [PATCH 3/3] fix(den): align generated app version for 0.16.2 --- ee/apps/den-api/src/generated/app-version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/apps/den-api/src/generated/app-version.ts b/ee/apps/den-api/src/generated/app-version.ts index b9fc2681e1..1e43bedf9d 100644 --- a/ee/apps/den-api/src/generated/app-version.ts +++ b/ee/apps/den-api/src/generated/app-version.ts @@ -1 +1 @@ -export const BUILD_LATEST_APP_VERSION = "0.15.4" as const +export const BUILD_LATEST_APP_VERSION = "0.16.2" as const