chore: automated housekeeping...
This commit is contained in:
parent
a8fd550b72
commit
6a0b77eb99
180 changed files with 16812 additions and 2509 deletions
|
@ -43,10 +43,10 @@ class DownloadNsiLogos extends Script {
|
|||
await ScriptUtils.DownloadFileTo(logos.facebook, path)
|
||||
// Validate
|
||||
const content = readFileSync(path, "utf8")
|
||||
if(content.startsWith('{"error"')){
|
||||
if (content.startsWith('{"error"')) {
|
||||
unlinkSync(path)
|
||||
console.error("Attempted to fetch",logos.facebook," but this gave an error")
|
||||
}else{
|
||||
console.error("Attempted to fetch", logos.facebook, " but this gave an error")
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,9 @@ export class GenerateFavouritesLayer extends Script {
|
|||
continue
|
||||
}
|
||||
if (optimized === false) {
|
||||
throw `Optimized ${TagUtils.Tag({or: conditions}).asHumanString()} into 'false', this is weird...`
|
||||
throw `Optimized ${TagUtils.Tag({
|
||||
or: conditions,
|
||||
}).asHumanString()} into 'false', this is weird...`
|
||||
}
|
||||
tr.condition = optimized
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
authors: ["Pieter Vander Vennet"],
|
||||
path: undefined,
|
||||
license: "CC0",
|
||||
sources: []
|
||||
sources: [],
|
||||
})
|
||||
knownLicenses.set("streetcomplete", {
|
||||
authors: ["Tobias Zwick (westnordost)"],
|
||||
|
@ -33,8 +33,8 @@ export class GenerateLicenseInfo extends Script {
|
|||
license: "CC0",
|
||||
sources: [
|
||||
"https://github.com/streetcomplete/StreetComplete/tree/master/res/graphics",
|
||||
"https://f-droid.org/packages/de.westnordost.streetcomplete/"
|
||||
]
|
||||
"https://f-droid.org/packages/de.westnordost.streetcomplete/",
|
||||
],
|
||||
})
|
||||
|
||||
knownLicenses.set("temaki", {
|
||||
|
@ -43,34 +43,34 @@ export class GenerateLicenseInfo extends Script {
|
|||
license: "CC0",
|
||||
sources: [
|
||||
"https://github.com/ideditor/temaki",
|
||||
"https://ideditor.github.io/temaki/docs/"
|
||||
]
|
||||
"https://ideditor.github.io/temaki/docs/",
|
||||
],
|
||||
})
|
||||
|
||||
knownLicenses.set("maki", {
|
||||
authors: ["Maki"],
|
||||
path: undefined,
|
||||
license: "CC0",
|
||||
sources: ["https://labs.mapbox.com/maki-icons/"]
|
||||
sources: ["https://labs.mapbox.com/maki-icons/"],
|
||||
})
|
||||
|
||||
knownLicenses.set("t", {
|
||||
authors: [],
|
||||
path: undefined,
|
||||
license: "CC0; trivial",
|
||||
sources: []
|
||||
sources: [],
|
||||
})
|
||||
knownLicenses.set("na", {
|
||||
authors: [],
|
||||
path: undefined,
|
||||
license: "CC0",
|
||||
sources: []
|
||||
sources: [],
|
||||
})
|
||||
knownLicenses.set("carto", {
|
||||
authors: ["OSM-Carto"],
|
||||
path: undefined,
|
||||
license: "CC0",
|
||||
sources: [""]
|
||||
sources: [""],
|
||||
})
|
||||
knownLicenses.set("tv", {
|
||||
authors: ["Toerisme Vlaanderen"],
|
||||
|
@ -78,20 +78,20 @@ export class GenerateLicenseInfo extends Script {
|
|||
license: "CC0",
|
||||
sources: [
|
||||
"https://toerismevlaanderen.be/pinjepunt",
|
||||
"https://mapcomplete.org/toerisme_vlaanderenn"
|
||||
]
|
||||
"https://mapcomplete.org/toerisme_vlaanderenn",
|
||||
],
|
||||
})
|
||||
knownLicenses.set("tvf", {
|
||||
authors: ["Jo De Baerdemaeker "],
|
||||
path: undefined,
|
||||
license: "All rights reserved",
|
||||
sources: ["https://www.studiotype.be/fonts/flandersart"]
|
||||
sources: ["https://www.studiotype.be/fonts/flandersart"],
|
||||
})
|
||||
knownLicenses.set("twemoji", {
|
||||
authors: ["Twemoji"],
|
||||
path: undefined,
|
||||
license: "CC-BY 4.0",
|
||||
sources: ["https://github.com/twitter/twemoji"]
|
||||
sources: ["https://github.com/twitter/twemoji"],
|
||||
})
|
||||
return knownLicenses
|
||||
}
|
||||
|
@ -147,36 +147,39 @@ export class GenerateLicenseInfo extends Script {
|
|||
const svg = await ScriptUtils.ReadSvg(icon)
|
||||
|
||||
const colours = new Set<string>()
|
||||
Utils.WalkObject(svg, leaf => {
|
||||
const style = leaf["style"].split(";")
|
||||
for (const styleElement of style) {
|
||||
const [key, value] = styleElement.split(":").map(x => x.trim())
|
||||
if (value === "none") {
|
||||
continue
|
||||
Utils.WalkObject(
|
||||
svg,
|
||||
(leaf) => {
|
||||
const style = leaf["style"].split(";")
|
||||
for (const styleElement of style) {
|
||||
const [key, value] = styleElement.split(":").map((x) => x.trim())
|
||||
if (value === "none") {
|
||||
continue
|
||||
}
|
||||
if (key === "fill" || key === "stroke") {
|
||||
colours.add(value)
|
||||
}
|
||||
return colours
|
||||
}
|
||||
if (key === "fill" || key === "stroke") {
|
||||
colours.add(value)
|
||||
}
|
||||
return colours
|
||||
}
|
||||
}, leaf => typeof leaf["style"] === "string" )
|
||||
if(colours.size === 0){
|
||||
},
|
||||
(leaf) => typeof leaf["style"] === "string"
|
||||
)
|
||||
if (colours.size === 0) {
|
||||
continue
|
||||
}
|
||||
const whiteColours = Array.from(colours).map(c => {
|
||||
const whiteColours = Array.from(colours).map((c) => {
|
||||
const rgb = Utils.color(c)
|
||||
if(!rgb){
|
||||
if (!rgb) {
|
||||
console.log("Could not parse ", c)
|
||||
return false
|
||||
}
|
||||
const {r,g,b} = rgb
|
||||
return (r > 245 && g > 245 && b > 245)
|
||||
const { r, g, b } = rgb
|
||||
return r > 245 && g > 245 && b > 245
|
||||
})
|
||||
const hasDark = whiteColours.some(isWhite => !isWhite)
|
||||
if(!hasDark){
|
||||
const hasDark = whiteColours.some((isWhite) => !isWhite)
|
||||
if (!hasDark) {
|
||||
whitePaths.add(icon)
|
||||
}
|
||||
|
||||
}
|
||||
return whitePaths
|
||||
}
|
||||
|
@ -228,7 +231,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
authors: author.split(";"),
|
||||
path: path,
|
||||
license: prompt("What is the license for artwork " + path + "? > "),
|
||||
sources: prompt("Where was this artwork found? > ").split(";")
|
||||
sources: prompt("Where was this artwork found? > ").split(";"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,7 +264,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
"ISC-LICENSE": "ISC",
|
||||
"LOGO-BY-THE-GOVERNMENT": "LOGO",
|
||||
PD: "PUBLIC-DOMAIN",
|
||||
"LOGO-(ALL-RIGHTS-RESERVED)": "LOGO"
|
||||
"LOGO-(ALL-RIGHTS-RESERVED)": "LOGO",
|
||||
/* ALL-RIGHTS-RESERVED:
|
||||
PD:
|
||||
PUBLIC-DOMAIN:
|
||||
|
@ -292,7 +295,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
path: license.path,
|
||||
license: license.license,
|
||||
authors: license.authors,
|
||||
sources: license.sources
|
||||
sources: license.sources,
|
||||
}
|
||||
|
||||
cloned.license = Utils.Dedup(
|
||||
|
@ -335,7 +338,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
}
|
||||
|
||||
queryMissingLicenses(missingLicenses: string[]) {
|
||||
process.on("SIGINT", function() {
|
||||
process.on("SIGINT", function () {
|
||||
console.log("Aborting... Bye!")
|
||||
process.exit()
|
||||
})
|
||||
|
@ -373,7 +376,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
licensePath.length - "license_info.json".length
|
||||
)
|
||||
license.path = dir + license.path
|
||||
if(mostlyWhite.some(l => license.path === l)){
|
||||
if (mostlyWhite.some((l) => license.path === l)) {
|
||||
license["mostly_white"] = true
|
||||
}
|
||||
allLicenses.push(license)
|
||||
|
@ -421,7 +424,7 @@ export class GenerateLicenseInfo extends Script {
|
|||
if (licenseInfo.sources.length + licenseInfo.authors.length == 0 && !isTrivial) {
|
||||
invalidLicenses.push(
|
||||
"Invalid license: No sources nor authors given in the license for " +
|
||||
JSON.stringify(licenseInfo)
|
||||
JSON.stringify(licenseInfo)
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
@ -444,10 +447,10 @@ export class GenerateLicenseInfo extends Script {
|
|||
const spdxContent = [
|
||||
"SPDX-FileCopyrightText: " + licenseInfo.authors.join("; "),
|
||||
"SPDX-License-Identifier: " +
|
||||
licenseInfo.license
|
||||
.split(" AND ")
|
||||
.map((s) => this.addLicenseRef(s))
|
||||
.join(" AND ")
|
||||
licenseInfo.license
|
||||
.split(" AND ")
|
||||
.map((s) => this.addLicenseRef(s))
|
||||
.join(" AND "),
|
||||
]
|
||||
writeFileSync(spdxPath, spdxContent.join("\n"))
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@ class HandleErrors extends Script {
|
|||
super("Inspects the errors made on a given day. Argument: path to errors")
|
||||
}
|
||||
|
||||
parseLine() {
|
||||
|
||||
}
|
||||
parseLine() {}
|
||||
|
||||
async main(args: string[]): Promise<void> {
|
||||
const osmConnection = new OsmConnection()
|
||||
|
@ -44,10 +42,14 @@ class HandleErrors extends Script {
|
|||
const refusedFiles: Set<string> = new Set<string>()
|
||||
refusedFiles.add("[]")
|
||||
|
||||
const changesObj = new Changes({
|
||||
dryRun: new ImmutableStore(true),
|
||||
osmConnection,
|
||||
}, false, err => console.error(err))
|
||||
const changesObj = new Changes(
|
||||
{
|
||||
dryRun: new ImmutableStore(true),
|
||||
osmConnection,
|
||||
},
|
||||
false,
|
||||
(err) => console.error(err)
|
||||
)
|
||||
|
||||
const all: ErrorMessage[] = []
|
||||
for (const line of lines) {
|
||||
|
@ -66,11 +68,10 @@ class HandleErrors extends Script {
|
|||
console.log(
|
||||
"\t https://osm.org/" + pendingChange.type + "/" + pendingChange.id,
|
||||
pendingChange.meta.changeType,
|
||||
pendingChange.doDelete ? "DELETE" : "",
|
||||
pendingChange.doDelete ? "DELETE" : ""
|
||||
)
|
||||
}
|
||||
all.push(parsed)
|
||||
|
||||
} catch (e) {
|
||||
console.log("Parsing line failed:", e)
|
||||
}
|
||||
|
@ -80,16 +81,15 @@ class HandleErrors extends Script {
|
|||
const e = parsed.message
|
||||
const neededIds = Changes.GetNeededIds(e.pendingChanges)
|
||||
// We _do not_ pass in the Changes object itself - we want the data from OSM directly in order to apply the changes
|
||||
const osmObjects: { id: string; osmObj: OsmObject | "deleted" }[] =
|
||||
await Promise.all<{
|
||||
id: string
|
||||
osmObj: OsmObject | "deleted"
|
||||
}>(
|
||||
neededIds.map(async (id) => ({
|
||||
id,
|
||||
osmObj: await downloader.DownloadObjectAsync(id),
|
||||
})),
|
||||
)
|
||||
const osmObjects: { id: string; osmObj: OsmObject | "deleted" }[] = await Promise.all<{
|
||||
id: string
|
||||
osmObj: OsmObject | "deleted"
|
||||
}>(
|
||||
neededIds.map(async (id) => ({
|
||||
id,
|
||||
osmObj: await downloader.DownloadObjectAsync(id),
|
||||
}))
|
||||
)
|
||||
|
||||
const objects = osmObjects
|
||||
.filter((obj) => obj.osmObj !== "deleted")
|
||||
|
@ -110,19 +110,16 @@ class HandleErrors extends Script {
|
|||
const path =
|
||||
"error_changeset_" + parsed.index + "_" + e.layout + "_" + e.username + ".osc"
|
||||
if (
|
||||
changeset ===
|
||||
"<osmChange version='0.6' generator='Mapcomplete 0.44.7'></osmChange>"
|
||||
changeset === "<osmChange version='0.6' generator='Mapcomplete 0.44.7'></osmChange>"
|
||||
) {
|
||||
console.log(
|
||||
"Changes for " +
|
||||
parsed.index +
|
||||
": empty changeset, not creating a file for it",
|
||||
"Changes for " + parsed.index + ": empty changeset, not creating a file for it"
|
||||
)
|
||||
} else if (createdChangesets.has(changeset)) {
|
||||
console.log(
|
||||
"Changeset " +
|
||||
parsed.index +
|
||||
" is identical to previously seen changeset, not writing to file",
|
||||
parsed.index +
|
||||
" is identical to previously seen changeset, not writing to file"
|
||||
)
|
||||
} else {
|
||||
writeFileSync(path, changeset, "utf8")
|
||||
|
@ -132,21 +129,16 @@ class HandleErrors extends Script {
|
|||
if (refusedFiles.has(refusedContent)) {
|
||||
console.log(
|
||||
"Refused changes for " +
|
||||
parsed.index +
|
||||
" is identical to previously seen changeset, not writing to file",
|
||||
parsed.index +
|
||||
" is identical to previously seen changeset, not writing to file"
|
||||
)
|
||||
} else {
|
||||
writeFileSync(path + ".refused.json", refusedContent, "utf8")
|
||||
refusedFiles.add(refusedContent)
|
||||
}
|
||||
console.log("Written", path, "with " + e.pendingChanges.length + " changes")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new
|
||||
|
||||
HandleErrors()
|
||||
|
||||
.run()
|
||||
new HandleErrors().run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue