mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
Merge pull request #1122 from TriliumNext/refactor_electron-forge-config
refactor: electron forge config
This commit is contained in:
commit
856a8a754e
@ -3,6 +3,12 @@ const fs = require("fs-extra");
|
|||||||
|
|
||||||
const APP_NAME = "TriliumNext Notes";
|
const APP_NAME = "TriliumNext Notes";
|
||||||
|
|
||||||
|
const extraResourcesForPlatform = getExtraResourcesForPlatform();
|
||||||
|
const baseLinuxMakerConfigOptions = {
|
||||||
|
icon: "./images/app-icons/png/128x128.png",
|
||||||
|
desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs"),
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
packagerConfig: {
|
packagerConfig: {
|
||||||
executableName: "trilium",
|
executableName: "trilium",
|
||||||
@ -12,7 +18,7 @@ module.exports = {
|
|||||||
icon: "./images/app-icons/icon",
|
icon: "./images/app-icons/icon",
|
||||||
extraResource: [
|
extraResource: [
|
||||||
// Moved to root
|
// Moved to root
|
||||||
...getExtraResourcesForPlatform(),
|
...extraResourcesForPlatform,
|
||||||
|
|
||||||
// Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
|
// Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
|
||||||
"translations/",
|
"translations/",
|
||||||
@ -20,22 +26,18 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
afterComplete: [
|
afterComplete: [
|
||||||
(buildPath, _electronVersion, platform, _arch, callback) => {
|
(buildPath, _electronVersion, platform, _arch, callback) => {
|
||||||
const extraResources = getExtraResourcesForPlatform();
|
for (const resource of extraResourcesForPlatform) {
|
||||||
for (const resource of extraResources) {
|
|
||||||
const baseName = path.basename(resource);
|
const baseName = path.basename(resource);
|
||||||
let sourcePath;
|
|
||||||
if (platform === "darwin") {
|
|
||||||
sourcePath = path.join(buildPath, `${APP_NAME}.app`, "Contents", "Resources", baseName);
|
|
||||||
} else {
|
|
||||||
sourcePath = path.join(buildPath, "resources", baseName);
|
|
||||||
}
|
|
||||||
let destPath;
|
|
||||||
|
|
||||||
if (baseName !== "256x256.png") {
|
// prettier-ignore
|
||||||
destPath = path.join(buildPath, baseName);
|
const sourcePath = (platform === "darwin")
|
||||||
} else {
|
? path.join(buildPath, `${APP_NAME}.app`, "Contents", "Resources", baseName)
|
||||||
destPath = path.join(buildPath, "icon.png");
|
: path.join(buildPath, "resources", baseName);
|
||||||
}
|
|
||||||
|
// prettier-ignore
|
||||||
|
const destPath = (baseName !== "256x256.png")
|
||||||
|
? path.join(buildPath, baseName)
|
||||||
|
: path.join(buildPath, "icon.png");
|
||||||
|
|
||||||
// Copy files from resources folder to root
|
// Copy files from resources folder to root
|
||||||
fs.move(sourcePath, destPath)
|
fs.move(sourcePath, destPath)
|
||||||
@ -53,8 +55,7 @@ module.exports = {
|
|||||||
name: "@electron-forge/maker-deb",
|
name: "@electron-forge/maker-deb",
|
||||||
config: {
|
config: {
|
||||||
options: {
|
options: {
|
||||||
icon: "./images/app-icons/png/128x128.png",
|
...baseLinuxMakerConfigOptions
|
||||||
desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -62,8 +63,7 @@ module.exports = {
|
|||||||
name: "@electron-forge/maker-rpm",
|
name: "@electron-forge/maker-rpm",
|
||||||
config: {
|
config: {
|
||||||
options: {
|
options: {
|
||||||
icon: "./images/app-icons/png/128x128.png",
|
...baseLinuxMakerConfigOptions
|
||||||
desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -100,21 +100,20 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getExtraResourcesForPlatform() {
|
function getExtraResourcesForPlatform() {
|
||||||
let resources = ["dump-db/", "./bin/tpl/anonymize-database.sql"];
|
const resources = ["dump-db/", "./bin/tpl/anonymize-database.sql"];
|
||||||
const scripts = ["trilium-portable", "trilium-safe-mode", "trilium-no-cert-check"];
|
|
||||||
|
const getScriptRessources = () => {
|
||||||
|
const scripts = ["trilium-portable", "trilium-safe-mode", "trilium-no-cert-check"];
|
||||||
|
const scriptExt = (process.platform === "win32") ? "bat" : "sh";
|
||||||
|
return scripts.map(script => `./bin/tpl/${script}.${scriptExt}`);
|
||||||
|
}
|
||||||
|
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32":
|
case "win32":
|
||||||
for (const script of scripts) {
|
resources.push(...getScriptRessources())
|
||||||
resources.push(`./bin/tpl/${script}.bat`);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "darwin":
|
|
||||||
break;
|
break;
|
||||||
case "linux":
|
case "linux":
|
||||||
resources.push("images/app-icons/png/256x256.png");
|
resources.push(...getScriptRessources(), "images/app-icons/png/256x256.png");
|
||||||
for (const script of scripts) {
|
|
||||||
resources.push(`./bin/tpl/${script}.sh`);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user