Socket
Socket
Sign inDemoInstall

@ms-cloudpack/package-utilities

Package Overview
Dependencies
59
Maintainers
3
Versions
173
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.5.2 to 7.5.3

13

lib/createResolveMap/dedupeLinkedPackages.js

@@ -1,2 +0,2 @@

import { satisfies } from 'semver';
import { satisfies, compare as semverCompare } from 'semver';
import { parseRequiredBy } from './parseRequiredBy.js';

@@ -12,3 +12,3 @@ import { detachEntry } from './detachEntry.js';

const packageName = parseRequiredBy(duplicate).name;
const entries = appMap[packageName];
const entries = appMap[packageName] || {};
// Sanity check to ensure that it is a duplicate.

@@ -19,2 +19,3 @@ if (Object.keys(entries).length <= 1) {

const availableVersions = Object.keys(entries);
const versionRequirements = new Set();
// Find if any of the duplicate entries satisfy the semver requirement of all the requiredBy entries.

@@ -25,7 +26,11 @@ const requiredBy = {};

requiredBy[requiredById] = range;
// We only care about satisfying version requirements that are already satisfied.
if (satisfies(entry.version, range)) {
versionRequirements.add(range);
}
}
}
const satisfiedVersions = availableVersions
.filter((v) => Object.values(requiredBy).every((range) => satisfies(v, range)))
.sort();
.filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))
.sort(semverCompare);
if (satisfiedVersions.length === 0) {

@@ -32,0 +37,0 @@ console.debug(`Could not find a version of "${packageName}" that satisfies the semver requirements of all the requiredBy entries.`);

@@ -17,2 +17,3 @@ import { isFolder } from '@ms-cloudpack/path-utilities';

const visitedPaths = new Set();
const realPathCache = {};
for (const searchPath of searchPaths) {

@@ -43,3 +44,3 @@ if (!(await isFolder(searchPath))) {

visitedPaths.add(packagePath);
const dependencyPaths = await visitPackage({ packagePath, packageMap, rootPath, importerContext }, context);
const dependencyPaths = await visitPackage({ packagePath, packageMap, rootPath, importerContext, realPathCache }, context);
for (const dependencyPath of dependencyPaths) {

@@ -61,3 +62,3 @@ // Let's avoid pushing tons of things into the work queue that we'll be skipping later.

async function visitPackage(options, context) {
const { packagePath, packageMap, rootPath, importerContext } = options;
const { packagePath, packageMap, rootPath, importerContext, realPathCache } = options;
const { packages } = context;

@@ -89,3 +90,3 @@ const packageDefinition = await packages.get(packagePath, { importerContext });

};
const dependencyPackage = await findPackage({ dependencyName, startPath: packagePath, rootPath, importerContext: depImporterContext }, context);
const dependencyPackage = await findPackage({ dependencyName, startPath: packagePath, rootPath, importerContext: depImporterContext, realPathCache }, context);
if (!dependencyPackage) {

@@ -92,0 +93,0 @@ if (packageDefinition.peerDependencies?.[dependencyName]) {

@@ -11,2 +11,3 @@ import type { PackageDefinitionsCache, PackageImporterContext, PackageJson } from '@ms-cloudpack/common-types';

rootPath?: string;
realPathCache?: Record<string, string | undefined>;
}, context: {

@@ -13,0 +14,0 @@ packages: PackageDefinitionsCache;

@@ -8,3 +8,3 @@ import path from 'path';

export async function findPackage(options, context) {
const { dependencyName, rootPath, startPath, importerContext } = options;
const { dependencyName, rootPath, startPath, importerContext, realPathCache } = options;
const { packages } = context;

@@ -18,3 +18,3 @@ let packagePath = startPath;

try {
realPath = fs.realpathSync.native(resolvedPath);
realPath = realPathCache?.[resolvedPath] || fs.realpathSync.native(resolvedPath);
definition = await packages.get(realPath, { importerContext });

@@ -26,2 +26,5 @@ }

if (realPath && definition) {
if (realPathCache && !realPathCache[resolvedPath]) {
realPathCache[resolvedPath] = realPath;
}
return { packagePath: realPath, definition };

@@ -28,0 +31,0 @@ }

{
"name": "@ms-cloudpack/package-utilities",
"version": "7.5.2",
"version": "7.5.3",
"description": "Utilities for resolving/parsing packages and their imports.",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc