@teambit/install 1.0.394 → 1.0.396
Sign up to get free protection for your applications and to get access to all the features.
- package/artifacts/__bit_junit.xml +3 -3
- package/artifacts/schema.json +456 -348
- package/dist/install.main.runtime.d.ts +15 -0
- package/dist/install.main.runtime.js +73 -0
- package/dist/install.main.runtime.js.map +1 -1
- package/package.json +17 -17
- /package/dist/{preview-1725074428767.js → preview-1725247248940.js} +0 -0
@@ -114,6 +114,21 @@ export declare class InstallMain {
|
|
114
114
|
private reloadNonLoadedEnvs;
|
115
115
|
private reloadEnvs;
|
116
116
|
private reloadAspects;
|
117
|
+
private reloadOneAspectsGroup;
|
118
|
+
/**
|
119
|
+
* This function groups the components to aspects to load into groups.
|
120
|
+
* The order of the groups is important, the first group should be loaded first.
|
121
|
+
* The order inside the group is not important.
|
122
|
+
* The groups are:
|
123
|
+
* 1. aspects definitions without components (this should be an empty group, if it's not, we should check why).
|
124
|
+
* 2. aspects which are not in the workspace but in the scope / node modules.
|
125
|
+
* 3. envs of aspects (which are also aspects)
|
126
|
+
* 4. other aspects (the rest)
|
127
|
+
* @param aspects
|
128
|
+
* @returns
|
129
|
+
*/
|
130
|
+
private groupAspectsToLoad;
|
131
|
+
private regroupEnvsIdsFromTheList;
|
117
132
|
private _getComponentsManifestsAndRootPolicy;
|
118
133
|
/**
|
119
134
|
* The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error
|
@@ -625,6 +625,21 @@ class InstallMain {
|
|
625
625
|
}
|
626
626
|
}
|
627
627
|
async reloadAspects(aspects) {
|
628
|
+
const groups = await this.groupAspectsToLoad(aspects);
|
629
|
+
// We need to make sure we load group by group and not in parallel
|
630
|
+
await (0, _pMapSeries().default)(groups, async group => {
|
631
|
+
await this.reloadOneAspectsGroup(group);
|
632
|
+
});
|
633
|
+
}
|
634
|
+
async reloadOneAspectsGroup(group) {
|
635
|
+
const aspects = group.aspects || [];
|
636
|
+
if (group.workspace && !group.envOfAspect) {
|
637
|
+
aspects.forEach(aspectDef => {
|
638
|
+
if (aspectDef.component?.id) {
|
639
|
+
this.workspace.clearComponentCache(aspectDef.component.id);
|
640
|
+
}
|
641
|
+
});
|
642
|
+
}
|
628
643
|
const loadedPlugins = (0, _lodash().compact)(await Promise.all(aspects.map(aspectDef => {
|
629
644
|
const localPath = aspectDef.aspectPath;
|
630
645
|
const component = aspectDef.component;
|
@@ -639,6 +654,64 @@ class InstallMain {
|
|
639
654
|
return runtime?.provider(undefined, undefined, undefined, this.harmony);
|
640
655
|
}));
|
641
656
|
}
|
657
|
+
|
658
|
+
/**
|
659
|
+
* This function groups the components to aspects to load into groups.
|
660
|
+
* The order of the groups is important, the first group should be loaded first.
|
661
|
+
* The order inside the group is not important.
|
662
|
+
* The groups are:
|
663
|
+
* 1. aspects definitions without components (this should be an empty group, if it's not, we should check why).
|
664
|
+
* 2. aspects which are not in the workspace but in the scope / node modules.
|
665
|
+
* 3. envs of aspects (which are also aspects)
|
666
|
+
* 4. other aspects (the rest)
|
667
|
+
* @param aspects
|
668
|
+
* @returns
|
669
|
+
*/
|
670
|
+
async groupAspectsToLoad(aspects) {
|
671
|
+
const groups = (0, _lodash().groupBy)(aspects, aspectDef => {
|
672
|
+
if (!aspectDef.component) return 'no-comp';
|
673
|
+
if (!this.workspace.hasId(aspectDef.component.id)) return 'scope';
|
674
|
+
return 'workspace';
|
675
|
+
});
|
676
|
+
const workspaceSubGroups = await this.regroupEnvsIdsFromTheList(groups.workspace || []);
|
677
|
+
return [{
|
678
|
+
comps: false,
|
679
|
+
workspace: false,
|
680
|
+
aspects: groups.noComp || []
|
681
|
+
}, {
|
682
|
+
comps: true,
|
683
|
+
workspace: false,
|
684
|
+
aspects: groups.scope || []
|
685
|
+
}, {
|
686
|
+
comps: true,
|
687
|
+
workspace: true,
|
688
|
+
envOfAspect: true,
|
689
|
+
aspects: workspaceSubGroups.envOfAspect
|
690
|
+
}, {
|
691
|
+
comps: true,
|
692
|
+
workspace: true,
|
693
|
+
aspects: workspaceSubGroups.otherAspects
|
694
|
+
}];
|
695
|
+
}
|
696
|
+
async regroupEnvsIdsFromTheList(aspects) {
|
697
|
+
const envsOfAspects = new Set();
|
698
|
+
await Promise.all(aspects.map(async aspectDef => {
|
699
|
+
if (!aspectDef.component) return;
|
700
|
+
const envId = aspectDef.component ? await this.envs.calculateEnvId(aspectDef.component) : undefined;
|
701
|
+
if (envId) {
|
702
|
+
envsOfAspects.add(envId.toString());
|
703
|
+
}
|
704
|
+
}));
|
705
|
+
const groups = (0, _lodash().groupBy)(aspects, aspectDef => {
|
706
|
+
const id = aspectDef.component?.id.toString();
|
707
|
+
const idWithoutVersion = aspectDef.component?.id.toStringWithoutVersion();
|
708
|
+
if (id && envsOfAspects.has(id) || idWithoutVersion && envsOfAspects.has(idWithoutVersion)) {
|
709
|
+
return 'envOfAspect';
|
710
|
+
}
|
711
|
+
return 'otherAspects';
|
712
|
+
});
|
713
|
+
return groups;
|
714
|
+
}
|
642
715
|
async _getComponentsManifestsAndRootPolicy(installer, options) {
|
643
716
|
const mergedRootPolicy = await this.addConfiguredAspectsToWorkspacePolicy();
|
644
717
|
await this.addConfiguredGeneratorEnvsToWorkspacePolicy(mergedRootPolicy);
|