Skip to content

Commit

Permalink
add git tag version to profile menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadim Ritter committed Jul 16, 2024
1 parent 596e002 commit c973234
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
11 changes: 11 additions & 0 deletions client/src/components/layout/ContainerLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@
<v-list-item-title class="mx-auto">{{ $t("navigation.signOut") }}</v-list-item-title>
</v-list-item>

<v-divider></v-divider>

<v-list-item class="d-flex">
<v-list-item-title>GUI Version: {{ gitTag }}</v-list-item-title>
</v-list-item>


</v-list>
</v-menu>
</div>
Expand Down Expand Up @@ -209,6 +216,10 @@
const localStorageLocale: string | null = localStorage.getItem("locale");
locale.value = localStorageLocale ?? "en";
const languageToggle = ref<number>(locale.value === "en" ? 0 : 1);
//git tag
//@ts-ignore
const gitTag = __GIT_TAG__;
//watchers
watch(languageToggle, () => {
Expand Down
26 changes: 26 additions & 0 deletions client/src/plugins/vite-plugin-git-tag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { execSync } from "child_process";
import { Plugin } from "vite";

function getGitTag() {
try {
return execSync("git describe --tags").toString().trim();
} catch (error) {
console.error("Error retrieving Git tag:", error);
return "unknown";
}
}

export function gitTagPlugin(): Plugin {
return {
name: "vite-plugin-git-tag",
config: () => {
const gitTag = getGitTag();
console.log(gitTag)
return {
define: {
__GIT_TAG__: JSON.stringify(gitTag),
},
};
},
};
}
2 changes: 1 addition & 1 deletion client/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.mts"]
"include": ["vite.config.mts", "./src/plugins/vite-plugin-git-tag.ts"]
}
36 changes: 20 additions & 16 deletions client/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Plugins
import vue from '@vitejs/plugin-vue'
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import vue from "@vitejs/plugin-vue"
import vuetify, { transformAssetUrls } from "vite-plugin-vuetify";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import { gitTagPlugin } from "./src/plugins/vite-plugin-git-tag";


// Utilities
import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from "vite"
import { fileURLToPath, URL } from "node:url"


// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -18,25 +21,26 @@ export default defineConfig({
autoImport: true,
}),
VueI18nPlugin({
include: fileURLToPath(new URL('./src/i18n/locales/**', import.meta.url)),
})
include: fileURLToPath(new URL("./src/i18n/locales/**", import.meta.url)),
}),
gitTagPlugin()
],
define: {
'process.env': {},
"process.env": {},
_global: ({})
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
"@": fileURLToPath(new URL("./src", import.meta.url))
},
extensions: [
'.js',
'.json',
'.jsx',
'.mjs',
'.ts',
'.tsx',
'.vue',
".js",
".json",
".jsx",
".mjs",
".ts",
".tsx",
".vue",
],
},
server: {
Expand Down

0 comments on commit c973234

Please sign in to comment.