Fix GH Actions
This commit is contained in:
parent
99a618a52c
commit
081a281c04
2 changed files with 26 additions and 27 deletions
|
@ -17,8 +17,8 @@
|
||||||
"generate:docs": "ts-node scripts/generateDocs.ts",
|
"generate:docs": "ts-node scripts/generateDocs.ts",
|
||||||
"generate:layeroverview": "ts-node scripts/generateLayerOverview.ts --no-fail",
|
"generate:layeroverview": "ts-node scripts/generateLayerOverview.ts --no-fail",
|
||||||
"generate:licenses": "ts-node scripts/generateLicenseInfo.ts --no-fail",
|
"generate:licenses": "ts-node scripts/generateLicenseInfo.ts --no-fail",
|
||||||
"validate:layeroverview": "ts-node scripts/generateLayerOverview.ts",
|
"validate:layeroverview": "ts-node scripts/generateLayerOverview.ts --report",
|
||||||
"validate:licenses": "ts-node scripts/generateLicenseInfo.ts",
|
"validate:licenses": "ts-node scripts/generateLicenseInfo.ts --report",
|
||||||
"optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'",
|
"optimize-images": "cd assets/generated/ && find -name '*.png' -exec optipng '{}' \\; && echo 'PNGs are optimized'",
|
||||||
"generate": "npm run generate:images && npm run generate:translations && npm run generate:licenses",
|
"generate": "npm run generate:images && npm run generate:translations && npm run generate:licenses",
|
||||||
"build": "rm -rf dist/ && npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*",
|
"build": "rm -rf dist/ && npm run generate && parcel build --public-url ./ *.html assets/** assets/**/** assets/**/**/** vendor/* vendor/*/*",
|
||||||
|
|
|
@ -9,6 +9,7 @@ import * as licenses from "../assets/generated/license_info.json"
|
||||||
import SmallLicense from "../Models/smallLicense";
|
import SmallLicense from "../Models/smallLicense";
|
||||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||||
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
import {LayerConfigJson} from "../Customizations/JSON/LayerConfigJson";
|
||||||
|
import {Layer} from "leaflet";
|
||||||
// This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files.
|
// This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files.
|
||||||
// It spits out an overview of those to be used to load them
|
// It spits out an overview of those to be used to load them
|
||||||
|
|
||||||
|
@ -50,59 +51,54 @@ for (const i in licenses) {
|
||||||
}
|
}
|
||||||
const knownPaths = new Set<string>(licensePaths)
|
const knownPaths = new Set<string>(licensePaths)
|
||||||
|
|
||||||
function validateLayer(layerJson: LayerConfigJson, context?: string): number {
|
function validateLayer(layerJson: LayerConfigJson, context?: string): string[] {
|
||||||
let errorCount = 0;
|
let errorCount = [];
|
||||||
if (layerJson["overpassTags"] !== undefined) {
|
if (layerJson["overpassTags"] !== undefined) {
|
||||||
errorCount++
|
errorCount.push("CRIT! Layer ", layerJson.id, "still uses the old 'overpassTags'-format. Please use 'source: {osmTags: <tags>}' instead")
|
||||||
console.error("CRIT! Layer ", layerJson.id, "still uses the old 'overpassTags'-format. Please use 'source: {osmTags: <tags>}' instead")
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const layer = new LayerConfig(layerJson, "test", true)
|
const layer = new LayerConfig(layerJson, "test", true)
|
||||||
const images = Array.from(layer.ExtractImages())
|
const images = Array.from(layer.ExtractImages())
|
||||||
const remoteImages = images.filter(img => img.indexOf("http") == 0)
|
const remoteImages = images.filter(img => img.indexOf("http") == 0)
|
||||||
for (const remoteImage of remoteImages) {
|
for (const remoteImage of remoteImages) {
|
||||||
console.error("Found a remote image:", remoteImage, "in layer", layer.id)
|
errorCount.push("Found a remote image: "+ remoteImage+ " in layer "+ layer.id)
|
||||||
errorCount++
|
|
||||||
}
|
}
|
||||||
for (const image of images) {
|
for (const image of images) {
|
||||||
if (!knownPaths.has(image)) {
|
if (!knownPaths.has(image)) {
|
||||||
console.error("Image with path", image, "not found or not attributed; it is used in", layer.id, context === undefined ? "" : ` in a layer defined in the theme ${context}`)
|
const ctx = context === undefined ? "" : ` in a layer defined in the theme ${context}`
|
||||||
errorCount++
|
errorCount.push(`Image with path ${image} not found or not attributed; it is used in ${layer.id}${ctx}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Layer ", layerJson.id ?? JSON.stringify(layerJson).substring(0, 50), " is invalid: ", e)
|
return [`Layer ${layerJson.id}` ?? JSON.stringify(layerJson).substring(0, 50)+" is invalid: "+ e]
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
return errorCount
|
return errorCount
|
||||||
}
|
}
|
||||||
|
|
||||||
let layerErrorCount = 0
|
let layerErrorCount = []
|
||||||
const knownLayerIds = new Set<string>();
|
const knownLayerIds = new Set<string>();
|
||||||
for (const layerFile of layerFiles) {
|
for (const layerFile of layerFiles) {
|
||||||
knownLayerIds.add(layerFile.id)
|
knownLayerIds.add(layerFile.id)
|
||||||
layerErrorCount += validateLayer(layerFile)
|
layerErrorCount .push(...validateLayer(layerFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
let themeErrorCount = 0
|
let themeErrorCount = []
|
||||||
for (const themeFile of themeFiles) {
|
for (const themeFile of themeFiles) {
|
||||||
|
|
||||||
for (const layer of themeFile.layers) {
|
for (const layer of themeFile.layers) {
|
||||||
if (typeof layer === "string") {
|
if (typeof layer === "string") {
|
||||||
if (!knownLayerIds.has(layer)) {
|
if (!knownLayerIds.has(layer)) {
|
||||||
console.error("Unknown layer id: ", layer)
|
themeErrorCount.push("Unknown layer id: "+ layer)
|
||||||
themeErrorCount++
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (layer.builtin !== undefined) {
|
if (layer.builtin !== undefined) {
|
||||||
if (!knownLayerIds.has(layer.builtin)) {
|
if (!knownLayerIds.has(layer.builtin)) {
|
||||||
console.error("Unknown layer id: ", layer.builtin, "(which uses inheritance)")
|
themeErrorCount.push("Unknown layer id: "+ layer.builtin+ "(which uses inheritance)")
|
||||||
themeErrorCount++
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// layer.builtin contains layer overrides - we can skip those
|
// layer.builtin contains layer overrides - we can skip those
|
||||||
layerErrorCount += validateLayer(layer, themeFile.id)
|
layerErrorCount .push(validateLayer(layer, themeFile.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,21 +110,24 @@ for (const themeFile of themeFiles) {
|
||||||
try {
|
try {
|
||||||
const theme = new LayoutConfig(themeFile, true, "test")
|
const theme = new LayoutConfig(themeFile, true, "test")
|
||||||
if (theme.id !== theme.id.toLowerCase()) {
|
if (theme.id !== theme.id.toLowerCase()) {
|
||||||
console.error("Theme ids should be in lowercase, but it is ", theme.id)
|
themeErrorCount.push("Theme ids should be in lowercase, but it is "+ theme.id)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not parse theme", themeFile["id"], "due to", e)
|
themeErrorCount.push("Could not parse theme "+ themeFile["id"]+ "due to", e)
|
||||||
themeErrorCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (layerErrorCount.length + themeErrorCount.length == 0) {
|
||||||
if (layerErrorCount + themeErrorCount == 0) {
|
|
||||||
console.log("All good!")
|
console.log("All good!")
|
||||||
} else {
|
} else {
|
||||||
const msg = (`Found ${layerErrorCount} errors in the layers; ${themeErrorCount} errors in the themes`)
|
const errors = layerErrorCount.concat(themeErrorCount).join("\n")
|
||||||
|
console.log(errors)
|
||||||
|
const msg = (`Found ${errors.length} errors in the layers; ${themeErrorCount} errors in the themes`)
|
||||||
if(process.argv.indexOf("--no-fail") >= 0) {
|
if(process.argv.indexOf("--no-fail") >= 0) {
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
|
}else if(process.argv.indexOf("--report") >= 0){
|
||||||
|
writeFileSync("layer-report.txt", errors)
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
throw msg;
|
throw msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue