Unverified 提交 5147d767 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Use hook module path (#2032)

<!-- CURSOR_SUMMARY --> > [!NOTE] > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is generating a summary for commit 9f54920421cc7c47882465f0dd0ca371a5620454. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
上级 594b3b4d
......@@ -7,20 +7,8 @@ import { VitePlugin } from "@electron-forge/plugin-vite";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
import { FuseV1Options, FuseVersion } from "@electron/fuses";
import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives";
import { execSync } from "child_process";
import path from "path";
// Path to signtool.exe bundled with electron-winstaller
// On GitHub Actions, this is the full path:
// D:\a\dyad\dyad\node_modules\electron-winstaller\vendor\signtool.exe
const SIGNTOOL_PATH = path.join(
__dirname,
"node_modules",
"electron-winstaller",
"vendor",
"signtool.exe",
);
// Based on https://github.com/electron/forge/blob/6b2d547a7216c30fde1e1fddd1118eee5d872945/packages/plugin/vite/src/VitePlugin.ts#L124
const ignore = (file: string) => {
if (!file) return false;
......@@ -100,17 +88,7 @@ const config: ForgeConfig = {
makers: [
new MakerSquirrel({
windowsSign: {
hookFunction: (filePath: string) => {
const fileName = path.basename(filePath).toLowerCase();
// Only sign dyad.exe, skip all other files
if (fileName !== "dyad.exe") {
return;
}
const signParams = `/sha1 ${process.env.SM_CODE_SIGNING_CERT_SHA1_HASH} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256`;
execSync(`"${SIGNTOOL_PATH}" sign ${signParams} "${filePath}"`, {
stdio: "inherit",
});
},
hookModulePath: path.join(__dirname, "scripts", "windows-sign-hook.js"),
},
}),
new MakerZIP({}, ["darwin"]),
......
const { execSync } = require("child_process");
const path = require("path");
// Path to signtool.exe bundled with electron-winstaller
// On GitHub Actions, this is the full path:
// D:\a\dyad\dyad\node_modules\electron-winstaller\vendor\signtool.exe
const SIGNTOOL_PATH = path.join(
__dirname,
"..",
"node_modules",
"electron-winstaller",
"vendor",
"signtool.exe",
);
/**
* Custom hook function for Windows code signing.
* Only signs dyad.exe, skips all other files.
* @param {string} filePath - Path to the file to sign
*/
module.exports = function (filePath) {
const fileName = path.basename(filePath).toLowerCase();
// Only sign dyad.exe, skip all other files
if (fileName !== "dyad.exe") {
return;
}
const signParams = `/sha1 ${process.env.SM_CODE_SIGNING_CERT_SHA1_HASH} /tr http://timestamp.digicert.com /td SHA256 /fd SHA256`;
execSync(`"${SIGNTOOL_PATH}" sign ${signParams} "${filePath}"`, {
stdio: "inherit",
});
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论