UNPKG

@teambit/lanes

Version:
242 lines (241 loc) • 10.3 kB
import type { CLIMain } from '@teambit/cli'; import type { ScopeMain } from '@teambit/scope'; import type { GraphqlMain } from '@teambit/graphql'; import type { ExpressMain } from '@teambit/express'; import type { Workspace } from '@teambit/workspace'; import type { LaneDiffResults } from '@teambit/lanes.modules.diff'; import type { TrackLane, LaneData } from '@teambit/legacy.scope'; import { LaneId } from '@teambit/lane-id'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { DiffOptions } from '@teambit/legacy.component-diff'; import type { MergeStrategy } from '@teambit/component.modules.merge-helper'; import type { MergingMain } from '@teambit/merging'; import type { ImporterMain } from '@teambit/importer'; import { ComponentID } from '@teambit/component-id'; import type { Component, ComponentMain } from '@teambit/component'; import type { LaneHistory } from '@teambit/objects'; import { Lane } from '@teambit/objects'; import type { SnapsDistance } from '@teambit/component.snap-distance'; import type { ExportMain } from '@teambit/export'; import type { ComponentCompareMain } from '@teambit/component-compare'; import type { ComponentWriterMain } from '@teambit/component-writer'; import type { RemoveMain } from '@teambit/remove'; import type { CheckoutMain } from '@teambit/checkout'; import { ChangeType } from '@teambit/lanes.entities.lane-diff'; import type { ComponentsList } from '@teambit/legacy.component-list'; import type { LaneCheckoutOpts } from './lane.cmd'; import type { InstallMain } from '@teambit/install'; export { Lane }; export type SnapsDistanceObj = { onSource: string[]; onTarget: string[]; common?: string; }; export type LaneResults = { lanes: LaneData[]; currentLane?: string | null; }; export type CreateLaneOptions = { scope?: string; alias?: string; forkLaneNewScope?: boolean; }; export type SwitchLaneOptions = { head?: boolean; alias?: string; merge?: MergeStrategy; forceOurs?: boolean; forceTheirs?: boolean; workspaceOnly?: boolean; pattern?: string; skipDependencyInstallation?: boolean; verbose?: boolean; override?: boolean; branch?: boolean; }; export type LaneComponentDiffStatus = { componentId: ComponentID; sourceHead: string; targetHead?: string; /** * @deprecated * use changes to get list of all the changes */ changeType?: ChangeType; changes?: ChangeType[]; upToDate?: boolean; snapsDistance?: SnapsDistanceObj; unrelated?: boolean; }; export type LaneDiffStatusOptions = { skipChanges?: boolean; }; export type DivergeDataPerId = { id: ComponentID; divergeData: SnapsDistance; }; export type LaneDiffStatus = { source: LaneId; target: LaneId; componentsStatus: LaneComponentDiffStatus[]; }; export type MarkRemoveOnLaneResult = { removedFromWs: ComponentID[]; markedRemoved: ComponentID[]; }; export type CreateLaneResult = { lane: Lane; laneId: LaneId; hash: string; alias?: string; }; export declare class LanesMain { readonly workspace: Workspace | undefined; private scope; private merging; private componentAspect; logger: Logger; readonly importer: ImporterMain; private exporter; private componentCompare; readonly componentWriter: ComponentWriterMain; private remove; readonly checkout: CheckoutMain; private install; constructor(workspace: Workspace | undefined, scope: ScopeMain, merging: MergingMain, componentAspect: ComponentMain, logger: Logger, importer: ImporterMain, exporter: ExportMain, componentCompare: ComponentCompareMain, componentWriter: ComponentWriterMain, remove: RemoveMain, checkout: CheckoutMain, install: InstallMain); /** * return the lane data without the deleted components. * the deleted components are filtered out in legacyScope.lanes.getLanesData() */ getLanes({ name, remote, merged, showDefaultLane, notMerged, }: { name?: string; remote?: string; merged?: boolean; showDefaultLane?: boolean; notMerged?: boolean; }): Promise<LaneData[]>; parseLaneId(idStr: string): Promise<LaneId>; getLaneHistory(laneId: LaneId): Promise<LaneHistory>; checkoutHistory(historyId: string, options?: LaneCheckoutOpts): Promise<import("@teambit/component.modules.merge-helper").ApplyVersionResults>; revertHistory(historyId: string, options?: LaneCheckoutOpts): Promise<import("@teambit/component.modules.merge-helper").ApplyVersionResults>; private getHistoryItemOfCurrentLane; importLaneHistory(laneId: LaneId): Promise<void>; isLaneExistsOnRemote(laneId: LaneId): Promise<boolean>; getCurrentLaneName(): string | null; getCurrentLaneNameOrAlias(): string | null; getCurrentLaneId(): LaneId | null; /** * get the currently checked out lane object, if on main - return null. */ getCurrentLane(): Promise<Lane | undefined>; getDefaultLaneId(): LaneId; setCurrentLane(laneId: LaneId, alias?: string, exported?: boolean): void; createLane(name: string, { scope, alias, forkLaneNewScope }?: CreateLaneOptions): Promise<CreateLaneResult>; loadLane(id: LaneId): Promise<Lane | undefined>; trackLane(localName: string, remoteScope: string, remoteName?: string): Promise<{ beforeTrackData?: TrackLane; afterTrackData: TrackLane; }>; aliasLane(laneName: string, alias: string): Promise<{ laneId: LaneId; }>; changeScope(remoteScope: string, laneName?: string): Promise<{ remoteScopeBefore: string; localName: string; }>; /** * change a lane-name and if possible, export the lane to the remote */ rename(newName: string, laneName?: string): Promise<{ currentName: string; }>; exportLane(lane: Lane): Promise<void>; importLaneObject(laneId: LaneId, persistIfNotExists?: boolean, includeLaneHistory?: boolean): Promise<Lane>; eject(pattern: string): Promise<ComponentID[]>; /** * get the head hash (snap) of main. return undefined if the component exists only on a lane and was never merged to main */ getHeadOnMain(componentId: ComponentID): Promise<string | undefined>; /** * fetch the lane object and its components from the remote. * save the objects and the lane to the local scope. * this method doesn't change anything in the workspace. */ fetchLaneWithItsComponents(laneId: LaneId, includeUpdateDependents?: boolean): Promise<Lane>; removeLanes(laneNames: string[], opts?: { remote: boolean; force: boolean; }): Promise<string[]>; /** * when deleting a lane object, it is sent into the "trash" directory in the scope. * this method restores it and put it back in the "objects" directory. * as an argument, it needs a hash. the reason for not supporting lane-id is because the trash may have multiple * lanes with the same lane-id but different hashes. */ restoreLane(laneHash: string): Promise<void>; /** * switch to a different local or remote lane. * switching to a remote lane also imports and writes the components of that remote lane. * by default, only the components existing on the workspace will be imported from that lane, unless the "getAll" * flag is true. */ switchLanes(laneName: string, { alias, merge, forceOurs, forceTheirs, pattern, workspaceOnly, skipDependencyInstallation, head, branch, }: SwitchLaneOptions): Promise<import("@teambit/component.modules.merge-helper").ApplyVersionResults>; private createGitBranchForLane; /** * the values array may include zero to two values and will be processed as following: * [] => diff between the current lane and default lane. (only inside workspace). * [to] => diff between the current lane (or default-lane when in scope) and "to" lane. * [from, to] => diff between "from" lane and "to" lane. */ getDiff(values: string[], diffOptions?: DiffOptions, pattern?: string): Promise<LaneDiffResults>; getLaneComponentModels(lane: LaneData): Promise<Component[]>; getLaneComponentIds(lane: LaneData): Promise<ComponentID[]>; getLaneReadmeComponent(lane: LaneData): Promise<Component | undefined>; removeLaneReadme(laneName?: string): Promise<{ result: boolean; message?: string; }>; diffStatus(sourceLaneId: LaneId, targetLaneId?: LaneId, options?: LaneDiffStatusOptions): Promise<LaneDiffStatus>; private componentDiffStatus; componentDiffStatusOld(componentId: ComponentID, sourceHead: string, targetHead?: string, options?: LaneDiffStatusOptions): Promise<LaneComponentDiffStatus>; private recreateNewLaneIfDeleted; /** * if the local lane was forked from another lane, this gets the differences between the two. * it also fetches the original lane from the remote to make sure the data is up to date. */ listUpdatesFromForked(componentsList: ComponentsList): Promise<DivergeDataPerId[]>; /** * list components on a lane that their main got updates. */ listUpdatesFromMainPending(componentsList: ComponentsList): Promise<DivergeDataPerId[]>; /** * default to remove all of them. * returns true if the lane has changed */ removeUpdateDependents(laneId: LaneId, ids?: ComponentID[]): Promise<boolean>; private getLaneDataOfDefaultLane; get createRoutePath(): string; get deleteRoutePath(): string; get restoreRoutePath(): string; static slots: never[]; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static provider([cli, scope, workspace, graphql, merging, component, loggerMain, importer, exporter, express, componentCompare, componentWriter, remove, checkout, install,]: [ CLIMain, ScopeMain, Workspace, GraphqlMain, MergingMain, ComponentMain, LoggerMain, ImporterMain, ExportMain, ExpressMain, ComponentCompareMain, ComponentWriterMain, RemoveMain, CheckoutMain, InstallMain ]): Promise<LanesMain>; } export default LanesMain;