Fix Theme Metadata Duplication and Add Missing Properties for Recent Pull Requests (#575)

* fix ability to add tags multiple times when rebuilding themes

* fix `createdAt` not being added for pull requests made prior

* adds tags property if it doesn't exist (old PRs)

* updated affected `theme.json` files

* updated more affected `theme.json` files

* fix action failing if new commits before finished

* make action only initiate when themes are changed
This commit is contained in:
TheRealMG 2024-10-13 02:59:29 -05:00 committed by GitHub
parent 65c8c1fed0
commit a73edd785e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 53 additions and 14 deletions

View file

@ -75,11 +75,12 @@ def main():
if "tags" not in theme_data:
theme_data["tags"] = []
# Add 'color theme' tag if colors.json is present
theme_data["tags"].append("color theme")
# Add 'color theme' tag if colors.json is present and tag isn't already in tags list
if "color scheme" not in theme_data["tags"]:
theme_data["tags"].append("color scheme")
# Add 'dark' tag if colors.json specifies dark mode
if "isDarkMode" in colors and colors["isDarkMode"]:
# Add 'dark' tag if colors.json specifies dark mode and tag isn't already in tags list
if "isDarkMode" in colors and colors["isDarkMode"] and "dark" not in theme_data["tags"]:
theme_data["tags"].append("dark")
themes_data[theme] = theme_data

View file

@ -21,9 +21,23 @@ def update_theme_date(theme_path):
theme_data = json.load(f)
except json.JSONDecodeError as e:
panic("Error reading theme.json: " + str(e))
# Get the current date
current_date = time.strftime("%Y-%m-%d")
# Set `createdAt` to the current date if it doesn't exist
if "createdAt" not in theme_data:
theme_data["createdAt"] = current_date
print(f"Set `createdAt` for {theme_path} to {theme_data['createdAt']}")
# Update the `updatedAt` field to the current date
theme_data["updatedAt"] = time.strftime("%Y-%m-%d")
theme_data["updatedAt"] = current_date
print(f"Updated `updatedAt` for {theme_path} to {theme_data['updatedAt']}")
# Add `tags` as an empty list if it doesn't exist
if "tags" not in theme_data:
theme_data["tags"] = []
print(f"Initialized `tags` for {theme_path} as an empty list")
# Write the changes back to theme.json
with open(theme_file, "w") as f: