#!/usr/bin/env bash # Regenerate internal/brand/icons_gen.go from Simple Icons. # # Simple Icons (https://simpleicons.org) is CC0 1.0: the icon paths are public # domain. The marks themselves remain the trademarks of their owners and are # used here only to identify the technology being described. # # This script runs at development time on a machine with network access. The # generated Go file IS committed, so `make build` never needs the network, never # needs Node and never needs node_modules. Re-run it only when the icon set # changes: # # tools/gen_brand_icons.sh # # Every icon is normalised to a 24x24 viewBox and inlined as path data, so the # page carries no image request and the mark takes the chip's text colour. set -euo pipefail root="$(cd "$(dirname "$0")/.." && pwd)" out="$root/internal/brand/icons_gen.go" cdn="${SIMPLE_ICONS_CDN:-https://cdn.simpleicons.org}" # slug:name as published by Simple Icons. Keep this list to marks the content # actually uses; an unused icon is dead weight in the binary. slugs=( javascript php python homeassistant raspberrypi nixos qdrant prefect n8n mqtt langgraph langchain ffmpeg zigbee threedotjs react proxmox mysql postgresql caddy tailscale neovim htmx go docker borgbackup sqlite spotify rabbitmq openrouter obsidian niri gitea ghostty googlegemini deepseek cplusplus typescript zsh minimax espressif grafana wireguard nginx hashicorp vault linux zig huggingface ollama ) tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT { echo "// Code generated by tools/gen_brand_icons.sh; DO NOT EDIT." echo "//" echo "// Path data from Simple Icons (CC0 1.0), retrieved from $cdn." echo "// Every mark is a 24x24 viewBox drawn in currentColor." echo echo "package brand" echo echo "// marks maps a Simple Icons slug to its path data." echo "var marks = map[string][]string{" } > "$out" for slug in "${slugs[@]}"; do if ! curl -fsS -m 20 -o "$tmp/$slug.svg" "$cdn/$slug"; then echo "gen_brand_icons: could not fetch $slug" >&2 exit 1 fi # One or more elements; monochrome, so the path data is all we keep. mapfile -t paths < <(grep -o 'd="[^"]*"' "$tmp/$slug.svg" | sed 's/^d="//; s/"$//') if [ "${#paths[@]}" -eq 0 ]; then echo "gen_brand_icons: $slug has no path data" >&2 exit 1 fi printf '\t"%s": {\n' "$slug" >> "$out" for p in "${paths[@]}"; do printf '\t\t`%s`,\n' "$p" >> "$out" done printf '\t},\n' >> "$out" done echo "}" >> "$out" gofmt -w "$out" 2>/dev/null || true echo "gen_brand_icons: wrote $out (${#slugs[@]} marks)"