@teambit/snapping 0.0.0-e7fd7469346b2343d178d5c41d5c2e1ce32c4c09 → 0.0.0-e88198f456e2dd4d5b628336ee913171c9f09eba

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,14 @@ async function removeLocalVersion(consumer, id, lane, head, force = false) {
49
49
  const component = await consumer.scope.getModelComponent(id);
50
50
  const idStr = id.toString();
51
51
  const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);
52
- const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);
52
+ // populate lane-aware heads so `getLocalHashes` diverges against the LANE remote head, not
53
+ // the empty main one — otherwise a hidden cascade entry (no bitmap row, no main-side state)
54
+ // would treat the entire local history as "local" and wipe the seeded base on reset.
55
+ if (lane) await component.populateLocalAndRemoteHeads(consumer.scope.objects, lane);
56
+ // Pass `lane` so the lean-lane filter only keeps lane-origin snaps in localVersions. Without
57
+ // it, a merged-in main tag (e.g. 0.0.2) would be wiped from the component's versions map
58
+ // even though it still lives on the component's home scope — silent data loss for the user.
59
+ const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap, lane);
53
60
  if (!localVersions.length) throw new (_bitError().BitError)(`unable to untag ${idStr}, the component is not staged`);
54
61
  const headRef = component.getHeadRegardlessOfLane();
