feat: render app version in bottom-left footer

This commit is contained in:
2026-05-04 20:08:24 -03:00
committed by hueso
parent d63cb8c6d3
commit 98c6e04a16
3 changed files with 30 additions and 7 deletions

View File

@@ -6,18 +6,26 @@ import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import svgLoader from "vite-svg-loader";
function getGitTag(): string {
function sh(cmd: string): string {
try {
const tags = execSync("git tag --sort=-version:refname")
return execSync(cmd, { stdio: ["ignore", "pipe", "ignore"] })
.toString()
.trim()
.split("\n");
return tags.length > 0 ? tags[0] : "unknown";
} catch (fallbackError) {
.trim();
} catch {
return "";
}
}
function getAppVersion(): string {
const tag = sh("git tag --sort=-version:refname").split("\n")[0] || "";
const shortSha = sh("git rev-parse --short HEAD");
const tagSha = tag ? sh(`git rev-list -n 1 ${tag}`) : "";
const headSha = sh("git rev-parse HEAD");
if (tag && tagSha === headSha) return tag;
if (tag && shortSha) return `${tag}+${shortSha}`;
return shortSha || "dev";
}
// https://vitejs.dev/config/
export default defineConfig({
base: "./",
@@ -25,7 +33,7 @@ export default defineConfig({
target: "esnext",
},
define: {
__APP_VERSION__: JSON.stringify(getGitTag()),
__APP_VERSION__: JSON.stringify(getAppVersion()),
},
optimizeDeps: {
esbuildOptions: {