| 64 | } |
| 65 | |
| 66 | async function isWorkspacePackageJson(directoryPath: string): Promise<boolean> { |
| 67 | const packageJsonPath = path.join(directoryPath, 'package.json'); |
| 68 | try { |
| 69 | const content = await fs.readFile(packageJsonPath, 'utf-8'); |
| 70 | const parsed = JSON.parse(content) as { workspaces?: unknown }; |
| 71 | if (Array.isArray(parsed.workspaces)) { |
| 72 | return parsed.workspaces.length > 0; |
| 73 | } |
| 74 | if ( |
| 75 | parsed.workspaces && |
| 76 | typeof parsed.workspaces === 'object' && |
| 77 | !Array.isArray(parsed.workspaces) && |
| 78 | 'packages' in parsed.workspaces |
| 79 | ) { |
| 80 | return Array.isArray((parsed.workspaces as { packages?: unknown }).packages); |
| 81 | } |
| 82 | return false; |
| 83 | } catch { |
| 84 | return false; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | async function classifyDirectory( |
| 89 | directoryPath: string, |