From 0286670b816b8a24e40d636c2329d915f2e13a96 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 4 Sep 2025 12:26:06 +0200 Subject: [PATCH] feat: local-cpl-sim system --- .env.development | 2 +- .env.production | 2 +- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- scripts/local-cpl-sim.mjs | 30 ++++++++++++++++++++++++++---- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.env.development b/.env.development index 51f4863..b617f7b 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.836 +NEXT_PUBLIC_APP_VERSION=1.6.837 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 4792396..1183bea 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.836 +NEXT_PUBLIC_APP_VERSION=1.6.837 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d7d47da..ff7b84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.837] – 2025-09-04 + +- feat: local-cpl-sim meldungen/Berichte + +--- ## [1.6.836] – 2025-09-04 - feat: local-cpl-sim.mjs kabelueberwachung diff --git a/package-lock.json b/package-lock.json index 0ed066a..bbae542 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.836", + "version": "1.6.837", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.836", + "version": "1.6.837", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index 7ee0579..1f238ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.836", + "version": "1.6.837", "private": true, "scripts": { "dev": "next dev -p 3000", diff --git a/scripts/local-cpl-sim.mjs b/scripts/local-cpl-sim.mjs index 17afed5..5b8a620 100644 --- a/scripts/local-cpl-sim.mjs +++ b/scripts/local-cpl-sim.mjs @@ -137,14 +137,21 @@ function tryServeSpecialMocks(res, relPath) { } } if (rp === "CPL/SERVICE/systemVoltTemp.js") { - const mockPath = path.join( + const base = path.join( process.cwd(), "mocks", "device-cgi-simulator", - "SERVICE", - "systemVoltTempMockData.js" + "SERVICE" ); - if (exists(mockPath)) return streamRaw(res, mockPath); + const preferred = path.join(base, "systemVoltTemp.js"); + if (exists(preferred)) return streamRaw(res, preferred); + const mockPath = path.join(base, "systemVoltTempMockData.js"); + if (exists(mockPath)) { + // Transform variable name to expected win_systemVoltTemp when streaming + return streamTransform(res, mockPath, (txt) => + txt.replace(/win_systemVoltTempMockData/g, "win_systemVoltTemp") + ); + } } if (rp === "CPL/SERVICE/last20Messages.js") { const mockPath = path.join( @@ -238,6 +245,21 @@ function streamRaw(res, filePath) { return true; } +function streamTransform(res, filePath, transformFn) { + const ext = path.extname(filePath).toLowerCase(); + const type = contentTypeByExt(ext); + const headers = { "Content-Type": type, "Cache-Control": "no-cache" }; + res.writeHead(200, headers); + try { + const txt = fs.readFileSync(filePath, "utf8"); + const out = transformFn(txt); + res.end(out); + } catch { + res.end(); + } + return true; +} + function resolvePlaceholders(filePath, content) { const rel = getRelFromRoot(filePath); const serviceSystem =