build-icons.ts — ui Source File
Architecture documentation for build-icons.ts, a typescript file in the ui codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f008c94_8a17_fd88_024f_322b76e3544a["build-icons.ts"] eac8f98f_e40a_7fe8_f505_372c83d20c7a["fs"] 2f008c94_8a17_fd88_024f_322b76e3544a --> eac8f98f_e40a_7fe8_f505_372c83d20c7a d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] 2f008c94_8a17_fd88_024f_322b76e3544a --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 a9fe3d3c_59c9_c6d6_013e_80fd635d3135["icons"] 2f008c94_8a17_fd88_024f_322b76e3544a --> a9fe3d3c_59c9_c6d6_013e_80fd635d3135 style 2f008c94_8a17_fd88_024f_322b76e3544a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
#!/usr/bin/env tsx
import * as fs from "fs"
import * as path from "path"
import { iconLibraries, type IconLibraryName } from "shadcn/icons"
type IconUsage = Record<IconLibraryName, Set<string>>
function findTsxFiles(dir: string) {
const files: string[] = []
const entries = fs.readdirSync(dir, { withFileTypes: true })
for (const entry of entries) {
const fullPath = path.join(dir, entry.name)
if (entry.isDirectory()) {
files.push(...findTsxFiles(fullPath))
} else if (entry.isFile() && entry.name.endsWith(".tsx")) {
files.push(fullPath)
}
}
return files
}
function scanIconUsage() {
const iconUsage: IconUsage = Object.keys(iconLibraries).reduce((acc, key) => {
acc[key as IconLibraryName] = new Set()
return acc
}, {} as IconUsage)
const registryBasesDir = path.join(process.cwd(), "registry/bases")
const files = findTsxFiles(registryBasesDir)
const libraryNames = Object.values(iconLibraries)
.map((lib) => lib.name)
.join("|")
const iconPlaceholderRegex = new RegExp(
`<IconPlaceholder\\s+([^>]*?)(?:${libraryNames})=["']([^"']+)["']([^>]*?)\\/?>`,
"g"
)
for (const file of files) {
const content = fs.readFileSync(file, "utf-8")
let match
while ((match = iconPlaceholderRegex.exec(content)) !== null) {
const fullMatch = match[0]
for (const [libraryName, config] of Object.entries(iconLibraries)) {
const attrMatch = fullMatch.match(
new RegExp(`${config.name}=["']([^"']+)["']`)
)
if (attrMatch) {
iconUsage[libraryName as IconLibraryName].add(attrMatch[1])
}
}
}
}
return iconUsage
}
// ... (72 more lines)
Domain
Subdomains
Types
Dependencies
- fs
- icons
- path
Source
Frequently Asked Questions
What does build-icons.ts do?
build-icons.ts is a source file in the ui codebase, written in typescript. It belongs to the DocumentationAtlas domain, Changelog subdomain.
What functions are defined in build-icons.ts?
build-icons.ts defines 5 function(s): findTsxFiles, generateIconFiles, main, scanIconUsage, startWatcher.
What does build-icons.ts depend on?
build-icons.ts imports 3 module(s): fs, icons, path.
Where is build-icons.ts in the architecture?
build-icons.ts is located at apps/v4/scripts/build-icons.ts (domain: DocumentationAtlas, subdomain: Changelog, directory: apps/v4/scripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free