Skip to content

Commit

Permalink
Add themes from discord
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovenoboyo committed Dec 30, 2024
1 parent 80f7f42 commit da3019a
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 1 deletion.
Binary file added Gruvbox_Green.mstx
Binary file not shown.
Binary file added Gruvbox_Orange.mstx
Binary file not shown.
Binary file added Rose_Pine_Gold.mstx
Binary file not shown.
Binary file added Rose_Pine_Iris.mstx
Binary file not shown.
Binary file added Rose_Pine_Rose.mstx
Binary file not shown.
Binary file added Rose_Pine_Saltwater.mstx
Binary file not shown.
66 changes: 66 additions & 0 deletions conflict-resolve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import os
import zipfile
import json
import uuid

# Directory path (current directory)
cwd = os.getcwd()

def resolve_and_repack():
ids_seen = set()

for file in os.listdir(cwd):
if file.endswith(".mstx"):
temp_dir = os.path.join(cwd, "temp_extract")
os.makedirs(temp_dir, exist_ok=True)

try:
with zipfile.ZipFile(file, 'r') as zip_ref:
zip_ref.extractall(temp_dir)

config_path = os.path.join(temp_dir, "config.json")
if os.path.exists(config_path):
with open(config_path, 'r') as config_file:
config_data = json.load(config_file)

if 'id' in config_data:
original_id = config_data['id']

if original_id in ids_seen:
# Generate a new UUID for the conflicting ID
new_id = str(uuid.uuid4())
print(f"Conflict detected for ID '{original_id}' in {file}. Replacing with new ID: {new_id}")
config_data['id'] = new_id

# Update config.json with new ID
with open(config_path, 'w') as config_file:
json.dump(config_data, config_file, indent=4)

ids_seen.add(config_data['id'])
else:
print(f"Warning: 'id' not found in config.json of {file}")

# Repack the zip file with updated config.json
new_zip_path = os.path.join(cwd, file)
with zipfile.ZipFile(new_zip_path, 'w') as new_zip:
for root, _, files in os.walk(temp_dir):
for fname in files:
file_path = os.path.join(root, fname)
arcname = os.path.relpath(file_path, start=temp_dir)
new_zip.write(file_path, arcname)

print(f"Repacked and updated {file} successfully.")

except zipfile.BadZipFile:
print(f"Error: {file} is not a valid zip file.")
except Exception as e:
print(f"Error processing {file}: {e}")
finally:
# Clean up temporary directory
for root, _, files in os.walk(temp_dir):
for fname in files:
os.remove(os.path.join(root, fname))
os.rmdir(temp_dir)

if __name__ == "__main__":
resolve_and_repack()
6 changes: 5 additions & 1 deletion gen-manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
import zipfile
import json
import sys

# Directory path (current directory)
cwd = os.getcwd()
Expand Down Expand Up @@ -29,9 +30,12 @@ def consolidate_manifest():
if 'theme' in config_data and 'customCSS' in config_data['theme']:
del config_data['theme']['customCSS']

# Extract the id and use the entire config.json as value
# Extract the id and check for conflicts
if 'id' in config_data:
id_value = config_data['id']
if id_value in manifest:
print(f"Error: Conflict detected for ID '{id_value}' in {file}")
sys.exit(1)
manifest[id_value] = {"data": config_data}

# Copy the .mstx file to the 'dist' directory with the new name
Expand Down
Binary file removed test.mstx
Binary file not shown.
Binary file added theme-Catppuccin_Frappe.mstx
Binary file not shown.
Binary file added theme-Catppuccin_Latte.mstx
Binary file not shown.
Binary file added theme-EverForest.mstx
Binary file not shown.
Binary file added theme-Spotistyle.mstx
Binary file not shown.
Binary file added theme-Tokyo_Night_.mstx
Binary file not shown.

0 comments on commit da3019a

Please sign in to comment.