authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-03 23:34:21-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-04 06:34:21+00:00
log203f58e45681c14e3f42104d8773c8293ed8c3a1
treed3563cc86c8ce09550cc14acce5c2542b366b6ed
parent52ae8e88dfc9c8de6aa1844b796e0fdd22cec477
signature Signed by PGP key B5690EEEBB952194

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

Co-authored-by: codex <codex@users.noreply.github.com>

2 files changed, 33 insertions(+), 0 deletions(-)

scripts/build-desktop-artifact.test.ts+16
...@@ -5,6 +5,7 @@ import * as Effect from "effect/Effect";...@@ -5,6 +5,7 @@ import * as Effect from "effect/Effect";
5import * as Option from "effect/Option";5import * as Option from "effect/Option";
66
7import {7import {
8 createStagePnpmConfig,
8 resolveDesktopRuntimeDependencies,9 resolveDesktopRuntimeDependencies,
9 resolveBuildOptions,10 resolveBuildOptions,
10 resolveDesktopBuildIconAssets,11 resolveDesktopBuildIconAssets,
...@@ -64,6 +65,21 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {...@@ -64,6 +65,21 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
64 );65 );
65 });66 });
6667
68 it("carries workspace patch metadata into staged desktop installs", () => {
69 assert.deepStrictEqual(
70 createStagePnpmConfig({
71 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
72 }),
73 {
74 patchedDependencies: {
75 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
76 },
77 },
78 );
79
80 assert.equal(createStagePnpmConfig({}), undefined);
81 });
82
67 it("falls back to the default mock update port when the configured port is blank", () => {83 it("falls back to the default mock update port when the configured port is blank", () => {
68 assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");84 assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
69 assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");85 assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
scripts/build-desktop-artifact.ts+17
...@@ -32,6 +32,7 @@ const BuildArch = Schema.Literals(["arm64", "x64", "universal"]);...@@ -32,6 +32,7 @@ const BuildArch = Schema.Literals(["arm64", "x64", "universal"]);
32const WorkspaceConfig = Schema.Struct({32const WorkspaceConfig = Schema.Struct({
33 catalog: Schema.optional(Schema.Record(Schema.String, Schema.String)),33 catalog: Schema.optional(Schema.Record(Schema.String, Schema.String)),
34 overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),34 overrides: Schema.optional(Schema.Record(Schema.String, Schema.String)),
35 patchedDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),
35});36});
36type WorkspaceConfig = typeof WorkspaceConfig.Type;37type WorkspaceConfig = typeof WorkspaceConfig.Type;
3738
...@@ -270,6 +271,15 @@ interface StagePackageJson {...@@ -270,6 +271,15 @@ interface StagePackageJson {
270 readonly electron: string;271 readonly electron: string;
271 };272 };
272 readonly overrides: Record<string, unknown>;273 readonly overrides: Record<string, unknown>;
274 readonly pnpm?: {
275 readonly patchedDependencies?: Record<string, string>;
276 };
277}
278
279export function createStagePnpmConfig(
280 patchedDependencies: Record<string, string>,
281): StagePackageJson["pnpm"] | undefined {
282 return Object.keys(patchedDependencies).length > 0 ? { patchedDependencies } : undefined;
273}283}
274284
275const AzureTrustedSigningOptionsConfig = Config.all({285const AzureTrustedSigningOptionsConfig = Config.all({
...@@ -757,6 +767,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -757,6 +767,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
757 const workspaceConfig = yield* readWorkspaceConfig();767 const workspaceConfig = yield* readWorkspaceConfig();
758 const workspaceCatalog = workspaceConfig.catalog ?? {};768 const workspaceCatalog = workspaceConfig.catalog ?? {};
759 const workspaceOverrides = workspaceConfig.overrides ?? {};769 const workspaceOverrides = workspaceConfig.overrides ?? {};
770 const workspacePatchedDependencies = workspaceConfig.patchedDependencies ?? {};
760771
761 const platformConfig = PLATFORM_CONFIG[options.platform];772 const platformConfig = PLATFORM_CONFIG[options.platform];
762 if (!platformConfig) {773 if (!platformConfig) {
...@@ -867,6 +878,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -867,6 +878,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
867 // electron-builder is filtering out stageResourcesDir directory in the AppImage for production878 // electron-builder is filtering out stageResourcesDir directory in the AppImage for production
868 yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));879 yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));
869880
881 const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies);
870 const stagePackageJson: StagePackageJson = {882 const stagePackageJson: StagePackageJson = {
871 name: "t3code",883 name: "t3code",
872 version: appVersion,884 version: appVersion,
...@@ -893,11 +905,16 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -893,11 +905,16 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
893 electron: electronVersion,905 electron: electronVersion,
894 },906 },
895 overrides: resolvedOverrides,907 overrides: resolvedOverrides,
908 ...(stagePnpmConfig ? { pnpm: stagePnpmConfig } : {}),
896 };909 };
897910
898 const stagePackageJsonString = yield* encodeJsonString(stagePackageJson);911 const stagePackageJsonString = yield* encodeJsonString(stagePackageJson);
899 yield* fs.writeFileString(path.join(stageAppDir, "package.json"), `${stagePackageJsonString}\n`);912 yield* fs.writeFileString(path.join(stageAppDir, "package.json"), `${stagePackageJsonString}\n`);
900913
914 if (Object.keys(workspacePatchedDependencies).length > 0) {
915 yield* fs.copy(path.join(repoRoot, "patches"), path.join(stageAppDir, "patches"));
916 }
917
901 yield* Effect.log("[desktop-artifact] Installing staged production dependencies...");918 yield* Effect.log("[desktop-artifact] Installing staged production dependencies...");
902 yield* runCommand(919 yield* runCommand(
903 ChildProcess.make({920 ChildProcess.make({