Repository navigation
Expand file tree
/
Copy pathgenerate_thunderstore_toml.py
More file actions
70 lines (56 loc) · 1.81 KB
/
Copy pathgenerate_thunderstore_toml.py
File metadata and controls
70 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import json
import toml # type: ignore
import os
THUNDERSTORE_TEAM = os.getenv("THUNDERSTORE_TEAM")
MANIFEST_PATH = "manifest.json"
THUNDERSTORE_TOML_PATH = "thunderstore.toml"
def load_manifest(path):
with open(path, 'r') as f:
return json.load(f)
def save_thunderstore_toml(path, data):
with open(path, 'w') as f:
toml.dump(data, f)
def main():
manifest = load_manifest(MANIFEST_PATH)
dependencies = manifest.get("dependencies", [])
deps = {}
for dep in dependencies:
try:
namespace, name, version = dep.split("-")
deps[f"{namespace}-{name}"] = f"{version}" # Always latest compatible
except ValueError:
print(f"Skipping malformed dependency: {dep}")
continue
package = {
"namespace": THUNDERSTORE_TEAM,
"name": manifest.get("name", "PackageName"),
"versionNumber": manifest.get("version_number", "1.0.0"),
"description": manifest.get("description", "No description provided."),
"website_url": manifest.get("website_url", "https://thunderstore.io"),
"containsNsfwContent": False,
"dependencies": deps
}
publish = {
"repository": "https://thunderstore.io",
"communities": [ "repo", ],
"categories": { "repo": [ "modpacks", ] }
}
config = {
"schemaVersion": "0.0.1"
}
build = {
"icon": "./icon.png",
"readme": "./README.md",
"outdir": "./build",
"copy": [{ "source": "./", "target": "" }]
}
thunderstore_data = {
"config": config,
"package": package,
"publish": publish,
"build": build
}
save_thunderstore_toml(THUNDERSTORE_TOML_PATH, thunderstore_data)
print("thunderstore.toml updated.")
if __name__ == "__main__":
main()