Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions scripts/build-desktop-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
27 changes: 21 additions & 6 deletions scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,22 @@ interface StagePackageJson {

export function createStagePnpmConfig(
patchedDependencies: Record<string, string>,
dependencies: Record<string, unknown>,
): 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({
Expand Down Expand Up @@ -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,
Expand All @@ -897,10 +915,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
options.mockUpdates,
options.mockUpdateServerPort,
),
dependencies: {
...resolvedServerDependencies,
...resolvedDesktopRuntimeDependencies,
},
dependencies: stageDependencies,
devDependencies: {
electron: electronVersion,
},
Expand Down
Loading