refactor: move road workbench into compiler package

This commit is contained in:
2026-08-25 17:18:49 +08:00
parent d5c58b5b0c
commit f542a64924
6 changed files with 643 additions and 165 deletions

View File

@@ -5,13 +5,14 @@ const assert = require("assert");
const fs = require("fs");
const path = require("path");
const html = fs.readFileSync(path.join(__dirname, "workbench", "index.html"), "utf8");
const client = path.join(__dirname, "..", "packages", "road-compiler", "workbench", "client");
const html = fs.readFileSync(path.join(client, "index.html"), "utf8");
assert.match(html, /id="width" type="number" min="1" step="0\.01"/);
assert.match(html, /data-layer="sidewalks" type="checkbox" checked> 路缘与步行带/);
assert.match(html, /data-layer="gaodeReference" type="checkbox" checked> 高德规整路口参考/);
assert.match(html, /id="scene-preview" type="checkbox"/);
assert.match(html, /id="selected-junction" hidden/);
const app = fs.readFileSync(path.join(__dirname, "workbench", "app.js"), "utf8");
const app = fs.readFileSync(path.join(client, "app.js"), "utf8");
assert.match(app, /async function saveStagedChanges\(\)/);
assert.match(app, /if \(!await saveStagedChanges\(\)\) return;/);
assert.match(app, /function stageRoadOverride\(road, changes\)/);
@@ -80,10 +81,10 @@ assert.match(app, /fromLonLat/);
assert.match(app, /armFeatures\.push\(new Feature/);
assert.match(app, /headFeatures\.push\(new Feature/);
assert.match(app, /faceFeatures\.push\(new Feature/);
const server = fs.readFileSync(path.join(__dirname, "road-workbench.js"), "utf8");
const server = fs.readFileSync(path.join(__dirname, "..", "packages", "road-compiler", "workbench", "server.js"), "utf8");
assert.match(server, /\/api\/traffic-signals\/generate/);
assert.match(server, /function compileFresh\(configPath\)/);
assert.match(server, /execFileSync\(process\.execPath, \[path\.join\(repoRoot, "scripts", "compile-native-roads\.js"\)/, "workbench regeneration must load the current compiler in a fresh process");
assert.match(server, /function startWorkbench\(/);
assert.match(server, /context\.compileFresh\(\)/, "workbench regeneration must use the host-provided fresh compiler callback");
assert.doesNotMatch(app, /导入 QGIS|导出 QGIS/);
assert.doesNotMatch(server, /traffic-signals\/(?:import|export)-qgis/);
console.log("road workbench tests passed");