@teambit/dependency-resolver 1.0.606 → 1.0.610

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.
@@ -2,6 +2,7 @@ import { PeerDependencyRules } from '@pnpm/types';
2
2
  import { WorkspacePolicyConfigObject } from './policy';
3
3
  import { PackageImportMethod } from './package-manager';
4
4
  export type NodeLinker = 'hoisted' | 'isolated';
5
+ export type ComponentRangePrefix = '~' | '^' | '+' | '-';
5
6
  export interface DependencyResolverWorkspaceConfig {
6
7
  policy: WorkspacePolicyConfigObject;
7
8
  /**
@@ -105,4 +106,13 @@ export interface DependencyResolverWorkspaceConfig {
105
106
  * Tells pnpm to automatically install peer dependencies. It is true by default.
106
107
  */
107
108
  autoInstallPeers?: boolean;
109
+ /**
110
+ * By default, Bit saves component dependencies with exact versions (pinned) in the package.json,
111
+ * even if the dependency-resolver policy specifies a version range.
112
+ *
113
+ * To preserve the range defined in the policy, set this value to "+".
114
+ * To apply a predefined range ("~" or "^") to other component dependencies not covered by the policy,
115
+ * set this to the desired range symbol.
116
+ */
117
+ componentRangePrefix?: ComponentRangePrefix;
108
118
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["dependency-resolver-workspace-config.ts"],"sourcesContent":["import { PeerDependencyRules } from '@pnpm/types';\nimport { WorkspacePolicyConfigObject } from './policy';\nimport { PackageImportMethod } from './package-manager';\n\nexport type NodeLinker = 'hoisted' | 'isolated';\n\nexport interface DependencyResolverWorkspaceConfig {\n policy: WorkspacePolicyConfigObject;\n /**\n * choose the package manager for Bit to use. you can choose between 'npm', 'yarn', 'pnpm'\n * and 'librarian'. our recommendation is use 'librarian' which reduces package duplicates\n * and totally removes the need of a 'node_modules' directory in your project.\n */\n packageManager?: string;\n\n /**\n * A proxy server for out going network requests by the package manager\n * Used for both http and https requests (unless the httpsProxy is defined)\n */\n proxy?: string;\n\n /**\n * A proxy server for outgoing https requests by the package manager (fallback to proxy server if not defined)\n * Use this in case you want different proxy for http and https requests.\n */\n httpsProxy?: string;\n\n /**\n * A path to a file containing one or multiple Certificate Authority signing certificates.\n * allows for multiple CA's, as well as for the CA information to be stored in a file on disk.\n */\n ca?: string;\n\n /**\n * Whether or not to do SSL key validation when making requests to the registry via https\n */\n strictSsl?: string;\n\n /**\n * A client certificate to pass when accessing the registry. Values should be in PEM format (Windows calls it \"Base-64 encoded X.509 (.CER)\") with newlines replaced by the string \"\\n\". For example:\n * cert=\"----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE----\"\n * It is not the path to a certificate file (and there is no \"certfile\" option).\n */\n cert?: string;\n\n /**\n * A client key to pass when accessing the registry. Values should be in PEM format with newlines replaced by the string \"\\n\". For example:\n * key=\"----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY----\"\n * It is not the path to a key file (and there is no \"keyfile\" option).\n */\n key?: string;\n\n /**\n * A comma-separated string of domain extensions that a proxy should not be used for.\n */\n noProxy?: string;\n\n /**\n * The IP address of the local interface to use when making connections to the npm registry.\n */\n localAddress?: string;\n\n /**\n * How many times to retry if Bit fails to fetch from the registry.\n */\n fetchRetries?: number;\n\n /*\n * The exponential factor for retry backoff.\n */\n fetchRetryFactor?: number;\n\n /*\n * The minimum (base) timeout for retrying requests.\n */\n fetchRetryMintimeout?: number;\n\n /*\n * The maximum fallback timeout to ensure the retry factor does not make requests too long.\n */\n fetchRetryMaxtimeout?: number;\n\n /*\n * The maximum amount of time (in milliseconds) to wait for HTTP requests to complete.\n */\n fetchTimeout?: number;\n\n /*\n * The maximum number of connections to use per origin (protocol/host/port combination).\n */\n maxSockets?: number;\n\n /*\n * Controls the maximum number of HTTP(S) requests to process simultaneously.\n */\n networkConcurrency?: number;\n\n /*\n * Set the prefix to use when adding dependency to workspace.jsonc via bit install\n * to lock version to exact version you can use empty string (default)\n */\n savePrefix?: string;\n\n /*\n * in case you want to disable this proxy set this config to false\n *\n */\n installFromBitDevRegistry?: boolean;\n\n /*\n * map of extra arguments to pass to the configured package manager upon the installation\n * of dependencies.\n */\n packageManagerArgs?: string[];\n\n /*\n * This field allows to instruct the package manager to override any dependency in the dependency graph.\n * This is useful to enforce all your packages to use a single version of a dependency, backport a fix,\n * or replace a dependency with a fork.\n */\n overrides?: Record<string, string>;\n\n /**\n * This is similar to overrides, but will only affect installation in capsules.\n * In case overrides is configured and this not, the regular overrides will affect capsules as well.\n * in case both configured, capsulesOverrides will be used for capsules, and overrides will affect the workspace.\n */\n capsulesOverrides?: Record<string, string>;\n\n /*\n * Defines what linker should be used for installing Node.js packages.\n * Supported values are hoisted and isolated.\n */\n nodeLinker?: NodeLinker;\n\n /*\n * Controls the way packages are imported from the store.\n */\n packageImportMethod?: PackageImportMethod;\n\n /*\n * Use and cache the results of (pre/post)install hooks.\n */\n sideEffectsCache?: boolean;\n\n /*\n * The list of components that should be installed in isolation from the workspace.\n * The component's package names should be used in this list, not their component IDs.\n */\n rootComponents?: boolean;\n\n /*\n * The node version to use when checking a package's engines setting.\n */\n nodeVersion?: string;\n\n /*\n * Refuse to install any package that claims to not be compatible with the current Node.js version.\n */\n engineStrict?: boolean;\n\n /*\n * Rules to mute specific peer dependeny warnings.\n */\n peerDependencyRules?: PeerDependencyRules;\n\n /*\n * This setting is \"true\" by default and tells bit to link core aspects to the node_modules of the workspace.\n * It only makes sense to set this to \"false\" in a workspace in which core aspects are actually developed.\n */\n linkCoreAspects?: boolean;\n\n /**\n * When false, Bit will create a shared node_modules directory for all components in a capsule.\n */\n isolatedCapsules?: boolean;\n\n /*\n * Ignore the builds of specific dependencies. The \"preinstall\", \"install\", and \"postinstall\" scripts\n * of the listed packages will not be executed during installation.\n */\n neverBuiltDependencies?: string[];\n\n /**\n * If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server.\n */\n preferOffline?: boolean;\n\n /**\n * When true, components in capsules are symlinked into their own node_modules.\n */\n capsuleSelfReference?: boolean;\n\n /**\n * Tells pnpm which packages should be hoisted to node_modules/.pnpm/node_modules.\n * By default, all packages are hoisted - however, if you know that only some flawed packages have phantom dependencies,\n * you can use this option to exclusively hoist the phantom dependencies (recommended).\n */\n hoistPatterns?: string[];\n\n /**\n * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules\n * even if they are found in the root node_modules\n */\n hoistInjectedDependencies?: boolean;\n\n /**\n * Tells pnpm to automatically install peer dependencies. It is true by default.\n */\n autoInstallPeers?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["dependency-resolver-workspace-config.ts"],"sourcesContent":["import { PeerDependencyRules } from '@pnpm/types';\nimport { WorkspacePolicyConfigObject } from './policy';\nimport { PackageImportMethod } from './package-manager';\n\nexport type NodeLinker = 'hoisted' | 'isolated';\n\nexport type ComponentRangePrefix = '~' | '^' | '+' | '-';\n\nexport interface DependencyResolverWorkspaceConfig {\n policy: WorkspacePolicyConfigObject;\n /**\n * choose the package manager for Bit to use. you can choose between 'npm', 'yarn', 'pnpm'\n * and 'librarian'. our recommendation is use 'librarian' which reduces package duplicates\n * and totally removes the need of a 'node_modules' directory in your project.\n */\n packageManager?: string;\n\n /**\n * A proxy server for out going network requests by the package manager\n * Used for both http and https requests (unless the httpsProxy is defined)\n */\n proxy?: string;\n\n /**\n * A proxy server for outgoing https requests by the package manager (fallback to proxy server if not defined)\n * Use this in case you want different proxy for http and https requests.\n */\n httpsProxy?: string;\n\n /**\n * A path to a file containing one or multiple Certificate Authority signing certificates.\n * allows for multiple CA's, as well as for the CA information to be stored in a file on disk.\n */\n ca?: string;\n\n /**\n * Whether or not to do SSL key validation when making requests to the registry via https\n */\n strictSsl?: string;\n\n /**\n * A client certificate to pass when accessing the registry. Values should be in PEM format (Windows calls it \"Base-64 encoded X.509 (.CER)\") with newlines replaced by the string \"\\n\". For example:\n * cert=\"----BEGIN CERTIFICATE-----\\nXXXX\\nXXXX\\n-----END CERTIFICATE----\"\n * It is not the path to a certificate file (and there is no \"certfile\" option).\n */\n cert?: string;\n\n /**\n * A client key to pass when accessing the registry. Values should be in PEM format with newlines replaced by the string \"\\n\". For example:\n * key=\"----BEGIN PRIVATE KEY-----\\nXXXX\\nXXXX\\n-----END PRIVATE KEY----\"\n * It is not the path to a key file (and there is no \"keyfile\" option).\n */\n key?: string;\n\n /**\n * A comma-separated string of domain extensions that a proxy should not be used for.\n */\n noProxy?: string;\n\n /**\n * The IP address of the local interface to use when making connections to the npm registry.\n */\n localAddress?: string;\n\n /**\n * How many times to retry if Bit fails to fetch from the registry.\n */\n fetchRetries?: number;\n\n /*\n * The exponential factor for retry backoff.\n */\n fetchRetryFactor?: number;\n\n /*\n * The minimum (base) timeout for retrying requests.\n */\n fetchRetryMintimeout?: number;\n\n /*\n * The maximum fallback timeout to ensure the retry factor does not make requests too long.\n */\n fetchRetryMaxtimeout?: number;\n\n /*\n * The maximum amount of time (in milliseconds) to wait for HTTP requests to complete.\n */\n fetchTimeout?: number;\n\n /*\n * The maximum number of connections to use per origin (protocol/host/port combination).\n */\n maxSockets?: number;\n\n /*\n * Controls the maximum number of HTTP(S) requests to process simultaneously.\n */\n networkConcurrency?: number;\n\n /*\n * Set the prefix to use when adding dependency to workspace.jsonc via bit install\n * to lock version to exact version you can use empty string (default)\n */\n savePrefix?: string;\n\n /*\n * in case you want to disable this proxy set this config to false\n *\n */\n installFromBitDevRegistry?: boolean;\n\n /*\n * map of extra arguments to pass to the configured package manager upon the installation\n * of dependencies.\n */\n packageManagerArgs?: string[];\n\n /*\n * This field allows to instruct the package manager to override any dependency in the dependency graph.\n * This is useful to enforce all your packages to use a single version of a dependency, backport a fix,\n * or replace a dependency with a fork.\n */\n overrides?: Record<string, string>;\n\n /**\n * This is similar to overrides, but will only affect installation in capsules.\n * In case overrides is configured and this not, the regular overrides will affect capsules as well.\n * in case both configured, capsulesOverrides will be used for capsules, and overrides will affect the workspace.\n */\n capsulesOverrides?: Record<string, string>;\n\n /*\n * Defines what linker should be used for installing Node.js packages.\n * Supported values are hoisted and isolated.\n */\n nodeLinker?: NodeLinker;\n\n /*\n * Controls the way packages are imported from the store.\n */\n packageImportMethod?: PackageImportMethod;\n\n /*\n * Use and cache the results of (pre/post)install hooks.\n */\n sideEffectsCache?: boolean;\n\n /*\n * The list of components that should be installed in isolation from the workspace.\n * The component's package names should be used in this list, not their component IDs.\n */\n rootComponents?: boolean;\n\n /*\n * The node version to use when checking a package's engines setting.\n */\n nodeVersion?: string;\n\n /*\n * Refuse to install any package that claims to not be compatible with the current Node.js version.\n */\n engineStrict?: boolean;\n\n /*\n * Rules to mute specific peer dependeny warnings.\n */\n peerDependencyRules?: PeerDependencyRules;\n\n /*\n * This setting is \"true\" by default and tells bit to link core aspects to the node_modules of the workspace.\n * It only makes sense to set this to \"false\" in a workspace in which core aspects are actually developed.\n */\n linkCoreAspects?: boolean;\n\n /**\n * When false, Bit will create a shared node_modules directory for all components in a capsule.\n */\n isolatedCapsules?: boolean;\n\n /*\n * Ignore the builds of specific dependencies. The \"preinstall\", \"install\", and \"postinstall\" scripts\n * of the listed packages will not be executed during installation.\n */\n neverBuiltDependencies?: string[];\n\n /**\n * If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server.\n */\n preferOffline?: boolean;\n\n /**\n * When true, components in capsules are symlinked into their own node_modules.\n */\n capsuleSelfReference?: boolean;\n\n /**\n * Tells pnpm which packages should be hoisted to node_modules/.pnpm/node_modules.\n * By default, all packages are hoisted - however, if you know that only some flawed packages have phantom dependencies,\n * you can use this option to exclusively hoist the phantom dependencies (recommended).\n */\n hoistPatterns?: string[];\n\n /**\n * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules\n * even if they are found in the root node_modules\n */\n hoistInjectedDependencies?: boolean;\n\n /**\n * Tells pnpm to automatically install peer dependencies. It is true by default.\n */\n autoInstallPeers?: boolean;\n\n /**\n * By default, Bit saves component dependencies with exact versions (pinned) in the package.json,\n * even if the dependency-resolver policy specifies a version range.\n *\n * To preserve the range defined in the policy, set this value to \"+\".\n * To apply a predefined range (\"~\" or \"^\") to other component dependencies not covered by the policy,\n * set this to the desired range symbol.\n */\n componentRangePrefix?: ComponentRangePrefix;\n}\n"],"mappings":"","ignoreList":[]}
@@ -8,7 +8,6 @@ import { GraphqlMain } from '@teambit/graphql';
8
8
  import { Logger } from '@teambit/logger';
9
9
  import { ExtensionDataList } from '@teambit/legacy.extension-data';
10
10
  import { ProxyConfig, NetworkConfig } from '@teambit/scope.network';
11
- import { onTagIdTransformer } from '@teambit/snapping';
12
11
  import { ConsumerComponent as LegacyComponent, Dependency as LegacyDependency } from '@teambit/legacy.consumer-component';
13
12
  import { ComponentID } from '@teambit/component-id';
14
13
  import { SourceFile } from '@teambit/component.sources';
@@ -20,8 +19,8 @@ import { UpdatedComponent } from './apply-updates';
20
19
  import { DependencyInstaller, PreInstallSubscriberList, PostInstallSubscriberList, DepInstallerContext } from './dependency-installer';
21
20
  import { DependencyVersionResolver } from './dependency-version-resolver';
22
21
  import { DepLinkerContext, DependencyLinker, LinkingOptions } from './dependency-linker';
23
- import { DependencyResolverWorkspaceConfig, NodeLinker } from './dependency-resolver-workspace-config';
24
- import { OutdatedPkg } from './get-all-policy-pkgs';
22
+ import { ComponentRangePrefix, DependencyResolverWorkspaceConfig, NodeLinker } from './dependency-resolver-workspace-config';
23
+ import { CurrentPkg, OutdatedPkg } from './get-all-policy-pkgs';
25
24
  import { CreateFromComponentsOptions, WorkspaceManifest, ManifestDependenciesObject } from './manifest';
26
25
  import { WorkspacePolicyConfigObject, VariantPolicyConfigObject, WorkspacePolicy, VariantPolicy, WorkspacePolicyAddEntryOptions, WorkspacePolicyEntry, SerializedVariantPolicy } from './policy';
27
26
  import { PackageManager, PackageManagerGetPeerDependencyIssuesOptions } from './package-manager';
@@ -36,6 +35,7 @@ export interface DependencyResolverComponentData {
36
35
  packageName: string;
37
36
  policy: SerializedVariantPolicy;
38
37
  dependencies: SerializedDependency[];
38
+ componentRangePrefix?: ComponentRangePrefix;
39
39
  }
40
40
  export interface DependencyResolverVariantConfig {
41
41
  policy: VariantPolicyConfigObject;
@@ -67,6 +67,12 @@ export type GetDependenciesOptions = {
67
67
  export type GetVersionResolverOptions = {
68
68
  cacheRootDirectory?: string;
69
69
  };
70
+ /**
71
+ * see @teambit/dependencies.aspect-docs.dependency-resolver for more information about this aspect.
72
+ *
73
+ * The data of this aspect gets saved in workspace-component-loader.ts, `executeLoadSlot()`.
74
+ * The type of the data is `DependencyResolverComponentData`.
75
+ */
70
76
  export declare class DependencyResolverMain {
71
77
  /**
72
78
  * Dependency resolver extension configuration.
@@ -350,7 +356,6 @@ export declare class DependencyResolverMain {
350
356
  * So policies installed only locally for the env, not to any components that use the env.
351
357
  */
352
358
  getPoliciesFromEnvForItself(id: ComponentID, legacyFiles?: SourceFile[], envExtendsDeps?: LegacyDependency[]): Promise<VariantPolicy | undefined>;
353
- updateDepsOnLegacyTag(component: LegacyComponent, idTransformer: onTagIdTransformer): LegacyComponent;
354
359
  /**
355
360
  * Register a new dependency detector. Detectors allow to extend Bit's dependency detection
356
361
  * mechanism to support new file extensions and types.
@@ -399,6 +404,23 @@ export declare class DependencyResolverMain {
399
404
  patterns?: string[];
400
405
  forceVersionBump?: 'major' | 'minor' | 'patch' | 'compatible';
401
406
  }): Promise<MergedOutdatedPkg[] | null>;
407
+ getAllDependencies({ variantPoliciesByPatterns, componentPolicies, components, }: {
408
+ variantPoliciesByPatterns: Record<string, VariantPolicyConfigObject>;
409
+ componentPolicies: Array<{
410
+ componentId: ComponentID;
411
+ policy: any;
412
+ }>;
413
+ components: Component[];
414
+ }): CurrentPkg[];
415
+ getAllDedupedDirectDependencies(opts: {
416
+ variantPoliciesByPatterns: Record<string, VariantPolicyConfigObject>;
417
+ componentPolicies: Array<{
418
+ componentId: ComponentID;
419
+ policy: any;
420
+ }>;
421
+ components: Component[];
422
+ }): CurrentPkg[];
423
+ private warnAboutOverwrite;
402
424
  /**
403
425
  * Fetching the package manifest from the full package document.
404
426
  * By default, we always request the abbreviated package document,
@@ -430,6 +452,8 @@ export declare class DependencyResolverMain {
430
452
  updatedVariants: string[];
431
453
  updatedComponents: UpdatedComponent[];
432
454
  };
455
+ getWorkspaceComponentRangePrefix(): ComponentRangePrefix | undefined;
456
+ calcComponentRangePrefixByConsumerComponent(component: LegacyComponent): ComponentRangePrefix | undefined;
433
457
  static runtime: import("@teambit/harmony").RuntimeDefinition;
434
458
  static dependencies: Aspect[];
435
459
  static slots: (((registerFn: () => string) => SlotRegistry<WorkspacePolicy>) | ((registerFn: () => string) => SlotRegistry<Partial<Record<keyof import("./policy").PolicyConfigKeys, {
@@ -65,6 +65,13 @@ function _component() {
65
65
  };
66
66
  return data;
67
67
  }
68
+ function _pkgModules() {
69
+ const data = require("@teambit/pkg.modules.semver-helper");
70
+ _pkgModules = function () {
71
+ return data;
72
+ };
73
+ return data;
74
+ }
68
75
  function _path() {
69
76
  const data = require("path");
70
77
  _path = function () {
@@ -128,9 +135,9 @@ function _legacy2() {
128
135
  };
129
136
  return data;
130
137
  }
131
- function _pkgModules() {
138
+ function _pkgModules2() {
132
139
  const data = require("@teambit/pkg.modules.component-package-name");
133
- _pkgModules = function () {
140
+ _pkgModules2 = function () {
134
141
  return data;
135
142
  };
136
143
  return data;
@@ -335,6 +342,13 @@ const defaultCreateFromComponentsOptions = {
335
342
  filterComponentsFromManifests: true,
336
343
  createManifestForComponentsWithoutDependencies: true
337
344
  };
345
+
346
+ /**
347
+ * see @teambit/dependencies.aspect-docs.dependency-resolver for more information about this aspect.
348
+ *
349
+ * The data of this aspect gets saved in workspace-component-loader.ts, `executeLoadSlot()`.
350
+ * The type of the data is `DependencyResolverComponentData`.
351
+ */
338
352
  class DependencyResolverMain {
339
353
  constructor(
340
354
  /**
@@ -648,7 +662,7 @@ class DependencyResolverMain {
648
662
  return component.state.aspects.get(_dependencyResolver().DependencyResolverAspect.id)?.data;
649
663
  }
650
664
  calcPackageName(component) {
651
- return (0, _pkgModules().componentIdToPackageName)(component.state._consumer);
665
+ return (0, _pkgModules2().componentIdToPackageName)(component.state._consumer);
652
666
  }
653
667
 
654
668
  /*
@@ -1226,26 +1240,6 @@ class DependencyResolverMain {
1226
1240
  const envPolicy = await this.getEnvPolicyFromEnvId(id, legacyFiles, envExtendsDeps);
1227
1241
  return envPolicy?.selfPolicy;
1228
1242
  }
1229
- updateDepsOnLegacyTag(component, idTransformer) {
1230
- const entry = component.extensions.findCoreExtension(_dependencyResolver().DependencyResolverAspect.id);
1231
- if (!entry) {
1232
- return component;
1233
- }
1234
- const dependencies = (0, _lodash().get)(entry, ['data', 'dependencies'], []);
1235
- dependencies.forEach(dep => {
1236
- if (dep.__type === _dependencies2().COMPONENT_DEP_TYPE) {
1237
- // @todo: it's unclear why "dep.componentId" randomly becomes a ComponentID instance.
1238
- // this check is added because on Ripple in some scenarios it was throwing:
1239
- // "ComponentID.fromObject expect to get an object, got an instance of ComponentID" (locally it didn't happen)
1240
- const depId = dep.componentId instanceof _componentId().ComponentID ? dep.componentId : _componentId().ComponentID.fromObject(dep.componentId);
1241
- const newDepId = idTransformer(depId);
1242
- dep.componentId = (newDepId || depId).serialize();
1243
- dep.id = (newDepId || depId).toString();
1244
- dep.version = (newDepId || depId).version;
1245
- }
1246
- });
1247
- return component;
1248
- }
1249
1243
 
1250
1244
  /**
1251
1245
  * Register a new dependency detector. Detectors allow to extend Bit's dependency detection
@@ -1385,10 +1379,37 @@ as an alternative, you can use "+" to keep the same version installed in the wor
1385
1379
  components,
1386
1380
  patterns,
1387
1381
  forceVersionBump
1382
+ }) {
1383
+ let allPkgs = this.getAllDependencies({
1384
+ variantPoliciesByPatterns,
1385
+ componentPolicies,
1386
+ components
1387
+ });
1388
+ if (patterns?.length) {
1389
+ const selectedPkgNames = new Set((0, _multimatch().default)(allPkgs.map(({
1390
+ name
1391
+ }) => name), patterns));
1392
+ allPkgs = allPkgs.filter(({
1393
+ name
1394
+ }) => selectedPkgNames.has(name));
1395
+ if (!allPkgs.length) {
1396
+ return null;
1397
+ }
1398
+ }
1399
+ const outdatedPkgs = await this.getOutdatedPkgs({
1400
+ rootDir,
1401
+ forceVersionBump
1402
+ }, allPkgs);
1403
+ return mergeOutdatedPkgs(outdatedPkgs);
1404
+ }
1405
+ getAllDependencies({
1406
+ variantPoliciesByPatterns,
1407
+ componentPolicies,
1408
+ components
1388
1409
  }) {
1389
1410
  const localComponentPkgNames = new Set(components.map(component => this.getPackageName(component)));
1390
- const componentModelVersions = (await Promise.all(components.map(async component => {
1391
- const depList = await this.getDependencies(component);
1411
+ const componentModelVersions = components.map(component => {
1412
+ const depList = this.getDependencies(component);
1392
1413
  return depList.filter(dep => typeof dep.getPackageName === 'function' &&
1393
1414
  // If the dependency is referenced not via a valid range it means that it wasn't yet published to the registry
1394
1415
  _semver().default.validRange(dep.version) != null && !dep['isExtension'] &&
@@ -1401,29 +1422,47 @@ as an alternative, you can use "+" to keep the same version installed in the wor
1401
1422
  componentId: component.id,
1402
1423
  lifecycleType: dep.lifecycle
1403
1424
  }));
1404
- }))).flat();
1405
- let allPkgs = (0, _getAllPolicyPkgs().getAllPolicyPkgs)({
1425
+ }).flat();
1426
+ return (0, _getAllPolicyPkgs().getAllPolicyPkgs)({
1406
1427
  rootPolicy: this.getWorkspacePolicyFromConfig(),
1407
1428
  variantPoliciesByPatterns,
1408
1429
  componentPolicies,
1409
1430
  componentModelVersions
1410
1431
  });
1411
- if (patterns?.length) {
1412
- const selectedPkgNames = new Set((0, _multimatch().default)(allPkgs.map(({
1413
- name
1414
- }) => name), patterns));
1415
- allPkgs = allPkgs.filter(({
1416
- name
1417
- }) => selectedPkgNames.has(name));
1418
- if (!allPkgs.length) {
1419
- return null;
1432
+ }
1433
+ getAllDedupedDirectDependencies(opts) {
1434
+ const allDeps = this.getAllDependencies(opts);
1435
+ const mergedDeps = {};
1436
+ for (const dep of allDeps) {
1437
+ const existing = mergedDeps[dep.name];
1438
+ if (existing) {
1439
+ if (existing.currentRange === dep.currentRange) continue;
1440
+ if (shouldOverwrite(existing, dep)) {
1441
+ this.warnAboutOverwrite(existing, dep);
1442
+ mergedDeps[dep.name] = dep;
1443
+ } else {
1444
+ this.warnAboutOverwrite(dep, existing);
1445
+ }
1446
+ } else {
1447
+ mergedDeps[dep.name] = dep;
1420
1448
  }
1421
1449
  }
1422
- const outdatedPkgs = await this.getOutdatedPkgs({
1423
- rootDir,
1424
- forceVersionBump
1425
- }, allPkgs);
1426
- return mergeOutdatedPkgs(outdatedPkgs);
1450
+ return Object.values(mergedDeps);
1451
+ function shouldOverwrite(existing, incoming) {
1452
+ if (isRootPolicy(existing)) {
1453
+ if (!isRootPolicy(incoming)) return false;
1454
+ return (0, _pkgModules().isRange1GreaterThanRange2Naively)(incoming.currentRange, existing.currentRange);
1455
+ }
1456
+ return isRootPolicy(incoming) || (0, _pkgModules().isRange1GreaterThanRange2Naively)(incoming.currentRange, existing.currentRange);
1457
+ }
1458
+ }
1459
+ warnAboutOverwrite(originalPkg, newPkg) {
1460
+ const message = `${originalPkg.name}@${originalPkg.currentRange} from ${originalPkg.source} overwritten by ${newPkg.currentRange} from ${newPkg.source}`;
1461
+ if (isRootPolicy(newPkg)) {
1462
+ this.logger.info(message);
1463
+ } else {
1464
+ this.logger.warn(message);
1465
+ }
1427
1466
  }
1428
1467
 
1429
1468
  /**
@@ -1500,6 +1539,24 @@ as an alternative, you can use "+" to keep the same version installed in the wor
1500
1539
  updatedComponents
1501
1540
  };
1502
1541
  }
1542
+ getWorkspaceComponentRangePrefix() {
1543
+ return this.config.componentRangePrefix;
1544
+ }
1545
+ calcComponentRangePrefixByConsumerComponent(component) {
1546
+ const fromWs = this.getWorkspaceComponentRangePrefix();
1547
+ if (fromWs) {
1548
+ return fromWs;
1549
+ }
1550
+ const modelData = component.componentFromModel?.extensions.findCoreExtension(_dependencyResolver().DependencyResolverAspect.id);
1551
+ if (modelData?.data?.componentRangePrefix) {
1552
+ return modelData.data.componentRangePrefix;
1553
+ }
1554
+ const currentData = component.extensions?.findCoreExtension(_dependencyResolver().DependencyResolverAspect.id)?.data;
1555
+ if (currentData?.componentRangePrefix) {
1556
+ return currentData.componentRangePrefix;
1557
+ }
1558
+ return undefined;
1559
+ }
1503
1560
  static async provider([envs, loggerExt, configMain, aspectLoader, componentAspect, graphql, configStore], config, [rootPolicyRegistry, policiesRegistry, packageManagerSlot, dependencyFactorySlot, preInstallSlot, postInstallSlot, addPackagesToLinkSlot]) {
1504
1561
  // const packageManager = new PackageManagerLegacy(config.packageManager, logger);
1505
1562
  const logger = loggerExt.createLogger(_dependencyResolver().DependencyResolverAspect.id);
@@ -1662,5 +1719,8 @@ function rangeToVersion(range) {
1662
1719
  }
1663
1720
  return range;
1664
1721
  }
1722
+ function isRootPolicy(dep) {
1723
+ return dep.source === 'rootPolicy';
1724
+ }
1665
1725
 
1666
1726
  //# sourceMappingURL=dependency-resolver.main.runtime.js.map