mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-25 13:46:07 +00:00
37 lines
711 B
TypeScript
37 lines
711 B
TypeScript
import fs from "fs"
|
|
import path, { basename, dirname } from "path"
|
|
|
|
import { components } from "../config/components"
|
|
|
|
const payload = components
|
|
.map((component) => {
|
|
const files = component.files?.map((file) => {
|
|
const content = fs.readFileSync(path.join(process.cwd(), file), "utf8")
|
|
|
|
return {
|
|
name: basename(file),
|
|
dir: dirname(file),
|
|
content,
|
|
}
|
|
})
|
|
|
|
return {
|
|
...component,
|
|
files,
|
|
}
|
|
})
|
|
.sort((a, b) => {
|
|
if (a.name < b.name) {
|
|
return -1
|
|
}
|
|
if (a.name > b.name) {
|
|
return 1
|
|
}
|
|
return 0
|
|
})
|
|
|
|
fs.writeFileSync(
|
|
path.join(process.cwd(), "pages/api/components.json"),
|
|
JSON.stringify(payload, null, 2)
|
|
)
|