Files
TRIMSP/forge.config.js
salman 5110ea4827 Build the Windows installer with electron-builder (NSIS)
The Squirrel path (electron-forge maker-squirrel -> electron-winstaller)
required Wine and Mono, plus a 64-bit Wine prefix, to cross-build on Linux.
electron-builder's NSIS target uses its own native tooling, so the same
cross-build now needs no Wine and no Mono, matching how muSRFlow is packaged.

- package.json: add an electron-builder 'build' block (win/nsis, extraResources
  for the engine and the flat rootfs, files allow-list, nsis options) and point
  package:win/make:win at 'electron-builder --win nsis'; drop maker-squirrel.
- packaging/wsl2/require-rootfs.js: fail the Windows build when the rootfs is
  missing (electron-builder has no config-time abort hook).
- forge.config.js: drop the Squirrel maker and the Windows rootfs guard; forge
  now builds Linux/macOS only.
- README/CHANGELOG: document the NSIS build and that no Wine/Mono is needed.

Verified locally: TRIMSP-NL-Workbench-Setup.exe (NSIS, 186 MB) builds with no
Wine/Mono; resources/bin/trimspNL and resources/trimspNL-runtime-rootfs.tar.gz
land where wsl-runtime.js looks; guard fails on a missing rootfs.
2026-10-20 13:35:17 +02:00

120 lines
3.6 KiB
JavaScript

const path = require('path');
const redhatInstaller = require('electron-installer-redhat');
const redhatDependencies = require('electron-installer-redhat/src/dependencies');
const linuxIconSet = {
'16x16': 'appicons/icons/png/16x16.png',
'24x24': 'appicons/icons/png/24x24.png',
'32x32': 'appicons/icons/png/32x32.png',
'48x48': 'appicons/icons/png/48x48.png',
'64x64': 'appicons/icons/png/64x64.png',
'128x128': 'appicons/icons/png/128x128.png',
'256x256': 'appicons/icons/png/256x256.png',
'512x512': 'appicons/icons/png/512x512.png',
};
const linuxDesktopTemplate = path.resolve(__dirname, 'packaging/linux/trimsp.desktop.ejs');
const linuxRpmSpecTemplate = path.resolve(__dirname, 'packaging/linux/trimsp.spec.ejs');
const includeFlatpak = process.env.FORGE_FLATPAK === '1';
// The packaged Linux engine.
const extraResource = ['resources/bin'];
// The upstream RPM maker assumes Fedora-style package names. Mageia provides
// GTK 3 under lib64gtk+3_0, so allow either name in the generated Requires.
redhatDependencies.dependencyMap.gtk3 = '(gtk3 or lib64gtk+3_0)';
// RPM 4.20 runs %install from an automatically generated build directory.
// Use our absolute-path template instead of the installer's relative usr/* copy.
redhatInstaller.Installer.prototype.createSpec = function () {
this.options.logger(`Creating package spec at ${this.specPath}`);
return this.createTemplatedFile(linuxRpmSpecTemplate, this.specPath);
};
const makers = [
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
name: 'trimsp',
productName: 'TRIMSP-NL Workbench',
genericName: 'Ion implantation simulator',
description: 'Workbench for low-energy muon and ion implantation simulations with TRIM.SP-NL.',
categories: ['Science'],
icon: linuxIconSet,
desktopTemplate: linuxDesktopTemplate,
},
},
},
{
name: '@electron-forge/maker-rpm',
config: {
options: {
name: 'trimsp',
productName: 'TRIMSP-NL Workbench',
genericName: 'Ion implantation simulator',
description: 'Workbench for low-energy muon and ion implantation simulations with TRIM.SP-NL.',
categories: ['Science'],
icon: linuxIconSet,
desktopTemplate: linuxDesktopTemplate,
},
},
},
];
if (includeFlatpak) {
makers.push({
name: '@electron-forge/maker-flatpak',
config: {
options: {
id: 'ch.psi.lem.TrimSP',
productName: 'TRIMSP-NL Workbench',
genericName: 'Ion implantation simulator',
description: 'Workbench for low-energy muon and ion implantation simulations with TRIM.SP-NL.',
baseVersion: '24.08',
runtimeVersion: '24.08',
extraFlatpakBuilderArgs: ['--state-dir=.flatpak-builder'],
icon: linuxIconSet,
modules: [],
categories: ['Science'],
finishArgs: [
'--share=ipc',
'--share=network',
'--socket=x11',
'--socket=wayland',
'--device=dri',
'--filesystem=home',
'--filesystem=/tmp',
],
},
},
});
}
module.exports = {
packagerConfig: {
icon: 'appicons/icons/png/1024x1024.png',
extraResource: extraResource,
ignore: [
'Readme.md',
'ToDo.txt',
'TrimSP.cfg',
'^/trimspNL$',
'fortran/*',
'(^|/)packaging($|/)',
'(^|/)resources/bin($|/)',
'(^|/)tests?[^/]*($|/)',
'(^|/)__tests__($|/)',
'(^|/)(test|spec)($|/)',
'\\.flatpak-builder($|/)',
'\\.tmp-flatpak-manual($|/)',
'out-flatpak-test($|/)',
],
},
makers: makers,
};