Added version to landing page

This commit is contained in:
2025-12-30 22:47:52 +01:00
parent d0c177b46e
commit 4e49a38cf9
14 changed files with 341 additions and 16 deletions
+87
View File
@@ -0,0 +1,87 @@
# Frontend Version Management
## Current Version: 0.1.30
The frontend version is managed independently from the backend.
## Version Locations
1. **Primary source**: `/frontend/src/version.js`
- Contains the VERSION constant
- Exports version info functions
2. **Package metadata**: `/frontend/package.json`
- Standard npm version field
- Should match version.js
## Updating the Version
### Option 1: Using the update script (Recommended)
```bash
# Updates both backend and frontend
./scripts/update-version.sh 0.1.31
```
### Option 2: Manual update
Edit `/frontend/src/version.js`:
```javascript
export const VERSION = '0.1.31' // Update this
```
And `/frontend/package.json`:
```json
{
"version": "0.1.31" // Update this
}
```
## Git Commit Information
The git commit is injected via environment variable:
- Set `VITE_GIT_COMMIT` in `.env` or at build time
- Falls back to "unknown" if not set
Example `.env`:
```bash
VITE_GIT_COMMIT=d0c177b
```
## Usage in Components
```javascript
import { getVersion, getGitCommit, getVersionInfo } from '@/version'
// Get version string
const version = getVersion() // "0.1.30"
// Get git commit
const commit = getGitCommit() // "d0c177b" or "unknown"
// Get full info object
const info = getVersionInfo() // { version: "0.1.30", gitCommit: "d0c177b" }
```
## Landing Page Display
The landing page shows both:
- **Frontend Version**: From `/frontend/src/version.js`
- **Backend Version**: Fetched from `/api/public/version`
This allows users to see if frontend and backend are in sync.
## Build-time Version Injection
To inject git commit at build time, update `vite.config.js`:
```javascript
import { defineConfig } from 'vite'
import { execSync } from 'child_process'
const gitCommit = execSync('git rev-parse --short HEAD').toString().trim()
export default defineConfig({
define: {
'import.meta.env.VITE_GIT_COMMIT': JSON.stringify(gitCommit)
}
})
```
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "my-app",
"version": "0.0.0",
"name": "bamort-frontend",
"version": "0.1.21",
"private": true,
"type": "module",
"scripts": {
+4 -2
View File
@@ -47,8 +47,10 @@ export default {
Home:'Startseite',
},
landing:{
title:'BaMoRT - Charakterverwaltung für Rollenspiele',
description:'Bamort ist ein modernes Werkzeug zur Charakterverwaltung für Rollenspiele. Es bietet umfassende Funktionen zur Charaktererstellung, -entwicklung und -verwaltung mit Unterstützung für Fertigkeiten, Zauber, Ausrüstung und mehr.',
title:'BaMoRT - Charakterverwaltung für mein Lieblingsrollenspielsystem',
description:'Bamort ist ein Werkzeug zur Charakterverwaltung für Rollenspiele. Es bietet Funktionen zur Charaktererstellung, -entwicklung und -verwaltung mit Unterstützung für Fertigkeiten, Zauber, Ausrüstung und mehr. Viele Ausrüstungsteile, Fertikeiten und Zauber fehlen noch, da das Projekt noch in der Entwicklung ist.',
frontendVersion:'Frontend Version',
backendVersion:'Backend Version',
version:'Version',
commit:'Commit',
login:'Zum Login',
+2
View File
@@ -48,6 +48,8 @@ export default {
landing:{
title:'BaMoRT - Character Management for Role-Playing Games',
description:'Bamort is a modern character management tool for role-playing games. It provides comprehensive features for character creation, development, and management with support for skills, spells, equipment, and more.',
frontendVersion:'Frontend Version',
backendVersion:'Backend Version',
version:'Version',
commit:'Commit',
login:'Login',
+20
View File
@@ -0,0 +1,20 @@
// Frontend version information
export const VERSION = '0.1.21'
// Git commit will be injected at build time or detected from env
export const GIT_COMMIT = import.meta.env.VITE_GIT_COMMIT || 'unknown'
export function getVersion() {
return VERSION
}
export function getGitCommit() {
return GIT_COMMIT
}
export function getVersionInfo() {
return {
version: VERSION,
gitCommit: GIT_COMMIT
}
}
+21 -12
View File
@@ -10,8 +10,8 @@
<p class="description">{{ $t('landing.description') }}</p>
<div class="version-info">
<p>{{ $t('landing.version') }}: {{ version }}</p>
<p>{{ $t('landing.commit') }}: {{ commit }}</p>
<p>{{ $t('landing.frontendVersion') }}: {{ frontendVersion }}<!-- ({{ frontendCommit }})--> </p>
<p>{{ $t('landing.backendVersion') }}: {{ backendVersion }}<!-- ({{ backendCommit }})--> </p>
</div>
<div class="action-links">
@@ -32,28 +32,37 @@
</style>
<script>
import axios from 'axios'
import { getVersion, getGitCommit } from '../version'
export default {
name: "LandingView",
data() {
return {
version: "0.1.0",
commit: "9775290",
frontendVersion: getVersion(),
frontendCommit: getGitCommit(),
backendVersion: "Loading...",
backendCommit: "Loading...",
githubUrl: "https://github.com/Bardioc26/bamort"
}
},
mounted() {
// Fetch version and commit from API if available
this.fetchVersionInfo()
this.fetchBackendVersion()
},
methods: {
async fetchVersionInfo() {
async fetchBackendVersion() {
try {
// For now, using static values
// In future, could fetch from backend API endpoint
this.version = import.meta.env.VITE_APP_VERSION || "0.1.0"
this.commit = import.meta.env.VITE_GIT_COMMIT || "9775290"
const apiUrl = import.meta.env.VITE_API_URL || 'http://localhost:8180'
const response = await axios.get(`${apiUrl}/api/public/version`)
if (response.data) {
this.backendVersion = response.data.version || "Unknown"
this.backendCommit = response.data.gitCommit || "Unknown"
}
} catch (error) {
console.warn("Could not fetch version info:", error)
console.warn("Could not fetch backend version:", error)
this.backendVersion = "Unavailable"
this.backendCommit = "N/A"
}
}
}