MCPcopy Index your code
hub / github.com/craftreactnative/ui / getAvailableComponents

Function getAvailableComponents

cli/src/utils/component-manager.ts:59–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 * Gets list of all available components by scanning for directories with info.json
58 */
59export async function getAvailableComponents(): Promise<string[]> {
60 const { componentsPath } = await ensureSourcePaths();
61 if (!(await fs.pathExists(componentsPath))) {
62 return [];
63 }
64
65 const dirs = await fs.readdir(componentsPath);
66 const components: string[] = [];
67
68 for (const dir of dirs) {
69 const componentPath = path.join(componentsPath, dir);
70 const stat = await fs.stat(componentPath);
71
72 if (stat.isDirectory()) {
73 const infoPath = path.join(componentPath, "info.json");
74 if (await fs.pathExists(infoPath)) {
75 components.push(dir);
76 }
77 }
78 }
79
80 return components;
81}
82
83/**
84 * Resolves all dependencies for a component including nested dependencies

Callers 2

cli.tsFile · 0.90
addCommandFunction · 0.90

Calls 1

ensureSourcePathsFunction · 0.85

Tested by

no test coverage detected