diff --git a/app/api/version/route.ts b/app/api/version/route.ts new file mode 100644 index 0000000..e96baa4 --- /dev/null +++ b/app/api/version/route.ts @@ -0,0 +1,42 @@ +import { NextResponse } from 'next/server'; +import { execSync } from 'child_process'; + +export async function GET() { + try { + // Try to get the git tag/version + let version = 'dev'; + + try { + // First try to get the exact tag if we're on a tagged commit + version = execSync('git describe --tags --exact-match 2>/dev/null', { + encoding: 'utf-8', + cwd: process.cwd() + }).trim(); + } catch { + try { + // If not on a tag, get the latest tag with commit info + version = execSync('git describe --tags --always 2>/dev/null', { + encoding: 'utf-8', + cwd: process.cwd() + }).trim(); + } catch { + // If git is not available or no tags exist, try to get commit hash + try { + const hash = execSync('git rev-parse --short HEAD 2>/dev/null', { + encoding: 'utf-8', + cwd: process.cwd() + }).trim(); + version = `dev-${hash}`; + } catch { + // Fallback to just 'dev' if git is not available + version = 'dev'; + } + } + } + + return NextResponse.json({ version }); + } catch (error) { + console.error('Error getting version:', error); + return NextResponse.json({ version: 'unknown' }); + } +} diff --git a/app/layout.tsx b/app/layout.tsx index 8df95ae..7e7b3e7 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -25,6 +25,7 @@ export const viewport: Viewport = { }; import InstallPrompt from "@/components/InstallPrompt"; +import AppFooter from "@/components/AppFooter"; export default function RootLayout({ children, @@ -36,15 +37,7 @@ export default function RootLayout({ {children} - + ); diff --git a/components/AppFooter.tsx b/components/AppFooter.tsx new file mode 100644 index 0000000..b038b20 --- /dev/null +++ b/components/AppFooter.tsx @@ -0,0 +1,34 @@ +'use client'; + +import { useEffect, useState } from 'react'; + +export default function AppFooter() { + const [version, setVersion] = useState(''); + + useEffect(() => { + fetch('/api/version') + .then(res => res.json()) + .then(data => setVersion(data.version)) + .catch(() => setVersion('')); + }, []); + + return ( + + ); +}