Remove 'shop=vacant' from presets

This commit is contained in:
Pieter Vander Vennet 2024-07-29 03:47:20 +02:00
parent 5098685c03
commit e26ffb567b

View file

@ -7,6 +7,7 @@ import known_languages from "../../src/assets/language_native.json"
import { LayerConfigJson } from "../../src/Models/ThemeConfig/Json/LayerConfigJson" import { LayerConfigJson } from "../../src/Models/ThemeConfig/Json/LayerConfigJson"
import { MappingConfigJson } from "../../src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson" import { MappingConfigJson } from "../../src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import SmallLicense from "../../src/Models/smallLicense" import SmallLicense from "../../src/Models/smallLicense"
import Script from "../Script"
interface IconThief { interface IconThief {
steal(iconName: string): boolean steal(iconName: string): boolean
@ -25,7 +26,7 @@ interface IdPresetJson {
} }
class IdPreset implements IdPresetJson { class IdPreset implements IdPresetJson {
private _preset: IdPresetJson private readonly _preset: IdPresetJson
constructor(preset: IdPresetJson) { constructor(preset: IdPresetJson) {
this._preset = preset this._preset = preset
@ -212,6 +213,11 @@ class IdThief {
continue continue
} }
if(preset.tags["shop"] === "vacant") {
console.log("Skipping 'vacant'")
continue
}
console.log(` ${name} (shop=${preset.tags["shop"]}), ${preset.icon}`) console.log(` ${name} (shop=${preset.tags["shop"]}), ${preset.icon}`)
const thenClause: Record<string, string> = { const thenClause: Record<string, string> = {
@ -239,7 +245,7 @@ class IdThief {
} }
} }
let tag = preset.parseTags() const tag = preset.parseTags()
const mapping: MappingConfigJson = { const mapping: MappingConfigJson = {
if: tag, if: tag,
then: thenClause, then: thenClause,
@ -276,7 +282,16 @@ class IdThief {
} }
} }
const targetDir = "./assets/layers/id_presets/"
class ReadIdPresets extends Script{
constructor() {
super("Reads the id-tagging-schema repository and steals the presets; which will be written into 'id_presets.json'\n\nArguments: [path-to-repository] [path-to-target]\n" +
"Note that default arguments are used")
}
async main(args: string[]): Promise<void> {
const targetDir = args[1] ?? "./assets/layers/id_presets/"
const makiThief = new MakiThief( const makiThief = new MakiThief(
"../maki/icons/", "../maki/icons/",
@ -314,7 +329,7 @@ const fasThief = new MakiThief(
) )
const iconThief = new AggregateIconThief([makiThief, temakiThief, fasThief]) const iconThief = new AggregateIconThief([makiThief, temakiThief, fasThief])
const thief = new IdThief("../id-tagging-schema/", iconThief) const thief = new IdThief(args[0] ?? "../id-tagging-schema/", iconThief)
const id_presets_path = targetDir + "id_presets.json" const id_presets_path = targetDir + "id_presets.json"
const idPresets = <LayerConfigJson>JSON.parse(readFileSync(id_presets_path, "utf8")) const idPresets = <LayerConfigJson>JSON.parse(readFileSync(id_presets_path, "utf8"))
@ -330,3 +345,9 @@ idPresets.tagRenderings = [
] ]
console.log("Writing id presets to", id_presets_path) console.log("Writing id presets to", id_presets_path)
writeFileSync(id_presets_path, JSON.stringify(idPresets, null, " "), "utf8") writeFileSync(id_presets_path, JSON.stringify(idPresets, null, " "), "utf8")
}
}
new ReadIdPresets().run()