From bb03f7db94a88dbdda44e36eabe49f8da0d124ce Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Thu, 20 Jul 2023 11:44:25 +0200 Subject: [PATCH] Display fediwall version in page footer --- env.d.ts | 2 ++ package-lock.json | 64 ++++++++++++++++++++++++++++++++++++++++++----- package.json | 5 ++-- src/App.vue | 4 ++- src/defaults.ts | 2 ++ vite.config.ts | 13 ++++++++++ 6 files changed, 81 insertions(+), 9 deletions(-) diff --git a/env.d.ts b/env.d.ts index 11f02fe..3ea6adc 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,3 @@ /// + +const __VERSION__: readonly string \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f4a7c7a..804d588 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "@types/node": "^18.16.17", "@vitejs/plugin-vue": "^4.2.3", "@vue/tsconfig": "^0.4.0", + "git-describe": "^4.1.1", "npm-run-all": "^4.1.5", "typescript": "~5.0.4", "vite": "^4.3.9", @@ -418,6 +419,12 @@ "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, "node_modules/@types/web-bluetooth": { "version": "0.0.17", "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.17.tgz", @@ -1109,6 +1116,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/git-describe": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/git-describe/-/git-describe-4.1.1.tgz", + "integrity": "sha512-JC8ganO5kO80G8+XE98TDDjnMXQN3Estk3qdJuG2EGRF/l6zuMTMcN+8OSfQZ5FWpqIRLB015anWX4aSRgnxAQ==", + "dev": true, + "dependencies": { + "@types/semver": "^7.3.8", + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=4.0.0" + }, + "optionalDependencies": { + "semver": "^5.6.0" + } + }, "node_modules/globalthis": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", @@ -1502,6 +1525,12 @@ "node": ">=4" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1858,9 +1887,9 @@ } }, "node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -2667,6 +2696,12 @@ "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", "dev": true }, + "@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, "@types/web-bluetooth": { "version": "0.0.17", "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.17.tgz", @@ -3228,6 +3263,17 @@ "get-intrinsic": "^1.1.1" } }, + "git-describe": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/git-describe/-/git-describe-4.1.1.tgz", + "integrity": "sha512-JC8ganO5kO80G8+XE98TDDjnMXQN3Estk3qdJuG2EGRF/l6zuMTMcN+8OSfQZ5FWpqIRLB015anWX4aSRgnxAQ==", + "dev": true, + "requires": { + "@types/semver": "^7.3.8", + "lodash": "^4.17.21", + "semver": "^5.6.0" + } + }, "globalthis": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", @@ -3502,6 +3548,12 @@ "strip-bom": "^3.0.0" } }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -3751,9 +3803,9 @@ } }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true }, "shebang-command": { diff --git a/package.json b/package.json index 313f312..a41a81b 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "bugs": "https://github.com/defnull/fediwall/issues", "license": "AGPL-3.0-or-later", "author": { - "name" : "Marcel Hellkamp", - "url" : "https://defnull.de/" + "name": "Marcel Hellkamp", + "url": "https://defnull.de/" }, "private": true, "scripts": { @@ -29,6 +29,7 @@ "@types/node": "^18.16.17", "@vitejs/plugin-vue": "^4.2.3", "@vue/tsconfig": "^0.4.0", + "git-describe": "^4.1.1", "npm-run-all": "^4.1.5", "typescript": "~5.0.4", "vite": "^4.3.9", diff --git a/src/App.vue b/src/App.vue index b2ef681..61cd473 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,6 +5,7 @@ import { useDocumentVisibility, useWindowSize, watchDebounced } from '@vueuse/co import ConfigModal from './components/ConfigModal.vue'; import { loadConfig, type Config } from './config'; import InfoBar from './components/InfoBar.vue'; +import { gitVersion } from '@/defaults' const config = ref(); @@ -418,9 +419,10 @@ const privacyLink = computed(() => { }} mode]
- Privacy policy + Fediwall {{ gitVersion }} - Github - Documentation + - Privacy policy
diff --git a/src/defaults.ts b/src/defaults.ts index 041bece..9b7621d 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -15,3 +15,5 @@ export const fallbackConfig: Config = { // URL for a site-config file that overrides the default configuration above, if present. export const siteConfigUrl = "wall-config.json" + +export const gitVersion = __VERSION__ || undefined; diff --git a/vite.config.ts b/vite.config.ts index a6c8698..4445fcb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,10 +3,23 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import viteCompression from 'vite-plugin-compression'; +import { gitDescribeSync } from 'git-describe'; + +var version; + +try { + var gitInfo = gitDescribeSync(); + version = `${gitInfo.tag}`; + if (gitInfo.distance) + version += `-${gitInfo.distance}+${gitInfo.hash}` +} catch { } // https://vitejs.dev/config/ export default defineConfig({ base: "./", + define: { + __VERSION__: JSON.stringify(version) + }, plugins: [ vue(), viteCompression() ],