import type { CLIMain } from '@teambit/cli'; import type { Workspace, AutoTagResult } from '@teambit/workspace'; import type { ReleaseType } from 'semver'; import { ComponentID, ComponentIdList } from '@teambit/component-id'; import type { BuildStatus } from '@teambit/legacy.constants'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { ConfigStoreMain } from '@teambit/config-store'; import type { ScopeMain } from '@teambit/scope'; import type { Lane, ModelComponent, Log, AddVersionOpts } from '@teambit/objects'; import { BitObject, Version } from '@teambit/objects'; import type { Component, ConsumerComponent } from '@teambit/component'; import type { DependencyResolverMain } from '@teambit/dependency-resolver'; import type { BuilderMain, LegacyOnTagResult } from '@teambit/builder'; import type { ImporterMain } from '@teambit/importer'; import type { ExportMain } from '@teambit/export'; import type { DependenciesMain } from '@teambit/dependencies'; import type { NewDependencies } from './generate-comp-from-scope'; import type { ResetResult } from './reset-component'; import type { ApplicationMain } from '@teambit/application'; import type { RemoveMain } from '@teambit/remove'; import type { BasicTagParams, BasicTagSnapParams, VersionMakerParams } from './version-maker'; import type { SlotRegistry } from '@teambit/harmony'; export type PackageIntegritiesByPublishedPackages = Map; export type TagDataPerComp = { componentId: ComponentID; dependencies: ComponentID[]; versionToTag?: string; prereleaseId?: string; message?: string; isNew?: boolean; }; export type SnapDataParsed = { componentId: ComponentID; dependencies: string[]; aspects?: Record; message?: string; files?: FileData[]; isNew?: boolean; newDependencies?: { id: string; version?: string; isComponent: boolean; type: 'runtime' | 'dev' | 'peer'; }[]; removeDependencies?: string[]; forkFrom?: ComponentID; }; export type SnapResults = BasicTagResults & { snappedComponents: ConsumerComponent[]; autoSnappedResults: AutoTagResult[]; laneName: string | null; }; export type SnapFromScopeResults = { snappedIds: ComponentID[]; exportedIds?: ComponentID[]; autoSnappedResults: AutoTagResult[]; snappedComponents: ConsumerComponent[]; }; export type TagResults = BasicTagResults & { taggedComponents: ConsumerComponent[]; autoTaggedResults: AutoTagResult[]; isSoftTag: boolean; publishedPackages: string[]; exportedIds?: ComponentIdList; }; export type BasicTagResults = { warnings: string[]; newComponents: ComponentIdList; removedComponents?: ComponentIdList; totalComponentsCount?: number; }; export type FileData = { path: string; content: string; delete?: boolean; }; export type SnapDataPerCompRaw = { componentId: string; dependencies?: string[]; aspects?: Record; message?: string; files?: FileData[]; isNew?: boolean; mainFile?: string; newDependencies?: NewDependencies; removeDependencies?: string[]; forkFrom?: string; version?: string; }; export type OnPreSnap = (componentsToSnap: Component[], idsToAutoSnap: ComponentID[], params: VersionMakerParams) => Promise; export type OnPreSnapSlot = SlotRegistry; export declare class SnappingMain { readonly workspace: Workspace; readonly logger: Logger; readonly dependencyResolver: DependencyResolverMain; readonly scope: ScopeMain; private exporter; readonly builder: BuilderMain; private importer; private deps; private application; private remove; readonly onPreSnapSlot: OnPreSnapSlot; private objectsRepo; constructor(workspace: Workspace, logger: Logger, dependencyResolver: DependencyResolverMain, scope: ScopeMain, exporter: ExportMain, builder: BuilderMain, importer: ImporterMain, deps: DependenciesMain, application: ApplicationMain, remove: RemoveMain, onPreSnapSlot: OnPreSnapSlot); registerOnPreSnap(onPreSnap: OnPreSnap): void; /** * tag the given component ids or all modified/new components if "all" param is set. * tag is a similar operation as a snap, which saves the changes into the local scope, but it also creates an alias * with a valid semver to that version. * tag can be done only on main, not on a lane. */ tag({ ids, message, version, editor, versionsFile, snapped, unmerged, releaseType, preReleaseId, ignoreIssues, ignoreNewestVersion, skipTests, skipTasks, skipAutoTag, build, unmodified, soft, persist, ignoreBuildErrors, rebuildDepsGraph, noLockDeps, incrementBy, disableTagAndSnapPipelines, failFast, detachHead, overrideHead, loose, }: { ids?: string[]; all?: boolean | string; snapped?: boolean; unmerged?: boolean; version?: string; releaseType?: ReleaseType; ignoreIssues?: string; scope?: string | boolean; incrementBy?: number; failFast?: boolean; } & Partial): Promise; makeVersion(ids: ComponentID[], components: Component[], params: VersionMakerParams): Promise<{ taggedComponents: ConsumerComponent[]; autoTaggedResults: AutoTagResult[]; publishedPackages: string[]; stagedConfig?: import("@teambit/scope").StagedConfig; removedComponents?: ComponentIdList; totalComponentsCount?: number; batchId: string; }>; private addAspectsFromConfigObject; snapFromScope(snapDataPerCompRaw: SnapDataPerCompRaw[], params: { push?: boolean; ignoreIssues?: string; lane?: string; updateDependents?: boolean; tag?: boolean; updatedLegacyComponents?: ConsumerComponent[]; loadAspectOnlyForIds?: ComponentIdList; } & Partial): Promise; /** * save the local changes of a component(s) into the scope. snap can be done on main or on a lane. * once a component is snapped on a lane, it becomes part of it. */ snap({ pattern, legacyBitIds, // @todo: change to ComponentID[]. pass only if have the ids already parsed. unmerged, editor, message, ignoreIssues, skipTests, skipTasks, skipAutoSnap, build, disableTagAndSnapPipelines, ignoreBuildErrors, rebuildDepsGraph, noLockDeps, unmodified, exitOnFirstFailedTask, detachHead, loose, }: Partial & { pattern?: string; legacyBitIds?: ComponentIdList; unmerged?: boolean; editor?: string; ignoreIssues?: string; skipAutoSnap?: boolean; disableTagAndSnapPipelines?: boolean; unmodified?: boolean; exitOnFirstFailedTask?: boolean; }): Promise; /** * Workspace-side merge snap. Routes both visible workspace components AND hidden lane * lane.updateDependents through the same `makeVersion` pipeline that * `snap`/`snapFromScope` use, so cascade snaps get fresh log/buildStatus/flattenedDependencies/ * lane-history/stagedSnaps just like every other snap. * * Visible: workspace.getMany picks up files written to disk by `applyVersion`. * Hidden: applyVersion's in-memory merged ConsumerComponents are passed in directly — they * have no bitmap entry, so they can't go through `loadComponentsForTagOrSnap`. * * version-maker's `isHiddenLaneEntry` detection (workspace-flow: not-in-bitmap) routes the * hidden ones to the right branches (no bitmap update, stagedSnaps tracking, * `addToUpdateDependentsInLane`). */ snapForMerge({ visibleIds, hiddenLegacyComponents, message, build, loose, }: { visibleIds: ComponentIdList; hiddenLegacyComponents: ConsumerComponent[]; message?: string; build?: boolean; loose?: boolean; }): Promise<{ snappedComponents: ConsumerComponent[]; autoSnappedResults: AutoTagResult[]; removedComponents?: ComponentIdList; } | null>; /** * remove tags/snaps that exist locally, which were not exported yet. * once a tag/snap is exported, it's impossible to delete it as other components may depend on it */ reset(componentPattern?: string, head?: boolean, force?: boolean, soft?: boolean): Promise<{ results: ResetResult[]; isSoftUntag: boolean; }>; resetNeverExported(): Promise; /** * used externally. don't make it private. */ _addFlattenedDependenciesToComponents(components: ConsumerComponent[], rebuildDepsGraph?: boolean): Promise; throwForDepsFromAnotherLane(components: ConsumerComponent[]): Promise; throwForVariousIssues(components: Component[], ignoreIssues?: string): Promise; private throwForDepsFromAnotherLaneForComp; _addFlattenedDepsGraphToComponents(components: ConsumerComponent[]): Promise; /** * used externally. don't make it private. */ _updateComponentsByTagResult(components: ConsumerComponent[], tagResult: LegacyOnTagResult[]): void; /** * used externally. don't make it private. */ _getPublishedPackages(components: ConsumerComponent[]): PackageIntegritiesByPublishedPackages; _addCompToObjects({ source, lane, shouldValidateVersion, addVersionOpts, batchId, }: { source: ConsumerComponent; lane?: Lane; shouldValidateVersion?: boolean; addVersionOpts?: AddVersionOpts; batchId?: string; }): Promise<{ component: ModelComponent; version: Version; addedVersionStr: string; }>; /** * used externally. don't make it private. */ _addCompFromScopeToObjects(source: ConsumerComponent, lane?: Lane, addVersionOpts?: AddVersionOpts): Promise<{ component: ModelComponent; version: Version; addedVersionStr: string; }>; /** * for an existing component in the local scope, add the updated Version-object/artifacts to the repository * so the next "persist()" call will save them to the filesystem */ enrichComp(component: Component, modifiedLog?: Log): Promise; /** * used externally. don't make it private. * needed to be updated after the build-pipeline was running */ setBuildStatus(component: Component, buildStatus: BuildStatus): void; /** * for an existing component in the local scope, update the Version object with the updated data from the * consumer-component and return the objects that need to be saved in the filesystem */ getObjectsToEnrichComp(component: Component, modifiedLog?: Log): Promise; private transformArtifactsFromVinylToSource; private loadComponentsForTagOrSnap; private throwForPendingImport; private throwForLegacyDependenciesInsideHarmony; /** * used externally. don't make it private. * * the compId.version can be a range (e.g. "^1.0.0"), in which case, it finds the component in the local scope and * resolves the latest version that falls under the range. * in case the version has no range, it returns the same compId. * in case it has no version, it returns the latest. */ getCompIdWithExactVersionAccordingToSemver(compId: ComponentID): Promise; updateSourceFiles(component: Component, files: FileData[]): Promise; /** * used externally. don't make it private. */ updateDependenciesVersionsOfComponent(component: Component, dependencies: ComponentID[], currentBitIds: ComponentID[]): Promise; /** * it does two things: * 1. update extensions versions according to the version provided in updatedIds. * 2. save all dependencies data from the legacy into DependencyResolver aspect. */ UpdateDepsAspectsSaveIntoDepsResolver(component: Component, updatedIds: string[]): Promise; private getTagPendingComponentsIds; private getComponentsToTag; static slots: ((registerFn: () => string) => SlotRegistry)[]; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static provider([workspace, cli, loggerMain, dependencyResolver, scope, exporter, builder, importer, configStore, deps, application, remove,]: [ Workspace, CLIMain, LoggerMain, DependencyResolverMain, ScopeMain, ExportMain, BuilderMain, ImporterMain, ConfigStoreMain, DependenciesMain, ApplicationMain, RemoveMain ], config: any, [onPreSnapSlot]: [OnPreSnapSlot]): Promise; } export default SnappingMain;