UNPKG

@teambit/workspace

Version:
78 lines (77 loc) 3.74 kB
import type { ComponentID } from '@teambit/component-id'; import type { ComponentMap, GetBitMapComponentOptions } from '@teambit/legacy.bit-map'; import { BitMap as LegacyBitMap } from '@teambit/legacy.bit-map'; import type { Consumer } from '@teambit/legacy.consumer'; import type { LaneId } from '@teambit/lane-id'; import type { PathOsBasedAbsolute } from '@teambit/toolbox.path.path'; export type MergeOptions = { mergeStrategy?: 'theirs' | 'ours' | 'manual'; }; /** * consider extracting to a new component. * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace) */ export declare class BitMap { private legacyBitMap; private consumer; constructor(legacyBitMap: LegacyBitMap, consumer: Consumer); mergeBitmaps(bitmapContent: string, otherBitmapContent: string, opts?: MergeOptions): string; getPath(): PathOsBasedAbsolute; getAllRootDirs(): string[]; /** * adds component config to the .bitmap file. * later, upon `bit tag`, the data is saved in the scope. * returns a boolean indicating whether a change has been made. */ addComponentConfig(id: ComponentID, aspectId: string, config?: Record<string, any>, shouldMergeConfig?: boolean): boolean; updateDefaultScope(oldScope: string, newScope: string): ComponentID[]; markAsChanged(): void; removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean; removeEntireConfig(id: ComponentID): boolean; setEntireConfig(id: ComponentID, config: Record<string, any>): void; removeDefaultScope(id: ComponentID): void; setDefaultScope(id: ComponentID, defaultScope: string): void; setLocalOnly(ids: ComponentID[]): void; unsetLocalOnly(ids: ComponentID[]): ComponentID[]; listLocalOnly(): ComponentID[]; /** * write .bitmap object to the filesystem * optionally pass a reason for the change to be saved in the local scope `bitmap-history-metadata.txt` file. */ write(reasonForChange?: string): Promise<void>; /** * get the data saved in the .bitmap file for this component-id. * throws if not found * @see this.getBitmapEntryIfExist */ getBitmapEntry(id: ComponentID, { ignoreVersion }?: GetBitMapComponentOptions): ComponentMap; getBitmapEntryIfExist(id: ComponentID, { ignoreVersion }?: GetBitMapComponentOptions): ComponentMap | undefined; getAspectIdFromConfig(componentId: ComponentID, aspectId: ComponentID, ignoreAspectVersion?: boolean): string | undefined; /** * components that were not tagged yet are safe to rename them from the .bitmap file. */ renameNewComponent(sourceId: ComponentID, targetId: ComponentID): void; /** * helpful when reaming an aspect and this aspect is used in the config of other components. */ renameAspectInConfig(sourceId: ComponentID, targetId: ComponentID): void; removeComponent(id: ComponentID): void; /** * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be * empty. */ getExportedLaneId(): LaneId | undefined; makeComponentsAvailableOnMain(ids: ComponentID[]): void; /** * whether .bitmap file has changed in-memory */ hasChanged(): boolean; takeSnapshot(): ComponentMap[]; restoreFromSnapshot(componentMaps: ComponentMap[]): void; /** * .bitmap file could be changed by other sources (e.g. manually or by "git pull") not only by bit. * this method returns the timestamp when the .bitmap has changed through bit. (e.g. as part of snap/tag/export/merge * process) */ getLastModifiedBitmapThroughBit(): Promise<number | undefined>; }