import type { CLIMain } from '@teambit/cli'; import type { ComponentID, ComponentIdList } from '@teambit/component-id'; import type { DependencyResolverMain } from '@teambit/dependency-resolver'; import type { Workspace } from '@teambit/workspace'; import type { ConsumerComponent, DependencyLoaderOpts } from '@teambit/legacy.consumer-component'; import type { DependenciesOverridesData } from '@teambit/legacy.consumer-config'; import type { DevFilesMain } from '@teambit/dev-files'; import type { ComponentIdGraph, GraphMain } from '@teambit/graph'; import type { AspectLoaderMain } from '@teambit/aspect-loader'; import type { ScopeMain } from '@teambit/scope'; import type { DependenciesData, OverridesDependenciesData } from './dependencies-loader/dependencies-data'; import type { RemoveDependenciesFlags, SetDependenciesFlags } from './dependencies-cmd'; import type { DebugDependencies } from './dependencies-loader/auto-detect-deps'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { Component } from '@teambit/component'; import type { IssuesMain } from '@teambit/issues'; export type RemoveDependencyResult = { id: ComponentID; removedPackages: string[]; }; export type SetDependenciesResult = { changedComps: string[]; addedPackages: Record; }; export type DependenciesResultsDebug = DebugDependencies & OverridesDependenciesData & { coreAspects: string[]; sources: { id: string; source: string; }[]; }; export type DependenciesResults = { graph: ComponentIdGraph; id: ComponentID; }; export type BlameResult = { snap: string; tag?: string; author: string; date: string; message: string; version: string; }; export type VersionOrigin = { version: string; envs: string[]; components: Array<{ componentId: string; envId: string; }>; }; export interface DiagnosisReport { componentCount: number; /** total directories in node_modules/.pnpm — the actual installed copies on disk */ pnpmStoreEntries: number; /** unique package names (regardless of version/peer combo) */ uniquePackages: number; /** packages that appear in more than one .pnpm directory (version spread + peer permutations) */ duplicatedPackages: number; versionSpread: Array<{ packageName: string; /** how many distinct versions exist across components */ versionCount: number; versions: string[]; /** how many actual .pnpm directories this package has (includes peer permutations) */ installedCopies: number; impact: 'HIGH' | 'MEDIUM' | 'LOW'; }>; peerPermutations: Array<{ packageName: string; /** declared peer-dep version ranges across components */ versions: string[]; /** actual .pnpm directories for this package (0 means declared but not installed) */ installedCopies: number; versionOrigins: VersionOrigin[]; }>; } export declare class DependenciesMain { private workspace; private scope; private dependencyResolver; private devFiles; private aspectLoader; private graph; private logger; constructor(workspace: Workspace, scope: ScopeMain, dependencyResolver: DependencyResolverMain, devFiles: DevFilesMain, aspectLoader: AspectLoaderMain, graph: GraphMain, logger: Logger); setPeer(componentId: string, range?: string): Promise; unsetPeer(componentId: string): Promise; setDependency(componentPattern: string, packages: string[], options?: SetDependenciesFlags): Promise; removeDependency(componentPattern: string, packages: string[], options?: RemoveDependenciesFlags, removeOnlyIfExists?: boolean): Promise; /** * add an issue for dependencies on workspace components whose version is set in the config (e.g. "bit deps set"). * such a dependency doesn't follow the workspace version of the component, e.g. it's not auto-tagged with it. * it's not a tag blocker, it's there to make it visible, because often a version is set this way when not needed. */ addPinnedDependenciesIssues(components: Component[], issuesToIgnore: string[]): Promise; reset(componentPattern: string): Promise; eject(componentPattern: string): Promise; /** * Find circular dependencies in the workspace component graph. * Returns an array of cycles, where each cycle is an array of component-id strings * (with the first component repeated at the end to make the circular path visible). */ getCircularDependencies(includeDeps?: boolean): Promise; getDependencies(id: string, scope?: boolean): Promise; loadDependencies(component: ConsumerComponent, opts: DependencyLoaderOpts): Promise<{ dependenciesData: DependenciesData; overridesDependencies: import("./dependencies-loader/overrides-dependencies").default; debugDependenciesData: DebugDependencies; }>; /** * load dependencies without the need for the workspace. * the "auto-detect" are passed here as "dependenciesData". the "overrides", such as dependencies from the env, * are calculated here. * eventually all these dependencies are added to the ConsumerComponent object. * see ApplyOverrides.workspaceComponentIds for "workspaceComponentIds". */ loadDependenciesFromScope(component: ConsumerComponent, dependenciesData: Partial, autoDetectOverrides?: DependenciesOverridesData, workspaceComponentIds?: ComponentIdList): Promise; debugDependencies(id: string): Promise; /** * helps determine what snap/tag changed a specific dependency. * the results are sorted from the oldest to newest. */ blame(compName: string, depName: string): Promise; usageDeep(depName: string, opts?: { depth?: number; }): Promise; /** * @param depName either component-id-string or package-name (of the component or not component) * @returns a map of component-id-string to the version of the dependency */ usage(depName: string): Promise<{ [compIdStr: string]: string; }>; /** * Analyze the workspace's installed dependencies to detect bloat and duplication. * Scans node_modules/.pnpm for ground truth on actual installed copies. * Only works with pnpm-managed workspaces. */ diagnose(): Promise; /** * Parse a .pnpm directory name to extract the package name. * Format: @scope+name@version_peers... or name@version_peers... */ private parsePnpmDirPackageName; /** * The per-copy directory names of everything the last install materialized for this workspace. * * Normally these are the directories inside `node_modules/.pnpm`. With the global virtual store * enabled the copies live in the shared store instead - and that store holds every workspace's * packages, so it cannot be scanned for this workspace's ground truth. The current lockfile pnpm * writes into `node_modules/.pnpm` records exactly what was materialized here, and its dep paths * map one-to-one onto the directory names of the project-local layout. */ private readVirtualStoreEntries; /** Inspect all .pnpm entries for a specific package, showing each installed copy and its peer combo. */ diagnoseDrillDown(packageName: string): Promise<{ packageName: string; pnpmDirs: Array<{ version: string; peerSuffix: string | null; }>; }>; private getPackageNameAndVerResolved; private splitPkgToNameAndVer; static slots: never[]; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static provider([cli, workspace, depsResolver, devFiles, aspectLoader, scope, graph, loggerMain, issues]: [ CLIMain, Workspace, DependencyResolverMain, DevFilesMain, AspectLoaderMain, ScopeMain, GraphMain, LoggerMain, IssuesMain ]): Promise; } export default DependenciesMain;