Rename some themes for more consistency, check of theme-ids, see #431

This commit is contained in:
Pieter Vander Vennet 2021-07-26 10:13:50 +02:00
parent bca995b985
commit 177649614d
38 changed files with 49 additions and 82 deletions

View file

@ -78,9 +78,8 @@ class LayerOverviewUtils {
main(args: string[]) {
const lt = this.loadThemesAndLayers();
const layerFiles = lt.layers;
const themeFiles = lt.themes;
const layerFiles = ScriptUtils.getLayerFiles();
const themeFiles = ScriptUtils.getThemeFiles();
console.log(" ---------- VALIDATING ---------")
const licensePaths = []
@ -98,7 +97,9 @@ class LayerOverviewUtils {
}
let themeErrorCount = []
for (const themeFile of themeFiles) {
for (const themeInfo of themeFiles) {
const themeFile = themeInfo.parsed
const themePath = themeInfo.path
if (typeof themeFile.language === "string") {
themeErrorCount.push("The theme " + themeFile.id + " has a string as language. Please use a list of strings")
}
@ -108,12 +109,13 @@ class LayerOverviewUtils {
themeErrorCount.push(`Unknown layer id: ${layer} in theme ${themeFile.id}`)
}
} else {
if (layer.builtin !== undefined) {
if (!knownLayerIds.has(layer.builtin)) {
themeErrorCount.push("Unknown layer id: " + layer.builtin + "(which uses inheritance)")
if (layer["builtin"] !== undefined) {
if (!knownLayerIds.has(layer["builtin"])) {
themeErrorCount.push("Unknown layer id: " + layer["builtin"] + "(which uses inheritance)")
}
} else {
// layer.builtin contains layer overrides - we can skip those
// @ts-ignore
layerErrorCount.push(...this.validateLayer(layer, undefined, knownPaths, themeFile.id))
}
}
@ -121,7 +123,7 @@ class LayerOverviewUtils {
themeFile.layers = themeFile.layers
.filter(l => typeof l != "string") // We remove all the builtin layer references as they don't work with ts-node for some weird reason
.filter(l => l.builtin === undefined)
.filter(l => l["builtin"] === undefined)
try {
@ -129,6 +131,12 @@ class LayerOverviewUtils {
if (theme.id !== theme.id.toLowerCase()) {
themeErrorCount.push("Theme ids should be in lowercase, but it is " + theme.id)
}
let filename = themePath.substring(themePath.lastIndexOf("/") + 1, themePath.length - 5)
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+")")
}
} catch (e) {
themeErrorCount.push("Could not parse theme " + themeFile["id"] + "due to", e)
}