diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index da7f462..9717000 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -47,7 +47,7 @@ const analyticsConsentVersion = 3 const themePreferenceKey = 'tssbot.theme' const themePreferenceCookie = 'tssbot_theme' const liveRefreshMs = 15000 -const siteVersion = '1.0.1' +const siteVersion = import.meta.env.VITE_SITE_VERSION || '1.0.0' const turnstileSiteKey = import.meta.env.VITE_TURNSTILE_SITE_KEY || '' const siteGateEnabled = String(import.meta.env.VITE_SITE_GATE || 'false').toLowerCase() === 'true' diff --git a/vite.config.js b/vite.config.js index 1a53dbe..d6bab3a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,10 +1,24 @@ import path from 'node:path' +import { execSync } from 'node:child_process' import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' const MAX_TEAM_NAME_LENGTH = 80 +function siteVersion() { + try { + const count = execSync('git rev-list --count HEAD', { + cwd: __dirname, + encoding: 'utf8', + stdio: ['ignore', 'pipe', 'ignore'], + }).trim() + return `1.0.${Number(count) || 0}` + } catch { + return '1.0.0' + } +} + function isAllowedApiUrl(req) { const url = new URL(req.url, 'http://localhost') const params = url.searchParams @@ -175,6 +189,9 @@ export default defineConfig(({ mode }) => { root: path.resolve(__dirname, 'frontend'), publicDir: path.resolve(__dirname, 'frontend/public'), plugins: [comingSoonDev(comingSoon), apiGuard(), react(), tailwindcss()], + define: { + 'import.meta.env.VITE_SITE_VERSION': JSON.stringify(siteVersion()), + }, build: { outDir: path.resolve(__dirname, 'dist'), emptyOutDir: true,