Skip to content

Commit 86122ee

Browse files
committed
Add commit version
1 parent 40803ab commit 86122ee

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useImport } from './sections/Import';
1515
import { ImportWallet } from './sections/ImportWallet';
1616
import { useWallets } from './stores/db/Wallets';
1717

18+
declare var __COMMIT_HASH__: string
1819

1920
export function App() {
2021
const importModal = useImport()
@@ -112,7 +113,9 @@ export function App() {
112113
/>
113114
<Box mt="auto" />
114115
<Box>
115-
<Text size="sm" c="dimmed">Source</Text>
116+
<Text size="sm" c="dimmed">
117+
Version: 0x{__COMMIT_HASH__ || "Development mode"}
118+
</Text>
116119
<Text
117120
size="sm"
118121
c="dimmed"

vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react-swc'
3+
import { execSync } from 'child_process';
4+
5+
const commitHash = execSync('git rev-parse --short HEAD').toString().trim()
6+
const isDirty = execSync('git diff-index --quiet HEAD --; echo $?').toString().trim() !== '0'
7+
const fullCommitHash = isDirty ? `${commitHash} (dirty)` : commitHash
38

4-
// https://vitejs.dev/config/
59
export default defineConfig(({ mode }: { mode: string }) => ({
610
plugins: [react()],
711
base: mode === 'production' ? '/enchanter/' : '/',
12+
define: {
13+
__COMMIT_HASH__: JSON.stringify(fullCommitHash)
14+
}
815
}))

0 commit comments

Comments
 (0)