@ms-cloudpack/package-utilities
Advanced tools
Comparing version 7.8.6 to 7.8.7
@@ -22,4 +22,4 @@ import { findProjectRoot } from './findProjectRoot.js'; | ||
let dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined; | ||
// If the dependency is already in the resolve map, we can return the path. | ||
if (dependencyPath && dependencyDefinition) { | ||
// If the dependency is already in the resolve map and required by the parent, return the path. | ||
if (dependencyPath && dependencyDefinition && resolveEntry?.requiredBy[`${definition.name}@${definition.version}`]) { | ||
return dependencyPath; | ||
@@ -34,27 +34,42 @@ } | ||
dependencyPath = dependencyPackage?.packagePath; | ||
dependencyDefinition = dependencyPackage?.definition || {}; | ||
dependencyDefinition = dependencyPackage?.definition; | ||
const version = dependencyDefinition?.version; | ||
// If we can't find the dependency, we can't add it to the resolve map. | ||
if (!dependencyPath || !dependencyDefinition || !dependencyDefinition.version) { | ||
if (!dependencyPath || !dependencyDefinition || !version) { | ||
return undefined; | ||
} | ||
const resolveMapEntry = { | ||
// Check if the dependency is already in the resolve map. | ||
let dependencyEntry = [resolveMap[dependencyName], ...Object.values(resolveMap[dependencyName]?.scopedVersions || {})] | ||
.filter(Boolean) | ||
.find((e) => e.version === version && e.path === dependencyPath); | ||
// If it already exists, add the requiredBy entry and return the path. | ||
if (dependencyEntry) { | ||
parentEntry.dependencies[dependencyName] = version; | ||
dependencyEntry.requiredBy[`${definition.name}@${definition.version}`] = version; | ||
return dependencyPath; | ||
} | ||
// If it is missing from the resolve map, add it. | ||
dependencyEntry = { | ||
name: dependencyName, | ||
version: dependencyDefinition.version, | ||
version, | ||
path: dependencyPath, | ||
dependencies: {}, | ||
requiredBy: {}, | ||
requiredBy: { | ||
[`${definition.name}@${definition.version}`]: version, | ||
}, | ||
}; | ||
if (isExternalPackage(dependencyPath)) { | ||
resolveMapEntry.isExternal = true; | ||
dependencyEntry.isExternal = true; | ||
} | ||
parentEntry.dependencies[dependencyName] = dependencyDefinition.version; | ||
resolveMapEntry.requiredBy[`${definition.name}@${definition.version}`] = | ||
// Try to get value from definition, if that fails default to exact version. | ||
definition.dependencies?.[dependencyName] || dependencyDefinition.version; | ||
// Add the dependency to the resolve map as a top-level entry as no entry exists for it yet. | ||
// This will be the case for most dependencies, there might be some edge cases where the dependency | ||
// has two different missing versions in the resolve map, but that's a rare case. | ||
resolveMap[dependencyName] = resolveMapEntry; | ||
parentEntry.dependencies[dependencyName] = version; | ||
// Add the dependency to the resolve map. | ||
if (!resolveMap[dependencyName]) { | ||
resolveMap[dependencyName] = dependencyEntry; | ||
} | ||
else { | ||
resolveMap[dependencyName].scopedVersions ??= {}; | ||
resolveMap[dependencyName].scopedVersions[version] = dependencyEntry; | ||
} | ||
return dependencyPath; | ||
} | ||
//# sourceMappingURL=ensureResolveMapEntry.js.map |
@@ -1,2 +0,2 @@ | ||
// eslint-disable-next-line no-restricted-imports -- this is the definition of the wrapper | ||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- this is the definition of the wrapper | ||
import { findProjectRoot as wsToolsFindProjectRoot, findPackageRoot } from 'workspace-tools'; | ||
@@ -3,0 +3,0 @@ /** |
{ | ||
"name": "@ms-cloudpack/package-utilities", | ||
"version": "7.8.6", | ||
"version": "7.8.7", | ||
"description": "Utilities for resolving/parsing packages and their imports.", | ||
@@ -17,8 +17,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/common-types": "^0.13.0", | ||
"@ms-cloudpack/common-types": "^0.13.1", | ||
"@ms-cloudpack/json-utilities": "^0.1.4", | ||
"@ms-cloudpack/package-overrides": "^0.9.11", | ||
"@ms-cloudpack/package-overrides": "^0.9.12", | ||
"@ms-cloudpack/path-string-parsing": "^1.2.3", | ||
"@ms-cloudpack/path-utilities": "^2.7.26", | ||
"@ms-cloudpack/task-reporter": "^0.14.2", | ||
"@ms-cloudpack/path-utilities": "^2.7.27", | ||
"@ms-cloudpack/task-reporter": "^0.14.3", | ||
"acorn": "^8.11.2", | ||
@@ -25,0 +25,0 @@ "acorn-walk": "^8.2.1", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318583
2678