feat: export portable native road packages
This commit is contained in:
@@ -4,13 +4,17 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { compiler } = require("../src");
|
||||
const { exportNativeRoadPackage } = require("../src/export/native-road-package");
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const index = args.indexOf("--input");
|
||||
if (index < 0 || !args[index + 1] || index + 2 !== args.length) {
|
||||
throw new Error("Usage: road-compiler --input <RoadCompilerInput.json>");
|
||||
const exportIndex = args.indexOf("--export-zip");
|
||||
const expectedLength = exportIndex >= 0 ? 4 : 2;
|
||||
if (index < 0 || !args[index + 1] || (exportIndex >= 0 && !args[exportIndex + 1]) || args.length !== expectedLength) {
|
||||
throw new Error("Usage: road-compiler --input <RoadCompilerInput.json> [--export-zip <output.zip>]");
|
||||
}
|
||||
const inputFile = path.resolve(args[index + 1]);
|
||||
const input = JSON.parse(fs.readFileSync(inputFile, "utf8"));
|
||||
const { result, comparison } = compiler.compileInput(input);
|
||||
if (exportIndex >= 0) exportNativeRoadPackage(input.outDir, path.resolve(args[exportIndex + 1]));
|
||||
console.log(`NATIVE_ROAD_COMPILE_DONE ${JSON.stringify({ areaId: input.areaId, roads: result.model.roads.length, endpoints: result.model.endpoints.length, diagnostics: result.diagnostics.length, output: input.outDir, comparison })}`);
|
||||
|
||||
Reference in New Issue
Block a user