mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-29 00:01:42 +08:00
e700fd4977
Maintain a CHANGELOG.md (Keep a Changelog format) at the repo root and surface it on the admin About page: - The page now shows the running build's short commit hash next to the version, linked to the GitHub commit. Commit is injected at build time via a new resolveAppCommit() (ZPAN_APP_COMMIT -> WORKERS_CI_COMMIT_SHA -> git rev-parse), wired through vite/tsup defines, the node entry, Docker, and CI. - A new admin-only GET /api/system/changelog endpoint fetches CHANGELOG.md from master on GitHub, caches it, parses the latest released version, and reports whether an update is available (semver compare against the running version). - The About page renders a "latest version" row with an update-available badge and a side drawer that displays the changelog markdown. Tests cover the semver compare, changelog parse/fetch caching, the API wrapper, and the route (admin-gated, parsed payload). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
565 B
TypeScript
18 lines
565 B
TypeScript
declare global {
|
|
var __ZPAN_APP_VERSION__: string | undefined
|
|
var __ZPAN_APP_COMMIT__: string | undefined
|
|
}
|
|
|
|
export function getAppVersion(): string {
|
|
if (!globalThis.__ZPAN_APP_VERSION__) {
|
|
throw new Error('__ZPAN_APP_VERSION__ is not configured')
|
|
}
|
|
return globalThis.__ZPAN_APP_VERSION__
|
|
}
|
|
|
|
// The commit SHA is best-effort: absent in build environments without git or an
|
|
// injected SHA. Returns null rather than throwing so the About page degrades.
|
|
export function getAppCommit(): string | null {
|
|
return globalThis.__ZPAN_APP_COMMIT__ || null
|
|
}
|