Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(desktop): use plugin to clean up languages
Elian Dorancbcc219f1f30
diff --git a/apps/desktop/electron-forge/forge.config.cjs b/apps/desktop/electron-forge/forge.config.cjsindex 27ab8ec8c3..630e99cc2f 100644--- a/apps/desktop/electron-forge/forge.config.cjs+++ b/apps/desktop/electron-forge/forge.config.cjs@@ -1,6 +1,7 @@const path = require("path");const fs = require("fs-extra");const { LOCALES } = require("@triliumnext/commons");+const setLanguages = require('electron-packager-languages');const ELECTRON_FORGE_DIR = __dirname;@@ -29,6 +30,10 @@ const macosSignConfiguration = process.env.APPLE_ID ? {}} : undefined;+const localesToKeep = LOCALES+ .filter(locale => !locale.contentOnly)+ .map(locale => locale.electronLocale);+module.exports = {outDir: "out",// Documentation of `packagerConfig` options: https://electron.github.io/packager/main/interfaces/Options.html@@ -45,6 +50,9 @@ module.exports = {...(process.platform === "darwin" ? [] : extraResourcesForPlatform)],prune: false,+ afterCopy: [+ setLanguages(localesToKeep)+ ],afterComplete: [(buildPath, _electronVersion, platform, _arch, callback) => {// Only move resources on non-macOS platforms@@ -142,53 +150,6 @@ module.exports = {}],hooks: {- // Remove unused locales from the packaged app to save some space.- postPackage(_, packageResult) {- const localesToKeep = LOCALES- .filter(locale => !locale.contentOnly)- .map(locale => locale.electronLocale.replace("_", "-"));- const keptLocales = new Set();- const removedLocales = [];-- for (const outputPath of packageResult.outputPaths) {- const localesDir = path.join(outputPath, 'locales');-- if (!fs.existsSync(localesDir)) {- console.log('No locales directory found. Skipping cleanup.');- return;- }-- const files = fs.readdirSync(localesDir);-- for (const file of files) {- let localeName = path.basename(file, ".pak");- if (localeName === "en-US" && process.platform === "win32") {- // If the locale is "en-US" on Windows, we treat it as "en".- // This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".- localeName = "en";- }-- if (localesToKeep.includes(localeName)) {- keptLocales.add(localeName);- continue;- }-- const filePath = path.join(localesDir, file);- fs.unlinkSync(filePath);- removedLocales.push(file);- }- }-- console.log(`Removed unused locale files: ${removedLocales.join(", ")}`);-- // Ensure all locales that should be kept are actually present.- for (const locale of localesToKeep) {- if (!keptLocales.has(locale)) {- console.error(`Locale ${locale} was not found in the packaged app.`);- process.exit(1);- }- }- },// Gather all the artifacts produced by the makers and copy them to a common upload directory.postMake(_, makeResults) {const outputDir = path.join(__dirname, "..", "upload");diff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 15b56a7364..eaf45291e4 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -10,14 +10,10 @@"electron-debug": "4.1.0","electron-dl": "4.0.0","electron-squirrel-startup": "1.0.1",- "jquery.fancytree": "2.38.5",- "jquery-hotkeys": "0.2.2"+ "jquery-hotkeys": "0.2.2",+ "jquery.fancytree": "2.38.5"},"devDependencies": {- "@types/electron-squirrel-startup": "1.0.2",- "@triliumnext/server": "workspace:*",- "copy-webpack-plugin": "13.0.0",- "electron": "36.4.0","@electron-forge/cli": "7.8.1","@electron-forge/maker-deb": "7.8.1","@electron-forge/maker-dmg": "7.8.1",@@ -26,6 +22,11 @@"@electron-forge/maker-squirrel": "7.8.1","@electron-forge/maker-zip": "7.8.1","@electron-forge/plugin-auto-unpack-natives": "7.8.1",+ "@triliumnext/server": "workspace:*",+ "@types/electron-squirrel-startup": "1.0.2",+ "copy-webpack-plugin": "13.0.0",+ "electron": "36.4.0",+ "electron-packager-languages": "0.6.0","prebuild-install": "^7.1.1"},"config": {@@ -75,7 +76,7 @@"cjs"],"thirdParty": true,- "declaration": false,+ "declaration": false,"esbuildOptions": {"splitting": false,"loader": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4e68845227..b20563ba42 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -394,6 +394,9 @@ importers:electron:specifier: 36.4.0version: 36.4.0+ electron-packager-languages:+ specifier: 0.6.0+ version: 0.6.0prebuild-install:specifier: ^7.1.1version: 7.1.3@@ -7191,6 +7194,10 @@ packages:resolution: {integrity: sha512-DWvhKv36GsdXKnaFFhEiK8kZZA+24/yFLgtTwJJHc7AFgDjNRIBJZ/jq62Y/dWv9E4ypYwrVWN2bVrCYw1uv7Q==}+ resolution: {integrity: sha512-vdSTJ6nH93RFo2YnoFbQDb9IAgMTG8ixYOQZuunpFVIUhKpPrRhmbQOuTBk7zJt5eaKUhMZixMD87WQynnM5iQ==}+ engines: {node: '>6.0.0'}+resolution: {integrity: sha512-sTfFIHGku+7PsHLJ7v0dRcZNkALrV+YEozINTW8X1nM//e5O3L+rfYuvSW00lmGHnYmUjARZulD8F2V8ISI9RA==}@@ -21351,6 +21358,10 @@ snapshots:transitivePeerDependencies:- supports-color+ dependencies:+ rimraf: 2.6.3+dependencies:debug: 2.6.9@@ -26258,7 +26269,6 @@ snapshots:dependencies:glob: 7.2.3- optional: truedependencies: