diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index e2ac408..2eadaea 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -54,6 +54,11 @@ jobs: python3 tools/generateShFiles.py echo 🏅 + - name: update themes in gogh file + run: | + python3 tools/updateThemes.py + echo 🏅 + - name: Git commit run: | git config user.name github-actions[bot] diff --git a/tools/generatJson.py b/tools/generatJson.py index 1f6d029..ac48c0d 100644 --- a/tools/generatJson.py +++ b/tools/generatJson.py @@ -3,7 +3,7 @@ import json import yaml import hashlib -source_path = "./themes-yml" +source_path = "./themes" dest_path = "./data/themes.json" themes = [] diff --git a/tools/generateShFiles.py b/tools/generateShFiles.py index 67de10c..1b4aef4 100644 --- a/tools/generateShFiles.py +++ b/tools/generateShFiles.py @@ -5,7 +5,7 @@ import re import subprocess import yaml -folder_path = "./themes-yml" +folder_path = "./themes" dest_path = './installs' themes = [] diff --git a/tools/updateThemes.py b/tools/updateThemes.py new file mode 100644 index 0000000..39eeb2f --- /dev/null +++ b/tools/updateThemes.py @@ -0,0 +1,32 @@ +import json +import re +from unidecode import unidecode + +input_file = 'data/themes.json' +output_file = 'gogh.sh' + +start_text = "declare -a THEMES=(" +end_text = ")" + +with open(input_file, "r") as f: + data = json.load(f) + +theme_names = [re.sub(r'[^a-zA-Z0-9\s]+', '-', unidecode(theme["name"]).lower().replace(' ', '-')).rstrip('-') for theme in data["themes"]] +themes = sorted(list(set([f"{name}.sh" for name in theme_names]))) + +with open(output_file, "r") as f: + lines = f.readlines() + +with open(output_file, "w") as f: + found_start = False + for line in lines: + if start_text in line: + found_start = True + f.write(line) + for theme in themes: + f.write(f" '{theme}'\n") + elif end_text in line: + found_start = False + f.write(line) + elif not found_start: + f.write(line)