diff --git a/.gitignore b/.gitignore index a547bf3..1435fad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +src/version.ts + # Logs logs *.log diff --git a/package.json b/package.json index ca4e659..b2ecc17 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@tailwindcss/forms": "^0.5.10", "@tauri-apps/cli": "^2.6.2", "@types/clusterize.js": "^0.18.3", + "@types/node": "^24.3.0", "@vitejs/plugin-vue": "^5.2.4", "autoprefixer": "^10.4.21", "postcss": "^8.5.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3e8be57..139c3ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,9 +54,12 @@ importers: '@types/clusterize.js': specifier: ^0.18.3 version: 0.18.3 + '@types/node': + specifier: ^24.3.0 + version: 24.3.0 '@vitejs/plugin-vue': 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: specifier: ^10.4.21 version: 10.4.21(postcss@8.5.6) @@ -71,7 +74,7 @@ importers: version: 5.8.3 vite: specifier: ^5.4.19 - version: 5.4.19 + version: 5.4.19(@types/node@24.3.0) vue-tsc: specifier: ^2.2.12 version: 2.2.12(typescript@5.8.3) @@ -475,6 +478,9 @@ packages: '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + '@types/node@24.3.0': + resolution: {integrity: sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==} + '@vitejs/plugin-vue@5.2.4': resolution: {integrity: sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA==} engines: {node: ^18.0.0 || >=20.0.0} @@ -977,6 +983,9 @@ packages: engines: {node: '>=14.17'} hasBin: true + undici-types@7.10.0: + resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==} + update-browserslist-db@1.1.3: resolution: {integrity: sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==} hasBin: true @@ -1323,9 +1332,13 @@ snapshots: '@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: - 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) '@volar/language-core@2.4.15': @@ -1865,6 +1878,8 @@ snapshots: typescript@5.8.3: {} + undici-types@7.10.0: {} + update-browserslist-db@1.1.3(browserslist@4.25.1): dependencies: browserslist: 4.25.1 @@ -1873,12 +1888,13 @@ snapshots: util-deprecate@1.0.2: {} - vite@5.4.19: + vite@5.4.19(@types/node@24.3.0): dependencies: esbuild: 0.21.5 postcss: 8.5.6 rollup: 4.44.1 optionalDependencies: + '@types/node': 24.3.0 fsevents: 2.3.3 vscode-uri@3.1.0: {} diff --git a/src/App.vue b/src/App.vue index f539c2f..04f1bae 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@ + + + + + + diff --git a/vite.config.ts b/vite.config.ts index a55076c..f76d70e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,12 +1,27 @@ import { defineConfig } from "vite"; 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; // https://vitejs.dev/config/ 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` //