Skip to content

Commit da3019a

Browse files
committed
Add themes from discord
1 parent 80f7f42 commit da3019a

14 files changed

+71
-1
lines changed

Gruvbox_Green.mstx

590 Bytes
Binary file not shown.

Gruvbox_Orange.mstx

589 Bytes
Binary file not shown.

Rose_Pine_Gold.mstx

592 Bytes
Binary file not shown.

Rose_Pine_Iris.mstx

713 Bytes
Binary file not shown.

Rose_Pine_Rose.mstx

713 Bytes
Binary file not shown.

Rose_Pine_Saltwater.mstx

713 Bytes
Binary file not shown.

conflict-resolve.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import os
2+
import zipfile
3+
import json
4+
import uuid
5+
6+
# Directory path (current directory)
7+
cwd = os.getcwd()
8+
9+
def resolve_and_repack():
10+
ids_seen = set()
11+
12+
for file in os.listdir(cwd):
13+
if file.endswith(".mstx"):
14+
temp_dir = os.path.join(cwd, "temp_extract")
15+
os.makedirs(temp_dir, exist_ok=True)
16+
17+
try:
18+
with zipfile.ZipFile(file, 'r') as zip_ref:
19+
zip_ref.extractall(temp_dir)
20+
21+
config_path = os.path.join(temp_dir, "config.json")
22+
if os.path.exists(config_path):
23+
with open(config_path, 'r') as config_file:
24+
config_data = json.load(config_file)
25+
26+
if 'id' in config_data:
27+
original_id = config_data['id']
28+
29+
if original_id in ids_seen:
30+
# Generate a new UUID for the conflicting ID
31+
new_id = str(uuid.uuid4())
32+
print(f"Conflict detected for ID '{original_id}' in {file}. Replacing with new ID: {new_id}")
33+
config_data['id'] = new_id
34+
35+
# Update config.json with new ID
36+
with open(config_path, 'w') as config_file:
37+
json.dump(config_data, config_file, indent=4)
38+
39+
ids_seen.add(config_data['id'])
40+
else:
41+
print(f"Warning: 'id' not found in config.json of {file}")
42+
43+
# Repack the zip file with updated config.json
44+
new_zip_path = os.path.join(cwd, file)
45+
with zipfile.ZipFile(new_zip_path, 'w') as new_zip:
46+
for root, _, files in os.walk(temp_dir):
47+
for fname in files:
48+
file_path = os.path.join(root, fname)
49+
arcname = os.path.relpath(file_path, start=temp_dir)
50+
new_zip.write(file_path, arcname)
51+
52+
print(f"Repacked and updated {file} successfully.")
53+
54+
except zipfile.BadZipFile:
55+
print(f"Error: {file} is not a valid zip file.")
56+
except Exception as e:
57+
print(f"Error processing {file}: {e}")
58+
finally:
59+
# Clean up temporary directory
60+
for root, _, files in os.walk(temp_dir):
61+
for fname in files:
62+
os.remove(os.path.join(root, fname))
63+
os.rmdir(temp_dir)
64+
65+
if __name__ == "__main__":
66+
resolve_and_repack()

gen-manifest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import shutil
33
import zipfile
44
import json
5+
import sys
56

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

32-
# Extract the id and use the entire config.json as value
33+
# Extract the id and check for conflicts
3334
if 'id' in config_data:
3435
id_value = config_data['id']
36+
if id_value in manifest:
37+
print(f"Error: Conflict detected for ID '{id_value}' in {file}")
38+
sys.exit(1)
3539
manifest[id_value] = {"data": config_data}
3640

3741
# Copy the .mstx file to the 'dist' directory with the new name

test.mstx

-16.3 KB
Binary file not shown.

theme-Catppuccin_Frappe.mstx

609 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)