Skip to content

Commit c947bea

Browse files
committed
Adding a build stamp to better confirm deployments
1 parent f796fb4 commit c947bea

4 files changed

Lines changed: 61 additions & 9 deletions

File tree

src/components/main.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { StoryTitleBar } from "@/components/authoring/StoryTitleBar";
66
import { MinervaLibraryPage } from "@/components/library/MinervaLibraryPage";
77
import { PlaybackRouter } from "@/components/playback/PlaybackRouter";
88
import { StoryReturnToLibraryBridge } from "@/components/StoryReturnToLibraryBridge";
9+
import { BuildStamp } from "@/components/shared/BuildStamp";
910
import { FileHandler } from "@/components/shared/FileHandler";
1011
import type { LoadedSourceSummary, ValidObj } from "@/components/shared/Upload";
1112
import { Upload } from "@/components/shared/Upload";
@@ -1651,18 +1652,24 @@ const Main = (props: Props) => {
16511652

16521653
if (props.demo_dicom_web || props.demo_url || hasAuthorShellSupport()) {
16531654
return (
1654-
<StoryPersistenceRoot>
1655-
<LibraryOrAuthor {...props} />
1656-
</StoryPersistenceRoot>
1655+
<>
1656+
<StoryPersistenceRoot>
1657+
<LibraryOrAuthor {...props} />
1658+
</StoryPersistenceRoot>
1659+
<BuildStamp />
1660+
</>
16571661
);
16581662
} else {
16591663
return (
1660-
<div>
1661-
<p>
1662-
Minerva needs a secure context (HTTPS or localhost). Serve this app
1663-
over HTTPS and reload.
1664-
</p>
1665-
</div>
1664+
<>
1665+
<div>
1666+
<p>
1667+
Minerva needs a secure context (HTTPS or localhost). Serve this app
1668+
over HTTPS and reload.
1669+
</p>
1670+
</div>
1671+
<BuildStamp />
1672+
</>
16661673
);
16671674
}
16681675
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import styled from "styled-components";
2+
3+
const Stamp = styled.div`
4+
position: fixed;
5+
right: max(10px, env(safe-area-inset-right));
6+
bottom: max(8px, env(safe-area-inset-bottom));
7+
z-index: 99999;
8+
pointer-events: none;
9+
font-size: 10px;
10+
line-height: 1.25;
11+
font-weight: 400;
12+
letter-spacing: 0.015em;
13+
opacity: 0.28;
14+
color: rgba(238, 238, 238, 0.85);
15+
`;
16+
17+
function utcShort(iso: string): string | null {
18+
const t = Date.parse(iso);
19+
if (Number.isNaN(t)) return null;
20+
return new Date(t).toISOString().replace("T", " ").slice(0, 16);
21+
}
22+
23+
/** Unobtrusive UTC build time so deployed previews are easy to tell apart from `main`/production. */
24+
const BuildStamp = () => {
25+
const label = utcShort(
26+
typeof __BUILD_TIME_ISO__ === "string" ? __BUILD_TIME_ISO__ : "",
27+
);
28+
if (!label) return null;
29+
return (
30+
<Stamp aria-hidden title={__BUILD_TIME_ISO__}>
31+
Updated {label} UTC
32+
</Stamp>
33+
);
34+
};
35+
36+
export { BuildStamp };

src/declaration.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ declare module "deck.gl" {
99
import "wicg-file-system-access";
1010
declare var showOpenFilePicker: ShowOpenFilePicker;
1111
declare global {
12+
/** Set in `vite.config.js` via `define` on each bundle (dev restart / `vite build`). */
13+
const __BUILD_TIME_ISO__: string;
1214
namespace Handle {
1315
type File = FileSystemFileHandle;
1416
type Dir = FileSystemDirectoryHandle;

vite.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import { standardCssModules } from "vite-plugin-standard-css-modules";
66
import { viteStaticCopy } from "vite-plugin-static-copy";
77
import svgr from "vite-plugin-svgr";
88

9+
/** ISO UTC time baked into each bundle; override in CI with `VITE_APP_BUILD_TIME` (ISO-8601). */
10+
const BUILD_TIME_ISO =
11+
process.env.VITE_APP_BUILD_TIME ?? new Date().toISOString();
12+
913
export default defineConfig({
14+
define: {
15+
__BUILD_TIME_ISO__: JSON.stringify(BUILD_TIME_ISO),
16+
},
1017
assetsInclude: ["**/*.wasm"],
1118
worker: {
1219
format: "es",

0 commit comments

Comments
 (0)