@teambit/dependency-resolver 1.0.276 → 1.0.278
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/artifacts/__bit_junit.xml +27 -27
- package/artifacts/preview/teambit_dependencies_dependency_resolver-preview.js +1 -1
- package/artifacts/schema.json +1516 -1356
- package/dist/dependency-resolver.main.runtime.d.ts +9 -1
- package/dist/dependency-resolver.main.runtime.js +29 -0
- package/dist/dependency-resolver.main.runtime.js.map +1 -1
- package/dist/policy/env-policy/env-policy.d.ts +1 -1
- package/dist/policy/env-policy/env-policy.js +5 -0
- package/dist/policy/env-policy/env-policy.js.map +1 -1
- package/dist/{preview-1716088732412.js → preview-1716302635312.js} +2 -2
- package/package.json +14 -14
- package/policy/env-policy/env-policy.ts +6 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, ComponentMap, ComponentMain, IComponent } from '@teambit/component';
|
|
2
2
|
import type { ConfigMain } from '@teambit/config';
|
|
3
|
-
import { DependenciesEnv, EnvDefinition, EnvsMain } from '@teambit/envs';
|
|
3
|
+
import type { DependenciesEnv, EnvDefinition, EnvJsonc, EnvsMain } from '@teambit/envs';
|
|
4
4
|
import { SlotRegistry, ExtensionManifest, Aspect } from '@teambit/harmony';
|
|
5
5
|
import { RequireableComponent } from '@teambit/harmony.modules.requireable-component';
|
|
6
6
|
import type { LoggerMain } from '@teambit/logger';
|
|
@@ -295,6 +295,14 @@ export declare class DependencyResolverMain {
|
|
|
295
295
|
getEnvPolicyFromEnvLegacyId(id: ComponentID, legacyFiles?: SourceFile[]): Promise<EnvPolicy | undefined>;
|
|
296
296
|
getComponentEnvPolicy(component: Component): Promise<EnvPolicy>;
|
|
297
297
|
getEnvManifest(envComponent?: Component, legacyFiles?: SourceFile[]): EnvPolicy | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Merge policy from parent and child env.jsonc files
|
|
300
|
+
* The rule is that for each type of dependency (dev, runtime, peer) we check each item.
|
|
301
|
+
* if a dep with a name exists on the child we will take the entire object from the child (including the version,
|
|
302
|
+
* supported range, force etc')
|
|
303
|
+
* if a dep exists with a version value "-" we will remove it from the policy
|
|
304
|
+
*/
|
|
305
|
+
mergeEnvManifestPolicy(parent: EnvJsonc, child: EnvJsonc): Object;
|
|
298
306
|
private getEnvPolicyFromFile;
|
|
299
307
|
getComponentEnvPolicyFromEnv(env: DependenciesEnv, options: {
|
|
300
308
|
envId: string;
|
|
@@ -1042,6 +1042,34 @@ class DependencyResolverMain {
|
|
|
1042
1042
|
});
|
|
1043
1043
|
return allPoliciesFromEnv;
|
|
1044
1044
|
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Merge policy from parent and child env.jsonc files
|
|
1048
|
+
* The rule is that for each type of dependency (dev, runtime, peer) we check each item.
|
|
1049
|
+
* if a dep with a name exists on the child we will take the entire object from the child (including the version,
|
|
1050
|
+
* supported range, force etc')
|
|
1051
|
+
* if a dep exists with a version value "-" we will remove it from the policy
|
|
1052
|
+
*/
|
|
1053
|
+
mergeEnvManifestPolicy(parent, child) {
|
|
1054
|
+
const policy = {};
|
|
1055
|
+
['peers', 'dev', 'runtime'].forEach(key => {
|
|
1056
|
+
policy[key] = (0, _lodash().cloneDeep)(parent.policy?.[key] || []);
|
|
1057
|
+
const childEntries = (0, _lodash().cloneDeep)(child.policy?.[key] || []);
|
|
1058
|
+
policy[key] = policy[key].filter(entry => {
|
|
1059
|
+
const foundChildEntry = childEntries.find(childEntry => {
|
|
1060
|
+
return childEntry.name === entry.name;
|
|
1061
|
+
});
|
|
1062
|
+
return !foundChildEntry;
|
|
1063
|
+
});
|
|
1064
|
+
policy[key] = policy[key].concat(childEntries);
|
|
1065
|
+
policy[key] = policy[key].filter(entry => {
|
|
1066
|
+
return entry.version !== '-';
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
1069
|
+
return {
|
|
1070
|
+
policy
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1045
1073
|
async getEnvPolicyFromFile(envId, legacyFiles) {
|
|
1046
1074
|
const isCoreEnv = this.envs.isCoreEnv(envId);
|
|
1047
1075
|
if (isCoreEnv) return undefined;
|
|
@@ -1377,6 +1405,7 @@ class DependencyResolverMain {
|
|
|
1377
1405
|
if (aspectLoader) aspectLoader.registerOnLoadRequireableExtensionSlot(dependencyResolver.onLoadRequireableExtensionSubscriber.bind(dependencyResolver));
|
|
1378
1406
|
graphql.register((0, _dependencyResolver2().dependencyResolverSchema)(dependencyResolver));
|
|
1379
1407
|
envs.registerService(new (_dependencies2().DependenciesService)());
|
|
1408
|
+
envs.registerEnvJsoncMergeCustomizer(dependencyResolver.mergeEnvManifestPolicy.bind(dependencyResolver));
|
|
1380
1409
|
|
|
1381
1410
|
// this is needed because during tag process, the data.dependencies can be loaded and the componentId can become
|
|
1382
1411
|
// an instance of ComponentID class. it needs to be serialized before saved into objects.
|