diff options
author | Florian Dold <florian@dold.me> | 2021-10-05 10:42:30 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-10-05 10:42:30 +0200 |
commit | be5e8be888f4e2ab033c12bbb37b1eec2478aa37 (patch) | |
tree | 500bdb9df1eedd92619c9e5955bf8502e07f8bbf | |
parent | 61ea83cbc019db5c000baf4debf873be59528e63 (diff) | |
download | anastasis-be5e8be888f4e2ab033c12bbb37b1eec2478aa37.tar.gz anastasis-be5e8be888f4e2ab033c12bbb37b1eec2478aa37.zip |
implement TypeScript data generation
-rw-r--r-- | contrib/.gitignore | 1 | ||||
-rwxr-xr-x | contrib/gen-ts.sh | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/contrib/.gitignore b/contrib/.gitignore new file mode 100644 index 0000000..93559bd --- /dev/null +++ b/contrib/.gitignore | |||
@@ -0,0 +1 @@ | |||
anastasis-data.ts | |||
diff --git a/contrib/gen-ts.sh b/contrib/gen-ts.sh new file mode 100755 index 0000000..bc204d1 --- /dev/null +++ b/contrib/gen-ts.sh | |||
@@ -0,0 +1,26 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Generate a single TS file from the JSON data files in contrib/. | ||
4 | # Requires prettier to be installed. | ||
5 | |||
6 | gen_ts() { | ||
7 | echo "// This file is auto-generated, do not modify." | ||
8 | echo "// Generated from $(git describe --tags) on $(date -R)" | ||
9 | echo "// To re-generate, run contrib/gen-ts.sh from the main anastasis code base." | ||
10 | echo | ||
11 | echo "export const anastasisData = {" | ||
12 | echo "providersList: $(cat provider-list.json)," | ||
13 | echo "countriesList: $(cat redux.countries.json)," | ||
14 | echo "countryDetails: {" | ||
15 | for f in redux.??.json; do | ||
16 | cc=$(echo $f | awk -F "." '{ print $2 }') | ||
17 | echo "$cc: $(cat $f)," | ||
18 | done | ||
19 | echo "}," # country details | ||
20 | echo "}" # anastasis data | ||
21 | |||
22 | } | ||
23 | |||
24 | gen_ts > anastasis-data.ts | ||
25 | # Auto-format | ||
26 | prettier -w anastasis-data.ts | ||