Binder/forge.config.js

136 lines
3.3 KiB
JavaScript

const { genBuildInfo } = require("./genbuildinfo.js");
const nodePath = require('node:path');
/*
const nodePath = {join: (base, end) => {
return `${base}/${end}`;
}}
*/
function ignoreFiles(path) {
if (!path) return true; //wtf why does it ever empty??
const val = JSON.stringify(path);
throw new Error(val);
const allowedDirectories = [
".vite",
"icons",
"node_modules",
];
//block takes precedence over pass
const disallowedDirectories = [
"out",
"node_modules/.bin",
"node_modules/electron",
"node_modules/electron-prebuilt",
"node_modules/electron-prebuilt-compile",
"node_modules/electron-packager",
".git",
];
//these take precedence over all else
const explicitlyAllowedFiles = [
"src/thumbnailworkercode.mjs",
"package.json",
];
for (const dirEnd of explicitlyAllowedFiles) {
const absolute = nodePath.join(__dirname, dirEnd);
if (absolute === path) {
throw new Error("passing explicit: " + path);
return false;
}
}
let inAllowed = false;
for (const dirEnd of allowedDirectories) {
const absolute = nodePath.join(__dirname, dirEnd);
if (path.startsWith(absolute)) {
inAllowed = true;
break;
}
}
for (const dirEnd of disallowedDirectories) {
const absolute = nodePath.join(__dirname, dirEnd);
if (path.startsWith(absolute)) {
inAllowed = false;
break;
}
}
if (inAllowed) {
throw new Error("disallowing: " + path);
} else {
throw new Error("allowing: " + path);
}
return !inAllowed;
}
module.exports = {
packagerConfig: {
asar: false, //having trouble getting workers to load modules...
appCopyright: "Copyright (c) 2024 Enesda.",
icon: 'icons/icon',
//please forgive me for I have sinned
//Actually no this is bullshit which does it dump in (potentially sensitive) files in
// by default until asked not to on a case-by-case basis?
//The predicate version didn't do anything but pass in undefined paths...
ignore: /^(?!\/\.vite|\/icons|\/package\.json|\/buildInfo.json|\/LICENSE.txt|\/node_modules).+$/,
},
hooks: {
generateAssets: genBuildInfo
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
authors: "Enesda.",
description: 'Binder, a tag based organizer.',
iconUrl: nodePath.join(nodePath.dirname(__dirname), 'icons', 'icon.ico'),
setupIcon: 'icons/setupIcon.ico'
}
},
{
name: '@electron-forge/maker-zip',
platforms: ['linux'],
},
],
plugins: [
{
name: '@electron-forge/plugin-vite',
config: {
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
// If you are familiar with Vite configuration, it will look really familiar.
build: [
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: 'src/main.js',
config: 'vite.main.config.mjs',
},
{
entry: 'src/preload.js',
config: 'vite.preload.config.mjs',
},
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.mjs',
},
],
},
},
],
};