Kennzeichne die Entwicklungsumgebung in der Oberflaeche, damit sie sich von Produktion unterscheiden laesst.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
db4063296b
commit
cbd45a8997
8 files changed
+106
-21
No files matched your search
@@ -63,6 +63,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_TSUMUGU_ENV: development
|
||||||
ports:
|
ports:
|
||||||
- "${TSUMUGU_FRONTEND_PORT:-3094}:80"
|
- "${TSUMUGU_FRONTEND_PORT:-3094}:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
VITE_TSUMUGU_ENV: production
|
||||||
container_name: tsumugu-ui
|
container_name: tsumugu-ui
|
||||||
ports:
|
ports:
|
||||||
- "${TSUMUGU_FRONTEND_PORT:-3007}:80"
|
- "${TSUMUGU_FRONTEND_PORT:-3007}:80"
|
||||||
|
|||||||
+3
-1
@@ -5,9 +5,11 @@ WORKDIR /src
|
|||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY index.html vite.config.js ./
|
COPY index.html vite.config.js mark-environment.mjs ./
|
||||||
COPY public ./public
|
COPY public ./public
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
|
ARG VITE_TSUMUGU_ENV=production
|
||||||
|
ENV VITE_TSUMUGU_ENV=$VITE_TSUMUGU_ENV
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
|
||||||
|
if (process.env.VITE_TSUMUGU_ENV !== "development") {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const manifestPath = new URL("./dist/manifest.webmanifest", import.meta.url);
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
||||||
|
manifest.name = "Tsumugu Entwicklung";
|
||||||
|
manifest.short_name = "Tsumugu Dev";
|
||||||
|
manifest.theme_color = "#8a5a12";
|
||||||
|
fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||||
|
|
||||||
|
const indexPath = new URL("./dist/index.html", import.meta.url);
|
||||||
|
const html = fs
|
||||||
|
.readFileSync(indexPath, "utf8")
|
||||||
|
.replace("<title>Tsumugu</title>", "<title>Tsumugu · Entwicklung</title>")
|
||||||
|
.replace('name="apple-mobile-web-app-title" content="Tsumugu"', 'name="apple-mobile-web-app-title" content="Tsumugu Dev"')
|
||||||
|
.replace('name="theme-color" content="#085041"', 'name="theme-color" content="#8a5a12"');
|
||||||
|
fs.writeFileSync(indexPath, html);
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build && node mark-environment.mjs",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+40
-19
@@ -14,6 +14,17 @@ import { Users } from "./pages/Users.jsx";
|
|||||||
import { Work } from "./pages/Work.jsx";
|
import { Work } from "./pages/Work.jsx";
|
||||||
import { Settings } from "./pages/Settings.jsx";
|
import { Settings } from "./pages/Settings.jsx";
|
||||||
import { Reader } from "./pages/Reader.jsx";
|
import { Reader } from "./pages/Reader.jsx";
|
||||||
|
import { appTitle, isDevelopment } from "./environment.js";
|
||||||
|
|
||||||
|
function EnvironmentBanner() {
|
||||||
|
useEffect(() => {
|
||||||
|
document.title = appTitle;
|
||||||
|
if (!isDevelopment) return;
|
||||||
|
document.querySelector('meta[name="theme-color"]')?.setAttribute("content", "#8a5a12");
|
||||||
|
}, []);
|
||||||
|
if (!isDevelopment) return null;
|
||||||
|
return <p className="env-banner" role="status">Entwicklungsumgebung</p>;
|
||||||
|
}
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
const [session, setSession] = useState(undefined);
|
const [session, setSession] = useState(undefined);
|
||||||
@@ -66,31 +77,41 @@ export function App() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session === undefined) {
|
if (session === undefined) {
|
||||||
return <p className="boot">Tsumugu wird geladen …</p>;
|
return (
|
||||||
|
<div className="app-root">
|
||||||
|
<EnvironmentBanner />
|
||||||
|
<p className="boot">Tsumugu wird geladen …</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = { session, setSession, refresh, changeScope, logout };
|
const value = { session, setSession, refresh, changeScope, logout };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SessionContext.Provider value={value}>
|
<SessionContext.Provider value={value}>
|
||||||
<Routes>
|
<div className="app-root">
|
||||||
<Route path="/login" element={session ? <Navigate to="/" replace /> : <Login />} />
|
<EnvironmentBanner />
|
||||||
<Route element={session ? <Shell /> : <Navigate to="/login" replace />}>
|
<div className="app-root__main">
|
||||||
<Route index element={<Overview />} />
|
<Routes>
|
||||||
<Route path="cases" element={<CaseList />} />
|
<Route path="/login" element={session ? <Navigate to="/" replace /> : <Login />} />
|
||||||
<Route path="cases/:id" element={<CaseDetail />} />
|
<Route element={session ? <Shell /> : <Navigate to="/login" replace />}>
|
||||||
<Route path="matters" element={<MatterList />} />
|
<Route index element={<Overview />} />
|
||||||
<Route path="matters/:id" element={<MatterDetail />} />
|
<Route path="cases" element={<CaseList />} />
|
||||||
<Route path="matters/:id/items/:bindingId" element={<Reader />} />
|
<Route path="cases/:id" element={<CaseDetail />} />
|
||||||
<Route path="cases/:id/items/:bindingId" element={<Reader />} />
|
<Route path="matters" element={<MatterList />} />
|
||||||
<Route path="work" element={<Work />} />
|
<Route path="matters/:id" element={<MatterDetail />} />
|
||||||
<Route path="settings" element={<Settings />} />
|
<Route path="matters/:id/items/:bindingId" element={<Reader />} />
|
||||||
<Route path="rooms" element={<Rooms />} />
|
<Route path="cases/:id/items/:bindingId" element={<Reader />} />
|
||||||
<Route path="sources" element={<Sources />} />
|
<Route path="work" element={<Work />} />
|
||||||
<Route path="users" element={<Users />} />
|
<Route path="settings" element={<Settings />} />
|
||||||
<Route path="search" element={<Search />} />
|
<Route path="rooms" element={<Rooms />} />
|
||||||
</Route>
|
<Route path="sources" element={<Sources />} />
|
||||||
</Routes>
|
<Route path="users" element={<Users />} />
|
||||||
|
<Route path="search" element={<Search />} />
|
||||||
|
</Route>
|
||||||
|
</Routes>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</SessionContext.Provider>
|
</SessionContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// Dieselbe Quellfassung läuft nach dem Merge in beiden Deployments.
|
||||||
|
// Development setzt VITE_TSUMUGU_ENV beim Image-Build. Der lokale Vite-Server gilt ebenfalls als Entwicklung.
|
||||||
|
export const isDevelopment =
|
||||||
|
import.meta.env.VITE_TSUMUGU_ENV === "development" ||
|
||||||
|
(import.meta.env.DEV && import.meta.env.VITE_TSUMUGU_ENV !== "production");
|
||||||
|
|
||||||
|
export const appTitle = isDevelopment ? "Tsumugu · Entwicklung" : "Tsumugu";
|
||||||
@@ -141,6 +141,37 @@ label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(-
|
|||||||
.error { color: var(--danger); font-size: 14px; }
|
.error { color: var(--danger); font-size: 14px; }
|
||||||
.banner { margin: 0 16px 8px; }
|
.banner { margin: 0 16px 8px; }
|
||||||
|
|
||||||
|
.app-root {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.app-root__main {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.app-root__main > .app-shell,
|
||||||
|
.app-root__main > .login,
|
||||||
|
.app-root > .boot {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.env-banner {
|
||||||
|
margin: 0;
|
||||||
|
flex: none;
|
||||||
|
background: var(--warn);
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.boot, .login {
|
.boot, .login {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
Reference in new issue
Block a user