2024-08-05 18:47:57 +02:00
const path = require ( 'path' ) ;
const fs = require ( 'fs-extra' ) ;
2023-11-08 21:27:48 +02:00
module . exports = {
packagerConfig : {
2024-08-05 18:47:57 +02:00
executableName : "trilium" ,
2024-08-05 20:20:35 +02:00
name : 'TriliumNextNotes' ,
2024-08-05 18:47:57 +02:00
overwrite : true ,
2023-11-08 21:27:48 +02:00
asar : true ,
2023-11-08 23:53:08 +02:00
// icon will break once we add .dmg support, since the .ico & .icns have to be in same dir (see https://www.electronforge.io/guides/create-and-add-icons#windows-and-macos)
2024-08-05 18:47:57 +02:00
icon : "./images/app-icons/icon" ,
extraResource : getExtraResourcesForPlatform ( ) ,
afterComplete : [ ( buildPath , electronVersion , platform , arch , callback ) => {
const extraResources = getExtraResourcesForPlatform ( ) ;
for ( const resource of extraResources ) {
2024-08-09 22:23:54 +02:00
let sourcePath ;
if ( platform === 'darwin' ) {
2024-08-10 11:38:23 +02:00
sourcePath = path . join ( buildPath , 'TriliumNextNotes.app' , 'Contents' , 'Resources' , path . basename ( resource ) ) ;
2024-08-09 22:23:54 +02:00
} else {
sourcePath = path . join ( buildPath , 'resources' , path . basename ( resource ) ) ;
}
2024-08-05 18:47:57 +02:00
const destPath = path . join ( buildPath , path . basename ( resource ) ) ;
// Copy files from resources folder to root
fs . move ( sourcePath , destPath )
. then ( ( ) => callback ( ) )
. catch ( err => callback ( err ) ) ;
}
} ]
} ,
rebuildConfig : {
force : true
2023-11-08 21:27:48 +02:00
} ,
makers : [
2024-08-05 18:47:57 +02:00
{
name : '@electron-forge/maker-deb' ,
config : {
options : {
icon : "./images/app-icons/png/128x128.png" ,
}
}
} ,
2023-11-08 21:27:48 +02:00
{
name : '@electron-forge/maker-squirrel' ,
2023-11-08 22:10:22 +02:00
config : {
2024-08-05 18:47:57 +02:00
iconUrl : "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico" ,
setupIcon : "./images/app-icons/icon.ico" ,
2023-11-08 23:08:38 +02:00
loadingGif : "./images/app-icons/win/setup-banner.gif"
2023-11-08 23:53:08 +02:00
}
2024-08-05 18:47:57 +02:00
} ,
{
name : '@electron-forge/maker-dmg' ,
config : {
2024-08-05 20:20:35 +02:00
icon : "./images/app-icons/icon.icns" ,
2024-08-05 18:47:57 +02:00
}
} ,
{
name : '@electron-forge/maker-zip' ,
config : {
options : {
iconUrl : "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico" ,
2024-08-05 20:20:35 +02:00
icon : "./images/app-icons/icon.ico" ,
2024-08-05 18:47:57 +02:00
}
}
2023-11-09 20:04:07 +02:00
}
2023-11-08 21:27:48 +02:00
] ,
plugins : [
{
name : '@electron-forge/plugin-auto-unpack-natives' ,
config : { } ,
} ,
] ,
} ;
2024-08-05 18:47:57 +02:00
function getExtraResourcesForPlatform ( ) {
let resources = [ 'dump-db/' , './bin/tpl/anonymize-database.sql' ]
const scripts = [ 'trilium-portable' , 'trilium-safe-mode' , 'trilium-no-cert-check' ]
switch ( process . platform ) {
case 'win32' :
for ( const script of scripts ) {
resources . push ( ` ./bin/tpl/ ${ script } .bat ` )
}
break ;
case 'darwin' :
break ;
case 'linux' :
for ( const script of scripts ) {
resources . push ( ` ./bin/tpl/ ${ script } .sh ` )
}
break ;
default :
break ;
}
return resources ;
}