@teambit/dependency-resolver 1.0.99 → 1.0.100
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/base-dependency.ts +11 -1
- package/dependencies/component-dependency/component-dependency-factory.ts +2 -1
- package/dependencies/component-dependency/component-dependency.ts +3 -2
- package/dependencies/constants.ts +2 -0
- package/dependencies/dependency-list.ts +19 -1
- package/dependencies/dependency.ts +2 -0
- package/dist/dependencies/base-dependency.d.ts +4 -1
- package/dist/dependencies/base-dependency.js +10 -2
- package/dist/dependencies/base-dependency.js.map +1 -1
- package/dist/dependencies/component-dependency/component-dependency-factory.js +1 -1
- package/dist/dependencies/component-dependency/component-dependency-factory.js.map +1 -1
- package/dist/dependencies/component-dependency/component-dependency.d.ts +1 -1
- package/dist/dependencies/component-dependency/component-dependency.js +2 -2
- package/dist/dependencies/component-dependency/component-dependency.js.map +1 -1
- package/dist/dependencies/constants.d.ts +2 -0
- package/dist/dependencies/constants.js +4 -2
- package/dist/dependencies/constants.js.map +1 -1
- package/dist/dependencies/dependency-list.d.ts +8 -0
- package/dist/dependencies/dependency-list.js +9 -2
- package/dist/dependencies/dependency-list.js.map +1 -1
- package/dist/dependencies/dependency.d.ts +2 -0
- package/dist/dependencies/dependency.js.map +1 -1
- package/dist/dependency-resolver.main.runtime.js +18 -0
- package/dist/dependency-resolver.main.runtime.js.map +1 -1
- package/dist/get-all-policy-pkgs.js.map +1 -1
- package/dist/manifest/deduping/dedupe-dependencies.d.ts +1 -1
- package/dist/manifest/deduping/dedupe-dependencies.js.map +1 -1
- package/dist/manifest/deduping/hoist-dependencies.js +2 -0
- package/dist/manifest/deduping/hoist-dependencies.js.map +1 -1
- package/dist/manifest/deduping/index-by-dep-id.js +9 -0
- package/dist/manifest/deduping/index-by-dep-id.js.map +1 -1
- package/dist/manifest/manifest.d.ts +5 -1
- package/dist/manifest/manifest.js +5 -1
- package/dist/manifest/manifest.js.map +1 -1
- package/dist/manifest/workspace-manifest-factory.js +3 -1
- package/dist/manifest/workspace-manifest-factory.js.map +1 -1
- package/dist/policy/env-policy/env-policy.d.ts +1 -0
- package/dist/policy/env-policy/env-policy.js +28 -8
- package/dist/policy/env-policy/env-policy.js.map +1 -1
- package/dist/policy/index.d.ts +1 -1
- package/dist/policy/index.js +6 -0
- package/dist/policy/index.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 +5 -2
- package/dist/policy/variant-policy/variant-policy.js +29 -23
- package/dist/policy/variant-policy/variant-policy.js.map +1 -1
- package/dist/{preview-1702955736433.js → preview-1703042095768.js} +2 -2
- package/dist/show-fragments/serialize-by-lifecycle.js +1 -1
- package/dist/show-fragments/serialize-by-lifecycle.js.map +1 -1
- package/manifest/deduping/dedupe-dependencies.ts +1 -1
- package/manifest/deduping/hoist-dependencies.ts +2 -0
- package/manifest/deduping/index-by-dep-id.ts +3 -0
- package/manifest/manifest.ts +9 -1
- package/manifest/workspace-manifest-factory.ts +2 -0
- package/package.json +18 -15
- package/policy/env-policy/env-policy.ts +22 -15
- package/policy/index.ts +6 -1
- package/policy/variant-policy/index.ts +1 -0
- package/policy/variant-policy/variant-policy.ts +28 -33
- package/show-fragments/serialize-by-lifecycle.ts +1 -1
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/dependency-resolver",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.100",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/dependencies/dependency-resolver",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.dependencies",
|
|
8
8
|
"name": "dependency-resolver",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.100"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"cli-highlight": "2.1.9",
|
|
@@ -36,19 +36,20 @@
|
|
|
36
36
|
"@teambit/component-id": "1.2.0",
|
|
37
37
|
"@teambit/legacy-bit-id": "1.1.0",
|
|
38
38
|
"@teambit/component-version": "1.0.3",
|
|
39
|
-
"@teambit/component": "1.0.
|
|
40
|
-
"@teambit/envs": "1.0.
|
|
41
|
-
"@teambit/aspect-loader": "1.0.
|
|
42
|
-
"@teambit/logger": "0.0.
|
|
43
|
-
"@teambit/graphql": "1.0.
|
|
44
|
-
"@teambit/bit": "1.5.
|
|
45
|
-
"@teambit/cli": "0.0.
|
|
46
|
-
"@teambit/config": "0.0.
|
|
47
|
-
"@teambit/global-config": "0.0.
|
|
39
|
+
"@teambit/component": "1.0.100",
|
|
40
|
+
"@teambit/envs": "1.0.100",
|
|
41
|
+
"@teambit/aspect-loader": "1.0.100",
|
|
42
|
+
"@teambit/logger": "0.0.927",
|
|
43
|
+
"@teambit/graphql": "1.0.100",
|
|
44
|
+
"@teambit/bit": "1.5.31",
|
|
45
|
+
"@teambit/cli": "0.0.834",
|
|
46
|
+
"@teambit/config": "0.0.851",
|
|
47
|
+
"@teambit/global-config": "0.0.836",
|
|
48
48
|
"@teambit/harmony.modules.requireable-component": "0.0.495",
|
|
49
|
-
"@teambit/snapping": "1.0.
|
|
50
|
-
"@teambit/
|
|
51
|
-
"@teambit/
|
|
49
|
+
"@teambit/snapping": "1.0.100",
|
|
50
|
+
"@teambit/workspace.modules.node-modules-linker": "0.0.155",
|
|
51
|
+
"@teambit/isolator": "1.0.100",
|
|
52
|
+
"@teambit/component-issues": "0.0.132",
|
|
52
53
|
"@teambit/component-package-version": "0.0.430"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
@@ -66,11 +67,13 @@
|
|
|
66
67
|
"@teambit/dependencies.aspect-docs.dependency-resolver": "0.0.174"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
|
-
"@teambit/legacy": "1.0.
|
|
70
|
+
"@teambit/legacy": "1.0.619",
|
|
70
71
|
"react": "^16.8.0 || ^17.0.0",
|
|
71
72
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
72
73
|
},
|
|
73
74
|
"license": "Apache-2.0",
|
|
75
|
+
"optionalDependencies": {},
|
|
76
|
+
"peerDependenciesMeta": {},
|
|
74
77
|
"exports": {
|
|
75
78
|
"node": {
|
|
76
79
|
"require": "./dist/index.js",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { validateEnvPolicyConfigObject } from './validate-env-policy';
|
|
2
2
|
import {
|
|
3
3
|
createVariantPolicyEntry,
|
|
4
|
-
DependencySource,
|
|
5
4
|
VariantPolicyEntry,
|
|
6
5
|
VariantPolicy,
|
|
7
6
|
VariantPolicyConfigObject,
|
|
@@ -20,6 +19,7 @@ type EnvJsoncPolicyEntry = {
|
|
|
20
19
|
* force add to component dependencies even if it's not used by the component.
|
|
21
20
|
*/
|
|
22
21
|
force?: boolean;
|
|
22
|
+
optional?: boolean;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type EnvJsoncPolicyPeerEntry = EnvJsoncPolicyEntry & {
|
|
@@ -62,7 +62,10 @@ export class EnvPolicy extends VariantPolicy {
|
|
|
62
62
|
if (includeLegacyPeersInSelfPolicy && !configObject.peers && configObject.peerDependencies) {
|
|
63
63
|
selfPeersEntries = handleLegacyPeers(configObject);
|
|
64
64
|
} else {
|
|
65
|
-
selfPeersEntries = entriesFromKey(configObject, 'peers', 'version', 'runtime',
|
|
65
|
+
selfPeersEntries = entriesFromKey(configObject, 'peers', 'version', 'runtime', {
|
|
66
|
+
source: 'env-own',
|
|
67
|
+
force: true,
|
|
68
|
+
});
|
|
66
69
|
}
|
|
67
70
|
const selfPolicy = VariantPolicy.fromArray(selfPeersEntries);
|
|
68
71
|
|
|
@@ -72,11 +75,13 @@ export class EnvPolicy extends VariantPolicy {
|
|
|
72
75
|
* Those were always forced on the components as visible dependencies.
|
|
73
76
|
*/
|
|
74
77
|
const legacyPolicy = VariantPolicy.fromConfigObject(configObject, { source: 'env', force: true, hidden: false });
|
|
75
|
-
const componentPeersEntries = entriesFromKey(configObject, 'peers', 'supportedRange', 'peer', 'env');
|
|
78
|
+
const componentPeersEntries = entriesFromKey(configObject, 'peers', 'supportedRange', 'peer', { source: 'env' });
|
|
76
79
|
const otherKeyNames: EnvJsoncPolicyConfigKey[] = ['dev', 'runtime'];
|
|
77
80
|
const otherEntries: VariantPolicyEntry[] = otherKeyNames.reduce(
|
|
78
81
|
(acc: VariantPolicyEntry[], keyName: EnvJsoncPolicyConfigKey) => {
|
|
79
|
-
const currEntries = entriesFromKey(configObject, keyName, 'version', keyName as DependencyLifecycleType,
|
|
82
|
+
const currEntries = entriesFromKey(configObject, keyName, 'version', keyName as DependencyLifecycleType, {
|
|
83
|
+
source: 'env',
|
|
84
|
+
});
|
|
80
85
|
return acc.concat(currEntries);
|
|
81
86
|
},
|
|
82
87
|
[]
|
|
@@ -96,7 +101,11 @@ function handleLegacyPeers(configObject: VariantPolicyConfigObject): VariantPoli
|
|
|
96
101
|
return [];
|
|
97
102
|
}
|
|
98
103
|
const entries = Object.entries(configObject.peerDependencies).map(([packageName, version]) => {
|
|
99
|
-
return createVariantPolicyEntry(packageName, version, 'runtime',
|
|
104
|
+
return createVariantPolicyEntry(packageName, version, 'runtime', {
|
|
105
|
+
source: 'env-own',
|
|
106
|
+
hidden: false,
|
|
107
|
+
force: true,
|
|
108
|
+
});
|
|
100
109
|
});
|
|
101
110
|
return entries;
|
|
102
111
|
}
|
|
@@ -106,23 +115,21 @@ function entriesFromKey(
|
|
|
106
115
|
keyName: EnvJsoncPolicyConfigKey,
|
|
107
116
|
versionKey: VersionKeyName = 'version',
|
|
108
117
|
lifecycleType: DependencyLifecycleType,
|
|
109
|
-
|
|
110
|
-
force?: boolean
|
|
118
|
+
options: VariantPolicyFromConfigObjectOptions
|
|
111
119
|
): VariantPolicyEntry[] {
|
|
112
120
|
const configEntries: Array<EnvJsoncPolicyPeerEntry | EnvJsoncPolicyEntry> = configObject[keyName];
|
|
113
121
|
if (!configEntries) {
|
|
114
122
|
return [];
|
|
115
123
|
}
|
|
116
124
|
const entries = configEntries.map((entry) => {
|
|
117
|
-
return createVariantPolicyEntry(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
source,
|
|
122
|
-
entry.hidden,
|
|
125
|
+
return createVariantPolicyEntry(entry.name, entry[versionKey], lifecycleType, {
|
|
126
|
+
...options,
|
|
127
|
+
source: options.source ?? 'env',
|
|
128
|
+
hidden: entry.hidden,
|
|
123
129
|
// allow override the entry's force value (used for the env itself)
|
|
124
|
-
force ?? !!entry.force
|
|
125
|
-
|
|
130
|
+
force: options.force ?? !!entry.force,
|
|
131
|
+
optional: options.optional ?? !!entry.optional,
|
|
132
|
+
});
|
|
126
133
|
});
|
|
127
134
|
return entries;
|
|
128
135
|
}
|
package/policy/index.ts
CHANGED
|
@@ -7,6 +7,11 @@ export {
|
|
|
7
7
|
WorkspacePolicyEntry,
|
|
8
8
|
WorkspacePolicyConfigKeysNames,
|
|
9
9
|
} from './workspace-policy';
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
VariantPolicy,
|
|
12
|
+
VariantPolicyEntryValue,
|
|
13
|
+
VariantPolicyConfigObject,
|
|
14
|
+
SerializedVariantPolicy,
|
|
15
|
+
} from './variant-policy';
|
|
11
16
|
|
|
12
17
|
export { EnvPolicy, EnvPolicyConfigObject } from './env-policy';
|
|
@@ -22,6 +22,7 @@ type VariantPolicyLifecycleConfigEntryObject = {
|
|
|
22
22
|
* force add to component dependencies even if it's not used by the component.
|
|
23
23
|
*/
|
|
24
24
|
force?: boolean;
|
|
25
|
+
optional?: boolean;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export type VariantPolicyConfigEntryValue = VariantPolicyEntryValue | VariantPolicyEntryVersion;
|
|
@@ -34,6 +35,7 @@ export type VariantPolicyEntryVersion = SemverVersion;
|
|
|
34
35
|
export type VariantPolicyEntryValue = {
|
|
35
36
|
version: VariantPolicyEntryVersion;
|
|
36
37
|
resolveFromEnv?: boolean;
|
|
38
|
+
optional?: boolean;
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
export type DependencySource = 'auto' | 'env' | 'env-own' | 'slots' | 'config';
|
|
@@ -49,6 +51,7 @@ export type VariantPolicyEntry = PolicyEntry & {
|
|
|
49
51
|
* force add to component dependencies even if it's not used by the component.
|
|
50
52
|
*/
|
|
51
53
|
force?: boolean;
|
|
54
|
+
optional?: boolean;
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
export type SerializedVariantPolicyEntry = VariantPolicyEntry;
|
|
@@ -59,6 +62,7 @@ export interface VariantPolicyFromConfigObjectOptions {
|
|
|
59
62
|
source?: DependencySource;
|
|
60
63
|
hidden?: boolean;
|
|
61
64
|
force?: boolean;
|
|
65
|
+
optional?: boolean;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
export class VariantPolicy implements Policy<VariantPolicyConfigObject> {
|
|
@@ -225,13 +229,10 @@ export class VariantPolicy implements Policy<VariantPolicyConfigObject> {
|
|
|
225
229
|
return res;
|
|
226
230
|
}
|
|
227
231
|
|
|
228
|
-
static fromConfigObject(
|
|
229
|
-
configObject,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const runtimeEntries = entriesFromKey(configObject, 'dependencies', source, hidden, force);
|
|
233
|
-
const devEntries = entriesFromKey(configObject, 'devDependencies', source, hidden, force);
|
|
234
|
-
const peerEntries = entriesFromKey(configObject, 'peerDependencies', source, hidden, force);
|
|
232
|
+
static fromConfigObject(configObject, options: VariantPolicyFromConfigObjectOptions = {}): VariantPolicy {
|
|
233
|
+
const runtimeEntries = entriesFromKey(configObject, 'dependencies', options);
|
|
234
|
+
const devEntries = entriesFromKey(configObject, 'devDependencies', options);
|
|
235
|
+
const peerEntries = entriesFromKey(configObject, 'peerDependencies', options);
|
|
235
236
|
const entries = runtimeEntries.concat(devEntries).concat(peerEntries);
|
|
236
237
|
return new VariantPolicy(entries);
|
|
237
238
|
}
|
|
@@ -269,9 +270,7 @@ function uniqEntries(entries: Array<VariantPolicyEntry>): Array<VariantPolicyEnt
|
|
|
269
270
|
function entriesFromKey(
|
|
270
271
|
configObject: VariantPolicyConfigObject,
|
|
271
272
|
keyName: PolicyConfigKeysNames,
|
|
272
|
-
|
|
273
|
-
hidden?: boolean,
|
|
274
|
-
force?: boolean
|
|
273
|
+
options: VariantPolicyFromConfigObjectOptions
|
|
275
274
|
): VariantPolicyEntry[] {
|
|
276
275
|
const obj = configObject[keyName];
|
|
277
276
|
if (!obj) {
|
|
@@ -279,24 +278,25 @@ function entriesFromKey(
|
|
|
279
278
|
}
|
|
280
279
|
const lifecycleType = LIFECYCLE_TYPE_BY_KEY_NAME[keyName];
|
|
281
280
|
if (Array.isArray(obj)) {
|
|
282
|
-
return entriesFromArrayKey(obj, lifecycleType,
|
|
281
|
+
return entriesFromArrayKey(obj, lifecycleType, options);
|
|
283
282
|
}
|
|
284
|
-
return entriesFromObjectKey(obj, lifecycleType,
|
|
283
|
+
return entriesFromObjectKey(obj, lifecycleType, options);
|
|
285
284
|
}
|
|
286
285
|
|
|
287
286
|
function entriesFromObjectKey(
|
|
288
287
|
obj: Record<string, VariantPolicyConfigEntryValue> | undefined,
|
|
289
288
|
lifecycleType: DependencyLifecycleType,
|
|
290
|
-
|
|
291
|
-
hidden?: boolean,
|
|
292
|
-
force = true
|
|
289
|
+
options: VariantPolicyFromConfigObjectOptions
|
|
293
290
|
): VariantPolicyEntry[] {
|
|
294
291
|
if (!obj) {
|
|
295
292
|
return [];
|
|
296
293
|
}
|
|
297
294
|
const entries = Object.entries(obj).map(([depId, value]: [string, VariantPolicyConfigEntryValue]) => {
|
|
298
295
|
if (value) {
|
|
299
|
-
return createVariantPolicyEntry(depId, value, lifecycleType,
|
|
296
|
+
return createVariantPolicyEntry(depId, value, lifecycleType, {
|
|
297
|
+
...options,
|
|
298
|
+
force: options.force ?? true,
|
|
299
|
+
});
|
|
300
300
|
}
|
|
301
301
|
return undefined;
|
|
302
302
|
});
|
|
@@ -306,23 +306,20 @@ function entriesFromObjectKey(
|
|
|
306
306
|
function entriesFromArrayKey(
|
|
307
307
|
configEntries: Array<VariantPolicyLifecycleConfigEntryObject> | undefined,
|
|
308
308
|
lifecycleType: DependencyLifecycleType,
|
|
309
|
-
|
|
310
|
-
hidden?: boolean,
|
|
311
|
-
force?: boolean
|
|
309
|
+
options: VariantPolicyFromConfigObjectOptions
|
|
312
310
|
): VariantPolicyEntry[] {
|
|
313
311
|
if (!configEntries) {
|
|
314
312
|
return [];
|
|
315
313
|
}
|
|
316
314
|
const entries = configEntries.map((entry) => {
|
|
317
|
-
return createVariantPolicyEntry(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
source,
|
|
322
|
-
hidden ?? !!entry.hidden,
|
|
315
|
+
return createVariantPolicyEntry(entry.name, entry.version, lifecycleType, {
|
|
316
|
+
...options,
|
|
317
|
+
source: options.source ?? 'config',
|
|
318
|
+
hidden: Boolean(options.hidden ?? entry.hidden),
|
|
323
319
|
// allow override the entry's force value (used for the env itself)
|
|
324
|
-
force ??
|
|
325
|
-
|
|
320
|
+
force: Boolean(options.force ?? entry.force),
|
|
321
|
+
optional: Boolean(options.optional ?? entry.optional),
|
|
322
|
+
});
|
|
326
323
|
});
|
|
327
324
|
return entries;
|
|
328
325
|
}
|
|
@@ -331,24 +328,22 @@ export function createVariantPolicyEntry(
|
|
|
331
328
|
depId: string,
|
|
332
329
|
value: VariantPolicyConfigEntryValue,
|
|
333
330
|
lifecycleType: DependencyLifecycleType,
|
|
334
|
-
|
|
335
|
-
hidden?: boolean,
|
|
336
|
-
force?: boolean
|
|
331
|
+
opts: VariantPolicyFromConfigObjectOptions
|
|
337
332
|
): VariantPolicyEntry {
|
|
338
333
|
const version = typeof value === 'string' ? value : value.version;
|
|
339
334
|
const resolveFromEnv = typeof value === 'string' ? false : value.resolveFromEnv;
|
|
335
|
+
const optional = typeof value === 'string' ? undefined : value.optional;
|
|
340
336
|
|
|
341
337
|
const entryValue: VariantPolicyEntryValue = {
|
|
342
338
|
version,
|
|
343
339
|
resolveFromEnv,
|
|
344
340
|
};
|
|
345
341
|
const entry: VariantPolicyEntry = {
|
|
342
|
+
...opts,
|
|
346
343
|
dependencyId: depId,
|
|
347
344
|
value: entryValue,
|
|
348
345
|
lifecycleType,
|
|
349
|
-
|
|
350
|
-
hidden,
|
|
351
|
-
force,
|
|
346
|
+
optional: optional ?? opts.optional,
|
|
352
347
|
};
|
|
353
348
|
return entry;
|
|
354
349
|
}
|
|
@@ -6,7 +6,7 @@ export function serializeByLifecycle(deps: DependencyList, lifecycle: Dependency
|
|
|
6
6
|
const longestLength = getLongestDepName(filteredByLifecycle);
|
|
7
7
|
const paddedNames = filteredByLifecycle.dependencies.map((dep) => {
|
|
8
8
|
const paddedName = getNameWithVersion(dep).padEnd(longestLength + 1, '-');
|
|
9
|
-
return `${paddedName} (${dep.type})`;
|
|
9
|
+
return `${paddedName} (${dep.type})${dep.optional ? '(optional)' : ''}`;
|
|
10
10
|
});
|
|
11
11
|
return paddedNames.join('\n');
|
|
12
12
|
}
|