File size: 846 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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",
]