diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts index 345217a540..8dc23484ab 100644 --- a/scripts/build-desktop-artifact.test.ts +++ b/scripts/build-desktop-artifact.test.ts @@ -65,19 +65,37 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { ); }); - it("carries workspace patch metadata into staged desktop installs", () => { + it("carries only staged dependency patch metadata into staged desktop installs", () => { assert.deepStrictEqual( - createStagePnpmConfig({ - "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch", - }), + createStagePnpmConfig( + { + "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch", + "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch", + "alchemy@2.0.0-beta.49": "patches/alchemy@2.0.0-beta.49.patch", + "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch", + }, + { + "@pierre/diffs": "1.1.20", + effect: "4.0.0-beta.73", + }, + ), { patchedDependencies: { "@pierre/diffs@1.1.20": "patches/@pierre%2Fdiffs@1.1.20.patch", + "effect@4.0.0-beta.73": "patches/effect@4.0.0-beta.73.patch", }, }, ); - assert.equal(createStagePnpmConfig({}), undefined); + assert.equal( + createStagePnpmConfig( + { + "@expo/metro-config@56.0.13": "patches/@expo%2Fmetro-config@56.0.13.patch", + }, + { effect: "4.0.0-beta.73" }, + ), + undefined, + ); }); it("falls back to the default mock update port when the configured port is blank", () => { diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index 53f7da8e69..f86c94e5d9 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -278,8 +278,22 @@ interface StagePackageJson { export function createStagePnpmConfig( patchedDependencies: Record, + dependencies: Record, ): StagePackageJson["pnpm"] | undefined { - return Object.keys(patchedDependencies).length > 0 ? { patchedDependencies } : undefined; + const stagePatchedDependencies = Object.fromEntries( + Object.entries(patchedDependencies).filter(([patchKey]) => + Object.hasOwn(dependencies, getPatchedDependencyPackageName(patchKey)), + ), + ); + + return Object.keys(stagePatchedDependencies).length > 0 + ? { patchedDependencies: stagePatchedDependencies } + : undefined; +} + +function getPatchedDependencyPackageName(patchKey: string): string { + const versionSeparator = patchKey.lastIndexOf("@"); + return versionSeparator > 0 ? patchKey.slice(0, versionSeparator) : patchKey; } const AzureTrustedSigningOptionsConfig = Config.all({ @@ -878,7 +892,11 @@ 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 stageDependencies = { + ...resolvedServerDependencies, + ...resolvedDesktopRuntimeDependencies, + }; + const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies, stageDependencies); const stagePackageJson: StagePackageJson = { name: "t3code", version: appVersion, @@ -897,10 +915,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* ( options.mockUpdates, options.mockUpdateServerPort, ), - dependencies: { - ...resolvedServerDependencies, - ...resolvedDesktopRuntimeDependencies, - }, + dependencies: stageDependencies, devDependencies: { electron: electronVersion, },