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
Revert "fix(desktop): use plugin to clean up languages"
Elian Doran3d7784ca1880
diff --git a/apps/desktop/electron-forge/forge.config.cjs b/apps/desktop/electron-forge/forge.config.cjsindex 630e99cc2f..27ab8ec8c3 100644--- a/apps/desktop/electron-forge/forge.config.cjs+++ b/apps/desktop/electron-forge/forge.config.cjs@@ -1,7 +1,6 @@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;@@ -30,10 +29,6 @@ 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@@ -50,9 +45,6 @@ module.exports = {...(process.platform === "darwin" ? [] : extraResourcesForPlatform)],prune: false,- afterCopy: [- setLanguages(localesToKeep)- ],afterComplete: [(buildPath, _electronVersion, platform, _arch, callback) => {// Only move resources on non-macOS platforms@@ -150,6 +142,53 @@ 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 eaf45291e4..15b56a7364 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -10,10 +10,14 @@"electron-debug": "4.1.0","electron-dl": "4.0.0","electron-squirrel-startup": "1.0.1",- "jquery-hotkeys": "0.2.2",- "jquery.fancytree": "2.38.5"+ "jquery.fancytree": "2.38.5",+ "jquery-hotkeys": "0.2.2"},"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",@@ -22,11 +26,6 @@"@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": {@@ -76,7 +75,7 @@"cjs"],"thirdParty": true,- "declaration": false,+ "declaration": false,"esbuildOptions": {"splitting": false,"loader": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b20563ba42..4e68845227 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -394,9 +394,6 @@ 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@@ -7194,10 +7191,6 @@ 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==}@@ -21358,10 +21351,6 @@ snapshots:transitivePeerDependencies:- supports-color- dependencies:- rimraf: 2.6.3-dependencies:debug: 2.6.9@@ -26269,6 +26258,7 @@ snapshots:dependencies:glob: 7.2.3+ optional: truedependencies: