feat: Add version to theme.json files

This commit is contained in:
Mauro Balades 2024-08-25 20:57:39 +02:00
parent a23e634a6e
commit bb113e7c8a
19 changed files with 197 additions and 33 deletions

View file

@ -0,0 +1,18 @@
import os
import json
if __name__ == "__main__":
for themeId in os.listdir("themes"):
themeFolder = os.path.join("themes", themeId)
if not os.path.isdir(themeFolder):
continue
themeDataFile = os.path.join(themeFolder, "theme.json")
if not os.path.exists(themeDataFile):
continue
with open(themeDataFile, "r") as f:
themeData = json.load(f)
if "version" not in themeData:
themeData["version"] = "1.0.0"
with open(themeDataFile, "w") as f:
json.dump(themeData, f, indent=4)
print(f"Added version to theme: {themeId}")

View file

@ -56,16 +56,7 @@ def main():
if 'isDarkMode' in colors:
theme_data['isDarkMode'] = colors['isDarkMode']
theme_data['isColorTheme'] = True
past_version = None
if theme in themes_data:
past_version = themes_data[theme].get('version', None)
themes_data[theme] = theme_data
if past_version is not None:
print(f" Found past version: {past_version}")
themes_data[theme]['version'] = past_version
else:
print(f" No past version found, setting to 1.0.0")
themes_data[theme]['version'] = "1.0.0"
with open(THEMES_DATA_FILE, 'w') as f:
json.dump(themes_data, f, indent=4)
del themes_data

View file

@ -165,7 +165,8 @@ Just joking, you can do whatever you want. You're the boss.
'style': get_static_asset(theme_id, STYLES_FILE),
'readme': get_static_asset(theme_id, README_FILE),
'image': get_static_asset(theme_id, IMAGE_FILE),
'author': author
'author': author,
'version': '1.0.0',
}
os.makedirs(f"themes/{theme_id}")