forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_onboarding_sync_bundle.sh
More file actions
executable file
·151 lines (135 loc) · 3.82 KB
/
Copy pathprepare_onboarding_sync_bundle.sh
File metadata and controls
executable file
·151 lines (135 loc) · 3.82 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 2 ]]; then
echo "usage: $0 <assets-dir> <bundle-dir> [source-commit] [source-branch]" >&2
exit 1
fi
ASSETS_DIR=$1
BUNDLE_DIR=$2
SOURCE_COMMIT=${3:-local}
SOURCE_BRANCH=${4:-local}
if [[ ! -d "$ASSETS_DIR" ]]; then
echo "assets directory not found: $ASSETS_DIR" >&2
exit 1
fi
rm -rf "$BUNDLE_DIR"
mkdir -p "$BUNDLE_DIR"
find "$ASSETS_DIR" -maxdepth 1 \( -name '*.png' -o -name '*.pdf' \) -print0 | while IFS= read -r -d '' file; do
cp "$file" "$BUNDLE_DIR/"
done
python3 - "$BUNDLE_DIR" "$SOURCE_COMMIT" "$SOURCE_BRANCH" <<'PY'
import json
import pathlib
import subprocess
import sys
from datetime import datetime, timezone
bundle_dir = pathlib.Path(sys.argv[1])
source_commit = sys.argv[2]
source_branch = sys.argv[3]
assets = []
for png_path in sorted(bundle_dir.glob("*.png")):
pdf_path = png_path.with_suffix(".pdf")
sips_output = subprocess.run(
["sips", "-g", "pixelWidth", "-g", "pixelHeight", str(png_path)],
check=True,
capture_output=True,
text=True,
).stdout
width = height = None
for line in sips_output.splitlines():
if "pixelWidth:" in line:
width = int(line.split(":")[-1].strip())
if "pixelHeight:" in line:
height = int(line.split(":")[-1].strip())
if width is None or height is None:
raise RuntimeError(f"failed to read image dimensions for {png_path.name}")
assets.append(
{
"name": png_path.stem,
"png": png_path.name,
"pdf": pdf_path.name if pdf_path.exists() else None,
"width": width,
"height": height,
}
)
manifest = {
"generatedAt": datetime.now(timezone.utc).isoformat(),
"sourceCommit": source_commit,
"sourceBranch": source_branch,
"assetCount": len(assets),
"assets": assets,
}
(bundle_dir / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
cards = []
for asset in assets:
cards.append(
f"""
<article class="card">
<h2>{asset["name"]}</h2>
<img src="{asset["png"]}" width="{asset["width"]}" height="{asset["height"]}" alt="{asset["name"]}">
</article>
""".strip()
)
html = f"""<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OMI Onboarding Sync</title>
<script src="https://mcp.figma.com/mcp/html-to-design/capture.js" async></script>
<style>
:root {{
color-scheme: dark;
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}}
body {{
margin: 0;
padding: 32px;
background: #111111;
color: #f5f5f5;
}}
header {{
margin-bottom: 24px;
}}
.grid {{
display: grid;
gap: 28px;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}}
.card {{
background: #1a1a1a;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 16px;
overflow: hidden;
}}
.card h2 {{
margin: 0;
padding: 14px 16px;
font-size: 14px;
font-weight: 600;
letter-spacing: 0.01em;
}}
.card img {{
display: block;
width: 100%;
height: auto;
}}
code {{
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}}
</style>
</head>
<body>
<header>
<h1>OMI Onboarding Sync</h1>
<p>Commit <code>{source_commit}</code> from <code>{source_branch}</code></p>
<p>{len(assets)} onboarding steps, generated {manifest["generatedAt"]}</p>
</header>
<section class="grid">
{"".join(cards)}
</section>
</body>
</html>
"""
(bundle_dir / "index.html").write_text(html)
PY