MCPcopy Create free account
hub / github.com/MigoXLab/coderio / resolveComponentPath

Method resolveComponentPath

src/utils/workspace.ts:117–138  ·  view source on GitHub ↗

* Resolve component alias path to absolute filesystem path. * * Handles various path formats: * - @/components/Button → /workspace/my-app/src/components/Button/index.tsx * - @/src/components/Button → /workspace/my-app/src/components/Button/index.tsx * - components/Button → /

(aliasPath: string)

Source from the content-addressed store, hash-verified

115 *
116 */
117 resolveComponentPath(aliasPath: string): string {
118 // Normalize path separators for robustness across platforms.
119 const normalizedAlias = aliasPath.replace(/\\/g, '/');
120
121 // Step 1: Strip @/ prefix if present
122 let relativePath = normalizedAlias.startsWith('@/')
123 ? normalizedAlias.substring(2) // '@/components/Button' → 'components/Button'
124 : normalizedAlias;
125
126 // Step 2: Strip 'src/' prefix if present (resolveAppSrc adds it)
127 // '@/src/components/Button' → 'components/Button'
128 if (relativePath.startsWith('src/')) {
129 relativePath = relativePath.substring(4);
130 }
131
132 // Step 3: Ensure path ends with /index.tsx (all components follow this convention)
133 if (!relativePath.endsWith('.tsx') && !relativePath.endsWith('.ts')) {
134 relativePath = `${relativePath}/index.tsx`;
135 }
136
137 return relativePath;
138 }
139}
140export const workspaceManager = new Workspace();

Callers 6

extractComponentPathsFunction · 0.80
generateFrameFunction · 0.80
generateComponentFunction · 0.80
workspace.test.tsFile · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected