(startDir: string)
| 4 | // Walk up from a piece folder to the monorepo root (the package.json that declares |
| 5 | // `workspaces`). Lets bundling run from any cwd — e.g. a per-package turbo task. |
| 6 | export function findRepoRoot(startDir: string): string { |
| 7 | let dir = startDir |
| 8 | while (true) { |
| 9 | const pkgPath = join(dir, 'package.json') |
| 10 | if (existsSync(pkgPath)) { |
| 11 | const pkg = JSON.parse(readFileSync(pkgPath).toString()) |
| 12 | if (Array.isArray(pkg.workspaces)) { |
| 13 | return dir |
| 14 | } |
| 15 | } |
| 16 | const parent = dirname(dir) |
| 17 | if (parent === dir) { |
| 18 | throw new Error(`[findRepoRoot] no workspace root found above ${startDir}`) |
| 19 | } |
| 20 | dir = parent |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | export function buildWorkspaceVersionMap(rootDir: string): Map<string, string> { |
| 25 | const versionMap = new Map<string, string>() |
no test coverage detected