From 83d5c9cbd400f3e86b45b949d3e905b367aa8cba Mon Sep 17 00:00:00 2001 From: lone-cloud Date: Sun, 14 Sep 2025 12:25:55 -0700 Subject: [PATCH] fix the --version handling regression for packaged builds --- package.json | 2 +- src/main/ipc.ts | 5 +++-- src/utils/node/fs.ts | 18 ++++-------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 4bf2e05..3db3a17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gerbil", "productName": "Gerbil", - "version": "1.3.0", + "version": "1.3.1", "description": "Run Large Language Models locally", "main": "out/main/index.js", "homepage": "./", diff --git a/src/main/ipc.ts b/src/main/ipc.ts index a926a7f..674a6fc 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -50,6 +50,7 @@ import { } from '@/main/modules/binary'; import { startMonitoring, stopMonitoring } from '@/main/modules/monitoring'; import type { FrontendPreference } from '@/types'; +import { getAppVersion } from '@/utils/node/fs'; async function launchKoboldCppWithCustomFrontends(args: string[] = []) { try { @@ -152,10 +153,10 @@ export function setupIPCHandlers() { ipcMain.handle('config:set', (_, key, value) => setConfig(key, value)); - ipcMain.handle('app:getVersion', () => app.getVersion()); + ipcMain.handle('app:getVersion', () => getAppVersion()); ipcMain.handle('app:getVersionInfo', () => ({ - appVersion: app.getVersion(), + appVersion: getAppVersion(), electronVersion: process.versions.electron, nodeVersion: process.versions.node, chromeVersion: process.versions.chrome, diff --git a/src/utils/node/fs.ts b/src/utils/node/fs.ts index 3b2109b..a7b44e1 100644 --- a/src/utils/node/fs.ts +++ b/src/utils/node/fs.ts @@ -1,6 +1,5 @@ import { readFile, writeFile, access, mkdir } from 'fs/promises'; import { constants } from 'fs'; -import { join } from 'path'; export const pathExists = async (path: string) => { try { @@ -11,9 +10,7 @@ export const pathExists = async (path: string) => { } }; -export const readJsonFile = async ( - path: string -): Promise => { +export const readJsonFile = async (path: string) => { try { const content = await readFile(path, 'utf-8'); return JSON.parse(content) as T; @@ -37,14 +34,7 @@ export const ensureDir = async (path: string) => { } }; -export const getAppVersion = async (): Promise => { - try { - const packageJsonPath = join(__dirname, '../../../package.json'); - const packageJson = await readJsonFile<{ version: string }>( - packageJsonPath - ); - return packageJson?.version || 'unknown'; - } catch { - return 'unknown'; - } +export const getAppVersion = async () => { + const { app } = await import('electron'); + return app.getVersion(); };