MCPcopy Create free account
hub / github.com/DarkInventor/easy-ui / readComponentFiles

Function readComponentFiles

scripts/build.ts:208–234  ·  view source on GitHub ↗
(directory: string)

Source from the content-addressed store, hash-verified

206};
207
208function 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
236function extractDependencies(content: string): { dependencies: string[], registryDependencies: string[] } {
237 const importRegex = /import\s+(?:{[^}]+}\s+from\s+)?['"](.+)['"]/g;

Callers 1

mainFunction · 0.85

Calls 3

extractDependenciesFunction · 0.85
extractCssVarsFunction · 0.85
extractTailwindConfigFunction · 0.85

Tested by

no test coverage detected