Skip to content

Build your personal knowledge base with Trilium Notes

chore(desktop): integrate icon change for dev nightlies

Elian Doranbd45043a36d1
diff --git a/apps/desktop/.gitignore b/apps/desktop/.gitignore
new file mode 100644
index 0000000000..9098b78ac3
--- /dev/null
+++ b/apps/desktop/.gitignore
@@ -0,0 +1 @@
+electron-forge/app-icon/mac
\ No newline at end of file
diff --git a/apps/desktop/electron-forge/forge.config.ts b/apps/desktop/electron-forge/forge.config.ts
index 5e3a39869b..03d5a4e857 100644
--- a/apps/desktop/electron-forge/forge.config.ts
+++ b/apps/desktop/electron-forge/forge.config.ts
@@ -1,9 +1,11 @@
-import path, { join } from "path";
-import fs from "fs-extra";
-import { LOCALES } from "@triliumnext/commons";
-import { PRODUCT_NAME } from "../src/app-info.js";
import type { ForgeConfig } from "@electron-forge/shared-types";
+import { LOCALES } from "@triliumnext/commons";
import { existsSync } from "fs";
+import fs from "fs-extra";
+import path, { join } from "path";
+
+import packageJson from "../package.json" assert { type: "json" };
+import { PRODUCT_NAME } from "../src/app-info.js";
const ELECTRON_FORGE_DIR = __dirname;
@@ -12,12 +14,12 @@ const APP_ICON_PATH = path.join(ELECTRON_FORGE_DIR, "app-icon");
const extraResourcesForPlatform = getExtraResourcesForPlatform();
const baseLinuxMakerConfigOptions = {
- name: EXECUTABLE_NAME,
- bin: EXECUTABLE_NAME,
- productName: PRODUCT_NAME,
- icon: path.join(APP_ICON_PATH, "png/128x128.png"),
- desktopTemplate: path.resolve(path.join(ELECTRON_FORGE_DIR, "desktop.ejs")),
- categories: ["Office", "Utility"]
+ name: EXECUTABLE_NAME,
+ bin: EXECUTABLE_NAME,
+ productName: PRODUCT_NAME,
+ icon: path.join(APP_ICON_PATH, "png/128x128.png"),
+ desktopTemplate: path.resolve(path.join(ELECTRON_FORGE_DIR, "desktop.ejs")),
+ categories: ["Office", "Utility"]
};
const windowsSignConfiguration = process.env.WINDOWS_SIGN_EXECUTABLE ? {
hookModulePath: path.join(ELECTRON_FORGE_DIR, "sign-windows.cjs")
@@ -30,6 +32,7 @@ const macosSignConfiguration = process.env.APPLE_ID ? {
teamId: process.env.APPLE_TEAM_ID!
}
} : undefined;
+const isNightly = packageJson.version.includes("test");
const config: ForgeConfig = {
outDir: "out",
@@ -37,9 +40,10 @@ const config: ForgeConfig = {
packagerConfig: {
executableName: EXECUTABLE_NAME,
name: PRODUCT_NAME,
+ appVersion: packageJson.version,
overwrite: true,
asar: true,
- icon: path.join(APP_ICON_PATH, "icon"),
+ icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev" : "icon"),
...macosSignConfiguration,
windowsSign: windowsSignConfiguration,
extraResource: [
@@ -87,7 +91,7 @@ const config: ForgeConfig = {
...baseLinuxMakerConfigOptions,
desktopTemplate: undefined, // otherwise it would put in the wrong exec
icon: {
- "128x128": path.join(APP_ICON_PATH, "png/128x128.png"),
+ "128x128": path.join(APP_ICON_PATH, isNightly ? "png/128x128-dev.png" : "png/128x128.png"),
},
id: "com.triliumnext.notes",
runtimeVersion: "24.08",
@@ -136,24 +140,24 @@ const config: ForgeConfig = {
config: {
name: EXECUTABLE_NAME,
productName: PRODUCT_NAME,
- iconUrl: "https://raw.githubusercontent.com/TriliumNext/Trilium/refs/heads/main/apps/desktop/electron-forge/app-icon/icon.ico",
- setupIcon: path.join(ELECTRON_FORGE_DIR, "setup-icon/setup.ico"),
- loadingGif: path.join(ELECTRON_FORGE_DIR, "setup-icon/setup-banner.gif"),
+ iconUrl: `https://raw.githubusercontent.com/TriliumNext/Trilium/refs/heads/main/apps/desktop/electron-forge/app-icon/${isNightly ? "icon-dev" : "icon"}.ico`,
+ setupIcon: path.join(ELECTRON_FORGE_DIR, isNightly ? "setup-icon/setup-dev.ico" : "setup-icon/setup.ico"),
+ loadingGif: path.join(ELECTRON_FORGE_DIR, isNightly ? "setup-icon/setup-banner-dev.gif" : "setup-icon/setup-banner.gif"),
windowsSign: windowsSignConfiguration
}
},
{
name: "@electron-forge/maker-dmg",
config: {
- icon: path.join(APP_ICON_PATH, "icon.icns")
+ icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev.icns" : "icon.icns")
}
},
{
name: "@electron-forge/maker-zip",
config: {
options: {
- iconUrl: "https://raw.githubusercontent.com/TriliumNext/Trilium/refs/heads/main/apps/desktop/electron-forge/app-icon/icon.ico",
- icon: path.join(APP_ICON_PATH, "icon.ico")
+ iconUrl: `https://raw.githubusercontent.com/TriliumNext/Trilium/refs/heads/main/apps/desktop/electron-forge/app-icon/${isNightly ? "icon-dev" : "icon"}.ico`,
+ icon: path.join(APP_ICON_PATH, isNightly ? "icon-dev.ico" : "icon.ico")
}
}
}
@@ -172,7 +176,7 @@ const config: ForgeConfig = {
.filter(locale => !locale.contentOnly)
.map(locale => locale.electronLocale) as string[];
if (!isMac) {
- localesToKeep = localesToKeep.map(locale => locale.replace("_", "-"))
+ localesToKeep = localesToKeep.map(locale => locale.replace("_", "-"));
}
const keptLocales = new Set();
@@ -283,11 +287,11 @@ function getExtraResourcesForPlatform() {
const scripts = ["trilium-portable", "trilium-safe-mode", "trilium-no-cert-check"];
const scriptExt = (process.platform === "win32") ? "bat" : "sh";
return scripts.map(script => `electron-forge/${script}.${scriptExt}`);
- }
+ };
switch (process.platform) {
case "win32":
- resources.push(...getScriptResources())
+ resources.push(...getScriptResources());
break;
case "linux":
resources.push(...getScriptResources(), path.join(APP_ICON_PATH, "png/256x256.png"));
@@ -300,18 +304,18 @@ function getExtraResourcesForPlatform() {
}
function getELFArch(file: string) {
- const buf = fs.readFileSync(file);
+ const buf = fs.readFileSync(file);
- if (buf[0] !== 0x7f || buf[1] !== 0x45 || buf[2] !== 0x4c || buf[3] !== 0x46) {
- throw new Error("Not an ELF file");
- }
+ if (buf[0] !== 0x7f || buf[1] !== 0x45 || buf[2] !== 0x4c || buf[3] !== 0x46) {
+ throw new Error("Not an ELF file");
+ }
- const eiClass = buf[4]; // 1=32-bit, 2=64-bit
- const eiMachine = buf[18]; // architecture code
+ const eiClass = buf[4]; // 1=32-bit, 2=64-bit
+ const eiMachine = buf[18]; // architecture code
- if (eiMachine === 0x3E) return 'x86-64';
- if (eiMachine === 0xB7) return 'ARM64';
- return 'other';
+ if (eiMachine === 0x3E) return 'x86-64';
+ if (eiMachine === 0xB7) return 'ARM64';
+ return 'other';
}
diff --git a/scripts/update-nightly-version.ts b/scripts/update-nightly-version.ts
index 71f5a96847..32bca10f34 100644
--- a/scripts/update-nightly-version.ts
+++ b/scripts/update-nightly-version.ts
@@ -46,7 +46,7 @@ function main() {
const rootPackageJson = join(scriptDir, "..", "package.json");
patchPackageJson(rootPackageJson);
- for (const app of ["server", "client"]) {
+ for (const app of ["server", "client", "desktop"]) {
const appPackageJsonPath = join(scriptDir, "..", "apps", app, "package.json");
patchPackageJson(appPackageJsonPath);
}