From ee781560714cdc69c999d7d77a0b8a0288eeae41 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 22 Oct 2025 18:37:27 -0500 Subject: [PATCH] Add CalVer to Settings --- src/pages/AboutSettings.tsx | 6 ++++++ src/pages/Settings.tsx | 5 +++++ vite.config.ts | 14 ++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/pages/AboutSettings.tsx b/src/pages/AboutSettings.tsx index 8e5e86dd..7f6292ba 100644 --- a/src/pages/AboutSettings.tsx +++ b/src/pages/AboutSettings.tsx @@ -128,6 +128,12 @@ export function AboutSettings() { + + {import.meta.env.VERSION && ( +
+ v{import.meta.env.VERSION} +
+ )} ); diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 6d421de8..4d5787ef 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -37,6 +37,11 @@ export function Settings() { ); })} + {import.meta.env.VERSION && ( +
+ v{import.meta.env.VERSION} +
+ )} ); } diff --git a/vite.config.ts b/vite.config.ts index b8a44cc8..9e54af58 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,14 +1,28 @@ +import { execSync } from "node:child_process"; import path from "node:path"; import react from "@vitejs/plugin-react-swc"; import { defineConfig } from "vitest/config"; +function getVersion(): string { + try { + const gitCommit = execSync('git rev-parse --short HEAD').toString().trim(); + const commitDate = execSync('git log -1 --format=%cd --date=format:%Y.%m.%d').toString().trim(); + return `${commitDate}+${gitCommit}`; + } catch { + return new Date().toISOString().split('T')[0].replace(/-/g, '.'); + } +} + // https://vitejs.dev/config/ export default defineConfig(() => ({ server: { host: "::", port: 8080, }, + define: { + 'import.meta.env.VERSION': JSON.stringify(getVersion()), + }, plugins: [ react(), ],