forked from MapComplete/MapComplete
Fix: regenerate NSI-logos, should fix regression reported in #2300
This commit is contained in:
parent
a858a85879
commit
4744471495
7 changed files with 50745 additions and 50156 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,5 @@
|
|||
import Script from "./Script"
|
||||
import NameSuggestionIndex, {
|
||||
NamgeSuggestionWikidata,
|
||||
NSIItem,
|
||||
} from "../src/Logic/Web/NameSuggestionIndex"
|
||||
import NameSuggestionIndex, { NamgeSuggestionWikidata, NSIItem } from "../src/Logic/Web/NameSuggestionIndex"
|
||||
import * as nsiWD from "../node_modules/name-suggestion-index/dist/wikidata.min.json"
|
||||
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs"
|
||||
import ScriptUtils from "./ScriptUtils"
|
||||
|
@ -218,7 +215,7 @@ class NsiLogos extends Script {
|
|||
const config: LayerConfigJson = {
|
||||
id: "nsi_" + type,
|
||||
description: {
|
||||
en: "Exposes part of the NSI to reuse in other themes, e.g. for rendering. Automatically generated and never directly loaded in a theme",
|
||||
en: "Exposes part of the NSI to reuse in other themes, e.g. for rendering. Automatically generated and never directly loaded in a theme. Generated with scripts/nsiLogos.ts"
|
||||
},
|
||||
source: "special:library",
|
||||
pointRendering: null,
|
||||
|
@ -234,6 +231,7 @@ class NsiLogos extends Script {
|
|||
allowMove: false,
|
||||
"#dont-translate": "*",
|
||||
}
|
||||
config["generation_time"] = new Date().toISOString()
|
||||
const path = "./assets/layers/nsi_" + type
|
||||
mkdirSync(path, { recursive: true })
|
||||
writeFileSync(path + "/nsi_" + type + ".json", JSON.stringify(config, null, " "))
|
||||
|
@ -395,7 +393,7 @@ class NsiLogos extends Script {
|
|||
download: { f: () => this.download(), doc: "Download all icons" },
|
||||
generateRenderings: {
|
||||
f: () => this.generateRenderings(),
|
||||
doc: "Generates the layer files 'nsi_brand' and 'nsi_operator' which allows to reuse the icons in renderings",
|
||||
doc: "Generates the layer files 'nsi_brand.json' and 'nsi_operator.json' which allows to reuse the icons in renderings"
|
||||
},
|
||||
prune: { f: () => NsiLogos.prune(), doc: "Remove no longer needed files" },
|
||||
addExtensions: {
|
||||
|
|
|
@ -52,7 +52,7 @@ export abstract class Conversion<TIn, TOut> {
|
|||
throw new Error(
|
||||
[
|
||||
"Detected one or more errors, stopping now:",
|
||||
context.getAll("error").map((e) => e.context.path.join(".") + ": " + e.message),
|
||||
context.getAll("error").map((e) => `${e.context.path.join(".")} (in operation: ${e.context.operation.join(".")}): ${e.message}`)
|
||||
].join("\n\t")
|
||||
)
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export class Bypass<T> extends DesugaringStep<T> {
|
|||
private readonly _step: DesugaringStep<T>
|
||||
|
||||
constructor(applyIf: (t: T) => boolean, step: DesugaringStep<T>) {
|
||||
super("Bypass", "Applies the step on the object, if the object satisfies the predicate")
|
||||
super("Bypass(" + step.name + ")", "Applies the step on the object, if the object satisfies the predicate")
|
||||
this._applyIf = applyIf
|
||||
this._step = step
|
||||
}
|
||||
|
|
|
@ -232,7 +232,12 @@ export class ExtractImages extends Conversion<
|
|||
|
||||
// Split "circle:white;./assets/layers/.../something.svg" into ["circle", "./assets/layers/.../something.svg"]
|
||||
const allPaths = Utils.NoNull(
|
||||
Utils.NoEmpty(foundImage.path?.split(";")?.map((part) => part.split(":")[0]))
|
||||
Utils.NoEmpty(foundImage.path?.split(";")?.map((part) => {
|
||||
if (part.startsWith("http")) {
|
||||
return part
|
||||
}
|
||||
return part.split(":")[0]
|
||||
}))
|
||||
)
|
||||
for (const path of allPaths) {
|
||||
cleanedImages.push({ path, context: foundImage.context })
|
||||
|
|
|
@ -6,6 +6,7 @@ import { ConversionContext } from "./ConversionContext"
|
|||
import ThemeConfig from "../ThemeConfig"
|
||||
import { Utils } from "../../../Utils"
|
||||
import { DetectDuplicatePresets, DoesImageExist, ValidateLanguageCompleteness } from "./Validation"
|
||||
import Constants from "../../Constants"
|
||||
|
||||
export class ValidateTheme extends DesugaringStep<ThemeConfigJson> {
|
||||
/**
|
||||
|
@ -64,6 +65,7 @@ export class ValidateTheme extends DesugaringStep<ThemeConfigJson> {
|
|||
// Check images: are they local, are the licenses there, is the theme icon square, ...
|
||||
const images = this._extractImages.convert(json, context.inOperation("ValidateTheme"))
|
||||
const remoteImages = images.filter((img) => img.path.indexOf("http") == 0)
|
||||
.filter(img => !img.path.startsWith(Constants.nsiLogosEndpoint))
|
||||
for (const remoteImage of remoteImages) {
|
||||
context.err(
|
||||
"Found a remote image: " +
|
||||
|
@ -110,7 +112,7 @@ export class ValidateTheme extends DesugaringStep<ThemeConfigJson> {
|
|||
if (json["mustHaveLanguage"] !== undefined) {
|
||||
new ValidateLanguageCompleteness(...json["mustHaveLanguage"]).convert(
|
||||
theme,
|
||||
context
|
||||
context.inOperation("ValidateLanguageCompleteness")
|
||||
)
|
||||
}
|
||||
if (!json.hideFromOverview && theme.id !== "personal" && this._isBuiltin) {
|
||||
|
@ -123,7 +125,7 @@ export class ValidateTheme extends DesugaringStep<ThemeConfigJson> {
|
|||
}
|
||||
|
||||
// Official, public themes must have a full english translation
|
||||
new ValidateLanguageCompleteness("en").convert(theme, context)
|
||||
new ValidateLanguageCompleteness("en").convert(theme, context.inOperation("ValidateLanguageCompleteness"))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
@ -131,7 +133,7 @@ export class ValidateTheme extends DesugaringStep<ThemeConfigJson> {
|
|||
}
|
||||
|
||||
if (theme.id !== "personal") {
|
||||
new DetectDuplicatePresets().convert(theme, context)
|
||||
new DetectDuplicatePresets().convert(theme, context.inOperation("DectectDuplicatePrsets"))
|
||||
}
|
||||
|
||||
if (!theme.title) {
|
||||
|
|
|
@ -111,6 +111,9 @@ export class DoesImageExist extends DesugaringStep<string> {
|
|||
if (!this._knownImagePaths.has(image)) {
|
||||
if (this.doesPathExist === undefined || image.indexOf("nsi/logos/") >= 0) {
|
||||
// pass
|
||||
} else if (image.startsWith("https://")) {
|
||||
// Pass
|
||||
// This is an online image. Normally forbidden, but not the responsability of this code to check for online images
|
||||
} else if (!this.doesPathExist(image)) {
|
||||
context.err(
|
||||
`Image with path ${image} does not exist.\n Check for typo's and missing directories in the path. `
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue