From a1ca76dc48a066cabe3a25ae8d8069376620ade0 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 7 May 2021 12:39:37 +0200 Subject: [PATCH] Fix of init scripts --- scripts/generateTaginfoProjectFiles.ts | 37 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/scripts/generateTaginfoProjectFiles.ts b/scripts/generateTaginfoProjectFiles.ts index 1b0d226d4..3a9360817 100644 --- a/scripts/generateTaginfoProjectFiles.ts +++ b/scripts/generateTaginfoProjectFiles.ts @@ -41,7 +41,7 @@ function generateLayerUsage(layer: LayerConfig, layout: LayoutConfig): any [] { const usesImageCarousel = (tr.render?.txt?.indexOf("image_carousel()") ?? -2) > 0 const usesImageUpload = (tr.render?.txt?.indexOf("image_upload()") ?? -2) > 0 if (usesImageCarousel || usesImageUpload) { - + const descrNoUpload = `The layer '${layer.name.txt} shows images based on the keys image, image:0, image:1,... and wikidata, wikipedia, wikimedia_commons and mapillary`; const descrUpload = `The layer '${layer.name.txt} allows to upload images and adds them under the 'image'-tag (and image:0, image:1, ... for multiple images). Furhtermore, this layer shows images based on the keys image, wikidata, wikipedia, wikimedia_commons and mapillary`; @@ -136,6 +136,28 @@ function generateTagInfoEntry(layout: LayoutConfig): any { return filename } +// Write the URLS to the taginfo repository. Might fail if the repository is not checked ou +function generateProjectsOverview() { + try { + const tagInfoList = "../taginfo-projects/project_list.txt" + let projectList = readFileSync(tagInfoList, "UTF8") + .split("\n") + .filter(entry => entry.indexOf("mapcomplete_") < 0) + .concat(files.map(f => `${f} https://raw.githubusercontent.com/pietervdvn/MapComplete/master/Docs/TagInfo/${f}.json`)) + .sort() + .filter(entry => entry != "") + + console.log("Writing taginfo project filelist"); + writeFileSync(tagInfoList, projectList.join("\n") + "\n"); + + + } catch (e) { + console.warn("Could not write the taginfo-projects list - the repository is probably not checked out. Are you creating a fork? Ignore this message then.") + } + +} + + console.log("Creating taginfo project files") @@ -150,15 +172,4 @@ for (const layout of AllKnownLayouts.layoutsList) { } files.push(generateTagInfoEntry(layout)); } - -const tagInfoList = "../taginfo-projects/project_list.txt" -let projectList = readFileSync(tagInfoList, "UTF8") - .split("\n") - .filter(entry => entry.indexOf("mapcomplete_") < 0) - .concat(files.map(f => `${f} https://raw.githubusercontent.com/pietervdvn/MapComplete/master/Docs/TagInfo/${f}.json`)) - .sort() - .filter(entry => entry != "") - -console.log("Writing taginfo project filelist"); -writeFileSync(tagInfoList, projectList.join("\n") + "\n"); - \ No newline at end of file +generateProjectsOverview(); \ No newline at end of file