From 8d013c6abb5e0a0b98409fb70aac54ab80c2dc5e Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Wed, 7 Aug 2024 15:39:07 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9D=20(svg=20tester)=20add=20helper=20?= =?UTF-8?q?script=20to=20update=20SVGs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devTools/svgTester/update-configs.sh | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 devTools/svgTester/update-configs.sh diff --git a/devTools/svgTester/update-configs.sh b/devTools/svgTester/update-configs.sh new file mode 100755 index 00000000000..ed67989aa8e --- /dev/null +++ b/devTools/svgTester/update-configs.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -o errexit # exit script when a command fails +set -o nounset # fail when accessing an unset variable +set -o pipefail # treats pipeline command as failed when one command in the pipeline fails + +CONFIGS_DIR=../owid-grapher-svgs/configs +REFERENCES_DIR=../owid-grapher-svgs/svg +ALL_VIEWS_DIR=../owid-grapher-svgs/all-views/svg +CHART_IDS_FILE=most-viewed-charts.txts + +usage() { + echo -e "Usage: ./$(basename $0) [-h | --help] + +Dump a new set of configs and generate reference SVGs. +Make sure to run \`make refresh\` and \`make refresh.pageviews\` before running this script." +} + +main() { + echo "=> Removing existing configs and reference svgs" + rm -rf $CONFIGS_DIR $REFERENCES_DIR $ALL_VIEWS_DIR + + echo "=> Dump new configs and data" + node itsJustJavascript/devTools/svgTester/dump-data.js -o $CONFIGS_DIR + node itsJustJavascript/devTools/svgTester/dump-chart-ids.js -o $CHART_IDS_FILE + + echo "=> Generate reference SVGs" + node itsJustJavascript/devTools/svgTester/export-graphs.js -i $CONFIGS_DIR -o $REFERENCES_DIR + node itsJustJavascript/devTools/svgTester/export-graphs.js -i $CONFIGS_DIR -o $ALL_VIEWS_DIR -f $CHART_IDS_FILE --all-views +} + +# show help +if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then + usage + exit +fi + +main