mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	add electron-forge for all platforms
This commit is contained in:
		
							parent
							
								
									5f6aba8a10
								
							
						
					
					
						commit
						e5e92c8ece
					
				
							
								
								
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							@ -11,4 +11,7 @@
 | 
				
			|||||||
    "[jsonc]": {
 | 
					    "[jsonc]": {
 | 
				
			||||||
        "editor.defaultFormatter": "vscode.json-language-features"
 | 
					        "editor.defaultFormatter": "vscode.json-language-features"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "[javascript]": {
 | 
				
			||||||
 | 
					        "editor.defaultFormatter": "vscode.typescript-language-features"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
echo "Packaging windows x64 electron build"
 | 
					echo "Packaging windows x64 electron build"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=win32  --arch=x64 --overwrite --icon=images/app-icons/win/icon.ico
 | 
					./node_modules/.bin/electron-packager $SRC_DIR --asar --out=dist --executable-name=trilium --platform=win32 --arch=x64 --overwrite --icon=images/app-icons/icon.ico
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BUILD_DIR=./dist/trilium-windows-x64
 | 
					BUILD_DIR=./dist/trilium-windows-x64
 | 
				
			||||||
rm -rf $BUILD_DIR
 | 
					rm -rf $BUILD_DIR
 | 
				
			||||||
 | 
				
			|||||||
@ -44,7 +44,7 @@ cp -R "$script_dir/../build/src" "$DIR"
 | 
				
			|||||||
cp "$script_dir/../build/electron.js" "$DIR"
 | 
					cp "$script_dir/../build/electron.js" "$DIR"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# run in subshell (so we return to original dir)
 | 
					# run in subshell (so we return to original dir)
 | 
				
			||||||
(cd $DIR && npm install --omit=dev)
 | 
					(cd $DIR && npm install --omit=dev && npx electron-rebuild)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ -d "$DIR"/node_modules ]]; then
 | 
					if [[ -d "$DIR"/node_modules ]]; then
 | 
				
			||||||
    # cleanup of useless files in dependencies
 | 
					    # cleanup of useless files in dependencies
 | 
				
			||||||
@ -52,7 +52,6 @@ if [[ -d "$DIR"/node_modules ]]; then
 | 
				
			|||||||
        '@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
 | 
					        '@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
 | 
				
			||||||
        'mermaid/dist/mermaid.js' \
 | 
					        'mermaid/dist/mermaid.js' \
 | 
				
			||||||
        'boxicons/svg' 'boxicons/node_modules/react'/* \
 | 
					        'boxicons/svg' 'boxicons/node_modules/react'/* \
 | 
				
			||||||
        'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' 'better-sqlite3/deps/sqlite3' \
 | 
					 | 
				
			||||||
        '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
 | 
					        '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
 | 
				
			||||||
        [[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d"
 | 
					        [[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d"
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
 | 
				
			|||||||
@ -39,7 +39,7 @@ done
 | 
				
			|||||||
icnsutil compose -f "mac/icon.icns" ./mac/*.png
 | 
					icnsutil compose -f "mac/icon.icns" ./mac/*.png
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Build Windows icon
 | 
					# Build Windows icon
 | 
				
			||||||
magick -background none "../icon-color.svg" -define icon:auto-resize=16,32,48,64,128,256 "./win/icon.ico"
 | 
					magick -background none "../icon-color.svg" -define icon:auto-resize=16,32,48,64,128,256 "./icon.ico"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Build Squirrel splash image
 | 
					# Build Squirrel splash image
 | 
				
			||||||
magick "./png/256x256.png" -background "#ffffff" -gravity center -extent 640x480 "./win/setup-banner.gif"
 | 
					magick "./png/256x256.png" -background "#ffffff" -gravity center -extent 640x480 "./win/setup-banner.gif"
 | 
				
			||||||
@ -1,18 +1,65 @@
 | 
				
			|||||||
 | 
					const path = require('path');
 | 
				
			||||||
 | 
					const fs = require('fs-extra');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
  packagerConfig: {
 | 
					  packagerConfig: {
 | 
				
			||||||
 | 
					    executableName: "trilium",
 | 
				
			||||||
 | 
					    name: 'trilium',
 | 
				
			||||||
 | 
					    overwrite: true,
 | 
				
			||||||
    asar: true,
 | 
					    asar: true,
 | 
				
			||||||
    // 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)
 | 
					    // 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)
 | 
				
			||||||
    icon: "./images/app-icons/win/icon"
 | 
					    icon: "./images/app-icons/icon",
 | 
				
			||||||
 | 
					    extraResource: getExtraResourcesForPlatform(),
 | 
				
			||||||
 | 
					    files: [{ from: './bin/tpl/anonymize-database.tql', to: '.' }],
 | 
				
			||||||
 | 
					    afterComplete: [(buildPath, electronVersion, platform, arch, callback) => {
 | 
				
			||||||
 | 
					      const extraResources = getExtraResourcesForPlatform();
 | 
				
			||||||
 | 
					      for (const resource of extraResources) {
 | 
				
			||||||
 | 
					        const sourcePath = path.join(buildPath, 'resources', path.basename(resource));
 | 
				
			||||||
 | 
					        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
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  rebuildConfig: {},
 | 
					 | 
				
			||||||
  makers: [
 | 
					  makers: [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      name: '@electron-forge/maker-deb',
 | 
				
			||||||
 | 
					      config: {
 | 
				
			||||||
 | 
					        options: {
 | 
				
			||||||
 | 
					          icon: "./images/app-icons/png/128x128.png",
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      name: '@electron-forge/maker-squirrel',
 | 
					      name: '@electron-forge/maker-squirrel',
 | 
				
			||||||
      config: {
 | 
					      config: {
 | 
				
			||||||
        iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/win/icon.ico",
 | 
					        iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico",
 | 
				
			||||||
        setupIcon: "./images/app-icons/win/icon.ico",
 | 
					        setupIcon: "./images/app-icons/icon.ico",
 | 
				
			||||||
        loadingGif: "./images/app-icons/win/setup-banner.gif"
 | 
					        loadingGif: "./images/app-icons/win/setup-banner.gif"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      name: '@electron-forge/maker-dmg',
 | 
				
			||||||
 | 
					      arch: ['x64', 'arm64'],
 | 
				
			||||||
 | 
					      config: {
 | 
				
			||||||
 | 
					        icon: "./images/app-icons/mac/icon.icns",
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      name: '@electron-forge/maker-zip',
 | 
				
			||||||
 | 
					      config: {
 | 
				
			||||||
 | 
					        options: {
 | 
				
			||||||
 | 
					          iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico",
 | 
				
			||||||
 | 
					          setupIcon: "./images/app-icons/icon.ico",
 | 
				
			||||||
 | 
					          loadingGif: "./images/app-icons/win/setup-banner.gif"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  plugins: [
 | 
					  plugins: [
 | 
				
			||||||
@ -22,3 +69,27 @@ module.exports = {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 112 KiB After Width: | Height: | Size: 112 KiB  | 
							
								
								
									
										2027
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2027
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -124,7 +124,11 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "@electron-forge/cli": "^6.4.2",
 | 
					    "@electron-forge/cli": "^6.4.2",
 | 
				
			||||||
 | 
					    "@electron-forge/maker-deb": "^7.4.0",
 | 
				
			||||||
 | 
					    "@electron-forge/maker-dmg": "^7.4.0",
 | 
				
			||||||
 | 
					    "@electron-forge/maker-rpm": "^7.4.0",
 | 
				
			||||||
    "@electron-forge/maker-squirrel": "^6.4.2",
 | 
					    "@electron-forge/maker-squirrel": "^6.4.2",
 | 
				
			||||||
 | 
					    "@electron-forge/maker-zip": "^7.4.0",
 | 
				
			||||||
    "@electron-forge/plugin-auto-unpack-natives": "^6.4.2",
 | 
					    "@electron-forge/plugin-auto-unpack-natives": "^6.4.2",
 | 
				
			||||||
    "@types/archiver": "^6.0.2",
 | 
					    "@types/archiver": "^6.0.2",
 | 
				
			||||||
    "@types/better-sqlite3": "^7.6.9",
 | 
					    "@types/better-sqlite3": "^7.6.9",
 | 
				
			||||||
 | 
				
			|||||||
@ -48,7 +48,7 @@ app.use(express.static(path.join(scriptDir, 'public/root')));
 | 
				
			|||||||
app.use(`/manifest.webmanifest`, express.static(path.join(scriptDir, 'public/manifest.webmanifest')));
 | 
					app.use(`/manifest.webmanifest`, express.static(path.join(scriptDir, 'public/manifest.webmanifest')));
 | 
				
			||||||
app.use(`/robots.txt`, express.static(path.join(scriptDir, 'public/robots.txt')));
 | 
					app.use(`/robots.txt`, express.static(path.join(scriptDir, 'public/robots.txt')));
 | 
				
			||||||
app.use(sessionParser);
 | 
					app.use(sessionParser);
 | 
				
			||||||
app.use(favicon(`${scriptDir}/../images/app-icons/win/icon.ico`));
 | 
					app.use(favicon(`${scriptDir}/../images/app-icons/icon.ico`));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
assets.register(app);
 | 
					assets.register(app);
 | 
				
			||||||
routes.register(app);
 | 
					routes.register(app);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user