You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.3 KiB
101 lines
3.3 KiB
const { FusesPlugin } = require('@electron-forge/plugin-fuses'); |
|
const { MakerSquirrel } = require('@electron-forge/maker-squirrel'); |
|
const { FuseV1Options, FuseVersion } = require('@electron/fuses'); |
|
const { convertVersion, createWindowsInstaller } = require('electron-winstaller'); |
|
const fs = require('fs-extra'); |
|
const os = require('node:os'); |
|
const path = require('node:path'); |
|
|
|
class AsciiOutputSquirrelMaker extends MakerSquirrel { |
|
async make({ dir, makeDir, targetArch, packageJSON, appName, forgeConfig }) { |
|
const finalOutPath = path.resolve(makeDir, `squirrel.windows/${targetArch}`); |
|
await this.ensureDirectory(finalOutPath); |
|
|
|
const tmpAppDir = await fs.mkdtemp(path.join(os.tmpdir(), 'squirrel-maker-app-')); |
|
const tmpOutPath = await fs.mkdtemp(path.join(os.tmpdir(), 'squirrel-maker-out-')); |
|
await fs.copy(dir, tmpAppDir); |
|
|
|
try { |
|
const winstallerConfig = { |
|
name: typeof packageJSON.name === 'string' |
|
? packageJSON.name.replace(/-/g, '_') |
|
: undefined, |
|
title: appName, |
|
noMsi: true, |
|
exe: `${forgeConfig.packagerConfig.executableName || appName}.exe`, |
|
setupExe: `${appName}-${packageJSON.version} Setup.exe`, |
|
...this.config, |
|
appDirectory: tmpAppDir, |
|
outputDirectory: tmpOutPath, |
|
}; |
|
|
|
await createWindowsInstaller(winstallerConfig); |
|
await fs.copy(tmpOutPath, finalOutPath, { overwrite: true }); |
|
|
|
const nupkgVersion = convertVersion(packageJSON.version); |
|
const artifacts = [ |
|
path.resolve(finalOutPath, 'RELEASES'), |
|
path.resolve(finalOutPath, winstallerConfig.setupExe || `${appName}Setup.exe`), |
|
path.resolve(finalOutPath, `${winstallerConfig.name}-${nupkgVersion}-full.nupkg`), |
|
]; |
|
const deltaPath = path.resolve(finalOutPath, `${winstallerConfig.name}-${nupkgVersion}-delta.nupkg`); |
|
if ( |
|
winstallerConfig.remoteReleases && |
|
!winstallerConfig.noDelta && |
|
await fs.pathExists(deltaPath) |
|
) { |
|
artifacts.push(deltaPath); |
|
} |
|
const msiPath = path.resolve(finalOutPath, winstallerConfig.setupMsi || `${appName}Setup.msi`); |
|
if (!winstallerConfig.noMsi && await fs.pathExists(msiPath)) { |
|
artifacts.push(msiPath); |
|
} |
|
|
|
return artifacts; |
|
} finally { |
|
await fs.remove(tmpAppDir); |
|
await fs.remove(tmpOutPath); |
|
} |
|
} |
|
} |
|
|
|
module.exports = { |
|
packagerConfig: { |
|
asar: true, |
|
}, |
|
rebuildConfig: { |
|
onlyModules: [], |
|
}, |
|
makers: [ |
|
new AsciiOutputSquirrelMaker(), |
|
{ |
|
name: '@electron-forge/maker-zip', |
|
platforms: ['darwin'], |
|
}, |
|
{ |
|
name: '@electron-forge/maker-deb', |
|
config: {}, |
|
}, |
|
{ |
|
name: '@electron-forge/maker-rpm', |
|
config: {}, |
|
}, |
|
], |
|
plugins: [ |
|
{ |
|
name: '@electron-forge/plugin-auto-unpack-natives', |
|
config: {}, |
|
}, |
|
// Fuses are used to enable/disable various Electron functionality |
|
// at package time, before code signing the application |
|
new FusesPlugin({ |
|
version: FuseVersion.V1, |
|
[FuseV1Options.RunAsNode]: false, |
|
[FuseV1Options.EnableCookieEncryption]: true, |
|
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, |
|
[FuseV1Options.EnableNodeCliInspectArguments]: false, |
|
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, |
|
[FuseV1Options.OnlyLoadAppFromAsar]: true, |
|
}), |
|
], |
|
};
|
|
|