UNPKG

@teambit/workspace

Version:
641 lines (639 loc) • 32 kB
import { Graph } from '@teambit/graph.cleargraph'; import type { IssuesList } from '@teambit/component-issues'; import type { AspectLoaderMain, AspectDefinition } from '@teambit/aspect-loader'; import type { ComponentMain, Component, ComponentFactory, InvalidComponent, ResolveAspectsOptions, AspectList } from '@teambit/component'; import type { ComponentScopeDirMap, WorkspaceConfig } from '@teambit/config'; import type { CurrentPkg, DependencyResolverMain, DependencyList, VariantPolicyConfigObject, VariantPolicyConfigArr } from '@teambit/dependency-resolver'; import type { EnvsMain, EnvJsonc } from '@teambit/envs'; import type { GraphqlMain } from '@teambit/graphql'; import type { Harmony } from '@teambit/harmony'; import type { Logger } from '@teambit/logger'; import type { ScopeMain } from '@teambit/scope'; import type { VariantsMain } from '@teambit/variants'; import { ComponentID, ComponentIdList } from '@teambit/component-id'; import { BitId } from '@teambit/legacy-bit-id'; import type { LaneId } from '@teambit/lane-id'; import type { Consumer } from '@teambit/legacy.consumer'; import type { GetBitMapComponentOptions } from '@teambit/legacy.bit-map'; import { ComponentsList } from '@teambit/legacy.component-list'; import { ExtensionDataList } from '@teambit/legacy.extension-data'; import type { PathOsBased, PathOsBasedRelative, PathOsBasedAbsolute } from '@teambit/toolbox.path.path'; import type { CompIdGraph, DepEdgeType } from '@teambit/graph'; import type { Dependency as LegacyDependency } from '@teambit/legacy.consumer-component'; import { ConsumerComponent } from '@teambit/legacy.consumer-component'; import type { WatchOptions } from '@teambit/watcher'; import type { ComponentLog, Lane } from '@teambit/objects'; import type { JsonVinyl } from '@teambit/component.sources'; import { SourceFile } from '@teambit/component.sources'; import type { GlobalConfigMain } from '@teambit/global-config'; import { ComponentConfigFile } from './component-config-file'; import type { OnComponentAdd, OnComponentChange, OnComponentEventResult, OnComponentLoad, OnComponentRemove } from './on-component-events'; import type { WorkspaceExtConfig } from './types'; import { ComponentStatus } from './workspace-component/component-status'; import type { OnAspectsResolve, OnAspectsResolveSlot, OnBitmapChange, OnBitmapChangeSlot, OnWorkspaceConfigChange, OnWorkspaceConfigChangeSlot, OnComponentAddSlot, OnComponentChangeSlot, OnComponentLoadSlot, OnComponentRemoveSlot, OnRootAspectAdded, OnRootAspectAddedSlot } from './workspace.main.runtime'; import type { ComponentLoadOptions } from './workspace-component/workspace-component-loader'; import { WorkspaceComponentLoader } from './workspace-component/workspace-component-loader'; import type { ShouldLoadFunc } from './build-graph-from-fs'; import { BitMap } from './bit-map'; import type { MergeOptions as BitmapMergeOptions } from './bit-map'; import type { AspectPackage, GetConfiguredUserAspectsPackagesOptions, WorkspaceLoadAspectsOptions } from './workspace-aspects-loader'; import { WorkspaceAspectsLoader } from './workspace-aspects-loader'; import type { MergeConflictFile } from './merge-conflict-file'; import { CompFiles } from './workspace-component/comp-files'; import { Filter } from './filter'; import type { ComponentStatusLegacy, ComponentStatusResult } from './workspace-component/component-status-loader'; import type { ConfigStoreMain, Store } from '@teambit/config-store'; import type { DependenciesOverridesData } from '@teambit/legacy.consumer-config'; export type EjectConfResult = { configPath: string; }; export type ClearCacheOptions = { skipClearFailedToLoadEnvs?: boolean; }; /** * Field used to mark aspect config as "specific" (set via .bitmap or component.json). * When __specific is true, this config takes precedence over workspace variants during merging. * See https://github.com/teambit/bit/pull/5342 for original implementation. * * Important behavior for dependency-resolver aspect: * - Dependencies set via workspace variants are saved WITHOUT __specific (until first `bit deps set`) * - Once `bit deps set` is called, the entire dependency-resolver config gets __specific: true * - From that point forward, ALL deps in that aspect are considered "specific" */ export declare const AspectSpecificField = "__specific"; export declare const ComponentAdded = "componentAdded"; export declare const ComponentChanged = "componentChanged"; export declare const ComponentRemoved = "componentRemoved"; export interface EjectConfOptions { propagate?: boolean; override?: boolean; } export type ComponentExtensionsOpts = { loadExtensions?: boolean; }; type ComponentExtensionsResponse = { extensions: ExtensionDataList; beforeMerge: Array<{ extensions: ExtensionDataList; origin: ExtensionsOrigin; extraData: any; }>; errors?: Error[]; envId?: string; }; export type ExtensionsOrigin = 'BitmapFile' | 'ModelSpecific' | 'ModelNonSpecific' | 'ConfigMerge' | 'WorkspaceVariants' | 'ComponentJsonFile' | 'FinalAfterMerge'; /** * API of the Bit Workspace */ export declare class Workspace implements ComponentFactory { private config; /** * private access to the legacy consumer instance. */ consumer: Consumer; /** * access to the workspace `Scope` instance */ readonly scope: ScopeMain; /** * access to the `ComponentProvider` instance */ private componentAspect; private dependencyResolver; readonly variants: VariantsMain; private aspectLoader; readonly logger: Logger; /** * private reference to the instance of Harmony. */ private harmony; /** * on component load slot. */ onComponentLoadSlot: OnComponentLoadSlot; /** * on component change slot. */ private onComponentChangeSlot; readonly envs: EnvsMain; readonly globalConfig: GlobalConfigMain; /** * on component add slot. */ private onComponentAddSlot; private onComponentRemoveSlot; private onAspectsResolveSlot; private onRootAspectAddedSlot; private graphql; private onBitmapChangeSlot; private onWorkspaceConfigChangeSlot; private configStore; private warnedAboutMisconfiguredEnvs; priority: boolean; owner?: string; componentsScopeDirsMap: ComponentScopeDirMap; componentLoader: WorkspaceComponentLoader; private componentStatusLoader; bitMap: BitMap; /** * Indicate that we are now running installation process * This is important to know to ignore missing modules across different places */ inInstallContext: boolean; /** * Indicate that we done with the package manager installation process * This is important to skip stuff when package manager install is not done yet */ inInstallAfterPmContext: boolean; private componentLoadedSelfAsAspects; private aspectsMerger; /** * Components paths are calculated from the component package names of the workspace * They are used in webpack configuration to only track changes from these paths inside `node_modules` */ private componentPathsRegExps; private _componentList; localAspects: Record<string, string>; filter: Filter; constructor(config: WorkspaceExtConfig, /** * private access to the legacy consumer instance. */ consumer: Consumer, /** * access to the workspace `Scope` instance */ scope: ScopeMain, /** * access to the `ComponentProvider` instance */ componentAspect: ComponentMain, dependencyResolver: DependencyResolverMain, variants: VariantsMain, aspectLoader: AspectLoaderMain, logger: Logger, /** * private reference to the instance of Harmony. */ harmony: Harmony, /** * on component load slot. */ onComponentLoadSlot: OnComponentLoadSlot, /** * on component change slot. */ onComponentChangeSlot: OnComponentChangeSlot, envs: EnvsMain, globalConfig: GlobalConfigMain, /** * on component add slot. */ onComponentAddSlot: OnComponentAddSlot, onComponentRemoveSlot: OnComponentRemoveSlot, onAspectsResolveSlot: OnAspectsResolveSlot, onRootAspectAddedSlot: OnRootAspectAddedSlot, graphql: GraphqlMain, onBitmapChangeSlot: OnBitmapChangeSlot, onWorkspaceConfigChangeSlot: OnWorkspaceConfigChangeSlot, configStore: ConfigStoreMain); private validateConfig; get componentList(): ComponentsList; /** * root path of the Workspace. */ get path(): string; /** * Get the location of the bit roots folder */ get rootComponentsPath(): string; /** get the `node_modules` folder of this workspace */ private get modulesPath(); get isLegacy(): boolean; registerOnComponentLoad(loadFn: OnComponentLoad): this; registerOnComponentChange(onComponentChangeFunc: OnComponentChange): this; registerOnComponentAdd(onComponentAddFunc: OnComponentAdd): this; registerOnComponentRemove(onComponentRemoveFunc: OnComponentRemove): this; registerOnBitmapChange(OnBitmapChangeFunc: OnBitmapChange): this; registerOnWorkspaceConfigChange(onWorkspaceConfigChangeFunc: OnWorkspaceConfigChange): void; registerOnAspectsResolve(onAspectsResolveFunc: OnAspectsResolve): this; registerOnRootAspectAdded(onRootAspectAddedFunc: OnRootAspectAdded): this; /** * name of the workspace as configured in either `workspace.json`. * defaults to workspace root directory name. */ get name(): string; get icon(): string; getConfigStore(): Store; getAutoTagInfo(changedComponents: ComponentIdList): Promise<import("./auto-tag").AutoTagResult[]>; listAutoTagPendingComponentIds(): Promise<ComponentID[]>; hasModifiedDependencies(component: Component): Promise<boolean>; /** * get Component issues */ getComponentIssues(component: Component): IssuesList | null; /** * provides status of all components in the workspace. */ getComponentStatus(component: Component): Promise<ComponentStatus>; /** * list all workspace components. */ list(filter?: { offset: number; limit: number; }, loadOpts?: ComponentLoadOptions): Promise<Component[]>; listWithInvalid(loadOpts?: ComponentLoadOptions): Promise<{ components: Component[]; invalidComponents: InvalidComponent[]; }>; /** * list all invalid components. * (see the invalid criteria in ConsumerComponent.isComponentInvalidByErrorType()) */ listInvalid(): Promise<InvalidComponent[]>; /** * get ids of all workspace components. * deleted components are filtered out. (use this.listIdsIncludeRemoved() if you need them) */ listIds(): ComponentIdList; listIdsIncludeRemoved(): ComponentIdList; /** * whether the given component-id is part of the workspace. default to check for the exact version */ hasId(componentId: ComponentID, opts?: { includeDeleted?: boolean; ignoreVersion?: boolean; }): boolean; /** * given component-ids, return the ones that are part of the workspace */ filterIds(ids: ComponentID[]): Promise<ComponentID[]>; /** * whether or not a workspace has a component with the given name */ hasName(name: string): Promise<boolean>; /** * Check if a specific id exist in the workspace or in the scope * @param componentId */ hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>; /** * list all modified components in the workspace. */ modified(loadOpts?: ComponentLoadOptions): Promise<Component[]>; /** * list all new components in the workspace. */ newComponents(): Promise<Component[]>; newComponentIds(): Promise<ComponentID[]>; locallyDeletedIds(): Promise<ComponentID[]>; duringMergeIds(): Promise<ComponentID[]>; /** * @deprecated use `listIds()` instead. * get all workspace component-ids */ getAllComponentIds(): ComponentID[]; listTagPendingIds(): Promise<ComponentID[]>; /** * list all components that can be tagged. (e.g. when tagging/snapping with --unmodified). * which are all components in the workspace, include locally deleted components. */ listPotentialTagIds(): Promise<ComponentID[]>; getNewAndModifiedIds(): Promise<ComponentID[]>; newAndModified(): Promise<Component[]>; getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string): Promise<ComponentLog[]>; getGraph(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>; getGraphIds(ids?: ComponentID[], shouldThrowOnMissingDep?: boolean): Promise<CompIdGraph>; getUnavailableOnMainComponents(): Promise<ComponentID[]>; getDependencies(component: Component): DependencyList; getSavedGraphOfComponentIfExist(component: Component): Promise<Graph<ComponentID, DepEdgeType> | null>; /** * given component ids, find their dependents in the workspace */ getDependentsIds(ids: ComponentID[], filterOutNowWorkspaceIds?: boolean): Promise<ComponentID[]>; createAspectList(extensionDataList: ExtensionDataList): Promise<AspectList>; private extensionDataEntryToAspectEntry; /** * this is not the complete legacy component (ConsumerComponent), it's missing dependencies and hooks from Harmony * are skipped. do not trust the data you get from this method unless you know what you're doing. */ getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>; getFilesModification(id: ComponentID): Promise<CompFiles>; /** * get a component from workspace * @param id component ID */ get(componentId: ComponentID, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean, loadOpts?: ComponentLoadOptions): Promise<Component>; getConfiguredUserAspectsPackages(options: GetConfiguredUserAspectsPackagesOptions): Promise<AspectPackage[]>; /** * clears workspace, scope and all components caches. * doesn't clear the dependencies-data from the filesystem-cache. */ clearCache(options?: ClearCacheOptions): Promise<void>; /** * clear the cache of all components in the workspace. * doesn't clear the dependencies-data from the filesystem-cache. */ clearAllComponentsCache(): void; clearComponentCache(id: ComponentID): void; clearComponentsCache(ids: ComponentID[]): void; warmCache(): Promise<void>; getWorkspaceConfig(): WorkspaceConfig; cleanFromConfig(ids: ComponentID[]): Promise<boolean>; /** * when tagging/snapping a component, its config data is written to the staged config. it helps for "bit reset" to * revert it back. * this method removes entries from that files. used by "bit export" and "bit remove". * in case the component is not found in the staged config, it doesn't throw an error. it simply ignores it. */ removeFromStagedConfig(ids: ComponentID[]): Promise<void>; triggerOnComponentChange(id: ComponentID, files: PathOsBasedAbsolute[], removedFiles: PathOsBasedAbsolute[], watchOpts: WatchOptions): Promise<OnComponentEventResult[]>; triggerOnComponentAdd(id: ComponentID, watchOpts: WatchOptions, loadOptions?: ComponentLoadOptions): Promise<OnComponentEventResult[]>; triggerOnComponentRemove(id: ComponentID): Promise<OnComponentEventResult[]>; triggerOnBitmapChange(): Promise<void>; /** * the purpose is mostly to reload the workspace config when it changes, so entries like "defaultScope" are updated. * it also updates the DependencyResolver config. I couldn't find a good way to update all aspects in workspace.jsonc. */ triggerOnWorkspaceConfigChange(): Promise<void>; getState(id: ComponentID, hash: string): Promise<import("@teambit/component").State>; getSnap(id: ComponentID, hash: string): Promise<import("@teambit/component").Snap>; getCurrentLaneId(): LaneId; getCurrentLaneObject(): Promise<Lane | undefined>; isOnMain(): boolean; isOnLane(): boolean; /** * if checked out to a lane and the lane exists in the remote, * return the remote lane. otherwise, return null. */ getCurrentRemoteLane(): Promise<Lane | null>; getDefaultExtensions(): ExtensionDataList; getComponentConfigVinylFile(id: ComponentID, options: EjectConfOptions, excludeLocalChanges?: boolean): Promise<JsonVinyl>; private removeEnvVersionIfExistsLocally; ejectMultipleConfigs(ids: ComponentID[], options: EjectConfOptions): Promise<EjectConfResult[]>; getAspectConfigForComponent(id: ComponentID, aspectId: string): Promise<object | undefined>; getExtensionsFromScopeAndSpecific(id: ComponentID, excludeComponentJson?: boolean): Promise<ExtensionDataList>; /** * @deprecated use `this.idsByPattern` instead for consistency. also, it supports negation and list of patterns. * * load components into the workspace through a variants pattern. * @param pattern variants. * @param scope scope name. */ byPattern(pattern: string, scope?: string): Promise<Component[]>; hasPattern(strArr: string[]): boolean; isPattern(str: string): boolean; /** * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma. * it supports negate (!) character to exclude ids. */ idsByPattern(pattern: string, throwForNoMatch?: boolean, opts?: { includeDeleted?: boolean; }): Promise<ComponentID[]>; filterIdsFromPoolIdsByPattern(pattern: string, ids: ComponentID[], throwForNoMatch?: boolean): Promise<ComponentID[]>; /** * useful for workspace commands, such as `bit build`, `bit compile`. * by default, it should be running on new and modified components. * a user can specify `--all` to run on all components or specify a pattern to limit to specific components. * some commands such as build/test needs to run also on the dependents. */ getComponentsByUserInput(all?: boolean, pattern?: string, includeDependents?: boolean): Promise<Component[]>; getComponentsUsingEnv(env: string, ignoreVersion?: boolean, throwIfNotFound?: boolean): Promise<Component[]>; getMany(ids: Array<ComponentID>, loadOpts?: ComponentLoadOptions, throwOnFailure?: boolean): Promise<Component[]>; getManyByLegacy(components: ConsumerComponent[], loadOpts?: ComponentLoadOptions): Promise<Component[]>; /** * don't throw an error if the component was not found, simply return undefined. */ getIfExist(componentId: ComponentID): Promise<Component | undefined>; /** * @deprecated use `hasId` with "ignoreVersion: true" instead. */ exists(componentId: ComponentID, opts?: { includeDeleted?: boolean; }): boolean; getIdIfExist(componentId: ComponentID): ComponentID | undefined; mergeBitmaps(bitmapContent: string, otherBitmapContent: string, opts?: BitmapMergeOptions): string; /** * This will make sure to fetch the objects prior to load them * do not use it if you are not sure you need it. * It will influence the performance * currently it used only for get many of aspects * @param ids */ importAndGetMany(ids: Array<ComponentID>, reason?: string, loadOpts?: ComponentLoadOptions, throwOnError?: boolean): Promise<Component[]>; /** * This is happening when the user is running "git pull", which updates ".bitmap" file, but the local scope objects * are not updated yet ("bit import" is not run yet). * Although it might happen on a lane. This is rare. Because using git with bit normally means that locally you don't have * any lane. The CI is the one that creates the lanes. * The following conditions are checked: * 1. we're on main. * 2. git is enabled. * 3. components on .bitmap has tags that are not in the local scope. * * It is designed to be performant. On mac M1 with 337 components, it takes around 100ms. * * @returns array of component IDs that have tags in .bitmap but not in local scope, or empty array if not outdated */ private getOutdatedIdsAgainstGit; /** * This is relevant when the user is running "git pull", which updates ".bitmap" file, but the local scope objects * are not updated yet ("bit import" is not run yet). In case it found outdated components, it imports them. * * Important: this is only for main (not lanes) and only when using git and only for tags, not snaps. * see `getOutdatedIdsAgainstGit` for more info. */ importObjectsIfOutdatedAgainstBitmap(): Promise<void>; /** * This is pretty much the same as `importer.importCurrentObjects`. * The reason for the duplication is that many aspects can't depend on the `importer` aspect, due to circular dependencies. * The importer aspect is reacher in a way that it shows the results of what was imported by comparing the before and after. */ importCurrentObjects(compIds?: ComponentID[]): Promise<void>; importCurrentLaneIfMissing(): Promise<Lane | undefined>; use(aspectIdStr: string): Promise<string>; unuse(aspectIdStr: string): Promise<boolean>; write(component: Component, rootPath?: string): Promise<void>; /** * @todo: the return path here is Linux when asking for relative and os-based when asking for absolute. fix this to be consistent. * * Get the component root dir in the file system (relative to workspace or full) * @param componentId * @param relative return the path relative to the workspace or full path */ componentDir(componentId: ComponentID, bitMapOptions?: GetBitMapComponentOptions, options?: { relative: boolean; }): PathOsBased; /** * component's files in the workspace are symlinked to the node_modules, and a package.json file is generated on that * package directory to simulate a valid node package. * @returns the package directory inside the node_module. * by default the absolute path, unless `options.relative` was set */ componentPackageDir(component: Component, options?: { relative: boolean; }): string; componentPackageName(component: Component): string; private componentDirFromLegacyId; componentDirToAbsolute(relativeComponentDir: PathOsBasedRelative): PathOsBasedAbsolute; /** * @deprecated long long ago we added it to the componentId object. use `componentId.scope` instead. */ componentDefaultScope(componentId: ComponentID): Promise<string | undefined>; componentDefaultScopeFromComponentDirAndName(relativeComponentDir: PathOsBasedRelative, name: string): Promise<string | undefined>; get defaultScope(): string; private componentDefaultScopeFromComponentDirAndNameWithoutConfigFile; /** * Calculate the component config based on: * the config property in the .bitmap file * the component.json file in the component folder * matching pattern in the variants config * defaults extensions from workspace config * extensions from the model. */ componentExtensions(componentId: ComponentID, componentFromScope?: Component, excludeOrigins?: ExtensionsOrigin[], opts?: ComponentExtensionsOpts): Promise<ComponentExtensionsResponse>; warnAboutMisconfiguredEnv(envId: string): Promise<void>; getConfigMergeFilePath(): string; getConflictMergeFile(): MergeConflictFile; getDepsDataOfMergeConfig(id: ComponentID): VariantPolicyConfigArr; /** * @deprecated * the workspace.jsonc conflicts are not written to the config-merge file anymore. * see https://github.com/teambit/bit/pull/8393 for more details. */ getWorkspaceJsonConflictFromMergeConfig(): { data?: Record<string, any>; conflict: boolean; }; getWorkspaceIssues(): Error[]; listComponentsDuringMerge(): Promise<ComponentID[]>; getUnmergedComponent(componentId: ComponentID): Promise<Component | undefined>; isModified(component: Component): Promise<boolean>; isModifiedOrNew(component: Component): Promise<boolean>; isExported(id: ComponentID): boolean; getExportedFrom(ids: ComponentID[]): ComponentID[]; /** * filter the given component-ids and set default-scope only to the new ones. * returns the affected components. */ setDefaultScopeToComponents(componentIds: ComponentID[], scopeName: string): Promise<ComponentID[]>; /** * @param scopeName * @param includeComponents whether to update new components in the workspace to use the new default-scope * this is relevant only for new components that were using the previous default-scope */ setDefaultScope(scopeName: string, includeComponents?: boolean): Promise<void>; addSpecificComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>, { shouldMergeWithExisting, shouldMergeWithPrevious, }?: { shouldMergeWithExisting?: boolean; /** * relevant only when writing to .bitmap. * eject config of the given aspect-id, so then it won't override previous config. (see "adding prod dep, tagging then adding devDep" e2e-test) */ shouldMergeWithPrevious?: boolean; }): Promise<void>; removeSpecificComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist?: boolean): Promise<boolean>; getAspectIdFromConfig(componentId: ComponentID, aspectIdStr: string, ignoreAspectVersion?: boolean): Promise<string | undefined>; getSpecificComponentConfig(id: ComponentID, aspectId: string): Promise<any>; private isVendorComponentByComponentDir; /** * return the component config from its folder (component.json) * @param componentId */ componentConfigFile(id: ComponentID): Promise<ComponentConfigFile | undefined>; /** * @param componentPath can be relative or absolute. supports Linux and Windows */ getComponentIdByPath(componentPath: PathOsBased): Promise<ComponentID | undefined>; private componentConfigFileFromComponentDirAndName; /** * load aspects from the workspace and if not exists in the workspace, load from the scope. * keep in mind that the graph may have circles. */ loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: string, opts?: WorkspaceLoadAspectsOptions): Promise<string[]>; loadComponentsExtensions(extensions: ExtensionDataList, originatedFrom?: ComponentID, opts?: WorkspaceLoadAspectsOptions): Promise<void>; /** * returns one graph that includes all dependencies types. each edge has a label of the dependency * type. the nodes content is the Component object. */ buildOneGraphForComponents(ids: ComponentID[], ignoreIds?: string[], shouldLoadFunc?: ShouldLoadFunc, shouldThrowOnMissingDep?: boolean): Promise<Graph<Component, string>>; resolveAspects(runtimeName?: string, componentIds?: ComponentID[], opts?: ResolveAspectsOptions): Promise<AspectDefinition[]>; /** * Provides a cache folder, unique per key. * Return value may be undefined, if workspace folder is unconventional (bare-scope, no node_modules, etc) */ getTempDir(id: string): string; getWorkspaceAspectsLoader(): WorkspaceAspectsLoader; getCapsulePath(): string; shouldUseHashForCapsules(): boolean; /** } /** * this should be rarely in-use. * it's currently used by watch extension as a quick workaround to load .bitmap and the components */ _reloadConsumer(): Promise<void>; getComponentPackagePath(component: Component): string; get defaultDirectory(): string; get legacyDefaultDirectory(): string; resolveComponentIdFromPackageName(packageName: string, keepOriginalVersion?: boolean): Promise<ComponentID>; private resolveComponentIdFromWsComponents; private resolveComponentIdFromRegistryManifest; private resolveComponentIdFromPackageJsonInNM; /** * Transform the id to ComponentId and get the exact id as appear in bitmap */ resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>; resolveMultipleComponentIds(ids: Array<string | ComponentID | ComponentID>): Promise<ComponentID[]>; /** * component-id coming from Scope don't have the defaultScope, the legacyComponentId.scope is always populated. * in the .bitmap we need to distinguish between the two, so the componentId needs to be corrected with the defaultScope. */ resolveIdWithDefaultScope(componentId: ComponentID): ComponentID; /** * This will mutate the original extensions list and resolve it's ids * * @param {ExtensionDataList} extensions * @returns {Promise<void[]>} * @memberof Workspace */ resolveExtensionsList(extensions: ExtensionDataList): Promise<void[]>; /** * configure an environment to the given components in the .bitmap file, this configuration overrides other, such as * overrides in workspace.jsonc. */ setEnvToComponents(envId: ComponentID, componentIds: ComponentID[], verifyEnv?: boolean): Promise<void>; /** * helpful when a user provides an env-string to be set and this env has no version. * in the workspace config, a custom-env needs to be set with a version unless it's part of the workspace. * (inside envs/envs it's set without a version). */ resolveEnvIdWithPotentialVersionForConfig(envId: ComponentID): Promise<string>; resolveEnvManifest(envId: string, envExtendsDeps?: LegacyDependency[]): Promise<EnvJsonc>; /** * remove env configuration from the .bitmap file, so then other configuration, such as "variants" will take place */ unsetEnvFromComponents(ids: ComponentID[]): Promise<{ changed: ComponentID[]; unchanged: ComponentID[]; }>; updateEnvForComponents(envIdStr?: string, pattern?: string): Promise<{ updated: { [envId: string]: ComponentID[]; }; alreadyUpToDate: ComponentID[]; }>; getComponentPathsRegExps(): RegExp[]; setComponentPathsRegExps(): Promise<void>; getInjectedDirs(component: Component): Promise<string[]>; /** * the dependencies returned from this method will override the auto-detected dependencies. (done by "applyAutoDetectOverridesOnComponent") * to calculate this, we merge several sources: env, env-for-itself, config from variant, and the merge-config. * keep in mind that component-config (coming from .bitmap or component.json) is not included in this merge. */ getAutoDetectOverrides(configuredExtensions: ExtensionDataList, id: ComponentID, legacyFiles: SourceFile[], envExtendedDeps?: LegacyDependency[]): Promise<DependenciesOverridesData>; getAutoDetectConfigMerge(id: ComponentID): DependenciesOverridesData | undefined; getManyComponentsStatuses(ids: ComponentID[]): Promise<ComponentStatusResult[]>; getComponentStatusById(id: ComponentID): Promise<ComponentStatusLegacy>; setLocalOnly(ids: ComponentID[]): Promise<void>; unsetLocalOnly(ids: ComponentID[]): Promise<ComponentID[]>; listLocalOnly(): ComponentIdList; writeDependencies(target?: 'workspace.jsonc' | 'package.json'): Promise<void>; writeDependenciesToWorkspaceJsonc(): Promise<void>; externalPackageManagerIsUsed(): boolean; writeDependenciesToPackageJson(dependencies?: Record<string, string>): Promise<void>; getAllDedupedDirectDependencies(): Promise<CurrentPkg[]>; variantPatternsToDepPolicesDict(): Record<string, VariantPolicyConfigObject>; getComponentsWithDependencyPolicies(): Promise<Array<{ componentId: ComponentID; policy: any; }>>; } export default Workspace;