From 5c0e3662c1f416f4e265764631a89fe96f98d78b Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 23 Apr 2021 16:52:20 +0200 Subject: [PATCH] Move translation checks to the validation step --- scripts/generateLayerOverview.ts | 12 +++++++++--- scripts/generateLicenseInfo.ts | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/generateLayerOverview.ts b/scripts/generateLayerOverview.ts index f959d4e..87cda73 100644 --- a/scripts/generateLayerOverview.ts +++ b/scripts/generateLayerOverview.ts @@ -67,6 +67,11 @@ function validateLayer(layerJson: LayerConfigJson, path: string, knownPaths: Set } for (const image of images) { + if(image.indexOf("{") >= 0){ + console.warn("Ignoring image with { in the path: ", image) + continue + } + if (!knownPaths.has(image)) { const ctx = context === undefined ? "" : ` in a layer defined in the theme ${context}` errorCount.push(`Image with path ${image} not found or not attributed; it is used in ${layer.id}${ctx}`) @@ -133,9 +138,6 @@ function validateTranslationCompletenessOfObject(object: any, expectedLanguages: isComplete = false; } } - if (!isComplete) { - console.log(message) - } return missingTranlations } @@ -205,11 +207,15 @@ function main(args: string[]) { } if(missingTranslations.length > 0){ + console.log(missingTranslations.length, "missing translations") writeFileSync("missing_translations.txt", missingTranslations.join("\n")) } if (layerErrorCount.length + themeErrorCount.length == 0) { console.log("All good!") + + // We load again from disc, as modifications were made above + const lt = loadThemesAndLayers(); writeFiles(lt); } else { const errors = layerErrorCount.concat(themeErrorCount).join("\n") diff --git a/scripts/generateLicenseInfo.ts b/scripts/generateLicenseInfo.ts index f7c0723..4e6db80 100644 --- a/scripts/generateLicenseInfo.ts +++ b/scripts/generateLicenseInfo.ts @@ -189,12 +189,25 @@ const contents = ScriptUtils.readDirRecSync("./assets") .filter(entry => entry.indexOf("./assets/generated") != 0) const licensePaths = contents.filter(entry => entry.indexOf("license_info.json") >= 0) const licenseInfos = generateLicenseInfos(licensePaths); + + writeFileSync("./assets/generated/license_info.json", JSON.stringify(licenseInfos, null, " ")) const artwork = contents.filter(pth => pth.match(/(.svg|.png|.jpg)$/i) != null) const missingLicenses = missingLicenseInfos(licenseInfos, artwork) const invalidLicenses = licenseInfos.filter(l => (l.license ?? "") === "").map(l => `License for artwork ${l.path} is empty string or undefined`) - +for (const licenseInfo of licenseInfos) { + for (const source of licenseInfo.sources) { + if(source == ""){ + invalidLicenses.push("Invalid license: empty string in "+JSON.stringify(licenseInfo)) + } + try{ + new URL(source); + }catch{ + invalidLicenses.push("Not a valid URL: "+source) + } + } +} if (process.argv.indexOf("--prompt") >= 0 || process.argv.indexOf("--query") >= 0) { queryMissingLicenses(missingLicenses) }