Skip to content

Commit

Permalink
feat: build info
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 4, 2025
1 parent 785a9b0 commit 8c462e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/routes/settings.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -158,6 +159,23 @@ function RouteComponent() {
<p>{t('cleanHandles.description')}</p>
</div>
{isAuthenticated && <Button onClick={logout}>{t('auth:logout')}</Button>}

<div>
<div>
<Link href={`https://github.com/akari-blue/akari/commit/${__COMMIT_HASH__}`}>
{'commit: '}
{__COMMIT_HASH__}
</Link>
</div>
<div>
{'build date: '}
{__BUILD_DATE__}
</div>
<div>
{'version: '}
{__APP_VERSION__}
</div>
</div>
</div>
</>
);
Expand Down
5 changes: 5 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/// <reference types="vite/client" />

declare const __APP_NAME__: string;
declare const __APP_VERSION__: string;
declare const __COMMIT_HASH__: string;
declare const __BUILD_DATE__: string;
16 changes: 15 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 8c462e0

Please sign in to comment.