@teambit/dependency-resolver 1.0.27 → 1.0.30
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/dependencies/component-dependency/component-dependency-factory.ts +7 -6
- package/dependencies/component-dependency/component-dependency.ts +1 -1
- package/dependencies/dependency-list.ts +19 -3
- package/dist/dependencies/component-dependency/component-dependency-factory.js +6 -5
- package/dist/dependencies/component-dependency/component-dependency-factory.js.map +1 -1
- package/dist/dependencies/component-dependency/component-dependency.js +1 -1
- package/dist/dependencies/component-dependency/component-dependency.js.map +1 -1
- package/dist/dependencies/dependency-list.js +18 -4
- package/dist/dependencies/dependency-list.js.map +1 -1
- package/dist/dependency-installer.js +1 -1
- package/dist/dependency-installer.js.map +1 -1
- package/dist/dependency-resolver.main.runtime.d.ts +8 -9
- package/dist/dependency-resolver.main.runtime.js +60 -33
- package/dist/dependency-resolver.main.runtime.js.map +1 -1
- package/dist/dependency-resolver.main.runtime.spec.js +5 -1
- package/dist/dependency-resolver.main.runtime.spec.js.map +1 -1
- package/dist/manifest/workspace-manifest-factory.js +3 -3
- package/dist/manifest/workspace-manifest-factory.js.map +1 -1
- package/dist/policy/env-policy/env-policy.d.ts +2 -2
- package/dist/policy/env-policy/env-policy.js +23 -3
- package/dist/policy/env-policy/env-policy.js.map +1 -1
- package/dist/policy/variant-policy/index.d.ts +1 -1
- package/dist/policy/variant-policy/index.js +6 -0
- package/dist/policy/variant-policy/index.js.map +1 -1
- package/dist/policy/variant-policy/variant-policy.d.ts +7 -1
- package/dist/policy/variant-policy/variant-policy.js +5 -1
- package/dist/policy/variant-policy/variant-policy.js.map +1 -1
- package/dist/{preview-1697628054879.js → preview-1697841196686.js} +2 -2
- package/manifest/workspace-manifest-factory.ts +4 -4
- package/package.json +20 -20
- package/policy/env-policy/env-policy.ts +22 -4
- package/policy/variant-policy/index.ts +1 -0
- package/policy/variant-policy/variant-policy.ts +11 -1
|
@@ -121,6 +121,13 @@ function _dependencyResolver() {
|
|
|
121
121
|
};
|
|
122
122
|
return data;
|
|
123
123
|
}
|
|
124
|
+
function _extensionData() {
|
|
125
|
+
const data = require("@teambit/legacy/dist/consumer/config/extension-data");
|
|
126
|
+
_extensionData = function () {
|
|
127
|
+
return data;
|
|
128
|
+
};
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
124
131
|
function _componentIdToPackageName() {
|
|
125
132
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/bit/component-id-to-package-name"));
|
|
126
133
|
_componentIdToPackageName = function () {
|
|
@@ -156,9 +163,9 @@ function _fsExtra() {
|
|
|
156
163
|
};
|
|
157
164
|
return data;
|
|
158
165
|
}
|
|
159
|
-
function
|
|
160
|
-
const data = require("@teambit/
|
|
161
|
-
|
|
166
|
+
function _componentId() {
|
|
167
|
+
const data = require("@teambit/component-id");
|
|
168
|
+
_componentId = function () {
|
|
162
169
|
return data;
|
|
163
170
|
};
|
|
164
171
|
return data;
|
|
@@ -949,15 +956,19 @@ class DependencyResolverMain {
|
|
|
949
956
|
const envId = await this.envs.calculateEnvIdFromExtensions(configuredExtensions);
|
|
950
957
|
if (this.envs.isCoreEnv(envId)) {
|
|
951
958
|
const env = await this.envs.calculateEnvFromExtensions(configuredExtensions);
|
|
952
|
-
return this.getComponentEnvPolicyFromEnv(env.env
|
|
959
|
+
return this.getComponentEnvPolicyFromEnv(env.env, {
|
|
960
|
+
envId
|
|
961
|
+
});
|
|
953
962
|
}
|
|
954
963
|
const fromFile = await this.getEnvPolicyFromFile(envId);
|
|
955
964
|
if (fromFile) return fromFile;
|
|
956
965
|
const env = await this.envs.calculateEnvFromExtensions(configuredExtensions);
|
|
957
|
-
return this.getComponentEnvPolicyFromEnv(env.env
|
|
966
|
+
return this.getComponentEnvPolicyFromEnv(env.env, {
|
|
967
|
+
envId
|
|
968
|
+
});
|
|
958
969
|
}
|
|
959
970
|
async getEnvPolicyFromEnvId(id, legacyFiles) {
|
|
960
|
-
return this.getEnvPolicyFromEnvLegacyId(id
|
|
971
|
+
return this.getEnvPolicyFromEnvLegacyId(id, legacyFiles);
|
|
961
972
|
}
|
|
962
973
|
async getEnvPolicyFromEnvLegacyId(id, legacyFiles) {
|
|
963
974
|
const fromFile = await this.getEnvPolicyFromFile(id.toString(), legacyFiles);
|
|
@@ -965,26 +976,35 @@ class DependencyResolverMain {
|
|
|
965
976
|
const envDef = await this.envs.getEnvDefinitionByLegacyId(id);
|
|
966
977
|
if (!envDef) return undefined;
|
|
967
978
|
const env = envDef.env;
|
|
968
|
-
return this.getComponentEnvPolicyFromEnv(env
|
|
979
|
+
return this.getComponentEnvPolicyFromEnv(env, {
|
|
980
|
+
envId: id.toStringWithoutVersion()
|
|
981
|
+
});
|
|
969
982
|
}
|
|
970
983
|
async getComponentEnvPolicy(component) {
|
|
971
984
|
// const envComponent = await this.envs.getEnvComponent(component);
|
|
972
985
|
const envId = await this.envs.calculateEnvId(component);
|
|
973
|
-
|
|
986
|
+
const envIdWithoutVersion = envId.toStringWithoutVersion();
|
|
987
|
+
if (this.envs.isCoreEnv(envIdWithoutVersion)) {
|
|
974
988
|
const env = this.envs.getEnv(component).env;
|
|
975
|
-
return this.getComponentEnvPolicyFromEnv(env
|
|
989
|
+
return this.getComponentEnvPolicyFromEnv(env, {
|
|
990
|
+
envId: envIdWithoutVersion
|
|
991
|
+
});
|
|
976
992
|
}
|
|
977
993
|
const fromFile = await this.getEnvPolicyFromFile(envId.toString());
|
|
978
994
|
if (fromFile) return fromFile;
|
|
979
995
|
this.envsWithoutManifest.add(envId.toString());
|
|
980
996
|
const env = this.envs.getEnv(component).env;
|
|
981
|
-
return this.getComponentEnvPolicyFromEnv(env
|
|
997
|
+
return this.getComponentEnvPolicyFromEnv(env, {
|
|
998
|
+
envId: envIdWithoutVersion
|
|
999
|
+
});
|
|
982
1000
|
}
|
|
983
1001
|
getEnvManifest(envComponent, legacyFiles) {
|
|
984
1002
|
const object = this.envs.getEnvManifest(envComponent, legacyFiles);
|
|
985
1003
|
const policy = object === null || object === void 0 ? void 0 : object.policy;
|
|
986
1004
|
if (!policy) return undefined;
|
|
987
|
-
const allPoliciesFromEnv = _envPolicy().EnvPolicy.fromConfigObject(policy
|
|
1005
|
+
const allPoliciesFromEnv = _envPolicy().EnvPolicy.fromConfigObject(policy, {
|
|
1006
|
+
includeLegacyPeersInSelfPolicy: envComponent && this.envs.isCoreEnv(envComponent.id.toStringWithoutVersion())
|
|
1007
|
+
});
|
|
988
1008
|
return allPoliciesFromEnv;
|
|
989
1009
|
}
|
|
990
1010
|
async getEnvPolicyFromFile(envId, legacyFiles) {
|
|
@@ -996,11 +1016,14 @@ class DependencyResolverMain {
|
|
|
996
1016
|
const envComponent = await this.envs.getEnvComponentByEnvId(envId, envId);
|
|
997
1017
|
return this.getEnvManifest(envComponent);
|
|
998
1018
|
}
|
|
999
|
-
async getComponentEnvPolicyFromEnv(env) {
|
|
1019
|
+
async getComponentEnvPolicyFromEnv(env, options) {
|
|
1000
1020
|
if (env.getDependencies && typeof env.getDependencies === 'function') {
|
|
1001
1021
|
const policiesFromEnvConfig = await env.getDependencies();
|
|
1002
1022
|
if (policiesFromEnvConfig) {
|
|
1003
|
-
const
|
|
1023
|
+
const idWithoutVersion = options.envId.split('@')[0];
|
|
1024
|
+
const allPoliciesFromEnv = _envPolicy().EnvPolicy.fromConfigObject(policiesFromEnvConfig, {
|
|
1025
|
+
includeLegacyPeersInSelfPolicy: this.envs.isCoreEnv(idWithoutVersion)
|
|
1026
|
+
});
|
|
1004
1027
|
return allPoliciesFromEnv;
|
|
1005
1028
|
}
|
|
1006
1029
|
}
|
|
@@ -1009,7 +1032,9 @@ class DependencyResolverMain {
|
|
|
1009
1032
|
async getComponentEnvPolicyFromEnvDefinition(envDef) {
|
|
1010
1033
|
const fromFile = await this.getEnvPolicyFromFile(envDef.id);
|
|
1011
1034
|
if (fromFile) return fromFile;
|
|
1012
|
-
return this.getComponentEnvPolicyFromEnv(envDef.env
|
|
1035
|
+
return this.getComponentEnvPolicyFromEnv(envDef.env, {
|
|
1036
|
+
envId: envDef.id
|
|
1037
|
+
});
|
|
1013
1038
|
}
|
|
1014
1039
|
|
|
1015
1040
|
/**
|
|
@@ -1052,14 +1077,18 @@ class DependencyResolverMain {
|
|
|
1052
1077
|
return policyRegistrar === extId || policyRegistrar.includes(extId);
|
|
1053
1078
|
});
|
|
1054
1079
|
if (policyTupleToApply && policyTupleToApply[1]) {
|
|
1055
|
-
const currentPolicy = _policy().VariantPolicy.fromConfigObject(policyTupleToApply[1],
|
|
1080
|
+
const currentPolicy = _policy().VariantPolicy.fromConfigObject(policyTupleToApply[1], {
|
|
1081
|
+
source: 'slots'
|
|
1082
|
+
});
|
|
1056
1083
|
policiesFromSlots = _policy().VariantPolicy.mergePolices([policiesFromSlots, currentPolicy]);
|
|
1057
1084
|
}
|
|
1058
1085
|
});
|
|
1059
1086
|
const currentExtension = configuredExtensions.findExtension(_dependencyResolver2().DependencyResolverAspect.id);
|
|
1060
1087
|
const currentConfig = currentExtension === null || currentExtension === void 0 ? void 0 : currentExtension.config;
|
|
1061
1088
|
if (currentConfig && currentConfig.policy) {
|
|
1062
|
-
policiesFromConfig = _policy().VariantPolicy.fromConfigObject(currentConfig.policy,
|
|
1089
|
+
policiesFromConfig = _policy().VariantPolicy.fromConfigObject(currentConfig.policy, {
|
|
1090
|
+
source: 'config'
|
|
1091
|
+
});
|
|
1063
1092
|
}
|
|
1064
1093
|
const policiesFromEnvForItself = (await this.getPoliciesFromEnvForItself(id, legacyFiles)) ?? _policy().VariantPolicy.getEmpty();
|
|
1065
1094
|
const result = _policy().VariantPolicy.mergePolices([policiesFromEnv, policiesFromEnvForItself, policiesFromSlots, policiesFromConfig]);
|
|
@@ -1082,7 +1111,7 @@ class DependencyResolverMain {
|
|
|
1082
1111
|
const dependencies = (0, _lodash().get)(entry, ['data', 'dependencies'], []);
|
|
1083
1112
|
dependencies.forEach(dep => {
|
|
1084
1113
|
if (dep.__type === _dependencies().COMPONENT_DEP_TYPE) {
|
|
1085
|
-
const depId =
|
|
1114
|
+
const depId = _componentId().ComponentID.fromObject(dep.componentId);
|
|
1086
1115
|
const newDepId = idTransformer(depId);
|
|
1087
1116
|
dep.componentId = (newDepId || depId).serialize();
|
|
1088
1117
|
dep.id = (newDepId || depId).toString();
|
|
@@ -1091,22 +1120,6 @@ class DependencyResolverMain {
|
|
|
1091
1120
|
});
|
|
1092
1121
|
return component;
|
|
1093
1122
|
}
|
|
1094
|
-
updateDepsOnLegacyExport(version, idTransformer) {
|
|
1095
|
-
const entry = version.extensions.findCoreExtension(_dependencyResolver2().DependencyResolverAspect.id);
|
|
1096
|
-
if (!entry) {
|
|
1097
|
-
return version;
|
|
1098
|
-
}
|
|
1099
|
-
const dependencies = (0, _lodash().get)(entry, ['data', 'dependencies'], []);
|
|
1100
|
-
dependencies.forEach(dep => {
|
|
1101
|
-
if (dep.__type === _dependencies().COMPONENT_DEP_TYPE) {
|
|
1102
|
-
const depId = new (_legacyBitId().BitId)(dep.componentId);
|
|
1103
|
-
const newDepId = idTransformer(depId);
|
|
1104
|
-
dep.componentId = (newDepId || depId).serialize();
|
|
1105
|
-
dep.id = (newDepId || depId).toString();
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
return version;
|
|
1109
|
-
}
|
|
1110
1123
|
|
|
1111
1124
|
/**
|
|
1112
1125
|
* Register a new dependency detector. Detectors allow to extend Bit's dependency detection
|
|
@@ -1339,6 +1352,20 @@ class DependencyResolverMain {
|
|
|
1339
1352
|
if (aspectLoader) aspectLoader.registerOnLoadRequireableExtensionSlot(dependencyResolver.onLoadRequireableExtensionSubscriber.bind(dependencyResolver));
|
|
1340
1353
|
graphql.register((0, _dependencyResolver3().dependencyResolverSchema)(dependencyResolver));
|
|
1341
1354
|
envs.registerService(new (_dependencies2().DependenciesService)());
|
|
1355
|
+
|
|
1356
|
+
// this is needed because during tag process, the data.dependencies can be loaded and the componentId can become
|
|
1357
|
+
// an instance of ComponentID class. it needs to be serialized before saved into objects.
|
|
1358
|
+
const serializeDepResolverDataBeforePersist = extDataList => {
|
|
1359
|
+
const entry = extDataList.findCoreExtension(_dependencyResolver2().DependencyResolverAspect.id);
|
|
1360
|
+
if (!entry) return;
|
|
1361
|
+
const dependencies = (0, _lodash().get)(entry, ['data', 'dependencies'], []);
|
|
1362
|
+
dependencies.forEach(dep => {
|
|
1363
|
+
if (dep.__type === _dependencies().COMPONENT_DEP_TYPE) {
|
|
1364
|
+
dep.componentId = dep.componentId instanceof _componentId().ComponentID ? dep.componentId.serialize() : dep.componentId;
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
_extensionData().ExtensionDataList.toModelObjectsHook.push(serializeDepResolverDataBeforePersist);
|
|
1342
1369
|
return dependencyResolver;
|
|
1343
1370
|
}
|
|
1344
1371
|
getEmptyDepsObject() {
|