fix(desktop): ship the plugin SDK inside Mac App Store builds (#1551)

This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-03 21:03:47 +08:00
1 parent 7b2198e18c
commit ab7a68aa84
2 files changed
+47 -10

No files matched your search

+15 -9
View File
@@ -30,6 +30,20 @@ function copyPluginSdk(resourcesDir, sdkDir = path.join(repoRoot, "packages", "p
exports.copyPluginSdk = copyPluginSdk; exports.copyPluginSdk = copyPluginSdk;
/** Mac App Store builds report "mas", not "darwin", but are still .app bundles. */
function resourcesDirFor({ electronPlatformName, appOutDir, packager }) {
return ["darwin", "mas"].includes(electronPlatformName)
? path.join(
appOutDir,
`${packager.appInfo.productFilename}.app`,
"Contents",
"Resources",
)
: path.join(appOutDir, "resources");
}
exports.resourcesDirFor = resourcesDirFor;
exports.default = async function afterPack(context) { exports.default = async function afterPack(context) {
const { targets, appOutDir } = context; const { targets, appOutDir } = context;
@@ -39,15 +53,7 @@ exports.default = async function afterPack(context) {
fs.writeFileSync(markerPath, ""); fs.writeFileSync(markerPath, "");
} }
const resourcesDir = const resourcesDir = resourcesDirFor(context);
context.electronPlatformName === "darwin"
? path.join(
appOutDir,
`${context.packager.appInfo.productFilename}.app`,
"Contents",
"Resources",
)
: path.join(appOutDir, "resources");
copyPluginSdk(resourcesDir); copyPluginSdk(resourcesDir);
+32 -1
View File
@@ -5,9 +5,14 @@ import path from "node:path";
import { afterEach, describe, expect, it } from "vitest"; import { afterEach, describe, expect, it } from "vitest";
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const { copyPluginSdk } = const { copyPluginSdk, resourcesDirFor } =
require("../../../../packaging/build/after-pack.cjs") as { require("../../../../packaging/build/after-pack.cjs") as {
copyPluginSdk: (resourcesDir: string, sdkDir?: string) => string; copyPluginSdk: (resourcesDir: string, sdkDir?: string) => string;
resourcesDirFor: (context: {
electronPlatformName: string;
appOutDir: string;
packager: { appInfo: { productFilename: string } };
}) => string;
}; };
let dir: string; let dir: string;
@@ -53,4 +58,30 @@ describe("afterPack plugin SDK copy", () => {
"npm run build:sdk", "npm run build:sdk",
); );
}); });
it.each(["darwin", "mas"])(
"copies into the app bundle for %s builds",
(electronPlatformName) => {
const context = {
electronPlatformName,
appOutDir: "/out",
packager: { appInfo: { productFilename: "Termix" } },
};
expect(resourcesDirFor(context)).toBe(
path.join("/out", "Termix.app", "Contents", "Resources"),
);
},
);
it.each(["win32", "linux"])(
"copies into resources for %s builds",
(electronPlatformName) => {
const context = {
electronPlatformName,
appOutDir: "/out",
packager: { appInfo: { productFilename: "Termix" } },
};
expect(resourcesDirFor(context)).toBe(path.join("/out", "resources"));
},
);
}); });