diff --git a/env.d.ts b/env.d.ts index 03f72df..e926355 100644 --- a/env.d.ts +++ b/env.d.ts @@ -6,6 +6,8 @@ interface ImportMetaEnv { readonly SAFETWITCH_HTTPS: string readonly SAFETWITCH_DEFAULT_LOCALE: string readonly SAFETWITCH_FALLBACK_LOCALE: string + readonly SAFETWITCH_COMMIT_HASH: string + readonly SAFETWITCH_TAG: string // more env variables... } diff --git a/src/components/FooterView.vue b/src/components/FooterView.vue index 406c218..f4954c4 100644 --- a/src/components/FooterView.vue +++ b/src/components/FooterView.vue @@ -3,16 +3,15 @@ import { inject } from 'vue' export default { setup() { - const version = inject('version') return { - version + version: `${import.meta.env.SAFETWITCH_TAG}-${import.meta.env.SAFETWITCH_COMMIT_HASH}` } - } + }, } diff --git a/src/main.ts b/src/main.ts index 7db08af..688f173 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,6 @@ import App from './App.vue' import router from './router' import './assets/index.css' import i18n from './i18n' -import { version } from '../package.json' const app = createApp(App).use(i18n) @@ -19,7 +18,6 @@ app.provide('protocol', protocol) app.provide('rootUrl', `${protocol}${import.meta.env.SAFETWITCH_INSTANCE_DOMAIN}`) app.provide('rootBackendUrl', `${protocol}${import.meta.env.SAFETWITCH_BACKEND_DOMAIN}`) app.provide('wsLink', `${wsProtocol}${import.meta.env.SAFETWITCH_BACKEND_DOMAIN}`) -app.provide('version', version) import { OhVueIcon, addIcons } from 'oh-vue-icons' import { diff --git a/src/mixins.ts b/src/mixins.ts index 0d6e2a5..d2a73a1 100644 --- a/src/mixins.ts +++ b/src/mixins.ts @@ -43,6 +43,7 @@ export async function getEndpoint(endpoint: string) { export function getDefaultSettings() { return { + version: import.meta.env.SAFETWITCH_TAG, audioOnly: { name: 'Audio Only', selected: false, diff --git a/vite.config.ts b/vite.config.ts index 091986a..c5f01e6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,6 +4,13 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite' import { dirname, resolve } from 'node:path' +import { gitDescribeSync } from 'git-describe' + +// Footer version +const gitVer = gitDescribeSync() +process.env.SAFETWITCH_COMMIT_HASH = gitVer.hash +process.env.SAFETWITCH_TAG = gitVer.tag! + // https://vitejs.dev/config/ export default defineConfig({ @@ -23,3 +30,4 @@ export default defineConfig({ }, envPrefix: 'SAFETWITCH_', }) +