(directory: string)
| 206 | }; |
| 207 | |
| 208 | function readComponentFiles(directory: string): ComponentDefinition[] { |
| 209 | const components: ComponentDefinition[] = []; |
| 210 | const files = fs.readdirSync(directory); |
| 211 | |
| 212 | for (const file of files) { |
| 213 | if (file.endsWith('.tsx')) { |
| 214 | const name = path.basename(file, '.tsx'); |
| 215 | const componentPath = path.join(directory, file); |
| 216 | const content = fs.readFileSync(componentPath, 'utf8'); |
| 217 | |
| 218 | const { dependencies, registryDependencies } = extractDependencies(content); |
| 219 | const cssVars = extractCssVars(content); |
| 220 | const tailwind = extractTailwindConfig(content); |
| 221 | |
| 222 | components.push({ |
| 223 | name, |
| 224 | path: componentPath, |
| 225 | dependencies, |
| 226 | registryDependencies, |
| 227 | cssVars, |
| 228 | tailwind, |
| 229 | }); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | return components; |
| 234 | } |
| 235 | |
| 236 | function extractDependencies(content: string): { dependencies: string[], registryDependencies: string[] } { |
| 237 | const importRegex = /import\s+(?:{[^}]+}\s+from\s+)?['"](.+)['"]/g; |
no test coverage detected