@teambit/workspace
Version:
49 lines (48 loc) • 2.57 kB
TypeScript
import { Graph } from '@teambit/graph.cleargraph';
import type { ComponentID } from '@teambit/component';
import type { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';
import type { DepEdgeType } from '@teambit/graph';
import type { Logger } from '@teambit/logger';
import type { Workspace } from './workspace';
export declare function lifecycleToDepType(compDep: ComponentDependency): DepEdgeType;
export declare class GraphIdsFromFsBuilder {
private workspace;
private logger;
private dependencyResolver;
private shouldThrowOnMissingDep;
private graph;
private completed;
private depth;
private consumer;
private loadedComponents;
private importedIds;
private shouldThrowOnInvalidDeps;
constructor(workspace: Workspace, logger: Logger, dependencyResolver: DependencyResolverMain, shouldThrowOnMissingDep?: boolean);
/**
* create a graph with all dependencies and flattened dependencies of the given components.
* the nodes are component-ids and the edges has a label of the dependency type.
* to get some info about this the graph build take a look into build-graph-from-fs.buildGraph() docs.
*/
buildGraph(ids: ComponentID[]): Promise<Graph<ComponentID, DepEdgeType>>;
private processManyComponents;
/**
* only for components from the workspace that can be modified to add/remove dependencies, we need to make sure that
* all their dependencies are imported.
* once a component from scope is imported, we know that either we have its dependency graph or all flattened deps
*/
private importObjects;
private processOneComponent;
/**
* this is tricky.
* the component is in the workspace so it can be modified. dependencies can be added/removed/updated/downgraded.
* we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.
* if we can't use it, we have to recursively load dependencies components and get the data from there.
* to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,
* and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or
* it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components
* and get its dependencies.
*/
private processCompFromWorkspaceWithGraph;
private addDepEdge;
private loadManyComponents;
}