Skip to content

Your favorite shift management application!

feat: Adds build metadata, build-info API and admin panel build infos (#110)

panteL5c3dde9e898c
diff --git a/.env.example b/.env.example
index 8319f41..e13991a 100644
--- a/.env.example
+++ b/.env.example
@@ -91,7 +91,6 @@ ALLOW_GUEST_ACCESS=false # Allow viewing calendars without login
GITHUB_REPO_OWNER=panteLx
GITHUB_REPO_NAME=BetterShift
-GITHUB_BRANCH=main
# Optional: Increases API rate limit from 60 to 5000 requests/hour
# GITHUB_TOKEN=
diff --git a/.github/workflows/docker-dev.yml b/.github/workflows/docker-dev.yml
index 396250b..6ae3848 100644
--- a/.github/workflows/docker-dev.yml
+++ b/.github/workflows/docker-dev.yml
@@ -39,6 +39,10 @@ jobs:
type=raw,value=dev,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
type=ref,event=pr,prefix=pr-
+ - name: Capture build timestamp
+ id: timestamp
+ run: echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
+
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
@@ -50,3 +54,6 @@ jobs:
cache-to: type=gha,mode=max
build-args: |
VERSION=dev
+ BUILD_DATE=${{ steps.timestamp.outputs.BUILD_DATE }}
+ COMMIT_SHA=${{ github.sha }}
+ COMMIT_REF=${{ github.ref_name }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index ccc71af..479f6b4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -139,6 +139,10 @@ jobs:
type=semver,pattern=v{{major}}
type=raw,value=latest
+ - name: Capture build timestamp
+ id: timestamp
+ run: echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
+
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
@@ -150,6 +154,9 @@ jobs:
cache-to: type=gha,mode=max
build-args: |
VERSION=v${{ steps.version.outputs.VERSION }}
+ BUILD_DATE=${{ steps.timestamp.outputs.BUILD_DATE }}
+ COMMIT_SHA=${{ github.sha }}
+ COMMIT_REF=${{ github.ref_name }}
- name: Create Release
uses: softprops/action-gh-release@v2
diff --git a/Dockerfile b/Dockerfile
index 7493a4e..1981eb9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -50,8 +50,11 @@ FROM node:20-alpine AS runner
RUN apk add --no-cache libc6-compat dumb-init
WORKDIR /app
-# Get VERSION from builder stage
+# Build-time metadata (passed from GitHub Actions)
ARG VERSION=dev
+ARG BUILD_DATE=unknown
+ARG COMMIT_SHA=unknown
+ARG COMMIT_REF=unknown
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
@@ -71,8 +74,8 @@ COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts
# Copy production dependencies
COPY --from=prod-deps /app/node_modules ./node_modules
-# Write VERSION to file
-RUN echo "$VERSION" > /app/.version
+# Write build metadata
+RUN node -e "const fs=require('fs');fs.writeFileSync('/app/.build-info.json',JSON.stringify({version:process.env.VERSION||'',buildDate:process.env.BUILD_DATE||'',commitSha:process.env.COMMIT_SHA||'',commitRef:process.env.COMMIT_REF||''}));"
# Expose port
EXPOSE 3000
diff --git a/app/admin/page.tsx b/app/admin/page.tsx
index 36225d2..ade96e2 100644
--- a/app/admin/page.tsx
+++ b/app/admin/page.tsx
@@ -2,6 +2,7 @@
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation";
+import { useState, useEffect } from "react";
import {
Card,
CardContent,
@@ -15,11 +16,31 @@ import { Badge } from "@/components/ui/badge";
import { FullscreenLoader } from "@/components/fullscreen-loader";
import { StatsCardsGrid } from "@/components/admin/stats-cards";
import { useAdminStats } from "@/hooks/useAdminStats";
-import { FolderOpen, RefreshCw } from "lucide-react";
-import { formatDistanceToNow } from "date-fns";
+import {
+ FolderOpen,
+ RefreshCw,
+ Info,
+ ExternalLink,
+ GitCommit,
+ Calendar as CalendarIcon,
+ CheckCircle,
+ AlertCircle,
+} from "lucide-react";
+import { formatDistanceToNow, format } from "date-fns";
import { getDateLocale } from "@/lib/locales";
import { useLocale } from "next-intl";
+interface VersionInfo {
+ version: string;
+ commitHash: string;
+ buildDate: string;
+ githubUrl: string;
+ isDev: boolean;
+ latestVersion?: string;
+ latestUrl?: string;
+ hasUpdate?: boolean;
+}
+
/**
* Admin Dashboard Page
*
@@ -32,9 +53,29 @@ export default function AdminDashboardPage() {
const locale = useLocale();
const dateLocale = getDateLocale(locale);
- const { stats, isLoading, refetch } = useAdminStats();
+ const { stats, isLoading: isLoadingStats, refetch } = useAdminStats();
+ const [versionInfo, setVersionInfo] = useState<VersionInfo | null>(null);
+ const [isLoadingVersion, setIsLoadingVersion] = useState(true);
+
+ // Fetch version info
+ useEffect(() => {
+ fetchVersionInfo();
+ }, []);
- if (isLoading && !stats) {
+ const fetchVersionInfo = async () => {
+ try {
+ const response = await fetch("/api/version");
+ if (!response.ok) return;
+ const data = await response.json();
+ setVersionInfo(data);
+ } catch (error) {
+ console.error("Failed to fetch version info:", error);
+ } finally {
+ setIsLoadingVersion(false);
+ }
+ };
+
+ if (isLoadingStats && !stats) {
return <FullscreenLoader />;
}
@@ -56,12 +97,150 @@ export default function AdminDashboardPage() {
variant="outline"
size="icon"
onClick={() => refetch()}
- disabled={isLoading}
+ disabled={isLoadingStats}
>
- <RefreshCw className={isLoading ? "animate-spin" : ""} />
+ <RefreshCw className={isLoadingStats ? "animate-spin" : ""} />
</Button>
</div>
+ {/* System Information */}
+ <Card>
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-3">
+ <div>
+ <CardTitle className="pb-3">
+ {t("admin.systemInfo.title")}
+ </CardTitle>
+ <CardDescription>
+ {t("admin.systemInfo.description")}
+ </CardDescription>
+ </div>
+ </div>
+ {versionInfo?.hasUpdate && !versionInfo.isDev && (
+ <Badge variant="default" className="gap-1">
+ <AlertCircle className="h-3 w-3" />
+ {t("admin.systemInfo.updateAvailable")}
+ </Badge>
+ )}
+ {versionInfo && !versionInfo.hasUpdate && !versionInfo.isDev && (
+ <Badge variant="secondary" className="gap-1">
+ <CheckCircle className="h-3 w-3" />
+ {t("admin.systemInfo.upToDate")}
+ </Badge>
+ )}
+ </div>
+ </CardHeader>
+ <CardContent>
+ {isLoadingVersion ? (
+ <div className="flex items-center justify-center py-8 text-muted-foreground">
+ <RefreshCw className="h-5 w-5 animate-spin mr-2" />
+ {t("common.loading")}
+ </div>
+ ) : versionInfo ? (
+ <div className="grid gap-4 md:grid-cols-2">
+ {/* Version */}
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-sm text-muted-foreground">
+ <Info className="h-4 w-4" />
+ {t("admin.systemInfo.version")}
+ </div>
+ <div className="flex items-center gap-2">
+ <code className="text-lg font-semibold font-mono">
+ {versionInfo.version}
+ </code>
+ {versionInfo.isDev && (
+ <Badge variant="outline">
+ {t("admin.systemInfo.development")}
+ </Badge>
+ )}
+ </div>
+ </div>
+
+ {/* Build Date */}
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-sm text-muted-foreground">
+ <CalendarIcon className="h-4 w-4" />
+ {t("admin.systemInfo.buildDate")}
+ </div>
+ <div className="text-lg font-semibold">
+ {versionInfo.buildDate !== "dev" &&
+ versionInfo.buildDate !== "unknown"
+ ? format(new Date(versionInfo.buildDate), "PPp", {
+ locale: dateLocale,
+ })
+ : t("admin.systemInfo.unknown")}
+ </div>
+ </div>
+
+ {/* Commit Hash */}
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-sm text-muted-foreground">
+ <GitCommit className="h-4 w-4" />
+ {t("admin.systemInfo.commitHash")}
+ </div>
+ <div className="flex items-center gap-2">
+ <code className="text-sm font-mono bg-muted px-2 py-1 rounded">
+ {versionInfo.commitHash}
+ </code>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 gap-1"
+ asChild
+ >
+ <a
+ href={versionInfo.githubUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <ExternalLink className="h-3 w-3" />
+ {t("admin.systemInfo.viewOnGitHub")}
+ </a>
+ </Button>
+ </div>
+ </div>
+
+ {/* Latest Version (if available) */}
+ {versionInfo.latestVersion && !versionInfo.isDev && (
+ <div className="space-y-1">
+ <div className="flex items-center gap-2 text-sm text-muted-foreground">
+ <Info className="h-4 w-4" />
+ {t("admin.systemInfo.latestVersion")}
+ </div>
+ <div className="flex items-center gap-2">
+ <code className="text-lg font-semibold font-mono">
+ {versionInfo.latestVersion}
+ </code>
+ {versionInfo.latestUrl && (
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 gap-1"
+ asChild
+ >
+ <a
+ href={versionInfo.latestUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <ExternalLink className="h-3 w-3" />
+ {t("admin.systemInfo.viewRelease")}
+ </a>
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ ) : (
+ <div className="text-center py-8 text-muted-foreground">
+ {t("admin.systemInfo.unknown")}
+ </div>
+ )}
+ </CardContent>
+ </Card>
+
{/* Orphaned Calendars Warning */}
{hasOrphanedCalendars && (
<Card className="border-yellow-500 bg-yellow-50 dark:bg-yellow-950/20">
@@ -93,7 +272,7 @@ export default function AdminDashboardPage() {
)}
{/* Stats Cards */}
- <StatsCardsGrid stats={stats} isLoading={isLoading} />
+ <StatsCardsGrid stats={stats} isLoading={isLoadingStats} />
{/* Recent Activity Preview */}
{stats?.activity.logs && stats.activity.logs.length > 0 && (
diff --git a/app/api/version/route.ts b/app/api/version/route.ts
index 36b29bb..ee5eeb7 100644
--- a/app/api/version/route.ts
+++ b/app/api/version/route.ts
@@ -1,18 +1,28 @@
import { NextResponse } from "next/server";
-import { getCurrentVersion } from "@/lib/version";
+import { getBuildInfo, buildGitHubUrl } from "@/lib/version";
/**
* Cache Strategy: 15 minutes unified across all version/release endpoints
- * - Server-side cache (cachedVersion): 15 minutes
+ * - Server-side cache (cachedVersionInfo): 15 minutes
* - HTTP Cache-Control: 15 minutes
* - GitHub API revalidation: 15 minutes
* - Client polling interval: 15 minutes
*/
-// Cache version info
-let cachedVersion: {
+interface VersionResponse {
version: string;
commitHash: string;
+ buildDate: string;
+ githubUrl: string;
+ isDev: boolean;
+ latestVersion?: string;
+ latestUrl?: string;
+ hasUpdate?: boolean;
+}
+
+// Cache version info with timestamp
+let cachedVersionInfo: {
+ data: VersionResponse;
timestamp: number;
} | null = null;
@@ -29,52 +39,8 @@ const CACHE_SECONDS = 15 * 60; // 15 minutes
const GITHUB_REPO_OWNER = process.env.GITHUB_REPO_OWNER || "panteLx";
const GITHUB_REPO_NAME = process.env.GITHUB_REPO_NAME || "BetterShift";
-const GITHUB_BRANCH = process.env.GITHUB_BRANCH || "main";
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
-async function fetchCommitHash(): Promise<string> {
- try {
- const response = await fetch(
- `https://api.github.com/repos/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}/commits/${GITHUB_BRANCH}`,
- {
- headers: {
- Accept: "application/vnd.github.v3+json",
- ...(GITHUB_TOKEN && { Authorization: `Bearer ${GITHUB_TOKEN}` }),
- },
- next: { revalidate: CACHE_SECONDS },
- }
- );
-
- if (!response.ok) {
- throw new Error(`GitHub API error: ${response.status}`);
- }
-
- const data = await response.json();
- return data.sha.substring(0, 7);
- } catch (error) {
- console.error("Failed to fetch commit hash:", error);
- return "unknown";
- }
-}
-
-function buildGitHubUrl(version: string, commitHash: string): string {
- const baseUrl = `https://github.com/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}`;
-
- // Check if version matches semver pattern (e.g., 1.1.1 or v1.1.1)
- const semverPattern = /^v?\d+\.\d+\.\d+$/;
- if (semverPattern.test(version)) {
- const tag = version.startsWith("v") ? version : `v${version}`;
- return `${baseUrl}/releases/tag/${tag}`;
- }
-
- // Otherwise link to commit
- if (commitHash && commitHash !== "unknown") {
- return `${baseUrl}/commit/${commitHash}`;
- }
-
- return baseUrl;
-}
-
async function getLatestRelease(): Promise<{
version: string;
url: string;
@@ -119,8 +85,12 @@ async function getLatestRelease(): Promise<{
function compareVersions(current: string, latest: string): boolean {
// Returns true if latest is newer than current
- const parseCurrent = current.split(".").map(Number);
- const parseLatest = latest.split(".").map(Number);
+ // Remove 'v' prefix if present
+ const cleanCurrent = current.replace(/^v/, "");
+ const cleanLatest = latest.replace(/^v/, "");
+
+ const parseCurrent = cleanCurrent.split(".").map(Number);
+ const parseLatest = cleanLatest.split(".").map(Number);
for (let i = 0; i < 3; i++) {
const curr = parseCurrent[i] || 0;
@@ -134,80 +104,64 @@ function compareVersions(current: string, latest: string): boolean {
}
function isDevVersion(version: string): boolean {
- // Check if version contains 'dev' or if it's a Docker :dev tag
- return version.includes("dev") || version === "dev";
+ // Check if version is 'dev' or contains 'dev'
+ return version === "dev" || version.includes("dev");
}
export async function GET() {
// Check cache
- if (cachedVersion && Date.now() - cachedVersion.timestamp < CACHE_DURATION) {
- const githubUrl = buildGitHubUrl(
- cachedVersion.version,
- cachedVersion.commitHash
- );
-
- // Get latest release for update check (only if not dev version)
- const isDev = isDevVersion(cachedVersion.version);
- const latestRelease = !isDev ? await getLatestRelease() : null;
- const hasUpdate =
- latestRelease &&
- !isDev &&
- compareVersions(cachedVersion.version, latestRelease.version);
-
- return NextResponse.json(
- {
- version: cachedVersion.version,
- commitHash: cachedVersion.commitHash,
- githubUrl,
- isDev,
- ...(latestRelease && {
- latestVersion: latestRelease.version,
- latestUrl: latestRelease.url,
- hasUpdate,
- }),
+ if (
+ cachedVersionInfo &&
+ Date.now() - cachedVersionInfo.timestamp < CACHE_DURATION
+ ) {
+ return NextResponse.json(cachedVersionInfo.data, {
+ headers: {
+ "Cache-Control": `public, max-age=${CACHE_SECONDS}`,
},
- {
- headers: {
- "Cache-Control": `public, max-age=${CACHE_SECONDS}`,
- },
- }
- );
+ });
}
- // Get current version
- const version = await getCurrentVersion();
- const commitHash = await fetchCommitHash();
+ // Get build info from .build-info.json (created at build time)
+ const buildInfo = await getBuildInfo();
- cachedVersion = {
- version,
- commitHash,
- timestamp: Date.now(),
- };
+ // Build GitHub URL based on version and commit
+ const githubUrl = buildGitHubUrl(buildInfo.version, buildInfo.commitSha);
- const githubUrl = buildGitHubUrl(version, commitHash);
+ // Determine if this is a dev version
+ const isDev = isDevVersion(buildInfo.version);
// Get latest release for update check (only if not dev version)
- const isDev = isDevVersion(version);
const latestRelease = !isDev ? await getLatestRelease() : null;
const hasUpdate =
- latestRelease && !isDev && compareVersions(version, latestRelease.version);
-
- return NextResponse.json(
- {
- version,
- commitHash,
- githubUrl,
- isDev,
- ...(latestRelease && {
- latestVersion: latestRelease.version,
- latestUrl: latestRelease.url,
- hasUpdate,
- }),
+ latestRelease && !isDev
+ ? compareVersions(buildInfo.version, latestRelease.version)
+ : undefined;
+
+ const response: VersionResponse = {
+ version: buildInfo.version,
+ commitHash:
+ buildInfo.commitSha.length >= 7
+ ? buildInfo.commitSha.substring(0, 7)
+ : buildInfo.commitSha, // Return full string if shorter than 7 chars (e.g., "dev", "unknown")
+ buildDate: buildInfo.buildDate,
+ githubUrl,
+ isDev,
+ ...(latestRelease && {
+ latestVersion: latestRelease.version,
+ latestUrl: latestRelease.url,
+ hasUpdate,
+ }),
+ };
+
+ // Cache the response
+ cachedVersionInfo = {
+ data: response,
+ timestamp: Date.now(),
+ };
+
+ return NextResponse.json(response, {
+ headers: {
+ "Cache-Control": `public, max-age=${CACHE_SECONDS}`,
},
- {
- headers: {
- "Cache-Control": `public, max-age=${CACHE_SECONDS}`,
- },
- }
- );
+ });
}
diff --git a/hooks/useVersionUpdate.ts b/hooks/useVersionUpdate.ts
index d9aeefd..b3b42fc 100644
--- a/hooks/useVersionUpdate.ts
+++ b/hooks/useVersionUpdate.ts
@@ -3,6 +3,7 @@ import { useState, useEffect } from "react";
interface VersionInfo {
version: string;
commitHash: string;
+ buildDate: string;
githubUrl: string;
isDev: boolean;
latestVersion?: string;
diff --git a/lib/version.ts b/lib/version.ts
index 4b0a7d8..60a3ba3 100644
--- a/lib/version.ts
+++ b/lib/version.ts
@@ -1,31 +1,51 @@
import { readFile, access } from "fs/promises";
import { join } from "path";
-let cachedVersion: string | null = null;
-let versionLoadPromise: Promise<string> | null = null;
+export interface BuildInfo {
+ version: string;
+ buildDate: string;
+ commitSha: string;
+ commitRef: string;
+}
+
+let cachedBuildInfo: BuildInfo | null = null;
+let buildInfoLoadPromise: Promise<BuildInfo> | null = null;
/**
- * Get version from Docker .version file
+ * Get build info from Docker .build-info.json file
*/
-async function getDockerVersion(): Promise<string | null> {
+async function getDockerBuildInfo(): Promise<BuildInfo | null> {
try {
- const versionFilePath = join(process.cwd(), ".version");
+ const buildInfoPath = join(process.cwd(), ".build-info.json");
// Check if file exists
- await access(versionFilePath);
-
- // Read and parse version
- const content = await readFile(versionFilePath, "utf-8");
- // Remove 'v' prefix for consistent version comparison
- return content.trim().replace(/^v/, "");
- } catch {
- // File doesn't exist or can't be read
+ await access(buildInfoPath);
+
+ // Read and parse build info
+ const content = await readFile(buildInfoPath, "utf-8");
+ let info;
+ try {
+ info = JSON.parse(content);
+ } catch (parseError) {
+ console.error("Failed to parse .build-info.json:", parseError);
+ return null;
+ }
+
+ return {
+ version: info.version || "unknown",
+ buildDate: info.buildDate || "unknown",
+ commitSha: info.commitSha || "unknown",
+ commitRef: info.commitRef || "unknown",
+ };
+ } catch (error) {
+ // File doesn't exist or can't be read (non-parsing errors)
+ console.error("Failed to read .build-info.json:", error);
return null;
}
}
/**
- * Get version from package.json
+ * Get version from package.json (fallback for dev mode)
*/
async function getPackageVersion(): Promise<string> {
try {
@@ -40,49 +60,66 @@ async function getPackageVersion(): Promise<string> {
}
/**
- * Load version from filesystem
- * Tries Docker .version file first, then package.json
+ * Load build info from filesystem
+ * Tries Docker .build-info.json first, then falls back to package.json
*/
-async function loadVersion(): Promise<string> {
- const dockerVersion = await getDockerVersion();
- if (dockerVersion) {
- return dockerVersion;
+async function loadBuildInfo(): Promise<BuildInfo> {
+ const dockerBuildInfo = await getDockerBuildInfo();
+ if (dockerBuildInfo) {
+ return dockerBuildInfo;
}
- return getPackageVersion();
+
+ // Fallback for local development (not running in Docker)
+ const packageVersion = await getPackageVersion();
+ return {
+ version: packageVersion,
+ buildDate: "dev",
+ commitSha: "dev",
+ commitRef: "dev",
+ };
}
/**
- * Initialize version cache during server startup
+ * Initialize build info cache during server startup
* This should be called from instrumentation.ts register() hook
*/
export async function initializeVersion(): Promise<void> {
- if (cachedVersion === null && versionLoadPromise === null) {
- versionLoadPromise = loadVersion();
- cachedVersion = await versionLoadPromise;
- versionLoadPromise = null;
+ if (cachedBuildInfo === null && buildInfoLoadPromise === null) {
+ buildInfoLoadPromise = loadBuildInfo();
+ cachedBuildInfo = await buildInfoLoadPromise;
+ buildInfoLoadPromise = null;
}
}
/**
- * Get current application version (async)
- * Returns cached version if available, otherwise loads it
+ * Get current application build info (async)
+ * Returns cached build info if available, otherwise loads it
*/
-export async function getCurrentVersion(): Promise<string> {
- if (cachedVersion !== null) {
- return cachedVersion;
+export async function getBuildInfo(): Promise<BuildInfo> {
+ if (cachedBuildInfo !== null) {
+ return cachedBuildInfo;
}
- // If another call is already loading the version, wait for it
- if (versionLoadPromise !== null) {
- return versionLoadPromise;
+ // If another call is already loading the build info, wait for it
+ if (buildInfoLoadPromise !== null) {
+ return buildInfoLoadPromise;
}
- // Load version and cache it
- versionLoadPromise = loadVersion();
- cachedVersion = await versionLoadPromise;
- versionLoadPromise = null;
+ // Load build info and cache it
+ buildInfoLoadPromise = loadBuildInfo();
+ cachedBuildInfo = await buildInfoLoadPromise;
+ buildInfoLoadPromise = null;
- return cachedVersion;
+ return cachedBuildInfo;
+}
+
+/**
+ * Get current application version (async)
+ * Returns cached version if available, otherwise loads it
+ */
+export async function getCurrentVersion(): Promise<string> {
+ const buildInfo = await getBuildInfo();
+ return buildInfo.version;
}
/**
@@ -91,13 +128,13 @@ export async function getCurrentVersion(): Promise<string> {
* @deprecated Use getCurrentVersion() async function instead
*/
export function getCurrentVersionSync(): string {
- return cachedVersion || "loading...";
+ return cachedBuildInfo?.version || "loading...";
}
/**
* Build GitHub URL for a version
*/
-export function buildGitHubUrl(version: string): string {
+export function buildGitHubUrl(version: string, commitSha?: string): string {
const repoOwner = process.env.GITHUB_REPO_OWNER || "panteLx";
const repoName = process.env.GITHUB_REPO_NAME || "BetterShift";
const baseUrl = `https://github.com/${repoOwner}/${repoName}`;
@@ -109,6 +146,11 @@ export function buildGitHubUrl(version: string): string {
return `${baseUrl}/releases/tag/${tag}`;
}
+ // For dev builds, link to commit if available
+ if (commitSha && commitSha !== "unknown" && commitSha !== "dev") {
+ return `${baseUrl}/commit/${commitSha}`;
+ }
+
// Otherwise link to main repo
return baseUrl;
}
@@ -120,11 +162,11 @@ export async function getVersionInfo(): Promise<{
version: string;
githubUrl: string;
}> {
- const version = await getCurrentVersion();
- const githubUrl = buildGitHubUrl(version);
+ const buildInfo = await getBuildInfo();
+ const githubUrl = buildGitHubUrl(buildInfo.version, buildInfo.commitSha);
return {
- version,
+ version: buildInfo.version,
githubUrl,
};
}
diff --git a/messages/de.json b/messages/de.json
index ab64d34..0104a39 100644
--- a/messages/de.json
+++ b/messages/de.json
@@ -645,6 +645,20 @@
"last7Days": "Letzte 7 Tage",
"needsAttention": "Benötigt Aufmerksamkeit"
},
+ "systemInfo": {
+ "title": "Systeminformationen",
+ "description": "Aktuelle Systemversion und Build-Details",
+ "version": "Version",
+ "buildDate": "Build-Datum",
+ "commitHash": "Commit-Hash",
+ "latestVersion": "Neueste Version",
+ "updateAvailable": "Update verfügbar",
+ "upToDate": "Aktuell",
+ "viewOnGitHub": "Auf GitHub anzeigen",
+ "viewRelease": "Release anzeigen",
+ "development": "Entwicklung",
+ "unknown": "Unbekannt"
+ },
"dashboardDescription": "Willkommen im BetterShift Admin-Panel",
"orphanedCalendarsWarning": "Verwaiste Kalender erkannt",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {Es gibt 1 Kalender ohne Besitzer} other {Es gibt # Kalender ohne Besitzer}}. Bitte weise diese(n) Benutzern zu.",
diff --git a/messages/en.json b/messages/en.json
index 7bfd98b..ae78fb9 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -645,6 +645,20 @@
"last7Days": "Last 7 days",
"needsAttention": "Needs Attention"
},
+ "systemInfo": {
+ "title": "System Information",
+ "description": "Current system version and build details",
+ "version": "Version",
+ "buildDate": "Build Date",
+ "commitHash": "Commit Hash",
+ "latestVersion": "Latest Version",
+ "updateAvailable": "Update Available",
+ "upToDate": "Up to Date",
+ "viewOnGitHub": "View on GitHub",
+ "viewRelease": "View Release",
+ "development": "Development",
+ "unknown": "Unknown"
+ },
"dashboardDescription": "Welcome to the BetterShift Admin Panel",
"orphanedCalendarsWarning": "Orphaned Calendars Detected",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {There is 1 calendar without an owner} other {There are # calendars without an owner}}. Please assign them to users.",
diff --git a/messages/it.json b/messages/it.json
index 3be40cd..8f06c1f 100644
--- a/messages/it.json
+++ b/messages/it.json
@@ -645,6 +645,20 @@
"last7Days": "Ultimi 7 giorni",
"needsAttention": "Richiede Attenzione"
},
+ "systemInfo": {
+ "title": "Informazioni di sistema",
+ "description": "Versione corrente del sistema e dettagli di build",
+ "version": "Versione",
+ "buildDate": "Data di build",
+ "commitHash": "Hash commit",
+ "latestVersion": "Versione più recente",
+ "updateAvailable": "Aggiornamento disponibile",
+ "upToDate": "Aggiornato",
+ "viewOnGitHub": "Visualizza su GitHub",
+ "viewRelease": "Visualizza release",
+ "development": "Sviluppo",
+ "unknown": "Sconosciuto"
+ },
"dashboardDescription": "Benvenuto nel Pannello Admin di BetterShift",
"orphanedCalendarsWarning": "Calendari Orfani Rilevati",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {C'è 1 calendario senza proprietario} other {Ci sono # calendari senza proprietario}}. Si prega di assegnarli agli utenti.",