diff --git a/src/components/settings/AboutTab.tsx b/src/components/settings/AboutTab.tsx index db9cb8f..9cbef93 100644 --- a/src/components/settings/AboutTab.tsx +++ b/src/components/settings/AboutTab.tsx @@ -43,8 +43,13 @@ export const AboutTab = () => { const versionItems = [ { label: PRODUCT_NAME, - value: versionInfo.isAUR - ? `${versionInfo.appVersion} (AUR)` + value: versionInfo.aurPackageVersion + ? (() => { + const pkgrel = versionInfo.aurPackageVersion.split('-')[1]; + return pkgrel && pkgrel !== '1' + ? `${versionInfo.appVersion} (AUR r${pkgrel})` + : versionInfo.appVersion; + })() : versionInfo.appVersion, }, { label: 'Electron', value: versionInfo.electronVersion }, diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 6064b41..8a60ff8 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -40,7 +40,7 @@ import { isNpxAvailable, getUvVersion, getSystemNodeVersion, - isAURInstallation, + getAURVersion, } from '@/main/modules/dependencies'; import { getMainWindow } from '@/main/modules/window'; import { @@ -160,12 +160,12 @@ export function setupIPCHandlers() { ipcMain.handle('app:getVersion', () => getAppVersion()); ipcMain.handle('app:getVersionInfo', async () => { - const [appVersion, nodeJsSystemVersion, uvVersion, isAUR] = + const [appVersion, nodeJsSystemVersion, uvVersion, aurPackageVersion] = await Promise.all([ getAppVersion(), getSystemNodeVersion(), getUvVersion(), - isAURInstallation(), + getAURVersion(), ]); return { @@ -179,7 +179,7 @@ export function setupIPCHandlers() { arch, nodeJsSystemVersion, uvVersion, - isAUR, + aurPackageVersion, }; }); @@ -276,7 +276,10 @@ export function setupIPCHandlers() { ipcMain.handle('app:canAutoUpdate', () => canAutoUpdate()); - ipcMain.handle('app:isAURInstallation', () => isAURInstallation()); + ipcMain.handle('app:isAURInstallation', async () => { + const aurPackageVersion = await getAURVersion(); + return aurPackageVersion !== null; + }); ipcMain.handle( 'notepad:saveTabContent', diff --git a/src/main/modules/autoUpdater.ts b/src/main/modules/autoUpdater.ts index 3b1f58e..81656cd 100644 --- a/src/main/modules/autoUpdater.ts +++ b/src/main/modules/autoUpdater.ts @@ -3,10 +3,7 @@ import { app } from 'electron'; import { platform } from 'process'; import { logError, safeExecute } from '@/utils/node/logging'; import { isDevelopment } from '@/utils/node/environment'; -import { - isAURInstallation, - isWindowsPortableInstallation, -} from './dependencies'; +import { getAURVersion, isWindowsPortableInstallation } from './dependencies'; export interface UpdateInfo { version: string; @@ -78,7 +75,7 @@ export const isUpdateDownloaded = () => updateDownloaded; export const canAutoUpdate = async () => { if (!app.isPackaged) return false; - if (platform === 'linux' && (await isAURInstallation())) { + if (platform === 'linux' && (await getAURVersion()) !== null) { return false; } diff --git a/src/main/modules/dependencies.ts b/src/main/modules/dependencies.ts index 1bfa4a1..e5f3cb3 100644 --- a/src/main/modules/dependencies.ts +++ b/src/main/modules/dependencies.ts @@ -154,15 +154,15 @@ async function tryVersionManagerPath( return false; } -let aurInstallationCache: boolean | null = null; +let aurVersionCache: string | null = null; -export async function isAURInstallation() { +export async function getAURVersion() { if (platform !== 'linux') { - return false; + return null; } - if (aurInstallationCache !== null) { - return aurInstallationCache; + if (aurVersionCache !== null) { + return aurVersionCache; } try { @@ -170,12 +170,15 @@ export async function isAURInstallation() { timeout: 1000, reject: false, }); - aurInstallationCache = stdout.trim().length > 0; - return aurInstallationCache; - } catch { - aurInstallationCache = false; - return false; - } + const trimmed = stdout.trim(); + if (trimmed.length > 0) { + aurVersionCache = trimmed.replace('gerbil ', ''); + return aurVersionCache; + } + } catch {} + + aurVersionCache = null; + return null; } function tryAddPathToEnv( diff --git a/src/types/electron.d.ts b/src/types/electron.d.ts index 26dcd26..57810d9 100644 --- a/src/types/electron.d.ts +++ b/src/types/electron.d.ts @@ -147,7 +147,7 @@ export interface VersionInfo { arch: string; nodeJsSystemVersion?: string; uvVersion?: string; - isAUR?: boolean; + aurPackageVersion?: string; } export interface AppAPI {