Skip to content

Commit

Permalink
Add commit version
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Apr 5, 2024
1 parent 40803ab commit 86122ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useImport } from './sections/Import';
import { ImportWallet } from './sections/ImportWallet';
import { useWallets } from './stores/db/Wallets';

declare var __COMMIT_HASH__: string

export function App() {
const importModal = useImport()
Expand Down Expand Up @@ -112,7 +113,9 @@ export function App() {
/>
<Box mt="auto" />
<Box>
<Text size="sm" c="dimmed">Source</Text>
<Text size="sm" c="dimmed">
Version: 0x{__COMMIT_HASH__ || "Development mode"}
</Text>
<Text
size="sm"
c="dimmed"
Expand Down
9 changes: 8 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import { execSync } from 'child_process';

const commitHash = execSync('git rev-parse --short HEAD').toString().trim()
const isDirty = execSync('git diff-index --quiet HEAD --; echo $?').toString().trim() !== '0'
const fullCommitHash = isDirty ? `${commitHash} (dirty)` : commitHash

// https://vitejs.dev/config/
export default defineConfig(({ mode }: { mode: string }) => ({
plugins: [react()],
base: mode === 'production' ? '/enchanter/' : '/',
define: {
__COMMIT_HASH__: JSON.stringify(fullCommitHash)
}
}))

0 comments on commit 86122ee

Please sign in to comment.