-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
76 lines (67 loc) · 2 KB
/
Copy pathbuild.py
File metadata and controls
76 lines (67 loc) · 2 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
71
72
73
74
75
76
#!/usr/bin/env python3
"""
Threadkeeper build script.
Produces dist/threadkeeper-firefox.zip and dist/threadkeeper-chrome.zip
"""
import json
import zipfile
import shutil
from pathlib import Path
ROOT = Path.home() / "dev/projects/active/threadkeeper"
DIST = ROOT / "dist"
COMMON_FILES = [
"icons/icon-16.png",
"icons/icon-32.png",
"icons/icon-48.png",
"icons/icon-96.png",
"icons/icon-128.png",
"popup/popup.html",
"popup/popup.css",
"popup/popup.js",
"export/export.html",
"export/export.css",
"export/export.js",
"content-scripts/shared.js",
"content-scripts/gemini.js",
"content-scripts/chatgpt.js",
"content-scripts/claude.js",
"background/background.js",
"lib/filename.js",
"lib/markdown.js",
"lib/json.js",
"LICENSE",
"README.md",
"ACKNOWLEDGMENTS.md",
]
def build_zip(name: str, manifest_path: Path, extra_files: list = []):
out = DIST / name
with zipfile.ZipFile(out, 'w', zipfile.ZIP_DEFLATED) as zf:
# Write manifest as manifest.json regardless of source filename
zf.write(manifest_path, "manifest.json")
for f in COMMON_FILES + extra_files:
full = ROOT / f
if not full.exists():
print(f" ⚠ missing: {f}")
continue
zf.write(full, f)
size_kb = out.stat().st_size // 1024
print(f" ✓ {name} ({size_kb} KB)")
return out
def main():
DIST.mkdir(exist_ok=True)
print("📦 Building Firefox package...")
build_zip(
"threadkeeper-firefox.zip",
ROOT / "manifest.json",
)
print("📦 Building Chrome package...")
build_zip(
"threadkeeper-chrome.zip",
ROOT / "manifest.chrome.json",
extra_files=["background/sw.js"],
)
print("\n✨ Done.")
print(f" Firefox: dist/threadkeeper-firefox.zip → addons.mozilla.org")
print(f" Chrome: dist/threadkeeper-chrome.zip → chrome.google.com/webstore/devconsole")
if __name__ == "__main__":
main()