Show version number in footer

This commit is contained in:
RunasSudo 2025-08-23 22:15:16 +10:00
parent 845640dc93
commit 0bb47f0368
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
6 changed files with 75 additions and 8 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
src/version.ts
# Logs # Logs
logs logs
*.log *.log

View File

@ -27,6 +27,7 @@
"@tailwindcss/forms": "^0.5.10", "@tailwindcss/forms": "^0.5.10",
"@tauri-apps/cli": "^2.6.2", "@tauri-apps/cli": "^2.6.2",
"@types/clusterize.js": "^0.18.3", "@types/clusterize.js": "^0.18.3",
"@types/node": "^24.3.0",
"@vitejs/plugin-vue": "^5.2.4", "@vitejs/plugin-vue": "^5.2.4",
"autoprefixer": "^10.4.21", "autoprefixer": "^10.4.21",
"postcss": "^8.5.6", "postcss": "^8.5.6",

26
pnpm-lock.yaml generated
View File

@ -54,9 +54,12 @@ importers:
'@types/clusterize.js': '@types/clusterize.js':
specifier: ^0.18.3 specifier: ^0.18.3
version: 0.18.3 version: 0.18.3
'@types/node':
specifier: ^24.3.0
version: 24.3.0
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: ^5.2.4 specifier: ^5.2.4
version: 5.2.4(vite@5.4.19)(vue@3.5.17(typescript@5.8.3)) version: 5.2.4(vite@5.4.19(@types/node@24.3.0))(vue@3.5.17(typescript@5.8.3))
autoprefixer: autoprefixer:
specifier: ^10.4.21 specifier: ^10.4.21
version: 10.4.21(postcss@8.5.6) version: 10.4.21(postcss@8.5.6)
@ -71,7 +74,7 @@ importers:
version: 5.8.3 version: 5.8.3
vite: vite:
specifier: ^5.4.19 specifier: ^5.4.19
version: 5.4.19 version: 5.4.19(@types/node@24.3.0)
vue-tsc: vue-tsc:
specifier: ^2.2.12 specifier: ^2.2.12
version: 2.2.12(typescript@5.8.3) version: 2.2.12(typescript@5.8.3)
@ -475,6 +478,9 @@ packages:
'@types/estree@1.0.8': '@types/estree@1.0.8':
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
'@types/node@24.3.0':
resolution: {integrity: sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==}
'@vitejs/plugin-vue@5.2.4': '@vitejs/plugin-vue@5.2.4':
resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==} resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==}
engines: {node: ^18.0.0 || >=20.0.0} engines: {node: ^18.0.0 || >=20.0.0}
@ -977,6 +983,9 @@ packages:
engines: {node: '>=14.17'} engines: {node: '>=14.17'}
hasBin: true hasBin: true
undici-types@7.10.0:
resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==}
update-browserslist-db@1.1.3: update-browserslist-db@1.1.3:
resolution: {integrity: sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==} resolution: {integrity: sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==}
hasBin: true hasBin: true
@ -1323,9 +1332,13 @@ snapshots:
'@types/estree@1.0.8': {} '@types/estree@1.0.8': {}
'@vitejs/plugin-vue@5.2.4(vite@5.4.19)(vue@3.5.17(typescript@5.8.3))': '@types/node@24.3.0':
dependencies: dependencies:
vite: 5.4.19 undici-types: 7.10.0
'@vitejs/plugin-vue@5.2.4(vite@5.4.19(@types/node@24.3.0))(vue@3.5.17(typescript@5.8.3))':
dependencies:
vite: 5.4.19(@types/node@24.3.0)
vue: 3.5.17(typescript@5.8.3) vue: 3.5.17(typescript@5.8.3)
'@volar/language-core@2.4.15': '@volar/language-core@2.4.15':
@ -1865,6 +1878,8 @@ snapshots:
typescript@5.8.3: {} typescript@5.8.3: {}
undici-types@7.10.0: {}
update-browserslist-db@1.1.3(browserslist@4.25.1): update-browserslist-db@1.1.3(browserslist@4.25.1):
dependencies: dependencies:
browserslist: 4.25.1 browserslist: 4.25.1
@ -1873,12 +1888,13 @@ snapshots:
util-deprecate@1.0.2: {} util-deprecate@1.0.2: {}
vite@5.4.19: vite@5.4.19(@types/node@24.3.0):
dependencies: dependencies:
esbuild: 0.21.5 esbuild: 0.21.5
postcss: 8.5.6 postcss: 8.5.6
rollup: 4.44.1 rollup: 4.44.1
optionalDependencies: optionalDependencies:
'@types/node': 24.3.0
fsevents: 2.3.3 fsevents: 2.3.3
vscode-uri@3.1.0: {} vscode-uri@3.1.0: {}

View File

@ -1,5 +1,5 @@
<!-- <!--
DrCr: Web-based double-entry bookkeeping framework DrCr: Double-entry bookkeeping framework
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo) Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -32,6 +32,7 @@
</div> </div>
</main> </main>
</div> </div>
<FooterBar />
</div> </div>
</template> </template>
@ -39,6 +40,7 @@
import { onErrorCaptured } from 'vue'; import { onErrorCaptured } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import FooterBar from './components/FooterBar.vue';
import HeaderBar from './components/HeaderBar.vue'; import HeaderBar from './components/HeaderBar.vue';
import { db } from './db.js'; import { db } from './db.js';
import { error, handleCriticalError } from './error.js'; import { error, handleCriticalError } from './error.js';

View File

@ -0,0 +1,31 @@
<!--
DrCr: Double-entry bookkeeping framework
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<footer class="print:hidden">
<div class="mx-auto max-w-7xl px-6 lg:px-8">
<div class="border-t border-gray-200 py-4 text-center text-sm text-gray-500 sm:text-left">
DrCr (build {{ COMMIT_HASH }})
</div>
</div>
</footer>
</template>
<script setup lang="ts">
import { COMMIT_HASH } from '../version.ts';
</script>

View File

@ -1,12 +1,27 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
// @ts-expect-error process is a nodejs global import * as child from "child_process";
import * as fs from "node:fs";
const host = process.env.TAURI_DEV_HOST; const host = process.env.TAURI_DEV_HOST;
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [vue()], plugins: [
vue(),
{
// Update version.ts when frontend built
name: "update-version",
async buildStart(options) {
// Get commit from git
const commitHash = child.execSync("git rev-parse --short HEAD").toString().trim();
// Write to src/version.ts
fs.writeFileSync("src/version.ts", "export const COMMIT_HASH = " + JSON.stringify(commitHash) + ";");
},
},
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// //