Porting fixes from stale branch

This commit is contained in:
pietervdvn 2021-09-04 18:59:51 +02:00
parent a9b6223e4d
commit 03d801733b
4 changed files with 24 additions and 19 deletions

View file

@ -101,7 +101,7 @@
{ {
"if": { "if": {
"and": [ "and": [
"addr:housenumber:=", "addr:housenumber=",
"not:addr:housenumber=yes", "not:addr:housenumber=yes",
"fixme=" "fixme="
] ]

View file

@ -1,5 +1,6 @@
import {lstatSync, readdirSync, readFileSync} from "fs"; import {lstatSync, readdirSync, readFileSync} from "fs";
import {Utils} from "../Utils"; import {Utils} from "../Utils";
Utils.runningFromConsole = true Utils.runningFromConsole = true
import * as https from "https"; import * as https from "https";
import * as fs from "fs"; import * as fs from "fs";
@ -90,7 +91,7 @@ export default class ScriptUtils {
} }
public static erasableLog(...text) { public static erasableLog(...text) {
process.stdout.write("\r "+text.join(" ")+" \r") process.stdout.write("\r " + text.join(" ") + " \r")
} }
public static sleep(ms) { public static sleep(ms) {
@ -107,12 +108,13 @@ export default class ScriptUtils {
public static getLayerFiles(): { parsed: LayerConfigJson, path: string }[] { public static getLayerFiles(): { parsed: LayerConfigJson, path: string }[] {
return ScriptUtils.readDirRecSync("./assets/layers") return ScriptUtils.readDirRecSync("./assets/layers")
.filter(path => path.indexOf(".json") > 0) .filter(path => path.indexOf(".json") > 0)
.filter(path => path.indexOf(".proto.json") < 0)
.filter(path => path.indexOf("license_info.json") < 0) .filter(path => path.indexOf("license_info.json") < 0)
.map(path => { .map(path => {
try { try {
const contents = readFileSync(path, "UTF8") const contents = readFileSync(path, "UTF8")
if(contents === ""){ if (contents === "") {
throw "The file "+path+" is empty, did you properly save?" throw "The file " + path + " is empty, did you properly save?"
} }
const parsed = JSON.parse(contents); const parsed = JSON.parse(contents);
@ -130,8 +132,8 @@ export default class ScriptUtils {
.map(path => { .map(path => {
try { try {
const contents = readFileSync(path, "UTF8"); const contents = readFileSync(path, "UTF8");
if(contents === ""){ if (contents === "") {
throw "The file "+path+" is empty, did you properly save?" throw "The file " + path + " is empty, did you properly save?"
} }
const parsed = JSON.parse(contents); const parsed = JSON.parse(contents);
return {parsed: parsed, path: path} return {parsed: parsed, path: path}

View file

@ -25,6 +25,9 @@ class LayerOverviewUtils {
const themeFiles: LayoutConfigJson[] = ScriptUtils.getThemeFiles().map(x => x.parsed); const themeFiles: LayoutConfigJson[] = ScriptUtils.getThemeFiles().map(x => x.parsed);
console.log("Discovered", layerFiles.length, "layers and", themeFiles.length, "themes\n") console.log("Discovered", layerFiles.length, "layers and", themeFiles.length, "themes\n")
if (layerFiles.length + themeFiles.length === 0) {
throw "Panic: no themes and layers loaded!"
}
return { return {
layers: layerFiles, layers: layerFiles,
themes: themeFiles themes: themeFiles
@ -56,8 +59,8 @@ class LayerOverviewUtils {
if (path != undefined && path.indexOf(expected) < 0) { if (path != undefined && path.indexOf(expected) < 0) {
errorCount.push("Layer is in an incorrect place. The path is " + path + ", but expected " + expected) errorCount.push("Layer is in an incorrect place. The path is " + path + ", but expected " + expected)
} }
if(layerJson["hideUnderlayingFeaturesMinPercentage"] !== undefined){ if (layerJson["hideUnderlayingFeaturesMinPercentage"] !== undefined) {
errorCount.push("Layer "+layer.id+" contains an old 'hideUnderlayingFeaturesMinPercentage'") errorCount.push("Layer " + layer.id + " contains an old 'hideUnderlayingFeaturesMinPercentage'")
} }
@ -146,8 +149,8 @@ class LayerOverviewUtils {
themeErrorCount.push("Theme ids should be in lowercase, but it is " + theme.id) themeErrorCount.push("Theme ids should be in lowercase, but it is " + theme.id)
} }
let filename = themePath.substring(themePath.lastIndexOf("/") + 1, themePath.length - 5) let filename = themePath.substring(themePath.lastIndexOf("/") + 1, themePath.length - 5)
if(theme.id !== filename){ if (theme.id !== filename) {
themeErrorCount.push("Theme ids should be the same as the name.json, but we got id: " + theme.id + " and filename "+filename+" ("+themePath+")") themeErrorCount.push("Theme ids should be the same as the name.json, but we got id: " + theme.id + " and filename " + filename + " (" + themePath + ")")
} }

View file

@ -235,7 +235,7 @@ function MergeTranslation(source: any, target: any, language: string, context: s
} }
if (typeof targetV === "string") { if (typeof targetV === "string") {
throw `At context ${context}: Could not add a translation. The target object has a string at the given path, whereas the translation contains an object.\n String at target: ${targetV}\n Object at translation source: ${JSON.stringify(sourceV)}` throw `At context ${context}: Could not add a translation in language ${language}. The target object has a string at the given path, whereas the translation contains an object.\n String at target: ${targetV}\n Object at translation source: ${JSON.stringify(sourceV)}`
} }
targetV[language] = sourceV; targetV[language] = sourceV;