|
| 1 | +// Type definitions for lerna 7.0.0 |
| 2 | + |
| 3 | +// NOTE: types taken from @see https://github.com/lerna/lerna/blob/main/libs/core/src/lib/project-graph-with-packages.ts |
| 4 | +// ISSUE: https://github.com/lerna/lerna/issues/3851 |
| 5 | + |
| 6 | +declare module 'lerna/utils' { |
| 7 | + import type { ProjectFileMap, ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode } from '@nx/devkit'; |
| 8 | + |
| 9 | + interface RawManifest { |
| 10 | + name: string; |
| 11 | + version: string; |
| 12 | + description?: string; |
| 13 | + private?: boolean; |
| 14 | + bin?: Record<string, string> | string; |
| 15 | + scripts?: Record<string, string>; |
| 16 | + dependencies?: Record<string, string>; |
| 17 | + devDependencies?: Record<string, string>; |
| 18 | + optionalDependencies?: Record<string, string>; |
| 19 | + peerDependencies?: Record<string, string>; |
| 20 | + publishConfig?: Record<'directory' | 'registry' | 'tag', string>; |
| 21 | + workspaces?: string[]; |
| 22 | + nx?: Record<string, unknown>; |
| 23 | + gitHead?: string; |
| 24 | + lerna?: RawManifestLernaConfig; |
| 25 | + } |
| 26 | + |
| 27 | + interface RawManifestLernaConfig { |
| 28 | + command?: { |
| 29 | + publish?: { |
| 30 | + directory?: string; |
| 31 | + assets?: AssetDefinition[]; |
| 32 | + }; |
| 33 | + }; |
| 34 | + } |
| 35 | + type AssetDefinition = string | { from: string; to: string }; |
| 36 | + |
| 37 | + interface Package extends Omit<RawManifest, 'lerna' | 'nx' | 'gitHead' | 'workspaces'> { |
| 38 | + /** |
| 39 | + * Map-like retrieval of arbitrary values from package.json |
| 40 | + */ |
| 41 | + get(key: string): unknown; |
| 42 | + binLocation: string; |
| 43 | + |
| 44 | + resolved: Record<string, unknown>; |
| 45 | + /** |
| 46 | + * path to package.json |
| 47 | + */ |
| 48 | + manifestLocation: string; |
| 49 | + location: string; |
| 50 | + lernaConfig: RawManifest['lerna'] | undefined; |
| 51 | + } |
| 52 | + |
| 53 | + type ExtendedNpaResult = { |
| 54 | + workspaceSpec?: string; |
| 55 | + workspaceAlias?: string; |
| 56 | + }; |
| 57 | + |
| 58 | + interface ProjectGraphProjectNodeWithPackage extends ProjectGraphProjectNode { |
| 59 | + package: Package | null; |
| 60 | + } |
| 61 | + interface ProjectGraphWorkspacePackageDependency extends ProjectGraphDependency { |
| 62 | + targetVersionMatchesDependencyRequirement: boolean; |
| 63 | + targetResolvedNpaResult: ExtendedNpaResult; |
| 64 | + dependencyCollection: 'dependencies' | 'devDependencies' | 'optionalDependencies'; // lerna doesn't manage peer dependencies |
| 65 | + } |
| 66 | + export interface ProjectGraphWithPackages extends ProjectGraph { |
| 67 | + nodes: Record<string, ProjectGraphProjectNodeWithPackage>; |
| 68 | + localPackageDependencies: Record<string, ProjectGraphWorkspacePackageDependency[]>; |
| 69 | + } |
| 70 | + |
| 71 | + export function detectProjects(): Promise<{ |
| 72 | + projectGraph: ProjectGraphWithPackages; |
| 73 | + projectFileMap: ProjectFileMap; |
| 74 | + }>; |
| 75 | +} |
0 commit comments