From 5d884a97f9024e4a084904e43223ab4756916d50 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 4 Feb 2022 00:42:02 +0100 Subject: [PATCH] Add a warning if a logo for a theme is not square --- package-lock.json | 20 +++++++++++++++++++- package.json | 4 +++- scripts/generateLayouts.ts | 27 +++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index bf2e78f06..0ec0cda14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "@types/papaparse": "^5.3.1", "@types/prompt-sync": "^4.1.0", "@types/wikidata-sdk": "^6.1.0", + "@types/xml2js": "^0.4.9", "country-language": "^0.1.7", "email-validator": "^2.0.4", "escape-html": "^1.0.3", @@ -53,7 +54,8 @@ "togpx": "^0.5.4", "tslint": "^6.1.3", "wikibase-sdk": "^7.14.0", - "wikidata-sdk": "^7.14.0" + "wikidata-sdk": "^7.14.0", + "xml2js": "^0.4.23" }, "devDependencies": { "@babel/polyfill": "^7.10.4", @@ -3313,6 +3315,14 @@ "wikidata-sdk": "*" } }, + "node_modules/@types/xml2js": { + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.9.tgz", + "integrity": "sha512-CHiCKIihl1pychwR2RNX5mAYmJDACgFVCMT5OArMaO3erzwXVcBqPcusr+Vl8yeeXukxZqtF8mZioqX+mpjjdw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", @@ -19297,6 +19307,14 @@ "wikidata-sdk": "*" } }, + "@types/xml2js": { + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.9.tgz", + "integrity": "sha512-CHiCKIihl1pychwR2RNX5mAYmJDACgFVCMT5OArMaO3erzwXVcBqPcusr+Vl8yeeXukxZqtF8mZioqX+mpjjdw==", + "requires": { + "@types/node": "*" + } + }, "abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", diff --git a/package.json b/package.json index 1ee44cb91..e29716e6b 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@types/papaparse": "^5.3.1", "@types/prompt-sync": "^4.1.0", "@types/wikidata-sdk": "^6.1.0", + "@types/xml2js": "^0.4.9", "country-language": "^0.1.7", "email-validator": "^2.0.4", "escape-html": "^1.0.3", @@ -94,7 +95,8 @@ "togpx": "^0.5.4", "tslint": "^6.1.3", "wikibase-sdk": "^7.14.0", - "wikidata-sdk": "^7.14.0" + "wikidata-sdk": "^7.14.0", + "xml2js": "^0.4.23" }, "devDependencies": { "@babel/polyfill": "^7.10.4", diff --git a/scripts/generateLayouts.ts b/scripts/generateLayouts.ts index 268b42ccf..fbb24e271 100644 --- a/scripts/generateLayouts.ts +++ b/scripts/generateLayouts.ts @@ -6,6 +6,8 @@ import Constants from "../Models/Constants"; import * as all_known_layouts from "../assets/generated/known_layers_and_themes.json" import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson"; import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"; +import xml2js from 'xml2js'; +import {exec} from "child_process"; const sharp = require('sharp'); const template = readFileSync("theme.html", "utf8"); @@ -35,7 +37,7 @@ async function createIcon(iconPath: string, size: number) { readFileSync(newname); return newname; // File already exists - nothing to do } catch (e) { - // Errors are normal here if this file exists + // Errors are normal here if this file does not exists } try { @@ -60,8 +62,29 @@ async function createManifest(layout: LayoutConfig) { let icon = layout.icon; if (icon.endsWith(".svg") || icon.startsWith(" { + console.log("Inkscape: ", stdout) + if (error !== null) { + console.error(error) + } + if (stderr !== "") { + console.error(stderr) + } + }))//*/ + + } + + } + let path = layout.icon; if (layout.icon.startsWith("<")) { // THis is already the svg