fix the --version handling regression for packaged builds

This commit is contained in:
lone-cloud 2025-09-14 12:25:55 -07:00
parent 2c485ef37d
commit 83d5c9cbd4
3 changed files with 8 additions and 17 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "gerbil", "name": "gerbil",
"productName": "Gerbil", "productName": "Gerbil",
"version": "1.3.0", "version": "1.3.1",
"description": "Run Large Language Models locally", "description": "Run Large Language Models locally",
"main": "out/main/index.js", "main": "out/main/index.js",
"homepage": "./", "homepage": "./",

View file

@ -50,6 +50,7 @@ import {
} from '@/main/modules/binary'; } from '@/main/modules/binary';
import { startMonitoring, stopMonitoring } from '@/main/modules/monitoring'; import { startMonitoring, stopMonitoring } from '@/main/modules/monitoring';
import type { FrontendPreference } from '@/types'; import type { FrontendPreference } from '@/types';
import { getAppVersion } from '@/utils/node/fs';
async function launchKoboldCppWithCustomFrontends(args: string[] = []) { async function launchKoboldCppWithCustomFrontends(args: string[] = []) {
try { try {
@ -152,10 +153,10 @@ export function setupIPCHandlers() {
ipcMain.handle('config:set', (_, key, value) => setConfig(key, value)); ipcMain.handle('config:set', (_, key, value) => setConfig(key, value));
ipcMain.handle('app:getVersion', () => app.getVersion()); ipcMain.handle('app:getVersion', () => getAppVersion());
ipcMain.handle('app:getVersionInfo', () => ({ ipcMain.handle('app:getVersionInfo', () => ({
appVersion: app.getVersion(), appVersion: getAppVersion(),
electronVersion: process.versions.electron, electronVersion: process.versions.electron,
nodeVersion: process.versions.node, nodeVersion: process.versions.node,
chromeVersion: process.versions.chrome, chromeVersion: process.versions.chrome,

View file

@ -1,6 +1,5 @@
import { readFile, writeFile, access, mkdir } from 'fs/promises'; import { readFile, writeFile, access, mkdir } from 'fs/promises';
import { constants } from 'fs'; import { constants } from 'fs';
import { join } from 'path';
export const pathExists = async (path: string) => { export const pathExists = async (path: string) => {
try { try {
@ -11,9 +10,7 @@ export const pathExists = async (path: string) => {
} }
}; };
export const readJsonFile = async <T = unknown>( export const readJsonFile = async <T = unknown>(path: string) => {
path: string
): Promise<T | null> => {
try { try {
const content = await readFile(path, 'utf-8'); const content = await readFile(path, 'utf-8');
return JSON.parse(content) as T; return JSON.parse(content) as T;
@ -37,14 +34,7 @@ export const ensureDir = async (path: string) => {
} }
}; };
export const getAppVersion = async (): Promise<string> => { export const getAppVersion = async () => {
try { const { app } = await import('electron');
const packageJsonPath = join(__dirname, '../../../package.json'); return app.getVersion();
const packageJson = await readJsonFile<{ version: string }>(
packageJsonPath
);
return packageJson?.version || 'unknown';
} catch {
return 'unknown';
}
}; };