authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-06-03 23:47:20-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-06-03 23:47:20-07:00
loga6edad19742869a1f3254292fd1b24e153b03901
tree0a69ae13849630214962a00ab2f4a1c233138d7d
parent203f58e45681c14e3f42104d8773c8293ed8c3a1
signature Signed by PGP key B5690EEEBB952194

[codex] Filter staged desktop patched dependencies (#2945)

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

2 files changed, 44 insertions(+), 11 deletions(-)

scripts/build-desktop-artifact.test.ts+23-5
...@@ -65,19 +65,37 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {...@@ -65,19 +65,37 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
65 );65 );
66 });66 });
6767
68 it("carries workspace patch metadata into staged desktop installs", () => {68 it("carries only staged dependency patch metadata into staged desktop installs", () => {
69 assert.deepStrictEqual(69 assert.deepStrictEqual(
70 createStagePnpmConfig({70 createStagePnpmConfig(
71 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",71 {
72 }),72 "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch",
73 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
74 "alchemy@2.0.0-beta.49": "patches/alchemy@2.0.0-beta.49.patch",
75 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
76 },
77 {
78 "@pierre/diffs": "1.1.20",
79 effect: "4.0.0-beta.73",
80 },
81 ),
73 {82 {
74 patchedDependencies: {83 patchedDependencies: {
75 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",84 "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch",
85 "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch",
76 },86 },
77 },87 },
78 );88 );
7989
80 assert.equal(createStagePnpmConfig({}), undefined);90 assert.equal(
91 createStagePnpmConfig(
92 {
93 "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch",
94 },
95 { effect: "4.0.0-beta.73" },
96 ),
97 undefined,
98 );
81 });99 });
82100
83 it("falls back to the default mock update port when the configured port is blank", () => {101 it("falls back to the default mock update port when the configured port is blank", () => {
scripts/build-desktop-artifact.ts+21-6
...@@ -278,8 +278,22 @@ interface StagePackageJson {...@@ -278,8 +278,22 @@ interface StagePackageJson {
278278
279export function createStagePnpmConfig(279export function createStagePnpmConfig(
280 patchedDependencies: Record<string, string>,280 patchedDependencies: Record<string, string>,
281 dependencies: Record<string, unknown>,
281): StagePackageJson["pnpm"] | undefined {282): StagePackageJson["pnpm"] | undefined {
282 return Object.keys(patchedDependencies).length > 0 ? { patchedDependencies } : undefined;283 const stagePatchedDependencies = Object.fromEntries(
284 Object.entries(patchedDependencies).filter(([patchKey]) =>
285 Object.hasOwn(dependencies, getPatchedDependencyPackageName(patchKey)),
286 ),
287 );
288
289 return Object.keys(stagePatchedDependencies).length > 0
290 ? { patchedDependencies: stagePatchedDependencies }
291 : undefined;
292}
293
294function getPatchedDependencyPackageName(patchKey: string): string {
295 const versionSeparator = patchKey.lastIndexOf("@");
296 return versionSeparator > 0 ? patchKey.slice(0, versionSeparator) : patchKey;
283}297}
284298
285const AzureTrustedSigningOptionsConfig = Config.all({299const AzureTrustedSigningOptionsConfig = Config.all({
...@@ -878,7 +892,11 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -878,7 +892,11 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
878 // electron-builder is filtering out stageResourcesDir directory in the AppImage for production892 // electron-builder is filtering out stageResourcesDir directory in the AppImage for production
879 yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));893 yield* fs.copy(stageResourcesDir, path.join(stageAppDir, "apps/desktop/prod-resources"));
880894
881 const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies);895 const stageDependencies = {
896 ...resolvedServerDependencies,
897 ...resolvedDesktopRuntimeDependencies,
898 };
899 const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies, stageDependencies);
882 const stagePackageJson: StagePackageJson = {900 const stagePackageJson: StagePackageJson = {
883 name: "t3code",901 name: "t3code",
884 version: appVersion,902 version: appVersion,
...@@ -897,10 +915,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -897,10 +915,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
897 options.mockUpdates,915 options.mockUpdates,
898 options.mockUpdateServerPort,916 options.mockUpdateServerPort,
899 ),917 ),
900 dependencies: {918 dependencies: stageDependencies,
901 ...resolvedServerDependencies,
902 ...resolvedDesktopRuntimeDependencies,
903 },
904 devDependencies: {919 devDependencies: {
905 electron: electronVersion,920 electron: electronVersion,
906 },921 },