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,9 +282,18 @@ class IdThief {
} }
} }
const targetDir = "./assets/layers/id_presets/"
const makiThief = new MakiThief( 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(
"../maki/icons/", "../maki/icons/",
targetDir + "maki-", targetDir + "maki-",
{ {
@ -288,9 +303,9 @@ const makiThief = new MakiThief(
sources: ["https://github.com/mapbox/maki"], sources: ["https://github.com/mapbox/maki"],
}, },
"maki-" "maki-"
) )
const temakiThief = new MakiThief( const temakiThief = new MakiThief(
"../temaki/icons/", "../temaki/icons/",
targetDir + "temaki-", targetDir + "temaki-",
{ {
@ -300,8 +315,8 @@ const temakiThief = new MakiThief(
sources: ["https://github.com/ideditor/temaki"], sources: ["https://github.com/ideditor/temaki"],
}, },
"temaki-" "temaki-"
) )
const fasThief = new MakiThief( const fasThief = new MakiThief(
"../Font-Awesome/svgs/solid/", "../Font-Awesome/svgs/solid/",
targetDir + "fas-", targetDir + "fas-",
{ {
@ -311,14 +326,14 @@ const fasThief = new MakiThief(
sources: ["https://github.com/FortAwesome/Font-Awesome"], sources: ["https://github.com/FortAwesome/Font-Awesome"],
}, },
"fas-" "fas-"
) )
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"))
idPresets.tagRenderings = [ idPresets.tagRenderings = [
{ {
id: "shop_types", id: "shop_types",
mappings: thief.readShopPresets(), mappings: thief.readShopPresets(),
@ -327,6 +342,12 @@ idPresets.tagRenderings = [
id: "shop_rendering", id: "shop_rendering",
mappings: thief.readShopIcons(), mappings: thief.readShopIcons(),
}, },
] ]
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()