Fix big license-info file, fix missing images, fix #553

This commit is contained in:
pietervdvn 2021-11-07 15:16:28 +01:00
parent 2a6a2d4f24
commit e3d6feeae9
3 changed files with 29 additions and 14 deletions

View file

@ -193,9 +193,9 @@
{
"if": "cycle_barrier:type=double",
"then": {
"en": "Double, two barriers behind each other <img src='./assets/themes/cycle_infra/Cycle_barrier_double.png' style='width:8em'>",
"nl": "Dubbel, twee hekjes achter elkaar <img src='./assets/themes/cycle_infra/Cycle_barrier_double.png' style='width:8em'>",
"de": "Doppelt, zwei Barrieren hintereinander <img src='./assets/themes/cycle_infra/Cycle_barrier_double.png' style='width:8em'>"
"en": "Double, two barriers behind each other <img src='./assets/themes/cycle_infra/Cycle_barrier_double.svg' style='width:8em'>",
"nl": "Dubbel, twee hekjes achter elkaar <img src='./assets/themes/cycle_infra/Cycle_barrier_double.svg' style='width:8em'>",
"de": "Doppelt, zwei Barrieren hintereinander <img src='./assets/themes/cycle_infra/Cycle_barrier_double.svg' style='width:8em'>"
}
},
{

View file

@ -138,7 +138,6 @@
},
{
"id": "walking_routes",
"icon": "./assets/themes/speelplekken/walking_route.svg",
"name": {
"nl": "Wandelroutes van provincie Antwerpen"
},

View file

@ -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 = <SmallLicense[]>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)