import { mkdir, writeFile } from "node:fs/promises"; const PAGE_URL = "https://www.microsoft.com/en-us/corporate-responsibility/topics/open-weight/"; const logos = [ ["AI21", "AI21", "ai21"], ["AMD", "AMD", "amd"], ["American Innovators Network", "American Innovators Network", "american-innovators-network"], ["AMP", "AMP", "amp"], ["Andreessen Horowitz", "Andreessen Horowitz", "andreessen-horowitz"], ["Arcee AI", "Arcee", "arcee-ai"], ["Arena", "Arena", "arena"], ["Baseten", "Baseten", "baseten"], ["Black Forest Labs", "Black Forest Labs", "black-forest-labs"], ["Block", "Block", "block"], ["Box", "Box", "box"], ["Cisco", "Cisco", "cisco"], ["Cloudflare", "Cloudflare", "cloudflare"], ["Cohere", "Cohere", "cohere"], ["CrowdStrike", "Crowdstrike", "crowdstrike"], ["Dell Technologies", "Dell Technologies", "dell-technologies"], ["DoorDash", "DoorDash", "doordash"], ["Emergence Capital", "Emergence", "emergence-capital"], ["Fireworks AI", "Fireworks AI", "fireworks-ai"], ["Genspark", "Genspark", "genspark"], ["GitHub", "GitHub", "github"], ["Google", "Google", "google"], ["Hugging Face", "Hugging Face", "hugging-face"], ["IBM", "IBM", "ibm"], ["Inferact", "Inferact", "inferact"], ["Interconnects AI", "Interconnects AI", "interconnects-ai"], ["The Linux Foundation", "Linux Foundation", "linux-foundation"], ["Mariana Minerals", "Mariana Minerals", "mariana-minerals"], ["Meta", "Meta", "meta"], ["Microsoft", "Microsoft", "microsoft"], ["Mistral", "Mistral", "mistral"], ["Morph", "Morph", "morph"], ["Mozilla", "Mozilla", "mozilla"], ["Nebius", "Nebius", "nebius"], ["Nous Research", "Nous Research", "nous-research"], ["NVIDIA", "NVIDIA", "nvidia"], ["Ollama", "Ollama", "ollama"], ["OpenAI", "OpenAI", "openai"], ["OpenClaw", "OpenClaw", "openclaw"], ["Palantir", "Palantir", "palantir"], ["Palo Alto Networks", "Palo Alto Networks", "palo-alto-networks"], ["Periodic Labs", "Periodic Labs", "periodic-labs"], ["Perplexity", "Perplexity", "perplexity"], ["Prime Intellect", "Prime Intellect", "prime-intellect"], ["Reflection", "Reflection", "reflection"], ["Replit", "Replit", "replit"], ["ServiceNow", "ServiceNow", "servicenow"], ["Telnyx", "Telnyx", "telnyx"], ["Trajectory", "Trajectory", "trajectory"], ["Y Combinator", "Y-Combinator", "y-combinator"], ]; const pageResponse = await fetch(PAGE_URL); if (!pageResponse.ok) { throw new Error(`Could not fetch logo source page (${pageResponse.status})`); } const html = await pageResponse.text(); const imageTags = html.match(/]*>/g) ?? []; const byAlt = new Map(); for (const tag of imageTags) { const alt = tag.match(/\balt="([^"]*)"/)?.[1]; if (!alt) continue; const src = tag.match(/\bsrc="([^"]+)"/)?.[1]; const smallSource = tag.match( /\bsrcset="[^"]*?(https:\/\/[^ ,"']+-300x\d+\.png)\s+300w/, )?.[1]; if (src) byAlt.set(alt, smallSource ?? src); } await mkdir(new URL("../public/logos/", import.meta.url), { recursive: true }); for (const [name, sourceAlt, slug] of logos) { const url = byAlt.get(sourceAlt); if (!url) throw new Error(`Missing source image for ${name}`); const response = await fetch(url); if (!response.ok) { throw new Error(`Could not fetch ${name} (${response.status})`); } const bytes = new Uint8Array(await response.arrayBuffer()); await writeFile(new URL(`../public/logos/${slug}.png`, import.meta.url), bytes); console.log(`${name}: ${bytes.length} bytes`); } console.log(`Downloaded ${logos.length} logo bricks.`);