UNPKG

@teambit/workspace

Version:
122 lines (121 loc) 5.53 kB
import type { ExtensionDataList } from '@teambit/legacy.extension-data'; import type { Harmony } from '@teambit/harmony'; import type { AspectDefinition, AspectLoaderMain } from '@teambit/aspect-loader'; import { ComponentID } from '@teambit/component-id'; import type { LoadAspectsOptions, ResolveAspectsOptions } from '@teambit/component'; import type { ScopeMain } from '@teambit/scope'; import type { Logger } from '@teambit/logger'; import type { EnvsMain } from '@teambit/envs'; import type { DependencyResolverMain } from '@teambit/dependency-resolver'; import type { Workspace } from './workspace'; import type { OnAspectsResolveSlot, OnRootAspectAddedSlot } from './workspace.main.runtime'; import type { ConfigStoreMain } from '@teambit/config-store'; export type GetConfiguredUserAspectsPackagesOptions = { externalsOnly?: boolean; }; export type WorkspaceLoadAspectsOptions = LoadAspectsOptions & { useScopeAspectsCapsule?: boolean; runSubscribers?: boolean; skipDeps?: boolean; resolveEnvsFromRoots?: boolean; }; export type AspectPackage = { packageName: string; version: string; }; export declare class WorkspaceAspectsLoader { private workspace; private scope; private aspectLoader; private envs; private dependencyResolver; private logger; private configStore; private harmony; private onAspectsResolveSlot; private onRootAspectAddedSlot; private resolveAspectsFromNodeModules; private resolveEnvsFromRoots; private consumer; private resolvedInstalledAspects; constructor(workspace: Workspace, scope: ScopeMain, aspectLoader: AspectLoaderMain, envs: EnvsMain, dependencyResolver: DependencyResolverMain, logger: Logger, configStore: ConfigStoreMain, harmony: Harmony, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, resolveAspectsFromNodeModules?: boolean, resolveEnvsFromRoots?: boolean); /** * load aspects from the workspace and if not exists in the workspace, load from the node_modules. * keep in mind that the graph may have circles. */ loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: string, opts?: WorkspaceLoadAspectsOptions): Promise<string[]>; private loadFromScopeAspectsCapsule; throwWsJsoncAspectNotFoundError(err: any): void; private loadAspectDefsByOrder; resolveAspects(runtimeName?: string, componentIds?: ComponentID[], opts?: ResolveAspectsOptions): Promise<AspectDefinition[]>; shouldUseHashForCapsules(): boolean; getCapsulePath(): string; private logFoundWorkspaceVsScope; use(aspectIdStr: string): Promise<string>; getConfiguredUserAspectsPackages(options?: GetConfiguredUserAspectsPackagesOptions): Promise<AspectPackage[]>; private aspectDefsToRequireableComponents; private linkIfMissingWorkspaceAspects; /** * This will return a resolver that knows to resolve aspects which are part of the workspace. * means aspects exist in the bitmap file * @param stringIds * @param runtimeName * @returns */ private getWorkspaceAspectResolver; private runOnAspectsResolveFunctions; private getOnAspectsResolveFunctions; private runOnRootAspectAddedFunctions; private getOnRootAspectAddedFunctions; /** * This will return a resolver that knows to resolve aspects which are not part of the workspace. * means aspects that does not exist in the bitmap file * instead it will resolve them from the node_modules recursively * @param graph * @param rootIds * @param runtimeName * @returns */ private getInstalledAspectResolver; private resolveInstalledAspectRecursively; /** * Create a graph of aspects without the core aspects. * @param components * @param isAspect * @returns */ private getAspectsGraphWithoutCore; /** * Load all unloaded extensions from an extension list * this will resolve the extensions from the scope aspects capsules if they are not in the ws * Only use it for component extensions * for workspace/scope root aspect use the load aspects directly * * The reason we are loading component extensions with "scope aspects capsules" is because for component extensions * we might have the same extension in multiple versions * (for example I might have 2 components using different versions of the same env) * in such case, I can't install both version into the root of the node_modules so I need to place it somewhere else (capsules) * @param extensions list of extensions with config to load */ loadComponentsExtensions(extensions: ExtensionDataList, originatedFrom?: ComponentID, opts?: WorkspaceLoadAspectsOptions): Promise<void>; private isAspect; /** * same as `this.importAndGetMany()` with a specific error handling of ComponentNotFound */ private importAndGetAspects; /** * split the provided components into 2 groups, one which are workspace components and the other which are not. * @param components * @returns */ private groupComponentsByWorkspaceExistence; private groupComponentsByLoadFromRootComps; private shouldLoadFromRootComps; /** * split the provided components into 2 groups, one which are workspace components and the other which are not. * @param components * @returns */ private groupAspectDefsByWorkspaceExistence; private groupIdsByWorkspaceExistence; }