(pkg: unknown)
| 59 | } |
| 60 | |
| 61 | export function normalizePackage(pkg: unknown): WorkspacePackage { |
| 62 | if (!pkg || typeof pkg !== 'object') { |
| 63 | throw new Error('workspace package entry must be an object') |
| 64 | } |
| 65 | const rawPackage = pkg as Record<string, unknown> |
| 66 | for (const field of ['path', 'name', 'version']) { |
| 67 | if (typeof rawPackage[field] !== 'string' || rawPackage[field] === '') { |
| 68 | throw new Error(`workspace package entry missing ${field}`) |
| 69 | } |
| 70 | } |
| 71 | return { |
| 72 | path: rawPackage.path as string, |
| 73 | name: rawPackage.name as string, |
| 74 | version: rawPackage.version as string, |
| 75 | dependencies: dependencyMap(rawPackage.dependencies), |
| 76 | optionalDependencies: dependencyMap(rawPackage.optionalDependencies), |
| 77 | peerDependencies: dependencyMap(rawPackage.peerDependencies), |
| 78 | releaseDependencies: stringArray(rawPackage.releaseDependencies), |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | export function readGraph(path: string): WorkspaceGraphFile { |
| 83 | const graph = readJsonFile(path) |
no test coverage detected