snyk 1.1253.0 → 1.1255.0

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.
@@ -221410,11 +221410,11 @@ const buildDepGraphNpmLockV2 = async (npmLockPkgs, pkgJson, options) => {
221410
221410
  return acc;
221411
221411
  }, new Map());
221412
221412
  const visitedMap = new Set();
221413
- await dfsVisit(depGraphBuilder, rootNode, visitedMap, npmLockPkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, [], pkgKeysByName);
221413
+ await dfsVisit(depGraphBuilder, rootNode, visitedMap, npmLockPkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, [], pkgKeysByName, pkgJson.overrides);
221414
221414
  return depGraphBuilder.build();
221415
221415
  };
221416
221416
  exports.buildDepGraphNpmLockV2 = buildDepGraphNpmLockV2;
221417
- const dfsVisit = async (depGraphBuilder, node, visitedMap, npmLockPkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, ancestry, pkgKeysByName) => {
221417
+ const dfsVisit = async (depGraphBuilder, node, visitedMap, npmLockPkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, ancestry, pkgKeysByName, overrides) => {
221418
221418
  visitedMap.add(node.id);
221419
221419
  for (const [name, depInfo] of Object.entries(node.dependencies || {})) {
221420
221420
  if (event_loop_spinner_1.eventLoopSpinner.isStarving()) {
@@ -221424,26 +221424,30 @@ const dfsVisit = async (depGraphBuilder, node, visitedMap, npmLockPkgs, strictOu
221424
221424
  ...ancestry,
221425
221425
  {
221426
221426
  name: node.name,
221427
+ version: node.version,
221427
221428
  key: node.key || '',
221428
221429
  inBundle: node.inBundle || false,
221429
221430
  },
221430
- ], pkgKeysByName);
221431
+ ], pkgKeysByName, overrides);
221431
221432
  if (!visitedMap.has(childNode.id)) {
221432
221433
  (0, util_1.addPkgNodeToGraph)(depGraphBuilder, childNode, {});
221433
221434
  await dfsVisit(depGraphBuilder, childNode, visitedMap, npmLockPkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, [
221434
221435
  ...ancestry,
221435
221436
  {
221436
221437
  name: node.name,
221438
+ version: node.version,
221437
221439
  key: node.key,
221438
221440
  inBundle: node.inBundle || false,
221439
221441
  },
221440
- ], pkgKeysByName);
221442
+ ], pkgKeysByName, overrides);
221441
221443
  }
221442
221444
  depGraphBuilder.connectDep(node.id, childNode.id);
221443
221445
  }
221444
221446
  };
221445
- const getChildNode = (name, depInfo, pkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, ancestry, pkgKeysByName) => {
221446
- let childNodeKey = (0, exports.getChildNodeKey)(name, depInfo.version, ancestry, pkgs, pkgKeysByName);
221447
+ const getChildNode = (name, depInfo, pkgs, strictOutOfSync, includeDevDeps, includeOptionalDeps, ancestry, pkgKeysByName, overrides) => {
221448
+ const override = overrides &&
221449
+ checkOverrides([...ancestry, { name, version: depInfo.version }], overrides);
221450
+ let childNodeKey = (0, exports.getChildNodeKey)(name, override ? override : depInfo.version, ancestry, pkgs, pkgKeysByName);
221447
221451
  if (!childNodeKey) {
221448
221452
  if (strictOutOfSync) {
221449
221453
  throw new errors_1.OutOfSyncError(`${name}@${depInfo.version}`, parsers_1.LockfileType.npm);
@@ -221585,6 +221589,35 @@ const getChildNodeKey = (name, version, ancestry, pkgs, pkgKeysByName) => {
221585
221589
  return undefined;
221586
221590
  };
221587
221591
  exports.getChildNodeKey = getChildNodeKey;
221592
+ const checkOverrides = (ancestry, overrides) => {
221593
+ const ancestryWithoutRoot = ancestry.slice(1);
221594
+ // First traverse into overrides from root down
221595
+ for (const [idx, pkg] of ancestryWithoutRoot.entries()) {
221596
+ // Do we have this in overrides
221597
+ const override = overrides[pkg.name] || overrides[`${pkg.name}@${pkg.version}`];
221598
+ // If we dont find current element move down the ancestry
221599
+ if (!override) {
221600
+ continue;
221601
+ }
221602
+ // If we find a string as override we know we found what we want
221603
+ if (typeof override === 'string') {
221604
+ return override;
221605
+ }
221606
+ // If we don't find a string we might have a dotted reference
221607
+ // we only care about this if we are the final element in the ancestry.
221608
+ if (idx + 1 === ancestryWithoutRoot.length && override['.']) {
221609
+ return override['.'];
221610
+ }
221611
+ // If we don't find a string or a dotted reference we need to recurse
221612
+ // to find the override
221613
+ const recursiveOverride = checkOverrides(ancestryWithoutRoot, override);
221614
+ // If we get a non-undefined result, it is our answer
221615
+ if (recursiveOverride) {
221616
+ return recursiveOverride;
221617
+ }
221618
+ }
221619
+ return;
221620
+ };
221588
221621
  //# sourceMappingURL=index.js.map
221589
221622
 
221590
221623
  /***/ }),