Skip to content

Commit df7fe92

Browse files
committed
feat(extensions): single-file catalog.json registry
- Manifests gain author, description, category fields - build workflow generates catalog.json from Extensions/raw/ and commits it - downloadURL now points at GitHub Release assets (which GitHub counts), so download counts actually increment when the app installs - route.ts reads catalog.json in one fetch (no git-tree walk, no per-manifest fetches, removes unauthenticated rate-limit exposure)
1 parent b17bb83 commit df7fe92

15 files changed

Lines changed: 153 additions & 92 deletions

File tree

.github/workflows/build-extensions.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,51 @@ jobs:
8181
git commit -m "build(extensions): rebuild .openclipext zips [skip ci]"
8282
git push origin main
8383
fi
84+
fi
85+
86+
- name: Generate and commit catalog.json
87+
env:
88+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
run: |
90+
set -euo pipefail
91+
shopt -s nullglob
92+
ROOT="$(pwd)"
93+
RAW_DIR="$ROOT/Extensions/raw"
94+
95+
# Build catalog.json from the raw extension manifests so the web API
96+
# serves metadata from a single file instead of walking the GitHub tree.
97+
CATALOG="$ROOT/catalog.json"
98+
jq -n '{updatedAt: (now | todateiso8601), extensions: []}' > "$CATALOG"
99+
100+
for pkg_dir in "$RAW_DIR"/*.openclipext; do
101+
[ -d "$pkg_dir" ] || continue
102+
pkg_name="$(basename "$pkg_dir")" # e.g. AppleMusic.openclipext
103+
manifest="$pkg_dir/openclip.json"
104+
[ -f "$manifest" ] || continue
105+
106+
identifier="$(jq -r '.identifier // empty' "$manifest")"
107+
if [ -z "$identifier" ]; then
108+
identifier="com.openclip.${pkg_name%.openclipext}"
109+
identifier="$(echo "$identifier" | tr '[:upper:]' '[:lower:]')"
110+
fi
111+
112+
entry=$(jq -nc \
113+
--arg id "$identifier" \
114+
--arg name "$(jq -r '.name // (.action.title // .actions[0].title // empty)' "$manifest")" \
115+
--arg desc "$(jq -r '.description // empty' "$manifest")" \
116+
--arg author "$(jq -r '.author // "OpenClip Team"' "$manifest")" \
117+
--arg icon "$(jq -r '(.action.icon // .actions[0].icon // "puzzlepiece")' "$manifest")" \
118+
--arg category "$(jq -r '.category // "productivity"' "$manifest")" \
119+
--arg version "$(jq -r '.version // "1.0.0"' "$manifest")" \
120+
--arg url "https://github.com/$GITHUB_REPOSITORY/releases/download/${identifier}@$(jq -r '.version // "1.0.0"' "$manifest")/$pkg_name.zip" \
121+
'{id: $id, name: $name, description: $desc, author: $author, icon: $icon, category: $category, version: $version, downloadCount: 0, downloadURL: $url}')
122+
123+
jq --argjson entry "$entry" '.extensions += [$entry]' "$CATALOG" > "$CATALOG.tmp"
124+
mv "$CATALOG.tmp" "$CATALOG"
125+
done
126+
127+
git add catalog.json
128+
if ! git diff --cached --quiet; then
129+
git commit -m "chore(extensions): regenerate catalog.json [skip ci]"
130+
git push origin main
84131
fi
54 Bytes
Binary file not shown.
68 Bytes
Binary file not shown.
66 Bytes
Binary file not shown.
67 Bytes
Binary file not shown.
63 Bytes
Binary file not shown.
67 Bytes
Binary file not shown.

Extensions/raw/AppleMusic.openclipext/openclip.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"identifier": "com.openclip.applemusic",
33
"name": "Apple Music",
44
"version": "1.0.0",
5+
"author": "OpenClip Team",
6+
"description": "Search Apple Music for the selected text.",
7+
"category": "music",
58
"action": {
69
"title": "Apple Music",
710
"icon": "music.note",

Extensions/raw/GoogleMaps.openclipext/openclip.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"identifier": "com.openclip.googlemaps",
33
"name": "Google Maps",
44
"version": "1.0.0",
5+
"author": "OpenClip Team",
6+
"description": "Open Google Maps with the selected text as a search query.",
7+
"category": "maps",
58
"action": {
69
"title": "Google Maps",
710
"icon": "map",

Extensions/raw/GoogleTranslate.openclipext/openclip.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"identifier": "com.openclip.translate",
33
"name": "Google Translate",
44
"version": "1.0.0",
5+
"author": "OpenClip Team",
6+
"description": "Translate the selected text into English with Google Translate.",
7+
"category": "translate",
58
"action": {
69
"title": "Translate",
710
"icon": "globe",

0 commit comments

Comments
 (0)