| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  | const path = require("path"); | 
					
						
							|  |  |  | const fs = require("fs-extra"); | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-11 06:57:34 +03:00
										 |  |  | const APP_NAME = "TriliumNext Notes"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-05 09:33:33 +01:00
										 |  |  | const extraResourcesForPlatform = getExtraResourcesForPlatform(); | 
					
						
							| 
									
										
										
										
											2025-02-05 09:30:55 +01:00
										 |  |  | const baseLinuxMakerConfigOptions = { | 
					
						
							|  |  |  |   icon: "./images/app-icons/png/128x128.png", | 
					
						
							|  |  |  |   desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs"), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-08 21:27:48 +02:00
										 |  |  | module.exports = { | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     packagerConfig: { | 
					
						
							|  |  |  |         executableName: "trilium", | 
					
						
							|  |  |  |         name: APP_NAME, | 
					
						
							|  |  |  |         overwrite: true, | 
					
						
							|  |  |  |         asar: true, | 
					
						
							|  |  |  |         icon: "./images/app-icons/icon", | 
					
						
							|  |  |  |         extraResource: [ | 
					
						
							|  |  |  |             // Moved to root
 | 
					
						
							| 
									
										
										
										
											2025-02-05 09:33:33 +01:00
										 |  |  |             ...extraResourcesForPlatform, | 
					
						
							| 
									
										
										
										
											2024-10-13 14:24:46 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |             // Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
 | 
					
						
							|  |  |  |             "translations/", | 
					
						
							|  |  |  |             "node_modules/@highlightjs/cdn-assets/styles" | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |         afterComplete: [ | 
					
						
							|  |  |  |             (buildPath, _electronVersion, platform, _arch, callback) => { | 
					
						
							| 
									
										
										
										
											2025-02-05 09:33:33 +01:00
										 |  |  |                 for (const resource of extraResourcesForPlatform) { | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                     const baseName = path.basename(resource); | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-05 08:53:06 +01:00
										 |  |  |                     // prettier-ignore
 | 
					
						
							|  |  |  |                     const sourcePath = (platform === "darwin") | 
					
						
							|  |  |  |                         ? path.join(buildPath, `${APP_NAME}.app`, "Contents", "Resources", baseName) | 
					
						
							|  |  |  |                         : path.join(buildPath, "resources", baseName); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     // prettier-ignore
 | 
					
						
							|  |  |  |                     const destPath = (baseName !== "256x256.png") | 
					
						
							|  |  |  |                         ? path.join(buildPath, baseName) | 
					
						
							|  |  |  |                         : path.join(buildPath, "icon.png"); | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     // Copy files from resources folder to root
 | 
					
						
							|  |  |  |                     fs.move(sourcePath, destPath) | 
					
						
							|  |  |  |                         .then(() => callback()) | 
					
						
							|  |  |  |                         .catch((err) => callback(err)); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         ] | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     rebuildConfig: { | 
					
						
							|  |  |  |         force: true | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     makers: [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-deb", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 options: { | 
					
						
							| 
									
										
										
										
											2025-02-05 09:30:55 +01:00
										 |  |  |                   ...baseLinuxMakerConfigOptions | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2025-02-03 23:21:27 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-flatpak", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 options: { | 
					
						
							|  |  |  |                     icon: "./images/app-icons/png/128x128.png", | 
					
						
							|  |  |  |                     desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs"), | 
					
						
							|  |  |  |                 }, | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2025-02-02 23:00:22 +01:00
										 |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-rpm", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 options: { | 
					
						
							| 
									
										
										
										
											2025-02-05 09:30:55 +01:00
										 |  |  |                   ...baseLinuxMakerConfigOptions | 
					
						
							| 
									
										
										
										
											2025-02-02 23:00:22 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-squirrel", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico", | 
					
						
							| 
									
										
										
										
											2025-02-01 14:36:55 +02:00
										 |  |  |                 setupIcon: "./images/app-icons/win/setup.ico", | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |                 loadingGif: "./images/app-icons/win/setup-banner.gif" | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-dmg", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 icon: "./images/app-icons/icon.icns" | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/maker-zip", | 
					
						
							|  |  |  |             config: { | 
					
						
							|  |  |  |                 options: { | 
					
						
							|  |  |  |                     iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico", | 
					
						
							|  |  |  |                     icon: "./images/app-icons/icon.ico" | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     ], | 
					
						
							|  |  |  |     plugins: [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             name: "@electron-forge/plugin-auto-unpack-natives", | 
					
						
							|  |  |  |             config: {} | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2023-11-08 21:27:48 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | function getExtraResourcesForPlatform() { | 
					
						
							| 
									
										
										
										
											2025-02-05 09:56:08 +01:00
										 |  |  |     const resources = ["dump-db/", "./bin/tpl/anonymize-database.sql"]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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}`); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     switch (process.platform) { | 
					
						
							|  |  |  |         case "win32": | 
					
						
							| 
									
										
										
										
											2025-02-05 09:56:08 +01:00
										 |  |  |             resources.push(...getScriptRessources()) | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case "linux": | 
					
						
							| 
									
										
										
										
											2025-02-05 09:56:08 +01:00
										 |  |  |             resources.push(...getScriptRessources(), "images/app-icons/png/256x256.png"); | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-08-05 18:47:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-09 18:07:02 +02:00
										 |  |  |     return resources; | 
					
						
							|  |  |  | } |