163e134ceb
- repository_content: repo icon - repository_content_branch: git-branch icon - repository_content_commit: git-commit icon (new) - repository_content_tag: tag icon - repository_content_pr: git-pull-request icon Resources now have explicit icons set rather than relying on toolset fallback.
97 lines
2.5 KiB
Bash
Executable File
97 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Fetch Octicon icons and convert them to PNG for embedding in the MCP server.
|
|
# Generates both light theme (dark icons) and dark theme (white icons) variants.
|
|
# Uses sed to modify SVG fill color before converting to PNG.
|
|
# Requires: rsvg-convert (from librsvg2-bin on Ubuntu/Debian)
|
|
#
|
|
# Usage:
|
|
# script/fetch-icons # Fetch all default icons
|
|
# script/fetch-icons icon1 icon2 # Fetch specific icons
|
|
|
|
set -e
|
|
|
|
ICONS_DIR="pkg/octicons/icons"
|
|
OCTICONS_BASE="https://raw.githubusercontent.com/primer/octicons/main/icons"
|
|
|
|
# Default icons used by toolsets - add new icons here as needed
|
|
DEFAULT_ICONS=(
|
|
apps
|
|
beaker
|
|
bell
|
|
check-circle
|
|
codescan
|
|
comment-discussion
|
|
copilot
|
|
dependabot
|
|
file
|
|
git-branch
|
|
git-commit
|
|
git-merge
|
|
git-pull-request
|
|
issue-opened
|
|
logo-gist
|
|
mark-github
|
|
organization
|
|
people
|
|
person
|
|
project
|
|
repo
|
|
repo-forked
|
|
shield
|
|
shield-lock
|
|
star
|
|
star-fill
|
|
tag
|
|
tools
|
|
workflow
|
|
)
|
|
|
|
# Check for rsvg-convert
|
|
if ! command -v rsvg-convert &> /dev/null; then
|
|
echo "Error: rsvg-convert not found. Install with:"
|
|
echo " Ubuntu/Debian: sudo apt-get install librsvg2-bin"
|
|
echo " macOS: brew install librsvg"
|
|
exit 1
|
|
fi
|
|
|
|
# Use provided icons or defaults
|
|
if [ $# -gt 0 ]; then
|
|
ICONS=("$@")
|
|
else
|
|
ICONS=("${DEFAULT_ICONS[@]}")
|
|
fi
|
|
|
|
# Ensure icons directory exists
|
|
mkdir -p "$ICONS_DIR"
|
|
|
|
echo "Fetching ${#ICONS[@]} icons (24px, light + dark themes)..."
|
|
|
|
for icon in "${ICONS[@]}"; do
|
|
svg_url="${OCTICONS_BASE}/${icon}-24.svg"
|
|
light_file="${ICONS_DIR}/${icon}-light.png"
|
|
dark_file="${ICONS_DIR}/${icon}-dark.png"
|
|
|
|
echo " ${icon} (light + dark)"
|
|
|
|
# Download SVG
|
|
svg_content=$(curl -sfL "$svg_url" 2>/dev/null) || {
|
|
echo " Warning: Failed to fetch ${icon}-24.svg (may not exist)"
|
|
continue
|
|
}
|
|
|
|
# Light theme: dark icons (#24292f) for light backgrounds
|
|
# Add fill attribute to the svg tag
|
|
light_svg=$(echo "$svg_content" | sed 's/<svg /<svg fill="#24292f" /')
|
|
echo "$light_svg" | rsvg-convert -o "$light_file"
|
|
|
|
# Dark theme: white icons (#ffffff) for dark backgrounds
|
|
dark_svg=$(echo "$svg_content" | sed 's/<svg /<svg fill="#ffffff" /')
|
|
echo "$dark_svg" | rsvg-convert -o "$dark_file"
|
|
done
|
|
|
|
echo "Done. Icons saved to $ICONS_DIR"
|
|
echo ""
|
|
echo "Remember to:"
|
|
echo " 1. Update pkg/octicons/octicons_test.go if adding new icons"
|
|
echo " 2. Run 'UPDATE_TOOLSNAPS=true go test ./...' to update snapshots"
|