$ErrorActionPreference = 'Stop' $seen = @{} $items = [System.Collections.Generic.List[object]]::new() function Fetch-Item([string]$name) { if ($seen.ContainsKey($name)) { return } $seen[$name] = $true $item = Invoke-RestMethod "https://park-ui.com/registry/react/$name.json" foreach ($dep in $item.registryDependencies) { Fetch-Item $dep } $items.Add($item) foreach ($file in $item.files) { $base = if ($file.type -eq 'registry:ui') { 'src/components/ui' } elseif ($file.type -eq 'registry:recipe') { 'src/theme/recipes' } else { 'src/theme' } $dest = Join-Path $base $file.path New-Item -ItemType Directory -Force (Split-Path $dest) | Out-Null [System.IO.File]::WriteAllText((Join-Path (Get-Location) $dest), $file.content) } } foreach ($name in @('__init','violet','neutral','button','input','textarea','badge','dialog')) { Fetch-Item $name } $items | ConvertTo-Json -Depth 100 | Set-Content park-registry.json