55
62
  if (!headRef) {
@@ -134,6 +141,9 @@ async function removeLocalVersionsForMultipleComponents(consumer, componentsToUn
134
141
  async function getComponentsWithOptionToUntag(workspace, remove) {
135
142
  const componentList = new (_legacy().ComponentsList)(workspace);
136
143
  const laneObj = await workspace.getCurrentLaneObject();
144
+ // The result includes hidden updateDependents — `bit reset` reverts cascade snaps end-to-end.
145
+ // The bitmap-update step in `snapping.reset` skips hidden entries explicitly so we don't try
146
+ // to write workspace state for components that don't live in the workspace.
137
147
  const components = await componentList.listExportPendingComponents(laneObj);
138
148
  const removedStagedIds = await remove.getRemovedStaged();
139
149
  if (!removedStagedIds.length) return components;
@@ -1 +1 @@
1
- {"version":3,"names":["_lodash","data","require","_bitError","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","localVersions","getLocalHashes","objects","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","batchIds","versionObjects","Promise","all","map","ver","loadVersion","loadedVersions","compact","Set","batchId","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","workspace","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { compact } from 'lodash';\nimport { BitError } from '@teambit/bit-error';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport type { Lane, ModelComponent } from '@teambit/objects';\nimport type { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport type { Workspace } from '@teambit/workspace';\n\nexport type ResetResult = {\n id: ComponentID;\n versions: string[];\n component?: ModelComponent;\n /**\n * relevant when the component was detached head so the head didn't change.\n * we want .bitmap to have the version before the detachment. not as the head.\n */\n versionToSetInBitmap?: string;\n /** batchIds from the version objects being removed, used to clean up lane history entries */\n batchIds?: string[];\n};\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n consumer: Consumer,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await consumer.scope.getModelComponent(id);\n const idStr = id.toString();\n const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n // Load version objects to extract batchIds before they are removed.\n // These batchIds are used to clean up the corresponding lane history entries.\n // Only needed on lanes — on main there's no lane history to clean up.\n let batchIds: string[] | undefined;\n if (lane) {\n const versionObjects = await Promise.all(\n versionsToRemoveStr.map((ver) => component.loadVersion(ver, consumer.scope.objects, false))\n );\n const loadedVersions = compact(versionObjects);\n batchIds = [...new Set(compact(loadedVersions.map((v) => v.batchId)))];\n }\n\n const headBefore = component.getHead();\n await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n const headAfter = component.getHead();\n let versionToSetInBitmap;\n if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {\n // if it's on main and the head didn't change, it means that it was in a detached-head state.\n const divergeData = component.getDivergeData();\n const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;\n if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);\n }\n\n return { id, versions: versionsToRemoveStr, component, versionToSetInBitmap, batchIds };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(workspace.consumer, componentsToUntag, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n consumer: Consumer,\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(consumer, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => workspace.consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAgBA;AACA;AACA;AACO,eAAeM,kBAAk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GAAG,MAAMJ,aAAa,CAACK,2BAA2B,CAACH,OAAO,CAAC;EAC7F,MAAMI,gBAAgB,GAAG,MAAMpB,MAAM,CAACqB,gBAAgB,CAAC,CAAC;EACxD,IAAI,CAACD,gBAAgB,CAACnE,MAAM,EAAE,OAAOiE,UAAU;EAC/C,MAAMI,mBAAmB,GAAGF,gBAAgB,CAACzC,GAAG,CAAEzC,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAMqF,iBAAiB,GAAGD,mBAAmB,CAACd,MAAM,CACjDtE,EAAE,IAAK,CAACgF,UAAU,CAAC5D,IAAI,CAAEkE,CAAC,IAAKA,CAAC,CAACtD,aAAa,CAAC,CAAC,CAACuD,qBAAqB,CAACvF,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAACqF,iBAAiB,CAACtE,MAAM,EAAE,OAAOiE,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMjD,OAAO,CAACC,GAAG,CAAC6C,iBAAiB,CAAC5C,GAAG,CAAEzC,EAAE,IAAK6D,SAAS,CAAC9D,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHgF,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
1
+ {"version":3,"names":["_lodash","data","require","_bitError","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","populateLocalAndRemoteHeads","objects","localVersions","getLocalHashes","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","batchIds","versionObjects","Promise","all","map","ver","loadVersion","loadedVersions","compact","Set","batchId","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","workspace","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { compact } from 'lodash';\nimport { BitError } from '@teambit/bit-error';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport type { Lane, ModelComponent } from '@teambit/objects';\nimport type { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport type { Workspace } from '@teambit/workspace';\n\nexport type ResetResult = {\n id: ComponentID;\n versions: string[];\n component?: ModelComponent;\n /**\n * relevant when the component was detached head so the head didn't change.\n * we want .bitmap to have the version before the detachment. not as the head.\n */\n versionToSetInBitmap?: string;\n /** batchIds from the version objects being removed, used to clean up lane history entries */\n batchIds?: string[];\n};\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n consumer: Consumer,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await consumer.scope.getModelComponent(id);\n const idStr = id.toString();\n const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);\n // populate lane-aware heads so `getLocalHashes` diverges against the LANE remote head, not\n // the empty main one — otherwise a hidden cascade entry (no bitmap row, no main-side state)\n // would treat the entire local history as \"local\" and wipe the seeded base on reset.\n if (lane) await component.populateLocalAndRemoteHeads(consumer.scope.objects, lane);\n // Pass `lane` so the lean-lane filter only keeps lane-origin snaps in localVersions. Without\n // it, a merged-in main tag (e.g. 0.0.2) would be wiped from the component's versions map\n // even though it still lives on the component's home scope — silent data loss for the user.\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap, lane);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n // Load version objects to extract batchIds before they are removed.\n // These batchIds are used to clean up the corresponding lane history entries.\n // Only needed on lanes — on main there's no lane history to clean up.\n let batchIds: string[] | undefined;\n if (lane) {\n const versionObjects = await Promise.all(\n versionsToRemoveStr.map((ver) => component.loadVersion(ver, consumer.scope.objects, false))\n );\n const loadedVersions = compact(versionObjects);\n batchIds = [...new Set(compact(loadedVersions.map((v) => v.batchId)))];\n }\n\n const headBefore = component.getHead();\n await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n const headAfter = component.getHead();\n let versionToSetInBitmap;\n if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {\n // if it's on main and the head didn't change, it means that it was in a detached-head state.\n const divergeData = component.getDivergeData();\n const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;\n if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);\n }\n\n return { id, versions: versionsToRemoveStr, component, versionToSetInBitmap, batchIds };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(workspace.consumer, componentsToUntag, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n consumer: Consumer,\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(consumer, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.getCurrentLaneObject();\n // The result includes hidden updateDependents — `bit reset` reverts cascade snaps end-to-end.\n // The bitmap-update step in `snapping.reset` skips hidden entries explicitly so we don't try\n // to write workspace state for components that don't live in the workspace.\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => workspace.consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,UAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAgBA;AACA;AACA;AACO,eAAeM,kBAAkBA,CACtCC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;EAC3B,MAAMc,aAAa,GAAG,KAAIC,wBAAc,EAAChB,SAAS,CAAC;EACnD,MAAMiB,OAAO,GAAG,MAAMjB,SAAS,CAACkB,oBAAoB,CAAC,CAAC;EACtD;EACA;EACA;EACA,MAAMC,UAA4B,GAAG,MAAMJ,aAAa,CAACK,2BAA2B,CAACH,OAAO,CAAC;EAC7F,MAAMI,gBAAgB,GAAG,MAAMpB,MAAM,CAACqB,gBAAgB,CAAC,CAAC;EACxD,IAAI,CAACD,gBAAgB,CAACnE,MAAM,EAAE,OAAOiE,UAAU;EAC/C,MAAMI,mBAAmB,GAAGF,gBAAgB,CAACzC,GAAG,CAAE1C,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAMsF,iBAAiB,GAAGD,mBAAmB,CAACd,MAAM,CACjDvE,EAAE,IAAK,CAACiF,UAAU,CAAC5D,IAAI,CAAEkE,CAAC,IAAKA,CAAC,CAACtD,aAAa,CAAC,CAAC,CAACuD,qBAAqB,CAACxF,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAACsF,iBAAiB,CAACtE,MAAM,EAAE,OAAOiE,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMjD,OAAO,CAACC,GAAG,CAAC6C,iBAAiB,CAAC5C,GAAG,CAAE1C,EAAE,IAAK8D,SAAS,CAAC/D,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHiF,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
@@ -20,7 +20,7 @@ export declare class SnapCmd implements Command {
20
20
  options: CommandOptions;
21
21
  loader: boolean;
22
22
  constructor(snapping: SnappingMain, logger: Logger, configStore: ConfigStoreMain);
23
- report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, unmodified, failFast, detachHead, loose, }: {
23
+ report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, noLockDeps, unmodified, failFast, detachHead, loose, }: {
24
24
  unmerged?: boolean;
25
25
  editor?: string;
26
26
  ignoreIssues?: string;
package/dist/snap-cmd.js CHANGED
@@ -70,7 +70,7 @@ snapshots maintain component history and enable collaboration without formal rel
70
70
  _defineProperty(this, "helpUrl", 'reference/components/snaps');
71
71
  _defineProperty(this, "alias", '');
72
72
  _defineProperty(this, "options", [['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'], ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'], ['', 'unmerged', 'complete a merge process by snapping the unmerged components'], ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'], ['', 'editor [editor]', 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).'], ['', 'skip-tests', 'skip running component tests during snap process'], ['', 'skip-tasks <string>', `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.
73
- specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. teambit.compilation/compiler)`], ['', 'skip-auto-snap', 'skip auto snapping dependents'], ['', 'disable-snap-pipeline', 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment'], ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'], ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'], ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'], ['i', 'ignore-issues <issues>', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
73
+ specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. teambit.compilation/compiler)`], ['', 'skip-auto-snap', 'skip auto snapping dependents'], ['', 'disable-snap-pipeline', 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment'], ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'], ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'], ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'], ['', 'no-lock-deps', 'do not save the dependencies graph in the snap'], ['i', 'ignore-issues <issues>', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
74
74
  [${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
75
75
  to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['', 'fail-fast', 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)'], ['', 'detach-head', 'UNSUPPORTED YET. in case a component is checked out to an older version, snap it without changing the head']]);
76
76
  _defineProperty(this, "loader", true);
@@ -87,6 +87,7 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
87
87
  disableSnapPipeline = false,
88
88
  ignoreBuildErrors = false,
89
89
  rebuildDepsGraph,
90
+ noLockDeps = false,
90
91
  unmodified = false,
91
92
  failFast = false,
92
93
  detachHead,
@@ -110,6 +111,7 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
110
111
  disableTagAndSnapPipelines,
111
112
  ignoreBuildErrors,
112
113
  rebuildDepsGraph,
114
+ noLockDeps,
113
115
  unmodified,
114
116
  exitOnFirstFailedTask: failFast,
115
117
  detachHead,
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_componentIssues","_cli","_legacy","_tagCmd","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapCmd","constructor","snapping","logger","configStore","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","detachHead","loose","getConfigBoolean","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snapResultReport","exports","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","totalComponentsCount","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoSnappedCount","length","totalCount","formatCompMinimal","formatItem","compInBold","formatCompDetailed","output","autoSnap","result","triggeredBy","autoSnapComp","map","a","toString","AUTO_SNAPPED_MSG","hasAutoSnapped","buildSections","formatComp","newSection","formatSection","changedSection","removedSection","outputIdsIfExists","warningsSection","w","warnSymbol","laneStr","summary","formatSuccessSummary","snapExplanation","formatHint","autoSnapSection","scopeCounts","countBy","scope","sorted","entries","sort","b","MAX_SHOWN","shown","slice","n","remaining","scopeLine","title","formatTitle","scopes","hint","formatDetailsHint","footerParts","joinSections","newDetailed","changedDetailed","detailedFooter","details","code","snapResultOutput"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { countBy } from 'lodash';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport type { Command, CommandOptions, Report } from '@teambit/cli';\nimport {\n formatItem,\n formatSection,\n formatTitle,\n formatHint,\n formatDetailsHint,\n formatSuccessSummary,\n warnSymbol,\n joinSections,\n} from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy.constants';\nimport type { Logger } from '@teambit/logger';\nimport type { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists, compInBold } from './tag-cmd';\nimport type { BasicTagSnapParams } from './version-maker';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create immutable component snapshots for development versions';\n extendedDescription = `creates snapshots with hash-based versions for development and testing. snapshots are immutable and exportable.\nby default snaps only new and modified components. use for development iterations before creating semantic version tags.\nsnapshots maintain component history and enable collaboration without formal releases.`;\n group = 'version-control';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n [\n '',\n 'disable-snap-pipeline',\n 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment',\n ],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n [\n '',\n 'detach-head',\n 'UNSUPPORTED YET. in case a component is checked out to an older version, snap it without changing the head',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger,\n private configStore: ConfigStoreMain\n ) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipTasks,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n unmodified = false,\n failFast = false,\n detachHead,\n loose = false,\n }: {\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = this.configStore.getConfigBoolean(CFG_FORCE_LOCAL_BUILD) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (!message && !editor) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap, will be displayed in the version history`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipTasks,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n unmodified,\n exitOnFirstFailedTask: failFast,\n detachHead,\n loose,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n return snapResultReport(results);\n }\n}\n\nexport function snapResultReport(results: SnapResults): string | Report {\n const {\n snappedComponents,\n autoSnappedResults,\n warnings,\n newComponents,\n laneName,\n removedComponents,\n totalComponentsCount,\n }: SnapResults = results;\n const changedComponents = snappedComponents.filter((component) => {\n return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoSnappedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n const totalCount = totalComponentsCount ?? snappedComponents.length + autoSnappedCount;\n\n const formatCompMinimal = (component: ConsumerComponent): string => {\n return formatItem(compInBold(component.id));\n };\n\n const formatCompDetailed = (component: ConsumerComponent): string => {\n let output = formatItem(compInBold(component.id));\n const autoSnap = (autoSnappedResults ?? []).filter((result) =>\n result.triggeredBy.searchWithoutVersion(component.id)\n );\n if (autoSnap.length) {\n const autoSnapComp = autoSnap.map((a) => a.component.id.toString());\n output += `\\n ${AUTO_SNAPPED_MSG} (${autoSnapComp.length} total):\\n ${autoSnapComp.join('\\n ')}`;\n }\n return output;\n };\n\n const hasAutoSnapped = autoSnappedCount > 0;\n\n const buildSections = (formatComp: (c: ConsumerComponent) => string) => {\n const newSection = formatSection('new components', 'first version for components', addedComponents.map(formatComp));\n const changedSection = formatSection(\n 'changed components',\n 'components that got a version bump',\n changedComponents.map(formatComp)\n );\n return { newSection, changedSection };\n };\n\n const removedSection = outputIdsIfExists('removed components', removedComponents);\n\n const warningsSection =\n warnings && warnings.length ? warnings.map((w) => `${warnSymbol} ${chalk.yellow(w)}`).join('\\n') : '';\n\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n const summary = formatSuccessSummary(`${totalCount} component(s) snapped${laneStr}`);\n const snapExplanation = formatHint(\n '(use \"bit export\" to push these components to a remote)\\n(use \"bit reset\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)'\n );\n\n // Build minimal output (no auto-snapped listing, just counts grouped by scope)\n const { newSection, changedSection } = buildSections(hasAutoSnapped ? formatCompMinimal : formatCompDetailed);\n\n const autoSnapSection = (() => {\n if (!hasAutoSnapped) return '';\n const scopeCounts = countBy(autoSnappedResults, (r) => r.component.id.scope);\n const sorted = Object.entries(scopeCounts).sort(([, a], [, b]) => b - a);\n const MAX_SHOWN = 4;\n const shown = sorted.slice(0, MAX_SHOWN).map(([scope, n]) => `${scope} (${n})`);\n const remaining = sorted.length - MAX_SHOWN;\n const scopeLine = remaining > 0 ? [...shown, `+ ${remaining} more scopes`].join(' · ') : shown.join(' · ');\n const title = formatTitle(`auto-snapped dependents (${autoSnappedCount})`);\n const scopes = ` ${scopeLine}`;\n const hint = formatDetailsHint('full list of auto-snapped dependents');\n return `${title}\\n${scopes}\\n${hint}`;\n })();\n\n const footerParts = [summary, snapExplanation].filter(Boolean).join('\\n');\n const data = joinSections([\n newSection,\n changedSection,\n autoSnapSection,\n removedSection,\n warningsSection,\n footerParts,\n ]);\n\n if (!hasAutoSnapped) {\n return data;\n }\n\n // Build detailed output (with full auto-snapped listing)\n const { newSection: newDetailed, changedSection: changedDetailed } = buildSections(formatCompDetailed);\n const detailedFooter = [summary, snapExplanation].filter(Boolean).join('\\n');\n const details = joinSections([newDetailed, changedDetailed, removedSection, warningsSection, detailedFooter]);\n\n return { data, code: 0, details };\n}\n\n/** @deprecated use snapResultReport instead */\nexport function snapResultOutput(results: SnapResults): string {\n const result = snapResultReport(results);\n return typeof result === 'string' ? result : result.details || result.data;\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,iBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,gBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAA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e,CAAC,CAACnC,MAAM,CAACnB,OAAO,CAAC,CAACpB,IAAI,CAAC,IAAI,CAAC;EAC5E,MAAMoG,OAAO,GAAG,IAAAJ,mBAAY,EAAC,CAACC,WAAW,EAAEC,eAAe,EAAEhC,cAAc,EAAEE,eAAe,EAAE+B,cAAc,CAAC,CAAC;EAE7G,OAAO;IAAE1I,IAAI;IAAE4I,IAAI,EAAE,CAAC;IAAED;EAAQ,CAAC;AACnC;;AAEA;AACO,SAASE,gBAAgBA,CAAC/E,OAAoB,EAAU;EAC7D,MAAM8B,MAAM,GAAGxB,gBAAgB,CAACN,OAAO,CAAC;EACxC,OAAO,OAAO8B,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAAC+C,OAAO,IAAI/C,MAAM,CAAC5F,IAAI;AAC5E","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_componentIssues","_cli","_legacy","_tagCmd","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapCmd","constructor","snapping","logger","configStore","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","noLockDeps","unmodified","failFast","detachHead","loose","getConfigBoolean","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snapResultReport","exports","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","totalComponentsCount","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoSnappedCount","length","totalCount","formatCompMinimal","formatItem","compInBold","formatCompDetailed","output","autoSnap","result","triggeredBy","autoSnapComp","map","a","toString","AUTO_SNAPPED_MSG","hasAutoSnapped","buildSections","formatComp","newSection","formatSection","changedSection","removedSection","outputIdsIfExists","warningsSection","w","warnSymbol","laneStr","summary","formatSuccessSummary","snapExplanation","formatHint","autoSnapSection","scopeCounts","countBy","scope","sorted","entries","sort","b","MAX_SHOWN","shown","slice","n","remaining","scopeLine","title","formatTitle","scopes","hint","formatDetailsHint","footerParts","joinSections","newDetailed","changedDetailed","detailedFooter","details","code","snapResultOutput"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { countBy } from 'lodash';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport type { Command, CommandOptions, Report } from '@teambit/cli';\nimport {\n formatItem,\n formatSection,\n formatTitle,\n formatHint,\n formatDetailsHint,\n formatSuccessSummary,\n warnSymbol,\n joinSections,\n} from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy.constants';\nimport type { Logger } from '@teambit/logger';\nimport type { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists, compInBold } from './tag-cmd';\nimport type { BasicTagSnapParams } from './version-maker';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create immutable component snapshots for development versions';\n extendedDescription = `creates snapshots with hash-based versions for development and testing. snapshots are immutable and exportable.\nby default snaps only new and modified components. use for development iterations before creating semantic version tags.\nsnapshots maintain component history and enable collaboration without formal releases.`;\n group = 'version-control';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n [\n '',\n 'disable-snap-pipeline',\n 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment',\n ],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n ['', 'no-lock-deps', 'do not save the dependencies graph in the snap'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n [\n '',\n 'detach-head',\n 'UNSUPPORTED YET. in case a component is checked out to an older version, snap it without changing the head',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger,\n private configStore: ConfigStoreMain\n ) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipTasks,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n noLockDeps = false,\n unmodified = false,\n failFast = false,\n detachHead,\n loose = false,\n }: {\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = this.configStore.getConfigBoolean(CFG_FORCE_LOCAL_BUILD) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (!message && !editor) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap, will be displayed in the version history`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipTasks,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n noLockDeps,\n unmodified,\n exitOnFirstFailedTask: failFast,\n detachHead,\n loose,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n return snapResultReport(results);\n }\n}\n\nexport function snapResultReport(results: SnapResults): string | Report {\n const {\n snappedComponents,\n autoSnappedResults,\n warnings,\n newComponents,\n laneName,\n removedComponents,\n totalComponentsCount,\n }: SnapResults = results;\n const changedComponents = snappedComponents.filter((component) => {\n return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoSnappedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n const totalCount = totalComponentsCount ?? snappedComponents.length + autoSnappedCount;\n\n const formatCompMinimal = (component: ConsumerComponent): string => {\n return formatItem(compInBold(component.id));\n };\n\n const formatCompDetailed = (component: ConsumerComponent): string => {\n let output = formatItem(compInBold(component.id));\n const autoSnap = (autoSnappedResults ?? []).filter((result) =>\n result.triggeredBy.searchWithoutVersion(component.id)\n );\n if (autoSnap.length) {\n const autoSnapComp = autoSnap.map((a) => a.component.id.toString());\n output += `\\n ${AUTO_SNAPPED_MSG} (${autoSnapComp.length} total):\\n ${autoSnapComp.join('\\n ')}`;\n }\n return output;\n };\n\n const hasAutoSnapped = autoSnappedCount > 0;\n\n const buildSections = (formatComp: (c: ConsumerComponent) => string) => {\n const newSection = formatSection('new components', 'first version for components', addedComponents.map(formatComp));\n const changedSection = formatSection(\n 'changed components',\n 'components that got a version bump',\n changedComponents.map(formatComp)\n );\n return { newSection, changedSection };\n };\n\n const removedSection = outputIdsIfExists('removed components', removedComponents);\n\n const warningsSection =\n warnings && warnings.length ? warnings.map((w) => `${warnSymbol} ${chalk.yellow(w)}`).join('\\n') : '';\n\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n const summary = formatSuccessSummary(`${totalCount} component(s) snapped${laneStr}`);\n const snapExplanation = formatHint(\n '(use \"bit export\" to push these components to a remote)\\n(use \"bit reset\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)'\n );\n\n // Build minimal output (no auto-snapped listing, just counts grouped by scope)\n const { newSection, changedSection } = buildSections(hasAutoSnapped ? formatCompMinimal : formatCompDetailed);\n\n const autoSnapSection = (() => {\n if (!hasAutoSnapped) return '';\n const scopeCounts = countBy(autoSnappedResults, (r) => r.component.id.scope);\n const sorted = Object.entries(scopeCounts).sort(([, a], [, b]) => b - a);\n const MAX_SHOWN = 4;\n const shown = sorted.slice(0, MAX_SHOWN).map(([scope, n]) => `${scope} (${n})`);\n const remaining = sorted.length - MAX_SHOWN;\n const scopeLine = remaining > 0 ? [...shown, `+ ${remaining} more scopes`].join(' · ') : shown.join(' · ');\n const title = formatTitle(`auto-snapped dependents (${autoSnappedCount})`);\n const scopes = ` ${scopeLine}`;\n const hint = formatDetailsHint('full list of auto-snapped dependents');\n return `${title}\\n${scopes}\\n${hint}`;\n })();\n\n const footerParts = [summary, snapExplanation].filter(Boolean).join('\\n');\n const data = joinSections([\n newSection,\n changedSection,\n autoSnapSection,\n removedSection,\n warningsSection,\n footerParts,\n ]);\n\n if (!hasAutoSnapped) {\n return data;\n }\n\n // Build detailed output (with full auto-snapped listing)\n const { newSection: newDetailed, changedSection: changedDetailed } = buildSections(formatCompDetailed);\n const detailedFooter = [summary, snapExplanation].filter(Boolean).join('\\n');\n const details = joinSections([newDetailed, changedDetailed, removedSection, warningsSection, detailedFooter]);\n\n return { data, code: 0, details };\n}\n\n/** @deprecated use snapResultReport instead */\nexport function snapResultOutput(results: SnapResults): string {\n const result = snapResultReport(results);\n return typeof result === 'string' ? result : result.details || result.data;\n}\n"],"mappings":";;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,iBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,gBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0D,SAAAC,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,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AAC,CAACC,WAAW,EAAEC,eAAe,EAAEhC,cAAc,EAAEE,eAAe,EAAE+B,cAAc,CAAC,CAAC;EAE7G,OAAO;IAAE3I,IAAI;IAAE6I,IAAI,EAAE,CAAC;IAAED;EAAQ,CAAC;AACnC;;AAEA;AACO,SAASE,gBAAgBA,CAAC/E,OAAoB,EAAU;EAC7D,MAAM8B,MAAM,GAAGxB,gBAAgB,CAACN,OAAO,CAAC;EACxC,OAAO,OAAO8B,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAAC+C,OAAO,IAAI/C,MAAM,CAAC7F,IAAI;AAC5E","ignoreList":[]}
@@ -113,7 +113,7 @@ export declare class SnappingMain {
113
113
  * with a valid semver to that version.
114
114
  * tag can be done only on main, not on a lane.
115
115
  */
116
- tag({ ids, message, version, editor, versionsFile, snapped, unmerged, releaseType, preReleaseId, ignoreIssues, ignoreNewestVersion, skipTests, skipTasks, skipAutoTag, build, unmodified, soft, persist, ignoreBuildErrors, rebuildDepsGraph, incrementBy, disableTagAndSnapPipelines, failFast, detachHead, overrideHead, loose, }: {
116
+ 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, }: {
117
117
  ids?: string[];
118
118
  all?: boolean | string;
119
119
  snapped?: boolean;
@@ -149,7 +149,7 @@ export declare class SnappingMain {
149
149
  * once a component is snapped on a lane, it becomes part of it.
150
150
  */
151
151
  snap({ pattern, legacyBitIds, // @todo: change to ComponentID[]. pass only if have the ids already parsed.
152
- unmerged, editor, message, ignoreIssues, skipTests, skipTasks, skipAutoSnap, build, disableTagAndSnapPipelines, ignoreBuildErrors, rebuildDepsGraph, unmodified, exitOnFirstFailedTask, detachHead, loose, }: Partial<BasicTagSnapParams> & {
152
+ unmerged, editor, message, ignoreIssues, skipTests, skipTasks, skipAutoSnap, build, disableTagAndSnapPipelines, ignoreBuildErrors, rebuildDepsGraph, noLockDeps, unmodified, exitOnFirstFailedTask, detachHead, loose, }: Partial<BasicTagSnapParams> & {
153
153
  pattern?: string;
154
154
  legacyBitIds?: ComponentIdList;
155
155
  unmerged?: boolean;
@@ -160,6 +160,31 @@ export declare class SnappingMain {
160
160
  unmodified?: boolean;
161
161
  exitOnFirstFailedTask?: boolean;
162
162
  }): Promise<SnapResults | null>;
163
+ /**
164
+ * Workspace-side merge snap. Routes both visible workspace components AND hidden lane
165
+ * lane.updateDependents through the same `makeVersion` pipeline that
166
+ * `snap`/`snapFromScope` use, so cascade snaps get fresh log/buildStatus/flattenedDependencies/
167
+ * lane-history/stagedSnaps just like every other snap.
168
+ *
169
+ * Visible: workspace.getMany picks up files written to disk by `applyVersion`.
170
+ * Hidden: applyVersion's in-memory merged ConsumerComponents are passed in directly — they
171
+ * have no bitmap entry, so they can't go through `loadComponentsForTagOrSnap`.
172
+ *
173
+ * version-maker's `isHiddenLaneEntry` detection (workspace-flow: not-in-bitmap) routes the
174
+ * hidden ones to the right branches (no bitmap update, stagedSnaps tracking,
175
+ * `addToUpdateDependentsInLane`).
176
+ */
177
+ snapForMerge({ visibleIds, hiddenLegacyComponents, message, build, loose, }: {
178
+ visibleIds: ComponentIdList;
179
+ hiddenLegacyComponents: ConsumerComponent[];
180
+ message?: string;
181
+ build?: boolean;
182
+ loose?: boolean;
183
+ }): Promise<{
184
+ snappedComponents: ConsumerComponent[];
185
+ autoSnappedResults: AutoTagResult[];
186
+ removedComponents?: ComponentIdList;
187
+ } | null>;
163
188
  /**
164
189
  * remove tags/snaps that exist locally, which were not exported yet.
165
190
  * once a tag/snap is exported, it's impossible to delete it as other components may depend on it
@@ -130,6 +130,13 @@ function _harmonyModules() {
130
130
  };
131
131
  return data;
132
132
  }
133
+ function _harmonyModules2() {
134
+ const data = require("@teambit/harmony.modules.get-basic-log");
135
+ _harmonyModules2 = function () {
136
+ return data;
137
+ };
138
+ return data;
139
+ }
133
140
  function _configStore() {
134
141
  const data = require("@teambit/config-store");
135
142
  _configStore = function () {
@@ -366,6 +373,7 @@ class SnappingMain {
366
373
  persist = false,
367
374
  ignoreBuildErrors = false,
368
375
  rebuildDepsGraph,
376
+ noLockDeps = false,
369
377
  incrementBy = 1,
370
378
  disableTagAndSnapPipelines = false,
371
379
  failFast = false,
@@ -414,6 +422,7 @@ class SnappingMain {
414
422
  disableTagAndSnapPipelines,
415
423
  ignoreBuildErrors,
416
424
  rebuildDepsGraph,
425
+ noLockDeps,
417
426
  incrementBy,
418
427
  packageManagerConfigRootDir: this.workspace.path,
419
428
  exitOnFirstFailedTask: failFast,
@@ -638,11 +647,17 @@ class SnappingMain {
638
647
  let exportedIds;
639
648
  if (params.push) {
640
649
  const updatedLane = lane ? await this.scope.legacyScope.loadLane(lane.toLaneId()) : undefined;
650
+ // include auto-tagged ids in the export set. For the bare-scope reverse cascade
651
+ // (`snapFromScope({ updateDependents: true })`), `getLaneAutoTagIdsFromScope` re-snaps
652
+ // lane.components that depend on the new hidden entry, and those new snaps must be pushed
653
+ // alongside the explicit target.
654
+ const autoTaggedIds = (results.autoTaggedResults || []).map(r => r.component.id);
655
+ const idsToExport = _componentId().ComponentIdList.uniqFromArray([...ids, ...autoTaggedIds]);
641
656
  const {
642
657
  exported
643
658
  } = await this.exporter.pushToScopes({
644
659
  scope: this.scope.legacyScope,
645
- ids,
660
+ ids: idsToExport,
646
661
  allVersions: false,
647
662
  laneObject: updatedLane,
648
663
  // no need other snaps. only the latest one. without this option, when snapping on lane from another-scope, it
@@ -679,6 +694,7 @@ class SnappingMain {
679
694
  disableTagAndSnapPipelines = false,
680
695
  ignoreBuildErrors = false,
681
696
  rebuildDepsGraph,
697
+ noLockDeps = false,
682
698
  unmodified = false,
683
699
  exitOnFirstFailedTask = false,
684
700
  detachHead,
@@ -710,6 +726,7 @@ class SnappingMain {
710
726
  disableTagAndSnapPipelines,
711
727
  ignoreBuildErrors,
712
728
  rebuildDepsGraph,
729
+ noLockDeps,
713
730
  packageManagerConfigRootDir: this.workspace.path,
714
731
  exitOnFirstFailedTask,
715
732
  detachHead,
@@ -769,6 +786,64 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
769
786
  }
770
787
  }
771
788
 
789
+ /**
790
+ * Workspace-side merge snap. Routes both visible workspace components AND hidden lane
791
+ * lane.updateDependents through the same `makeVersion` pipeline that
792
+ * `snap`/`snapFromScope` use, so cascade snaps get fresh log/buildStatus/flattenedDependencies/
793
+ * lane-history/stagedSnaps just like every other snap.
794
+ *
795
+ * Visible: workspace.getMany picks up files written to disk by `applyVersion`.
796
+ * Hidden: applyVersion's in-memory merged ConsumerComponents are passed in directly — they
797
+ * have no bitmap entry, so they can't go through `loadComponentsForTagOrSnap`.
798
+ *
799
+ * version-maker's `isHiddenLaneEntry` detection (workspace-flow: not-in-bitmap) routes the
800
+ * hidden ones to the right branches (no bitmap update, stagedSnaps tracking,
801
+ * `addToUpdateDependentsInLane`).
802
+ */
803
+ async snapForMerge({
804
+ visibleIds,
805
+ hiddenLegacyComponents,
806
+ message,
807
+ build,
808
+ loose
809
+ }) {
810
+ if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
811
+ if (!visibleIds.length && !hiddenLegacyComponents.length) return null;
812
+ this.logger.debug(`snapForMerge, visible: ${visibleIds.length}, hidden: ${hiddenLegacyComponents.length}`);
813
+ const visibleHarmony = visibleIds.length ? await this.loadComponentsForTagOrSnap(visibleIds) : [];
814
+ const hiddenHarmony = hiddenLegacyComponents.length ? await this.scope.getManyByLegacy(hiddenLegacyComponents) : [];
815
+ // issue checks are workspace-source-tree concerns — hidden entries are scope-only
816
+ if (visibleHarmony.length) await this.throwForVariousIssues(visibleHarmony);
817
+ const hiddenIds = _componentId().ComponentIdList.fromArray(hiddenLegacyComponents.map(c => c.componentId));
818
+ const allIds = _componentId().ComponentIdList.uniqFromArray([...visibleIds, ...hiddenIds]);
819
+ const allComponents = [...visibleHarmony, ...hiddenHarmony];
820
+ const makeVersionParams = {
821
+ ignoreNewestVersion: false,
822
+ message: message || '',
823
+ skipTests: false,
824
+ skipAutoTag: false,
825
+ persist: true,
826
+ soft: false,
827
+ build,
828
+ isSnap: true,
829
+ packageManagerConfigRootDir: this.workspace.path,
830
+ loose
831
+ };
832
+ const {
833
+ taggedComponents,
834
+ autoTaggedResults,
835
+ stagedConfig,
836
+ removedComponents
837
+ } = await this.makeVersion(allIds, allComponents, makeVersionParams);
838
+ await this.workspace.consumer.onDestroy(`merge-snap (message: ${message || 'N/A'})`);
839
+ await stagedConfig?.write();
840
+ return {
841
+ snappedComponents: taggedComponents,
842
+ autoSnappedResults: autoTaggedResults,
843
+ removedComponents
844
+ };
845
+ }
846
+
772
847
  /**
773
848
  * remove tags/snaps that exist locally, which were not exported yet.
774
849
  * once a tag/snap is exported, it's impossible to delete it as other components may depend on it
@@ -828,6 +903,11 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
828
903
  versionToSetInBitmap
829
904
  }) => {
830
905
  if (!component) return;
906
+ // hidden lane entries (lane.updateDependents) are not in the workspace bitmap, so skip
907
+ // bitmap updates for them. A soft-deleted (visible) entry is also absent from bitmap but
908
+ // `updateVersions` knows how to restore it from stagedConfig.
909
+ const compId = component.toComponentId();
910
+ if (currentLane?.findUpdateDependent(compId)) return;
831
911
  await (0, _versionMaker().updateVersions)(this.workspace, stagedConfig, currentLaneId, component, versionToSetInBitmap, false);
832
912
  });
833
913
  await this.workspace.scope.legacyScope.stagedSnaps.write();
@@ -1075,6 +1155,21 @@ another option, in case this dependency is not in main yet is to remove all refe
1075
1155
  });
1076
1156
  version.addAsOnlyParent(unrelated.headOnCurrentLane);
1077
1157
  }
1158
+ } else if (unmergedComponent.shouldSquash) {
1159
+ // --squash on diverged components: record the dropped lane-b head in squashed metadata
1160
+ // and leave `version.parents` as the single current-lane head. lane-b's history remains
1161
+ // reachable only on its own scope; the merge snap chain stays self-contained on this lane.
1162
+ // The diverged path always has a current-lane parent (that's what makes it diverged).
1163
+ const previousParents = [version.parents[0], unmergedComponent.head];
1164
+ // Fresh Log object — setSquashed retains it via version.modified[], and we mutate
1165
+ // version.log.message below, which would corrupt the modified-log entry if shared.
1166
+ const squashLog = await (0, _harmonyModules2().getLogForSquash)(unmergedComponent.laneId);
1167
+ version.setSquashed({
1168
+ previousParents,
1169
+ laneId: unmergedComponent.laneId
1170
+ }, squashLog);
1171
+ this.logger.debug(`sources.addSource, unmerged component "${component.name}". squash-on-diverged: dropping parent ${unmergedComponent.head.hash}`);
1172
+ version.log.message = version.log.message || _legacy().UnmergedComponents.buildSnapMessage(unmergedComponent);
1078
1173
  } else {
1079
1174
  // this is adding a second parent to the version. the order is important. the first parent is coming from the current-lane.
1080
1175
  version.addParent(unmergedComponent.head);