fix: ship the plugin sdk and serialport in desktop builds

This commit is contained in:
LukeGus committed 2026-09-30 11:21:16 -05:00
1 parent b45d0f9ed2
commit 4076eb66ab
4 files changed
+92 -4

No files matched your search

+34 -4
View File
@@ -2,6 +2,34 @@ const fs = require("fs");
const path = require("path");
const { chmodSpawnHelpers } = require("../../scripts/patch-node-pty.cjs");
const repoRoot = path.resolve(__dirname, "..", "..");
/**
* The SDK is a workspace package, so electron-builder skips it, yet core and
* every plugin import it at runtime. Ship its package.json and dist the way
* the Docker image does.
*/
function copyPluginSdk(resourcesDir, sdkDir = path.join(repoRoot, "packages", "plugin-sdk")) {
const target = path.join(
resourcesDir,
"app.asar.unpacked",
"node_modules",
"@termix",
"plugin-sdk",
);
const dist = path.join(sdkDir, "dist");
if (!fs.existsSync(dist)) {
throw new Error(`Plugin SDK is not built (${dist}). Run: npm run build:sdk`);
}
fs.rmSync(target, { recursive: true, force: true });
fs.mkdirSync(target, { recursive: true });
fs.copyFileSync(path.join(sdkDir, "package.json"), path.join(target, "package.json"));
fs.cpSync(dist, path.join(target, "dist"), { recursive: true });
return target;
}
exports.copyPluginSdk = copyPluginSdk;
exports.default = async function afterPack(context) {
const { targets, appOutDir } = context;
@@ -11,10 +39,6 @@ exports.default = async function afterPack(context) {
fs.writeFileSync(markerPath, "");
}
if (context.electronPlatformName === "win32") {
return;
}
const resourcesDir =
context.electronPlatformName === "darwin"
? path.join(
@@ -25,6 +49,12 @@ exports.default = async function afterPack(context) {
)
: path.join(appOutDir, "resources");
copyPluginSdk(resourcesDir);
if (context.electronPlatformName === "win32") {
return;
}
const nodePtyDir = path.join(
resourcesDir,
"app.asar.unpacked",