From e3d6feeae9415b2c62858903255a6e71d00cc800 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 7 Nov 2021 15:16:28 +0100 Subject: [PATCH] Fix big license-info file, fix missing images, fix #553 --- assets/layers/barrier/barrier.json | 6 ++-- assets/themes/speelplekken/speelplekken.json | 1 - scripts/generateLicenseInfo.ts | 36 ++++++++++++++------ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/assets/layers/barrier/barrier.json b/assets/layers/barrier/barrier.json index a73882611..42f49a481 100644 --- a/assets/layers/barrier/barrier.json +++ b/assets/layers/barrier/barrier.json @@ -193,9 +193,9 @@ { "if": "cycle_barrier:type=double", "then": { - "en": "Double, two barriers behind each other ", - "nl": "Dubbel, twee hekjes achter elkaar ", - "de": "Doppelt, zwei Barrieren hintereinander " + "en": "Double, two barriers behind each other ", + "nl": "Dubbel, twee hekjes achter elkaar ", + "de": "Doppelt, zwei Barrieren hintereinander " } }, { diff --git a/assets/themes/speelplekken/speelplekken.json b/assets/themes/speelplekken/speelplekken.json index d25d24cf9..c8cca3162 100644 --- a/assets/themes/speelplekken/speelplekken.json +++ b/assets/themes/speelplekken/speelplekken.json @@ -138,7 +138,6 @@ }, { "id": "walking_routes", - "icon": "./assets/themes/speelplekken/walking_route.svg", "name": { "nl": "Wandelroutes van provincie Antwerpen" }, diff --git a/scripts/generateLicenseInfo.ts b/scripts/generateLicenseInfo.ts index a6c2eee9c..e6c47b922 100644 --- a/scripts/generateLicenseInfo.ts +++ b/scripts/generateLicenseInfo.ts @@ -76,7 +76,7 @@ knownLicenses.set("streetcomplete", { authors: ["Tobias Zwick (westnordost)"], path: undefined, license: "CC0", - sources: ["https://github.com/streetcomplete/StreetComplete/tree/master/res/graphics","https://f-droid.org/packages/de.westnordost.streetcomplete/"] + sources: ["https://github.com/streetcomplete/StreetComplete/tree/master/res/graphics", "https://f-droid.org/packages/de.westnordost.streetcomplete/"] }) @@ -164,15 +164,15 @@ function cleanLicenseInfo(allPaths: string[], allLicenseInfos: SmallLicense[]) { perDirectory.forEach((licenses, dir) => { - for (let i = licenses.length - 1; i >= 0; i--){ + for (let i = licenses.length - 1; i >= 0; i--) { const license = licenses[i]; - const path = dir+"/"+license.path - if(! existsSync(path)){ + const path = dir + "/" + license.path + if (!existsSync(path)) { console.log("Found license for now missing file: ", path, " - removing this license") licenses.splice(i, 1) } } - + licenses.sort((a, b) => a.path < b.path ? -1 : 1) writeFileSync(dir + "/license_info.json", JSON.stringify(licenses, null, 2)) }) @@ -198,6 +198,26 @@ function queryMissingLicenses(missingLicenses: string[]) { console.log("You're through!") } + +/** + * Creates the humongous license_info in the generated assets, containing all licenses with a path relative to the root + * @param licensePaths + */ +function createFullLicenseOverview(licensePaths) { + + const allLicenses: SmallLicense[] = [] + for (const licensePath of licensePaths) { + const licenses = JSON.parse(readFileSync(licensePath, "UTF-8")) + for (const license of licenses) { + const dir = licensePath.substring(0, licensePath.length - "license_info.json".length) + license.path = dir + license.path + allLicenses.push(license) + } + } + + writeFileSync("./assets/generated/license_info.json", JSON.stringify(allLicenses, null, " ")) +} + console.log("Checking and compiling license info") const contents = ScriptUtils.readDirRecSync("./assets") .filter(entry => entry.indexOf("./assets/generated") != 0) @@ -208,7 +228,6 @@ if (!existsSync("./assets/generated")) { mkdirSync("./assets/generated") } -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) @@ -232,13 +251,10 @@ if (missingLicenses.length > 0) { const msg = `There are ${missingLicenses.length} licenses missing and ${invalidLicenses.length} invalid licenses.` console.log(missingLicenses.concat(invalidLicenses).join("\n")) console.error(msg) - if (process.argv.indexOf("--report") >= 0) { - console.log("Writing report!") - writeFileSync("missing_licenses.txt", missingLicenses.concat(invalidLicenses).join("\n")) - } if (process.argv.indexOf("--no-fail") < 0) { throw msg } } cleanLicenseInfo(licensePaths, licenseInfos) +createFullLicenseOverview(licensePaths) \ No newline at end of file