From 6b0df21a052ca03e1aafe42ed486219117e1941d Mon Sep 17 00:00:00 2001 From: Will Chen Date: Tue, 15 Apr 2025 00:22:19 -0700 Subject: [PATCH] show version & bump --- package.json | 2 +- src/ipc/handlers/app_handlers.ts | 7 +++++++ src/ipc/ipc_client.ts | 11 +++++++++++ src/pages/settings.tsx | 20 ++++++++++++++++++++ src/preload.ts | 1 + 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ad70056..64e5bf2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dyad", "productName": "dyad", - "version": "0.1.0", + "version": "0.1.1", "description": "My Electron application description", "main": ".vite/build/main.js", "repository": { diff --git a/src/ipc/handlers/app_handlers.ts b/src/ipc/handlers/app_handlers.ts index e670904..e215b86 100644 --- a/src/ipc/handlers/app_handlers.ts +++ b/src/ipc/handlers/app_handlers.ts @@ -1071,4 +1071,11 @@ export function registerAppHandlers() { return { success: true, message: "Successfully reset everything" }; }); + + ipcMain.handle("get-app-version", async () => { + // Read version from package.json at project root + const packageJsonPath = path.resolve(__dirname, "..", "..", "package.json"); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")); + return { version: packageJson.version }; + }); } diff --git a/src/ipc/ipc_client.ts b/src/ipc/ipc_client.ts index 25ac9ed..65addae 100644 --- a/src/ipc/ipc_client.ts +++ b/src/ipc/ipc_client.ts @@ -617,6 +617,17 @@ export class IpcClient { } // --- End GitHub Repo Management --- + // Get the main app version + public async getAppVersion(): Promise { + try { + const result = await this.ipcRenderer.invoke("get-app-version"); + return result.version as string; + } catch (error) { + showError(error); + throw error; + } + } + // Example methods for listening to events (if needed) // public on(channel: string, func: (...args: any[]) => void): void { } diff --git a/src/pages/settings.tsx b/src/pages/settings.tsx index e03b99a..2686953 100644 --- a/src/pages/settings.tsx +++ b/src/pages/settings.tsx @@ -26,6 +26,7 @@ export default function SettingsPage() { const [nodeVersion, setNodeVersion] = useState(null); const [npmVersion, setNpmVersion] = useState(null); const [downloadClicked, setDownloadClicked] = useState(false); + const [appVersion, setAppVersion] = useState(null); useEffect(() => { const checkNode = async () => { @@ -40,6 +41,17 @@ export default function SettingsPage() { } }; checkNode(); + + // Fetch app version + const fetchVersion = async () => { + try { + const version = await IpcClient.getInstance().getAppVersion(); + setAppVersion(version); + } catch (error) { + setAppVersion(null); + } + }; + fetchVersion(); }, []); const handleResetEverything = async () => { @@ -123,6 +135,14 @@ export default function SettingsPage() { Settings + {/* App Version Section */} +
+ App Version: + + {appVersion ? appVersion : "-"} + +
+

diff --git a/src/preload.ts b/src/preload.ts index baa16d8..3ed2214 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -36,6 +36,7 @@ const validInvokeChannels = [ "github:is-repo-available", "github:create-repo", "github:push", + "get-app-version", ] as const; // Add valid receive channels