gpt4 book ai didi

electron - 编写定制的Electron-Forge Maker

转载 作者:行者123 更新时间:2023-12-03 12:37:09 24 4
gpt4 key购买 nike

我一直在尝试通过创建一个使用innosetup的新制造商来扩展 Electron 伪造。
现在,文档非常清晰,而且清楚如何扩展MakerBase并实现isSupportedOnCurrentPlatform和make来创建新制造商,但是我对如何在代码中使用/注册新制造商感到有些困惑。

maker-inno.js 

const path = require("path");
const fs = require("fs");

class MakerInno extends require("@electron-forge/maker-base").default {
isSupportedOnCurrentPlatform() {
return process.platform === "win32";
}
async make(options) {
...
return [pathToOutput];
}
}

module.exports = MakerInno;

forge.config.js

const InnoMaker = require("./scripts/maker-inno.js");
const innoMakerConfig = {};

module.exports = {
...
makers : [
new InnoMaker(innoMakerConfig)
]
...
}

现在,我已经将伪造的make代码调试到了@ electron-forge/core/api/make ...,但是在加载配置并使用制造商时,把伪造的forgeConfig包装在Proxy对象中,然后制造商也是如此,从那以后就无法检查我的制造商了。
这样说来,就可以使用指向该指针的指针。
旁注:我真的很讨厌使用require()。default来扩展类,必须在代码中输入我的代码,但是当涉及到配置文件时,我很茫然,如果能找到一种更干净的方法,将非常感激: p

最佳答案

好吧,我无法仅通过本地类来完成此工作,因此不得不在我的项目下创建本地包

{
"name": "electron-forge-maker-inno",
"version": "1.0.0",
"description": "InnoSetup maker for Electron Forge",
"main": "dist/index.js",
"scripts": {
"build": "tsc --project tsconfig.json"
},
"engines": {
"node": ">= 10.0.0"
},
"dependencies": {
"@electron-forge/maker-base": "6.0.0-beta.54",
"@electron-forge/shared-types": "6.0.0-beta.54",
"innosetup-compiler": "^5.6.1"
}
}
并在主项目package.json中引用它
"devDependencies": {
...
"electron-forge-maker-inno": "file:scripts/maker-inno",
...
}
然后我就可以将制造商添加到我的伪造配置中
module.exports = {
...
makers : [
{ name: "electron-forge-maker-inno", config: innoConfig },
]
...
}
感觉很糟,但又奏效了,理想情况下,有人会添加一个Inno Setup Maker进行伪造。 "innosetup-compiler"已经完成了工作,它只需要一个伪造者包装器即可。

关于electron - 编写定制的Electron-Forge Maker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66318858/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com