diff --git a/Dockerfile b/Dockerfile index 4a01c84..a675f8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /build/frontend ARG VITE_API_URL=/api ENV VITE_API_URL=${VITE_API_URL} -COPY backend/src/main/resources/application.yml /build/backend/src/main/resources/application.yml +COPY backend/pom.xml /build/backend/pom.xml COPY frontend/package*.json ./ RUN npm ci diff --git a/backend/pom.xml b/backend/pom.xml index 36dd5be..ac3c90b 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -12,7 +12,7 @@ de.svencarstensen muh-backend - 0.0.1-SNAPSHOT + 0.9.4 muh-backend MUH application backend diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 3b70115..fb5939e 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -32,7 +32,7 @@ spring: muh: app: - version: 0.9.3 + version: '@project.version@' cors: allowed-origins: ${MUH_ALLOWED_ORIGINS:http://localhost:5173,http://localhost:3000} security: diff --git a/docker_push.sh b/docker_push.sh index d2080c7..863d84d 100755 --- a/docker_push.sh +++ b/docker_push.sh @@ -4,7 +4,7 @@ set -euo pipefail readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" readonly REGISTRY_IMAGE="registry.assecutor.org/muh" -readonly APP_CONFIG_FILE="${SCRIPT_DIR}/backend/src/main/resources/application.yml" +readonly POM_FILE="${SCRIPT_DIR}/backend/pom.xml" usage() { cat <<'EOF' @@ -20,7 +20,7 @@ Voraussetzungen: - Login zur Registry wurde bereits ausgeführt: docker login registry.assecutor.org -Ohne Versionsargument wird automatisch die Version aus backend/src/main/resources/application.yml verwendet. +Ohne Versionsargument wird automatisch die Version aus backend/pom.xml verwendet. Optional kann VITE_API_URL als Umgebungsvariable gesetzt werden. EOF } @@ -35,39 +35,13 @@ require_command() { } resolve_app_version() { - [[ -f "${APP_CONFIG_FILE}" ]] || fail "'${APP_CONFIG_FILE}' wurde nicht gefunden." + [[ -f "${POM_FILE}" ]] || fail "'${POM_FILE}' wurde nicht gefunden." local version - version="$( - awk ' - $0 ~ /^muh:[[:space:]]*$/ { - in_muh = 1 - in_app = 0 - next - } + version="$(sed -n '//,/<\/parent>/!{ s/.*\(.*\)<\/version>.*/\1/p; }' "${POM_FILE}" | head -1)" - in_muh && $0 ~ /^[^[:space:]]/ { - in_muh = 0 - in_app = 0 - } - - in_muh && $0 ~ /^[[:space:]][[:space:]]app:[[:space:]]*$/ { - in_app = 1 - next - } - - in_app && $0 ~ /^[[:space:]][[:space:]][^[:space:]]/ { - in_app = 0 - } - - in_muh && in_app && match($0, /^[[:space:]][[:space:]][[:space:]][[:space:]]version:[[:space:]]*"?([0-9]+\.[0-9]+\.[0-9]+)"?[[:space:]]*$/, a) { - print a[1] - exit - } - ' "${APP_CONFIG_FILE}" - )" - - [[ -n "${version}" ]] || fail "Version konnte nicht aus ${APP_CONFIG_FILE} ermittelt werden." + [[ -n "${version}" ]] || fail "Version konnte nicht aus ${POM_FILE} ermittelt werden." + [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "Version in ${POM_FILE} muss das Format x.y.z haben." echo "${version}" } diff --git a/frontend/src/pages/UserManagementPage.tsx b/frontend/src/pages/UserManagementPage.tsx index e384010..5848a9b 100644 --- a/frontend/src/pages/UserManagementPage.tsx +++ b/frontend/src/pages/UserManagementPage.tsx @@ -126,7 +126,7 @@ export default function UserManagementPage() { if (!userToUpdate) return; await apiPost("/portal/users", { - id: userId, + ...userToUpdate, active: newStatus, }); diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 5bf0961..bca3573 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,35 +4,17 @@ import { fileURLToPath } from "node:url"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; const CONFIG_DIR = path.dirname(fileURLToPath(import.meta.url)); -const APPLICATION_CONFIG_PATH = path.resolve(CONFIG_DIR, "../backend/src/main/resources/application.yml"); +const POM_PATH = path.resolve(CONFIG_DIR, "../backend/pom.xml"); function resolveAppVersion() { - const lines = fs.readFileSync(APPLICATION_CONFIG_PATH, "utf8").split(/\r?\n/); - let inMuhSection = false; - let inAppSection = false; - for (const line of lines) { - const trimmedLine = line.trim(); - if (!trimmedLine || trimmedLine.startsWith("#")) { - continue; - } - const indentation = line.length - line.trimStart().length; - if (indentation === 0) { - inMuhSection = trimmedLine === "muh:"; - inAppSection = false; - continue; - } - if (inMuhSection && indentation === 2) { - inAppSection = trimmedLine === "app:"; - continue; - } - if (inMuhSection && inAppSection && indentation === 4 && trimmedLine.startsWith("version:")) { - const version = trimmedLine.slice("version:".length).trim().replace(/^['"]|['"]$/g, ""); - if (/^\d+\.\d+\.\d+$/.test(version)) { - return version; - } - throw new Error(`Ungueltige Versionsnummer in ${APPLICATION_CONFIG_PATH}: ${version}`); - } + const content = fs.readFileSync(POM_PATH, "utf8"); + const parentRange = content.indexOf(""); + const parentEnd = content.indexOf(""); + const withoutParent = content.slice(0, parentRange) + content.slice(parentEnd + "".length); + const match = withoutParent.match(/(\d+\.\d+\.\d+)<\/version>/); + if (match) { + return match[1]; } - throw new Error(`muh.app.version konnte nicht aus ${APPLICATION_CONFIG_PATH} ermittelt werden.`); + throw new Error(`Version konnte nicht aus ${POM_PATH} ermittelt werden.`); } export default defineConfig({ plugins: [react()],