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",
"productName": "Gerbil",
"version": "1.3.0",
"version": "1.3.1",
"description": "Run Large Language Models locally",
"main": "out/main/index.js",
"homepage": "./",

View file

@ -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,

View file

@ -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 <T = unknown>(
path: string
): Promise<T | null> => {
export const readJsonFile = async <T = unknown>(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<string> => {
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();
};