@teambit/snapping 1.0.444 → 1.0.445
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.
|
@@ -624,9 +624,9 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
624
624
|
targetId: f.componentId.fullName,
|
|
625
625
|
targetScope: f.componentId.scope
|
|
626
626
|
}));
|
|
627
|
-
const forkResults =
|
|
627
|
+
const forkResults = await this.forking.forkMultipleFromRemote(forkMultipleData, {
|
|
628
628
|
refactor: true
|
|
629
|
-
})
|
|
629
|
+
});
|
|
630
630
|
const newEnvData = {};
|
|
631
631
|
forkedFromData.forEach(f => {
|
|
632
632
|
const bitmapElem = this.workspace.bitMap.getBitmapEntry(f.componentId);
|
|
@@ -642,7 +642,6 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
642
642
|
await (0, _pMapSeries().default)(Object.entries(newEnvData), async ([env, compIds]) => {
|
|
643
643
|
await this.workspace.setEnvToComponents(_componentId().ComponentID.fromString(env), compIds, false);
|
|
644
644
|
});
|
|
645
|
-
// @todo: merge current config in .bitmap with "aspect" prop of forkedFromData.
|
|
646
645
|
const getSnapData = id => {
|
|
647
646
|
const snapData = snapDataPerComp.find(t => {
|
|
648
647
|
return t.componentId.isEqual(id, {
|
|
@@ -652,15 +651,35 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
652
651
|
if (!snapData) throw new Error(`unable to find ${id.toString()} in snapDataPerComp`);
|
|
653
652
|
return snapData;
|
|
654
653
|
};
|
|
655
|
-
const newForkedComponents =
|
|
654
|
+
const newForkedComponents = await this.workspace.getMany(forkResults.map(f => f.targetCompId));
|
|
656
655
|
await Promise.all(newForkedComponents.map(async comp => {
|
|
657
656
|
const snapData = getSnapData(comp.id);
|
|
658
|
-
// if (snapData.aspects) await this.scope.addAspectsFromConfigObject(comp, snapData.aspects);
|
|
659
657
|
if (snapData.files?.length) {
|
|
660
658
|
await this.updateSourceFiles(comp, snapData.files);
|
|
661
659
|
await this.workspace.write(comp);
|
|
662
660
|
}
|
|
661
|
+
if (snapData.aspects) {
|
|
662
|
+
const bitmapElem = this.workspace.bitMap.getBitmapEntry(comp.id);
|
|
663
|
+
if (!bitmapElem) throw new Error(`unable to find ${comp.id.toString()} in the bitmap`);
|
|
664
|
+
const currentConfig = bitmapElem.config;
|
|
665
|
+
if (!currentConfig) {
|
|
666
|
+
this.workspace.bitMap.setEntireConfig(comp.id, snapData.aspects);
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const currentEnvSettings = currentConfig['teambit.envs/envs'];
|
|
670
|
+
const currentEnv = currentEnvSettings !== '-' && currentEnvSettings.env;
|
|
671
|
+
const newEnv = snapData.aspects['teambit.envs/envs']?.env;
|
|
672
|
+
if (!currentEnv || !newEnv) {
|
|
673
|
+
this.workspace.bitMap.setEntireConfig(comp.id, _objectSpread(_objectSpread({}, currentConfig), snapData.aspects));
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const currentEnvWithPotentialVer = Object.keys(currentConfig).find(c => c === currentEnv || c.startsWith(`${currentEnv}@`));
|
|
677
|
+
if (currentEnvWithPotentialVer) delete currentConfig[currentEnvWithPotentialVer];
|
|
678
|
+
delete currentConfig['teambit.envs/envs'];
|
|
679
|
+
this.workspace.bitMap.setEntireConfig(comp.id, _objectSpread(_objectSpread({}, currentConfig), snapData.aspects));
|
|
680
|
+
}
|
|
663
681
|
}));
|
|
682
|
+
await this.workspace.bitMap.write();
|
|
664
683
|
// if you don't clear the cache here, the installation assumes all components have the old env.
|
|
665
684
|
await this.workspace.clearCache();
|
|
666
685
|
await this.install.install(undefined, {
|