feat: show the build commit as a faint corner mark
Declares ARG NEXT_PUBLIC_APP_COMMIT, supplied by Ship, and renders it as a nearly transparent, click-through stamp. Renders nothing when unset. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
cfd54385b3
commit
ceca743e58
3 changed files with 39 additions and 1 deletions
|
|
@ -50,6 +50,11 @@ RUN test -n "$NEXT_PUBLIC_PB_URL" \
|
|||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# The commit being built, supplied by Ship. Declared late so the layers above
|
||||
# stay cached; it is empty for builds that do not pass it.
|
||||
ARG NEXT_PUBLIC_APP_COMMIT
|
||||
ENV NEXT_PUBLIC_APP_COMMIT=${NEXT_PUBLIC_APP_COMMIT}
|
||||
|
||||
# `next build --webpack` is deliberate: @ducanh2912/next-pwa is Webpack-only
|
||||
# and is what generates public/sw.js + public/workbox-*.js. Dropping the flag
|
||||
# silently ships an app with no service worker and no offline install.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import "./globals.css";
|
|||
import type { Metadata, Viewport } from "next";
|
||||
import { ThemeProvider } from "@/components/ThemeProvider";
|
||||
import { SessionLifecycle } from "@/components/auth/SessionLifecycle";
|
||||
import { BuildStamp } from "@/components/BuildStamp";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Mega Plant Dashboard",
|
||||
|
|
@ -45,7 +46,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|||
/>
|
||||
</head>
|
||||
<body className="min-h-screen">
|
||||
<ThemeProvider><SessionLifecycle />{children}</ThemeProvider>
|
||||
<ThemeProvider><SessionLifecycle />{children}<BuildStamp /></ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
|
|
|||
32
components/BuildStamp.tsx
Normal file
32
components/BuildStamp.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* The commit this build came from, as a faint mark in the corner.
|
||||
*
|
||||
* `NEXT_PUBLIC_APP_COMMIT` is set by Ship (the Forgejo Desktop app) when it
|
||||
* builds the image. A build made any other way has no value, so nothing is
|
||||
* rendered. It never takes a click and is nearly transparent.
|
||||
*/
|
||||
export function BuildStamp() {
|
||||
const commit = process.env.NEXT_PUBLIC_APP_COMMIT;
|
||||
if (!commit) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
title={`Build ${commit}`}
|
||||
style={{
|
||||
position: "fixed",
|
||||
right: 6,
|
||||
bottom: "calc(env(safe-area-inset-bottom, 0px) + 3px)",
|
||||
zIndex: 2147483647,
|
||||
fontSize: 9,
|
||||
lineHeight: 1,
|
||||
fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
|
||||
opacity: 0.3,
|
||||
pointerEvents: "none",
|
||||
userSelect: "none",
|
||||
}}
|
||||
>
|
||||
{commit}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue