Ariver
2026-07-13 14a1efc86d0295be3a0d3fe1ebe7b8080266da2d
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
77
78
79
80
81
82
83
#!/usr/bin/env python3
"""Sync Aligner's macOS app icon assets from the design handoff."""
 
from __future__ import annotations
 
import json
import shutil
from pathlib import Path
 
 
OUTPUT_ROOT = Path(__file__).resolve().parents[1]
PROJECT_ROOT = OUTPUT_ROOT.parent
RESOURCES = OUTPUT_ROOT / "C1.source" / "Resources"
APPICONSET = RESOURCES / "Assets.xcassets" / "AppIcon.appiconset"
ICNS_PATH = RESOURCES / "AppIcon.icns"
 
HANDOFF_DIR = (
    PROJECT_ROOT
    / "02-P"
    / "Round01-QuickSwitch-MVP"
    / "02.ui设计稿"
    / "AppIcon-D1-BigBars-Handoff-20260604"
)
HANDOFF_ICONSET = HANDOFF_DIR / "AppIcon-D1-BigBars.iconset"
HANDOFF_ICNS = HANDOFF_DIR / "Aligner-AppIcon-D1-BigBars.icns"
HANDOFF_PREVIEW = HANDOFF_DIR / "Aligner-AppIcon-D1-BigBars-1024.png"
 
ICON_FILES = [
    "icon_16x16.png",
    "icon_16x16@2x.png",
    "icon_32x32.png",
    "icon_32x32@2x.png",
    "icon_128x128.png",
    "icon_128x128@2x.png",
    "icon_256x256.png",
    "icon_256x256@2x.png",
    "icon_512x512.png",
    "icon_512x512@2x.png",
]
 
 
def require_file(path: Path) -> None:
    if not path.is_file():
        raise FileNotFoundError(f"missing app icon source: {path}")
 
 
def load_contents_json() -> dict:
    contents_path = HANDOFF_ICONSET / "Contents.json"
    require_file(contents_path)
    with contents_path.open("r", encoding="utf-8") as file:
        return json.load(file)
 
 
def sync_iconset() -> None:
    APPICONSET.mkdir(parents=True, exist_ok=True)
    contents = load_contents_json()
 
    for filename in ICON_FILES:
        source = HANDOFF_ICONSET / filename
        require_file(source)
        shutil.copy2(source, APPICONSET / filename)
 
    require_file(HANDOFF_PREVIEW)
    shutil.copy2(HANDOFF_PREVIEW, APPICONSET / "icon_1024_preview.png")
 
    with (APPICONSET / "Contents.json").open("w", encoding="utf-8") as file:
        json.dump(contents, file, indent=2, ensure_ascii=False)
        file.write("\n")
 
 
def sync_icns() -> None:
    require_file(HANDOFF_ICNS)
    shutil.copy2(HANDOFF_ICNS, ICNS_PATH)
 
 
def main() -> None:
    sync_iconset()
    sync_icns()
    print(f"Synced AppIcon assets from: {HANDOFF_DIR}")
 
 
if __name__ == "__main__":
    main()