feat: migrate workbench to React

This commit is contained in:
que01 committed 2026-08-26 15:01:07 +08:00
1 parent f15e69c868
commit 3ddb33e321
48 files changed
+16748 -1509

No files matched your search

+28 -13
View File
@@ -1,27 +1,42 @@
"use strict";
'use strict';
const fs = require("fs");
const path = require("path");
const fs = require('fs');
const path = require('path');
function checkOutput({ areaId, outDir }) {
if (typeof areaId !== "string" || !areaId) throw new Error("RoadCompilerCheckInput.areaId must be a non-empty string");
if (typeof outDir !== "string" || !outDir) throw new Error("RoadCompilerCheckInput.outDir must be a non-empty string");
const compiledPath = path.join(outDir, "compiled.json");
if (typeof areaId !== 'string' || !areaId)
throw new Error('RoadCompilerCheckInput.areaId must be a non-empty string');
if (typeof outDir !== 'string' || !outDir)
throw new Error('RoadCompilerCheckInput.outDir must be a non-empty string');
const compiledPath = path.join(outDir, 'compiled.json');
if (!fs.existsSync(compiledPath)) throw new Error(`Native road output is missing: ${compiledPath}`);
const compiled = readJson(compiledPath);
const connectors = readJson(path.join(outDir, "layers", "connectors.geojson"));
const connectors = readJson(path.join(outDir, 'layers', 'connectors.geojson'));
const published = new Set(connectors.features.map((feature) => feature.properties.movement_id));
const failures = [];
for (const movement of compiled.movements || []) {
if (movement.geometryPublished && !published.has(movement.id)) failures.push(`Published movement has no connector: ${movement.id}`);
if (!movement.geometryPublished && published.has(movement.id)) failures.push(`Non-published movement has a connector: ${movement.id}`);
if (movement.geometryPublished && !published.has(movement.id))
failures.push(`Published movement has no connector: ${movement.id}`);
if (!movement.geometryPublished && published.has(movement.id))
failures.push(`Non-published movement has a connector: ${movement.id}`);
if (!movement.geometryStatus) failures.push(`Movement has no geometry status: ${movement.id}`);
}
const errors = (compiled.diagnostics || []).filter((item) => item.severity === "error");
const warnings = (compiled.diagnostics || []).filter((item) => item.severity === "warning");
return { schema: "native-road-check/v1", areaId, ok: failures.length === 0 && errors.length === 0, movementCount: (compiled.movements || []).length, connectorCount: connectors.features.length, errors: errors.map((item) => ({ id: item.id, rule: item.rule, message: item.message })), warningCount: warnings.length, failures };
const errors = (compiled.diagnostics || []).filter((item) => item.severity === 'error');
const warnings = (compiled.diagnostics || []).filter((item) => item.severity === 'warning');
return {
schema: 'native-road-check/v1',
areaId,
ok: failures.length === 0 && errors.length === 0,
movementCount: (compiled.movements || []).length,
connectorCount: connectors.features.length,
errors: errors.map((item) => ({ id: item.id, rule: item.rule, message: item.message })),
warningCount: warnings.length,
failures,
};
}
function readJson(file) { return JSON.parse(fs.readFileSync(file, "utf8")); }
function readJson(file) {
return JSON.parse(fs.readFileSync(file, 'utf8'));
}
module.exports = { checkOutput };