From 8c462e0cff425f86e1b25e9c33ead5dc081b49e3 Mon Sep 17 00:00:00 2001 From: luna Date: Sat, 4 Jan 2025 22:43:02 +1030 Subject: [PATCH] feat: build info --- src/routes/settings.lazy.tsx | 18 ++++++++++++++++++ src/vite-env.d.ts | 5 +++++ vite.config.ts | 16 +++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/routes/settings.lazy.tsx b/src/routes/settings.lazy.tsx index d7fca42..8305b92 100644 --- a/src/routes/settings.lazy.tsx +++ b/src/routes/settings.lazy.tsx @@ -10,6 +10,7 @@ import { Helmet } from 'react-helmet'; import { Moon, Sun } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { useTheme } from '@/components/theme-provider/use-theme'; +import { Link } from '@/components/ui/Link'; export const Route = createLazyFileRoute('/settings')({ component: RouteComponent, @@ -158,6 +159,23 @@ function RouteComponent() {

{t('cleanHandles.description')}

{isAuthenticated && } + +
+
+ + {'commit: '} + {__COMMIT_HASH__} + +
+
+ {'build date: '} + {__BUILD_DATE__} +
+
+ {'version: '} + {__APP_VERSION__} +
+
); diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 11f02fe..5853cfb 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1 +1,6 @@ /// + +declare const __APP_NAME__: string; +declare const __APP_VERSION__: string; +declare const __COMMIT_HASH__: string; +declare const __BUILD_DATE__: string; diff --git a/vite.config.ts b/vite.config.ts index 32b81bc..f5664f5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,10 +4,24 @@ import react from '@vitejs/plugin-react'; import { TanStackRouterVite } from '@tanstack/router-plugin/vite'; import { VitePWA } from 'vite-plugin-pwa'; import ogPlugin from 'vite-plugin-open-graph'; -import { name, description } from './package.json'; +import { name, version, description } from './package.json'; +import { execSync } from 'child_process'; + +const commitHash = execSync('git rev-parse --short HEAD').toString().trim(); +const buildDate = new Date().toISOString(); + +const define = JSON.parse( + JSON.stringify({ + __APP_NAME__: `"${name}"`, + __APP_VERSION__: `"${version}"`, + __COMMIT_HASH__: `"${commitHash}"`, + __BUILD_DATE__: `"${buildDate}"`, + }), +); // https://vitejs.dev/config/ export default defineConfig({ + define, plugins: [ TanStackRouterVite({ routeFileIgnorePattern: 'components',