Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

[codex] Fix desktop packaging patched dependencies (#2944)

Julius Marminge203f58e45681
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index 743263d43..345217a54 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -5,6 +5,7 @@ import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import {
+ createStagePnpmConfig,
resolveDesktopRuntimeDependencies,
resolveBuildOptions,
resolveDesktopBuildIconAssets,
@@ -64,6 +65,21 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
);
});
+ it("carries workspace patch metadata into staged desktop installs", () => {
+ assert.deepStrictEqual(
+ createStagePnpmConfig({
+ "@pierre/[email protected]": "patches/@pierre%[email protected]",
+ }),
+ {
+ patchedDependencies: {
+ "@pierre/[email protected]": "patches/@pierre%[email protected]",
+ },
+ },
+ );
+
+ assert.equal(createStagePnpmConfig({}), undefined);
+ });
+
it("falls back to the default mock update port when the configured port is blank", () => {
assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index 288881eed..53f7da8e6 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -32,6 +32,7 @@ const BuildArch = Schema.Literals(["arm64", "x64", "universal"]);
const WorkspaceConfig = Schema.Struct({
catalog: Schema.optional(Schema.Record(Schema.String, Schema.String)),
overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
+ patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
});
type WorkspaceConfig = typeof WorkspaceConfig.Type;
@@ -270,6 +271,15 @@ interface StagePackageJson {
readonly electron: string;
};
readonly overrides: Record<string, unknown>;
+ readonly pnpm?: {
+ readonly patchedDependencies?: Record<string, string>;
+ };
+}
+
+export function createStagePnpmConfig(
+ patchedDependencies: Record<string, string>,
+): StagePackageJson["pnpm"] | undefined {
+ return Object.keys(patchedDependencies).length > 0 ? { patchedDependencies } : undefined;
}
const AzureTrustedSigningOptionsConfig = Config.all({
@@ -757,6 +767,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
const workspaceConfig = yield* readWorkspaceConfig();
const workspaceCatalog = workspaceConfig.catalog ?? {};
const workspaceOverrides = workspaceConfig.overrides ?? {};
+ const workspacePatchedDependencies = workspaceConfig.patchedDependencies ?? {};
const platformConfig = PLATFORM_CONFIG[options.platform];
if (!platformConfig) {
@@ -867,6 +878,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
// electron-builder is filtering out stageResourcesDir directory in the AppImage for production
yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));
+ const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies);
const stagePackageJson: StagePackageJson = {
name: "t3code",
version: appVersion,
@@ -893,11 +905,16 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
electron: electronVersion,
},
overrides: resolvedOverrides,
+ ...(stagePnpmConfig ? { pnpm: stagePnpmConfig } : {}),
};
const stagePackageJsonString = yield* encodeJsonString(stagePackageJson);
yield* fs.writeFileString(path.join(stageAppDir, "package.json"), `${stagePackageJsonString}\n`);
+ if (Object.keys(workspacePatchedDependencies).length > 0) {
+ yield* fs.copy(path.join(repoRoot, "patches"), path.join(stageAppDir, "patches"));
+ }
+
yield* Effect.log("[desktop-artifact] Installing staged production dependencies...");
yield* runCommand(
ChildProcess.make({