react-code-dataset / chakra-ui /apps /www /utils /get-component-list.ts
Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
846 Bytes
import { findUpSync } from "find-up"
import { readdir } from "fs/promises"
import { dirname, extname, resolve } from "path/posix"
const isFileType = (file: string) => extname(file).startsWith(".ts")
export const getComponentDir = () => {
const rootPath = findUpSync("pnpm-workspace.yaml")
if (!rootPath) throw new Error("Not found")
return resolve(dirname(rootPath), "packages", "react", "src", "components")
}
export const getComponentList = async () => {
const componentDir = getComponentDir()
const dirs = await readdir(componentDir, { withFileTypes: false })
return dirs.filter((v) => !isFileType(v))
}
export const staticComponentList = [
"box",
"center",
"container",
"flex",
"float",
"grid",
"group",
"highlight",
"portal",
"for",
"client-only",
"show",
"checkmark",
"radiomark",
"heading",
]