@teambit/snapping 1.0.1254 → 1.0.1256
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.
- package/dist/generate-comp-from-scope.d.ts +2 -1
- package/dist/generate-comp-from-scope.js +2 -2
- package/dist/generate-comp-from-scope.js.map +1 -1
- package/dist/snapping.main.runtime.js +4 -1
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/version-maker.js +27 -34
- package/dist/version-maker.js.map +1 -1
- package/package.json +12 -12
- /package/dist/{preview-1793047077349.js → preview-1793052807994.js} +0 -0
package/dist/version-maker.js
CHANGED
|
@@ -173,6 +173,13 @@ function _dependencyResolver() {
|
|
|
173
173
|
};
|
|
174
174
|
return data;
|
|
175
175
|
}
|
|
176
|
+
function _workspace() {
|
|
177
|
+
const data = require("@teambit/workspace");
|
|
178
|
+
_workspace = function () {
|
|
179
|
+
return data;
|
|
180
|
+
};
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
176
183
|
function _workspaceRoot() {
|
|
177
184
|
const data = require("@teambit/workspace-root");
|
|
178
185
|
_workspaceRoot = function () {
|
|
@@ -230,7 +237,9 @@ class VersionMaker {
|
|
|
230
237
|
const componentsToTag = this.getUniqCompsToTag();
|
|
231
238
|
const idsToTag = _componentId().ComponentIdList.fromArray(componentsToTag.map(c => c.id));
|
|
232
239
|
// a component that is tagged explicitly is not auto-tagged too (the scope flow may find it as both)
|
|
233
|
-
|
|
240
|
+
// like updateDependenciesVersions, a removed component is not a new version of its dependents' dependency
|
|
241
|
+
const removedIds = _componentId().ComponentIdList.fromArray(componentsToTag.filter(c => c.isRemoved()).map(c => c.id));
|
|
242
|
+
const autoTagData = (await this.getAutoTagData(idsToTag, removedIds)).filter(autoTagItem => !idsToTag.has(autoTagItem.component.id));
|
|
234
243
|
const autoTagComponents = autoTagData.map(autoTagItem => autoTagItem.component);
|
|
235
244
|
const autoTagIds = _componentId().ComponentIdList.fromArray(autoTagComponents.map(autoTag => autoTag.id));
|
|
236
245
|
|
|
@@ -547,13 +556,13 @@ class VersionMaker {
|
|
|
547
556
|
});
|
|
548
557
|
return Object.values(consumerComponentsIdsMap); // consumerComponents unique
|
|
549
558
|
}
|
|
550
|
-
async getAutoTagData(idsToTag) {
|
|
559
|
+
async getAutoTagData(idsToTag, removedIds) {
|
|
551
560
|
if (this.params.skipAutoTag) return [];
|
|
552
561
|
// hidden lane.updateDependents are scope-only — they're not in the workspace
|
|
553
562
|
// bitmap, so the workspace autotag candidate pool can't see them. Always run the scope-side
|
|
554
563
|
// autotag pass alongside the workspace one when on a lane, so cascading a hidden updateDependent
|
|
555
564
|
// off a workspace snap (scenario 1) works.
|
|
556
|
-
const fromScope = await this.getLaneAutoTagIdsFromScope(idsToTag, /* hiddenOnly */Boolean(this.workspace));
|
|
565
|
+
const fromScope = await this.getLaneAutoTagIdsFromScope(idsToTag, removedIds, /* hiddenOnly */Boolean(this.workspace));
|
|
557
566
|
if (!this.workspace) return fromScope;
|
|
558
567
|
// ids without versions are new. it's impossible that tagged (and not-modified) components has
|
|
559
568
|
// them as dependencies. Also filter out hidden lane entries — getAutoTagInfo loads
|
|
@@ -574,43 +583,27 @@ class VersionMaker {
|
|
|
574
583
|
const fromScopeFiltered = fromScope.filter(a => !workspaceIds.has(a.component.id.toStringWithoutVersion()));
|
|
575
584
|
return [...fromWorkspace, ...fromScopeFiltered];
|
|
576
585
|
}
|
|
577
|
-
async getLaneAutoTagIdsFromScope(idsToTag, hiddenOnly = false) {
|
|
586
|
+
async getLaneAutoTagIdsFromScope(idsToTag, removedIds, hiddenOnly = false) {
|
|
587
|
+
const triggerIds = _componentId().ComponentIdList.fromArray(idsToTag.filter(id => !removedIds.has(id)));
|
|
588
|
+
if (!triggerIds.length) return [];
|
|
578
589
|
const lane = await this.legacyScope.getCurrentLaneObject();
|
|
579
590
|
if (!lane) return [];
|
|
580
591
|
// for the workspace+lane path we only care about hidden entries — workspace autotag handles
|
|
581
592
|
// visible ones. for the bare-scope path (no workspace), include all lane entries.
|
|
582
|
-
const
|
|
583
|
-
const candidateLaneIds =
|
|
593
|
+
const laneIds = hiddenOnly ? lane.updateDependents || [] : lane.toComponentIdsIncludeUpdateDependents();
|
|
594
|
+
const candidateLaneIds = laneIds.filter(id => !idsToTag.hasWithoutVersion(id));
|
|
584
595
|
if (!candidateLaneIds.length) return [];
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
const graphSeedIds = _componentId().ComponentIdList.uniqFromArray([...laneCompIds, ...idsToTag]);
|
|
592
|
-
const graphIds = await this.scope.getGraphIds(graphSeedIds);
|
|
593
|
-
const dependentsMap = idsToTag.reduce((acc, id) => {
|
|
594
|
-
const dependents = graphIds.predecessors(id.toString());
|
|
595
|
-
const dependentsCompIds = dependents.map(d => d.attr);
|
|
596
|
-
const dependentsCompIdsFromTheLane = dependentsCompIds.filter(s => laneCompIds.has(s));
|
|
597
|
-
if (!dependentsCompIdsFromTheLane.length) return acc;
|
|
598
|
-
acc[id.toString()] = _componentId().ComponentIdList.fromArray(dependentsCompIdsFromTheLane);
|
|
599
|
-
return acc;
|
|
600
|
-
}, {});
|
|
601
|
-
if (Object.keys(dependentsMap).length === 0) return [];
|
|
602
|
-
const allDependentsIds = _componentId().ComponentIdList.uniqFromArray(Object.values(dependentsMap).flat());
|
|
603
|
-
const allDependents = await this.legacyScope.getManyConsumerComponents(allDependentsIds);
|
|
604
|
-
// a component that was removed from the lane is not snapped again, same as in a workspace, where it's not loaded
|
|
605
|
-
const notRemovedDependents = allDependents.filter(dependent => !dependent.isRemoved());
|
|
606
|
-
return notRemovedDependents.map(dependent => {
|
|
607
|
-
const triggeredByIds = Object.keys(dependentsMap).filter(id => dependentsMap[id].has(dependent.id));
|
|
608
|
-
const triggeredBy = _componentId().ComponentIdList.fromStringArray(triggeredByIds);
|
|
609
|
-
return {
|
|
610
|
-
component: dependent,
|
|
611
|
-
triggeredBy
|
|
612
|
-
};
|
|
596
|
+
// a bare scope (e.g. a Ripple cascade) has only the components it snaps. fetch the lane entries that are missing.
|
|
597
|
+
await this.scope.import(candidateLaneIds, {
|
|
598
|
+
lane,
|
|
599
|
+
includeUpdateDependents: true,
|
|
600
|
+
reFetchUnBuiltVersion: false,
|
|
601
|
+
reason: 'to find the lane components to snap along'
|
|
613
602
|
});
|
|
603
|
+
const candidates = await this.legacyScope.getManyConsumerComponents(_componentId().ComponentIdList.fromArray(candidateLaneIds));
|
|
604
|
+
// a component that was removed from the lane is not snapped again, same as in a workspace, where it's not loaded
|
|
605
|
+
const notRemovedCandidates = candidates.filter(candidate => !candidate.isRemoved());
|
|
606
|
+
return (0, _workspace().getAutoTagInfoFromComponents)(notRemovedCandidates, triggerIds);
|
|
614
607
|
}
|
|
615
608
|
async setFutureVersions(autoTagIds) {
|
|
616
609
|
const {
|