* 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)
| 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 | } |
| 140 | export const workspaceManager = new Workspace(); |
no outgoing calls
no test coverage detected