@ms-cloudpack/package-utilities 12.3.24 → 12.4.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.
- package/lib/resolveMap/createHelpers/{addLinkedEntryDependencies.d.ts → link/addLinkedEntryDependencies.d.ts} +1 -1
- package/lib/resolveMap/createHelpers/link/addLinkedEntryDependencies.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/{addLinkedEntryDependencies.js → link/addLinkedEntryDependencies.js} +1 -1
- package/lib/resolveMap/createHelpers/link/addLinkedEntryDependencies.js.map +1 -0
- package/lib/resolveMap/createHelpers/{convertToLinkResolveMap.d.ts → link/convertToLinkResolveMap.d.ts} +1 -1
- package/lib/resolveMap/createHelpers/link/convertToLinkResolveMap.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/{convertToLinkResolveMap.js → link/convertToLinkResolveMap.js} +1 -1
- package/lib/resolveMap/createHelpers/link/convertToLinkResolveMap.js.map +1 -0
- package/lib/resolveMap/createHelpers/{dedupeLinkedPackages.d.ts → link/dedupeLinkedPackages.d.ts} +2 -2
- package/lib/resolveMap/createHelpers/link/dedupeLinkedPackages.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/{dedupeLinkedPackages.js → link/dedupeLinkedPackages.js} +5 -9
- package/lib/resolveMap/createHelpers/link/dedupeLinkedPackages.js.map +1 -0
- package/lib/resolveMap/createHelpers/{detachEntry.d.ts → link/detachEntry.d.ts} +1 -1
- package/lib/resolveMap/createHelpers/link/detachEntry.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/{detachEntry.js → link/detachEntry.js} +1 -1
- package/lib/resolveMap/createHelpers/link/detachEntry.js.map +1 -0
- package/lib/resolveMap/createHelpers/{flattenResolveMap.d.ts → link/flattenResolveMap.d.ts} +1 -1
- package/lib/resolveMap/createHelpers/link/flattenResolveMap.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/link/flattenResolveMap.js.map +1 -0
- package/lib/resolveMap/createHelpers/link/getEffectiveResolutions.d.ts +9 -0
- package/lib/resolveMap/createHelpers/link/getEffectiveResolutions.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/link/getEffectiveResolutions.js +20 -0
- package/lib/resolveMap/createHelpers/link/getEffectiveResolutions.js.map +1 -0
- package/lib/resolveMap/createHelpers/{linkPath.d.ts → link/linkPath.d.ts} +1 -1
- package/lib/resolveMap/createHelpers/link/linkPath.d.ts.map +1 -0
- package/lib/resolveMap/createHelpers/{linkPath.js → link/linkPath.js} +5 -4
- package/lib/resolveMap/createHelpers/link/linkPath.js.map +1 -0
- package/lib/resolveMap/createLinkResolveMap.js +1 -1
- package/lib/resolveMap/createLinkResolveMap.js.map +1 -1
- package/lib/resolveMap/createResolveMap.js +1 -1
- package/lib/resolveMap/createResolveMap.js.map +1 -1
- package/package.json +4 -4
- package/lib/resolveMap/createHelpers/addLinkedEntryDependencies.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/addLinkedEntryDependencies.js.map +0 -1
- package/lib/resolveMap/createHelpers/convertToLinkResolveMap.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/convertToLinkResolveMap.js.map +0 -1
- package/lib/resolveMap/createHelpers/dedupeLinkedPackages.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/dedupeLinkedPackages.js.map +0 -1
- package/lib/resolveMap/createHelpers/detachEntry.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/detachEntry.js.map +0 -1
- package/lib/resolveMap/createHelpers/flattenResolveMap.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/flattenResolveMap.js.map +0 -1
- package/lib/resolveMap/createHelpers/linkPath.d.ts.map +0 -1
- package/lib/resolveMap/createHelpers/linkPath.js.map +0 -1
- /package/lib/resolveMap/createHelpers/{flattenResolveMap.js → link/flattenResolveMap.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PackageDefinitionsCache, PackageJson, ResolveMapEntry } from '@ms-cloudpack/common-types';
|
|
2
|
-
import type { PackageMap } from '
|
|
2
|
+
import type { PackageMap } from '../types/PackageMap.js';
|
|
3
3
|
/**
|
|
4
4
|
* Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,
|
|
5
5
|
* preferring packageMap dependencies over linkedMap dependencies.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addLinkedEntryDependencies.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAExG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE;IACP,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,eAAe,CAAC;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CAC1C,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA8FnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { satisfies } from 'semver';
|
|
2
|
-
import { getDependencies } from '
|
|
2
|
+
import { getDependencies } from '../../../packageJson/getDependencies.js';
|
|
3
3
|
/**
|
|
4
4
|
* Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,
|
|
5
5
|
* preferring packageMap dependencies over linkedMap dependencies.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addLinkedEntryDependencies.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,eAA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,kBAAkB,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,GAAG,kBAAkB,CAAC;oBAEzE,OAAO,CAAC,kBAAkB,CAAC,CAAC;gBAC9B,CAAC;qBAAM,CAAC;oBACN,yFAAyF;oBACzF,6FAA6F;oBAC7F,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9E,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,kBAAkB,CAAC,CACzC,CAAC;oBACF,IAAI,eAAe,EAAE,CAAC;wBACpB,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;wBACvD,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,uBAAuB,CAAC;wBAC7D,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC;wBAC5E,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,IAAI,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;wBAChE,mDAAmD;wBACnD,OAAO,CAAC,eAAe,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import type { PackageDefinitionsCache, PackageJson, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { satisfies } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport { getDependencies } from '../../../packageJson/getDependencies.js';\n\n/**\n * Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,\n * preferring packageMap dependencies over linkedMap dependencies.\n * Returns a list of duplicated packages that were added to the packageMap.\n */\nexport async function addLinkedEntryDependencies(\n options: {\n appMap: PackageMap;\n linkMap: PackageMap;\n linkedEntry: ResolveMapEntry;\n resolutions?: PackageJson['resolutions'];\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<{ duplicates: string[] }> {\n const { appMap, linkMap, linkedEntry, resolutions } = options;\n const { packages } = context;\n const visitedEntryPaths = new Set<string>(linkedEntry.path);\n const duplicates: string[] = [];\n const entriesToVisit: ResolveMapEntry[] = [linkedEntry];\n\n function enqueue(newEntry: ResolveMapEntry): void {\n if (!visitedEntryPaths.has(newEntry.path)) {\n visitedEntryPaths.add(newEntry.path);\n entriesToVisit.push(newEntry);\n }\n }\n\n while (entriesToVisit.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked the length\n const entry = entriesToVisit.pop()!;\n\n const { name, version, dependencies } = entry;\n\n const linkDefinition = await packages.tryGet(entry.path);\n if (!linkDefinition) {\n continue;\n }\n\n const versionRequirements = getDependencies(linkDefinition);\n\n // Iterate through the dependencies of the linked package.\n for (const [dependencyName, linkedDependencyVersion] of Object.entries(dependencies)) {\n const versionRequirement = versionRequirements[dependencyName];\n if (!versionRequirement) {\n continue;\n }\n\n const appVersions = appMap[dependencyName];\n\n if (!appVersions) {\n // The app does not have any version of this dependency, so we need to bring over the version\n // used by the linkedEntry.\n const dependencyEntry = linkMap[dependencyName]?.[linkedDependencyVersion];\n if (dependencyEntry) {\n appMap[dependencyName] = { [linkedDependencyVersion]: dependencyEntry };\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n\n // Recurse through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n } else {\n // We have one or more versions of this dependency already. If a sufficient version\n // of the dependency is already in the appMap, we we just need to update the linkedEntry's\n // dependency and the dependency's requiredBy record for the parent.\n const appDependencyVersions = Object.values(appVersions);\n\n if (appDependencyVersions.length === 1 && !appDependencyVersions[0]?.isExternal) {\n continue;\n }\n\n // See if an existing version of the dependency satisfies the semver.\n const appDependencyEntry = appDependencyVersions.find(\n (e) =>\n // If the dependency is linked, use that.\n e.isLinked ||\n // If the dependency version is required as a resolution, use that.\n resolutions?.[dependencyName] ||\n // If the dependency satisfies the semver, use that.\n satisfies(e.version, versionRequirement),\n );\n\n if (appDependencyEntry) {\n // If the dependency satisfies the semver, use that!\n entry.dependencies[dependencyName] = appDependencyEntry.version;\n appDependencyEntry.requiredBy[`${name}@${version}`] = versionRequirement;\n\n enqueue(appDependencyEntry);\n } else {\n // We have at least one version of this dependency but nothing satisfies the requirement.\n // We need to introduce a duplicate. During the final pass, we will remove non-required deps.\n const dependencyEntry = Object.values(linkMap[dependencyName] || {}).find((e) =>\n satisfies(e.version, versionRequirement),\n );\n if (dependencyEntry) {\n appVersions[dependencyEntry.version] = dependencyEntry;\n entry.dependencies[dependencyName] = linkedDependencyVersion;\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n duplicates.push(`${dependencyName}@${dependencyEntry.version}`);\n // Recursive through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n }\n }\n }\n }\n\n return { duplicates };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertToLinkResolveMap.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/convertToLinkResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAoBnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertToLinkResolveMap.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/convertToLinkResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA+B;IACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,UAAU,GAAe,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE7E,wFAAwF;QACxF,2EAA2E;QAC3E,IAAI,oBAAoB,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;YAElE,wDAAwD;YACxD,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { ResolveMap } from '@ms-cloudpack/common-types';\nimport { entrySorter } from '../entrySorter.js';\nimport type { PackageMap } from '../types/PackageMap.js';\n\n/**\n * Given a PackageMap returns a ResolveMap.\n */\nexport function convertToLinkResolveMap(options: { appMap: PackageMap }): ResolveMap {\n const { appMap } = options;\n const resolveMap: ResolveMap = {};\n\n for (const [packageName, packageEntries] of Object.entries(appMap)) {\n const sortedPackageEntries = Object.values(packageEntries).sort(entrySorter);\n\n // Get the sorted package entries based on the most to least requiredBy references. This\n // ends up reducing the size of the resolve map by minimizing scoped cases.\n if (sortedPackageEntries.length) {\n const entry = (resolveMap[packageName] = sortedPackageEntries[0]);\n\n // Update scoped versions (version to resolve map entry)\n if (sortedPackageEntries.length > 1) {\n entry.scopedVersions = Object.fromEntries(sortedPackageEntries.slice(1).map((e) => [e.version, e]));\n }\n }\n }\n\n return resolveMap;\n}\n"]}
|
package/lib/resolveMap/createHelpers/{dedupeLinkedPackages.d.ts → link/dedupeLinkedPackages.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageMap } from '
|
|
1
|
+
import type { PackageMap } from '../types/PackageMap.js';
|
|
2
2
|
import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
3
3
|
/**
|
|
4
4
|
* Deduplicates linked packages by removing all but the highest version,
|
|
@@ -7,7 +7,7 @@ import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
|
7
7
|
export declare function dedupeLinkedPackages(options: {
|
|
8
8
|
appMap: PackageMap;
|
|
9
9
|
allDuplicates: Set<string>;
|
|
10
|
-
|
|
10
|
+
linkMap: PackageMap;
|
|
11
11
|
rootPath?: string;
|
|
12
12
|
}, context: {
|
|
13
13
|
packages: PackageDefinitionsCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedupeLinkedPackages.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/dedupeLinkedPackages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,OAAO,KAAK,EAAE,uBAAuB,EAAgC,MAAM,4BAA4B,CAAC;AAKxG;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACnG,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,IAAI,CAAC,CA4Gf"}
|
package/lib/resolveMap/createHelpers/{dedupeLinkedPackages.js → link/dedupeLinkedPackages.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { satisfies, rcompare as semverReverseCompare } from 'semver';
|
|
2
|
-
import { parseRequiredBy } from '
|
|
2
|
+
import { parseRequiredBy } from '../parseRequiredBy.js';
|
|
3
3
|
import { detachEntry } from './detachEntry.js';
|
|
4
4
|
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
|
7
7
|
* that satisfies the semver requirements of all the requiredBy entries.
|
|
8
8
|
*/
|
|
9
9
|
export async function dedupeLinkedPackages(options, context) {
|
|
10
|
-
const { rootPath, appMap, allDuplicates,
|
|
10
|
+
const { rootPath, appMap, allDuplicates, linkMap } = options;
|
|
11
11
|
const { packages } = context;
|
|
12
12
|
console.debug(`The following packages were duplicated by linking:\n ${Array.from(allDuplicates).join(', ')}`);
|
|
13
13
|
for (const duplicate of allDuplicates) {
|
|
@@ -53,22 +53,18 @@ export async function dedupeLinkedPackages(options, context) {
|
|
|
53
53
|
// We assume that the host has a single version of the package.
|
|
54
54
|
const hostVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(rootPath)));
|
|
55
55
|
if (!hostVersion) {
|
|
56
|
-
console.error(`Could not find a version of "${packageName}" that
|
|
56
|
+
console.error(`Could not find a version of "${packageName}" that belongs to the host.`);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
satisfiedVersion = hostVersion;
|
|
60
60
|
}
|
|
61
61
|
else if (dedupeStrategy === 'force-remote-version') {
|
|
62
|
-
if (!remotePath) {
|
|
63
|
-
console.error('Root path for project not found and is required when using the "force-remote-version" dedupe strategy.');
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
62
|
// Use the version of the package that is the remote.
|
|
67
63
|
// Find the version of the package that does not belong to the host.
|
|
68
64
|
// We assume that the remote has a single version of the package.
|
|
69
|
-
const remoteVersion = availableVersions.find((v) =>
|
|
65
|
+
const remoteVersion = availableVersions.find((v) => entries[v].path === linkMap[packageName]?.[v]?.path);
|
|
70
66
|
if (!remoteVersion) {
|
|
71
|
-
console.error(`Could not find a version of "${packageName}" that
|
|
67
|
+
console.error(`Could not find a version of "${packageName}" that belongs to the remote.`);
|
|
72
68
|
continue;
|
|
73
69
|
}
|
|
74
70
|
satisfiedVersion = remoteVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/dedupeLinkedPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAI1D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAmG,EACnG,OAA8C;IAE9C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,wDAAwD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9G,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;QAEpD,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAE1C,iDAAiD;QACjD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM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,CAAC,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CACX,YAAY,gBAAgB,SAAS,WAAW,oEAAoE,CACrH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,sDAAsD;YACtD,mEAAmE;YACnE,sDAAsD;YACtD,OAAO,CAAC,KAAK,CACX,gCAAgC,WAAW,yEAAyE,CACrH,CAAC;YACF,SAAS;QACX,CAAC;QAED,OAAO,CAAC,gBAAgB,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC;QAElD,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;YACxC,IAAI,OAAO,IAAI,gBAAgB,EAAE,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;YAC3F,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC;QACzF,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,wBAAwB,WAAW,iBAAiB,gBAAgB,IAAI,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["import { satisfies, rcompare as semverReverseCompare } from 'semver';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport { parseRequiredBy } from '../parseRequiredBy.js';\nimport { detachEntry } from './detachEntry.js';\nimport type { PackageDefinitionsCache, ResolveMapEntry, LinkOptions } from '@ms-cloudpack/common-types';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\ntype DuplicatedDependencyBehavior = NonNullable<LinkOptions['duplicatedDependencyBehavior']>;\n\n/**\n * Deduplicates linked packages by removing all but the highest version,\n * that satisfies the semver requirements of all the requiredBy entries.\n */\nexport async function dedupeLinkedPackages(\n options: { appMap: PackageMap; allDuplicates: Set<string>; linkMap: PackageMap; rootPath?: string },\n context: { packages: PackageDefinitionsCache },\n): Promise<void> {\n const { rootPath, appMap, allDuplicates, linkMap } = options;\n const { packages } = context;\n console.debug(`The following packages were duplicated by linking:\\n ${Array.from(allDuplicates).join(', ')}`);\n for (const duplicate of allDuplicates) {\n const packageName = parseRequiredBy(duplicate).name;\n\n const entries = appMap[packageName] || {};\n\n // Sanity check to ensure that it is a duplicate.\n if (Object.keys(entries).length <= 1) {\n continue;\n }\n\n let dedupeStrategy: DuplicatedDependencyBehavior = 'allow-duplication';\n for (const entry of Object.values(entries)) {\n const packageJson = await packages.get(entry.path);\n if (packageJson.cloudpack?.link?.duplicatedDependencyBehavior) {\n dedupeStrategy = packageJson.cloudpack.link.duplicatedDependencyBehavior;\n }\n }\n\n const availableVersions = Object.keys(entries);\n\n const versionRequirements = new Set<string>();\n // Find if any of the duplicate entries satisfy the semver requirement of all the requiredBy entries.\n const requiredBy: ResolveMapEntry['requiredBy'] = {};\n for (const entry of Object.values(entries)) {\n for (const [requiredById, range] of Object.entries(entry.requiredBy) as [`${string}@${string}`, string][]) {\n requiredBy[requiredById] = range;\n // We only care about satisfying version requirements that are already satisfied.\n if (satisfies(entry.version, range)) {\n versionRequirements.add(range);\n }\n }\n }\n\n // Find the versions that satisfy the semver requirements of all the requiredBy entries.\n // Sort the versions in descending order.\n const satisfiedVersions = availableVersions\n .filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))\n .sort(semverReverseCompare);\n\n let satisfiedVersion: string | undefined;\n\n if (dedupeStrategy === 'force-host-version') {\n if (!rootPath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-host-version\" dedupe strategy.',\n );\n continue;\n }\n // Use the app host's version of the package.\n // Find the version of the package that belongs to the host.\n // We assume that the host has a single version of the package.\n const hostVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(rootPath)));\n\n if (!hostVersion) {\n console.error(`Could not find a version of \"${packageName}\" that belongs to the host.`);\n continue;\n }\n\n satisfiedVersion = hostVersion;\n } else if (dedupeStrategy === 'force-remote-version') {\n // Use the version of the package that is the remote.\n // Find the version of the package that does not belong to the host.\n // We assume that the remote has a single version of the package.\n const remoteVersion = availableVersions.find((v) => entries[v].path === linkMap[packageName]?.[v]?.path);\n\n if (!remoteVersion) {\n console.error(`Could not find a version of \"${packageName}\" that belongs to the remote.`);\n continue;\n }\n\n satisfiedVersion = remoteVersion;\n } else if (dedupeStrategy === 'allow-duplication' && satisfiedVersions.length > 0) {\n // Select the highest version that satisfies the semver requirements of all the requiredBy entries.\n satisfiedVersion = satisfiedVersions[0];\n console.debug(\n `Version \"${satisfiedVersion}\" of \"${packageName}\" satisfies the semver requirements of all the requiredBy entries.`,\n );\n } else {\n // If the deduplication strategy allows duplicates and\n // no version satisfies the semver requirements for all dependents,\n // then deduplication of this package is not possible.\n console.debug(\n `Could not find a version of \"${packageName}\" that satisfies the semver requirements of all the requiredBy entries.`,\n );\n continue;\n }\n\n entries[satisfiedVersion].requiredBy = requiredBy;\n\n for (const version of availableVersions) {\n if (version == satisfiedVersion) {\n continue;\n }\n detachEntry({ appMap, entry: entries[version] });\n delete appMap[packageName][version];\n }\n\n for (const requiredById of Object.keys(requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n appMap[requiredByName][requiredByVersion].dependencies[packageName] = satisfiedVersion;\n }\n\n console.debug(`Removed versions of \"${packageName}\" except for \"${satisfiedVersion}\".`);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detachEntry.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/detachEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MA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C,CAAC;QACH,CAAC;QAED,0CAA0C;QAC1C,KAAK,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;YACrF,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;YAEpE,IAAI,eAAe,EAAE,CAAC;gBACpB,OAAO,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;gBACxD,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACzD,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport type { PackageMap } from '../types/PackageMap.js';\nimport { parseRequiredBy } from '../parseRequiredBy.js';\n\n/**\n * Removes requiredBy references for an entry being removed.\n */\nexport function detachEntry(options: { appMap: PackageMap; entry: ResolveMapEntry }): void {\n const { appMap } = options;\n const dependenciesToDetach: ResolveMapEntry[] = [options.entry];\n\n while (dependenciesToDetach.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked length\n const entry = dependenciesToDetach.pop()!;\n const { name, version, requiredBy } = entry;\n\n if (entry.isLinked || !appMap[name]?.[version]) {\n continue;\n }\n\n // Disconnect the entry from consumers.\n for (const requiredByName of Object.keys(requiredBy)) {\n const { name: parentName, version: parentVersion } = parseRequiredBy(requiredByName);\n const parentEntry = appMap[parentName]?.[parentVersion];\n\n if (parentEntry) {\n delete parentEntry.dependencies[name];\n }\n }\n\n // Disconnect dependencies from the entry.\n for (const [dependencyName, dependencyVersion] of Object.entries(entry.dependencies)) {\n const dependencyEntry = appMap[dependencyName]?.[dependencyVersion];\n\n if (dependencyEntry) {\n delete dependencyEntry.requiredBy[`${name}@${version}`];\n if (Object.keys(dependencyEntry.requiredBy).length === 0) {\n dependenciesToDetach.push(dependencyEntry);\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResolveMap } from '@ms-cloudpack/common-types';
|
|
2
|
-
import type { PackageMap } from '
|
|
2
|
+
import type { PackageMap } from '../types/PackageMap.js';
|
|
3
3
|
/**
|
|
4
4
|
* Flatten a ResolveMap into a PackageMap.
|
|
5
5
|
* This is useful for converting a ResolveMap into a format that can be easily consumed by other parts of the system.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenResolveMap.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/flattenResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAqBjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenResolveMap.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/flattenResolveMap.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmC;IACnE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,UAAU,GAAe,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,mDAAmD;QACnD,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAE/B,qBAAqB;QACrB,MAAM,EAAE,cAAc,EAAE,GAAG,0BAA0B,EAAE,GAAG,KAAK,CAAC;QAEhE,gEAAgE;QAChE,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,0BAA0B,EAAE,CAAC;QAE3E,0BAA0B;QAC1B,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,CAAC;YAC1E,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { ResolveMap } from '@ms-cloudpack/common-types';\nimport type { PackageMap } from '../types/PackageMap.js';\n\n/**\n * Flatten a ResolveMap into a PackageMap.\n * This is useful for converting a ResolveMap into a format that can be easily consumed by other parts of the system.\n * The main entry is added to the package map, and any scoped versions are added as well.\n */\nexport function flattenResolveMap(options: { resolveMap: ResolveMap }): PackageMap {\n const { resolveMap } = options;\n const packageMap: PackageMap = {};\n\n for (const [packageName, entry] of Object.entries(resolveMap)) {\n // Initialize the package entry if it doesn't exist\n packageMap[packageName] ??= {};\n\n // Add the main entry\n const { scopedVersions, ...entryWithoutScopedVersions } = entry;\n\n // Remove scopedVersions from the main entry to avoid redundancy\n packageMap[packageName][entry.version] = { ...entryWithoutScopedVersions };\n\n // Add any scoped versions\n for (const [version, scopedEntry] of Object.entries(scopedVersions || {})) {\n packageMap[packageName][version] = { ...scopedEntry };\n }\n }\n\n return packageMap;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LinkedPath, PackageJson } from '@ms-cloudpack/common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the effective resolutions to apply based on ignoreResolutions setting.
|
|
4
|
+
* - ignoreResolutions === true -> ignore all host resolutions (return undefined)
|
|
5
|
+
* - ignoreResolutions is string[] -> ignore only those package entries
|
|
6
|
+
* - otherwise apply all host resolutions
|
|
7
|
+
*/
|
|
8
|
+
export declare function getEffectiveResolutions(appRepoDefinition: PackageJson | undefined, ignoreResolutions: LinkedPath['ignoreResolutions']): PackageJson['resolutions'] | undefined;
|
|
9
|
+
//# sourceMappingURL=getEffectiveResolutions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEffectiveResolutions.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/getEffectiveResolutions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,WAAW,GAAG,SAAS,EAC1C,iBAAiB,EAAE,UAAU,CAAC,mBAAmB,CAAC,GACjD,WAAW,CAAC,aAAa,CAAC,GAAG,SAAS,CAgBxC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the effective resolutions to apply based on ignoreResolutions setting.
|
|
3
|
+
* - ignoreResolutions === true -> ignore all host resolutions (return undefined)
|
|
4
|
+
* - ignoreResolutions is string[] -> ignore only those package entries
|
|
5
|
+
* - otherwise apply all host resolutions
|
|
6
|
+
*/
|
|
7
|
+
export function getEffectiveResolutions(appRepoDefinition, ignoreResolutions) {
|
|
8
|
+
if (!appRepoDefinition?.resolutions)
|
|
9
|
+
return undefined;
|
|
10
|
+
const hostResolutions = appRepoDefinition.resolutions;
|
|
11
|
+
if (ignoreResolutions === true) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(ignoreResolutions) && ignoreResolutions.length) {
|
|
15
|
+
const filtered = Object.fromEntries(Object.entries(hostResolutions).filter(([pkgName]) => !ignoreResolutions.includes(pkgName)));
|
|
16
|
+
return Object.keys(filtered).length ? filtered : undefined;
|
|
17
|
+
}
|
|
18
|
+
return hostResolutions;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=getEffectiveResolutions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEffectiveResolutions.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/getEffectiveResolutions.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,iBAA0C,EAC1C,iBAAkD;IAElD,IAAI,CAAC,iBAAiB,EAAE,WAAW;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,eAAe,GAAG,iBAAiB,CAAC,WAAW,CAAC;IAEtD,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CACjC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAC5F,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,QAAmC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzF,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import type { LinkedPath, PackageJson } from '@ms-cloudpack/common-types';\n\n/**\n * Compute the effective resolutions to apply based on ignoreResolutions setting.\n * - ignoreResolutions === true -> ignore all host resolutions (return undefined)\n * - ignoreResolutions is string[] -> ignore only those package entries\n * - otherwise apply all host resolutions\n */\nexport function getEffectiveResolutions(\n appRepoDefinition: PackageJson | undefined,\n ignoreResolutions: LinkedPath['ignoreResolutions'],\n): PackageJson['resolutions'] | undefined {\n if (!appRepoDefinition?.resolutions) return undefined;\n const hostResolutions = appRepoDefinition.resolutions;\n\n if (ignoreResolutions === true) {\n return undefined;\n }\n\n if (Array.isArray(ignoreResolutions) && ignoreResolutions.length) {\n const filtered = Object.fromEntries(\n Object.entries(hostResolutions).filter(([pkgName]) => !ignoreResolutions.includes(pkgName)),\n );\n return Object.keys(filtered).length ? (filtered as typeof hostResolutions) : undefined;\n }\n\n return hostResolutions;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageMap } from '
|
|
1
|
+
import type { PackageMap } from '../types/PackageMap.js';
|
|
2
2
|
import type { LinkedPath, PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';
|
|
3
3
|
/**
|
|
4
4
|
* Find packages from `linkedPath` and add them to the `appMap`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPath.d.ts","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/linkPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMzD,OAAO,KAAK,EAAE,UAAU,EAAmB,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAMpH;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,iBAAiB,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,IAAI,CAAC,CA8Gf"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { addLinkedEntryDependencies } from './addLinkedEntryDependencies.js';
|
|
2
2
|
import { detachEntry } from './detachEntry.js';
|
|
3
|
-
import { findPackagesFromPath } from '
|
|
4
|
-
import { parseRequiredBy } from '
|
|
3
|
+
import { findPackagesFromPath } from '../findPackagesFromPath.js';
|
|
4
|
+
import { parseRequiredBy } from '../parseRequiredBy.js';
|
|
5
5
|
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
6
6
|
import { dedupeLinkedPackages } from './dedupeLinkedPackages.js';
|
|
7
7
|
import { findProjectRoot } from '@ms-cloudpack/path-utilities';
|
|
8
8
|
import { flattenResolveMap } from './flattenResolveMap.js';
|
|
9
|
+
import { getEffectiveResolutions } from './getEffectiveResolutions.js';
|
|
9
10
|
/**
|
|
10
11
|
* Find packages from `linkedPath` and add them to the `appMap`.
|
|
11
12
|
*/
|
|
@@ -21,7 +22,7 @@ export async function linkPath(options, context) {
|
|
|
21
22
|
}, context);
|
|
22
23
|
const entriesToLink = [];
|
|
23
24
|
const { path, ignoredPackages = [], includeAll } = linkedPath;
|
|
24
|
-
const resolutions = linkedPath.ignoreResolutions
|
|
25
|
+
const resolutions = getEffectiveResolutions(appRepoDefinition, linkedPath.ignoreResolutions);
|
|
25
26
|
// Iterate through the linkMap, looking for internal packages to link to the appMap.
|
|
26
27
|
for (const [packageName, packageVersions] of Object.entries(linkMap)) {
|
|
27
28
|
const appEntries = Object.values(appMap[packageName] || {});
|
|
@@ -88,7 +89,7 @@ export async function linkPath(options, context) {
|
|
|
88
89
|
allDuplicates.push(...duplicates);
|
|
89
90
|
}
|
|
90
91
|
if (linkedPath.resolveStrategy !== 'duplicate') {
|
|
91
|
-
await dedupeLinkedPackages({ appMap, allDuplicates: new Set(allDuplicates), rootPath: appRootPath,
|
|
92
|
+
await dedupeLinkedPackages({ appMap, allDuplicates: new Set(allDuplicates), rootPath: appRootPath, linkMap }, context);
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
function isContainedInPath(path, basePath) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../../../src/resolveMap/createHelpers/link/linkPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC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AC;AACxB,CAAC","sourcesContent":["import type { PackageMap } from '../types/PackageMap.js';\nimport { addLinkedEntryDependencies } from './addLinkedEntryDependencies.js';\nimport { detachEntry } from './detachEntry.js';\nimport { findPackagesFromPath } from '../findPackagesFromPath.js';\nimport { parseRequiredBy } from '../parseRequiredBy.js';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport type { LinkedPath, ResolveMapEntry, PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';\nimport { dedupeLinkedPackages } from './dedupeLinkedPackages.js';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { flattenResolveMap } from './flattenResolveMap.js';\nimport { getEffectiveResolutions } from './getEffectiveResolutions.js';\n\n/**\n * Find packages from `linkedPath` and add them to the `appMap`.\n */\nexport async function linkPath(\n options: {\n linkedPath: LinkedPath;\n appMap: PackageMap;\n appRootPath: string | undefined;\n appRepoDefinition: PackageJson | undefined;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<void> {\n const { linkedPath, appMap, appRootPath, appRepoDefinition } = options;\n\n const linkedRootPath = linkedPath.rootPath || findProjectRoot(linkedPath.path, { noPackageRoot: true });\n\n const linkMap = linkedPath?.remote\n ? flattenResolveMap({ resolveMap: linkedPath.remote.resolveMap })\n : await findPackagesFromPath(\n {\n searchPaths: [linkedPath.path],\n discoverPackages: true,\n rootPath: linkedRootPath,\n },\n context,\n );\n const entriesToLink: ResolveMapEntry[] = [];\n const { path, ignoredPackages = [], includeAll } = linkedPath;\n const resolutions = getEffectiveResolutions(appRepoDefinition, linkedPath.ignoreResolutions);\n\n // Iterate through the linkMap, looking for internal packages to link to the appMap.\n for (const [packageName, packageVersions] of Object.entries(linkMap)) {\n const appEntries = Object.values(appMap[packageName] || {});\n\n if (!appEntries.length) {\n continue;\n }\n\n const linkedEntries = Object.values(packageVersions);\n const linkedEntry = linkedEntries.length === 1 ? linkedEntries[0] : undefined;\n\n // For linked dependencies, we don't want multiple versions referenced. Remove them\n // all and add them in a second pass.\n if (\n linkedEntry &&\n !linkedEntry.isExternal &&\n ignoredPackages.indexOf(packageName) === -1 &&\n (includeAll || isContainedInPath(linkedEntry.path, path))\n ) {\n // Linked packages use an asterisk for the version description. This keeps it semver compatible with\n // anything.\n linkedEntry.version += '-linked';\n linkedEntry.isLinked = true;\n\n entriesToLink.push(linkedEntry);\n }\n }\n\n // We now have a list of paths to link. Iterate through them, add them to the appMap,\n // and ensure their dependencies are satisfied.\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n linkedEntry.requiredBy = {};\n for (const entry of existingEntries) {\n for (const [requiredById, requirement] of Object.entries(entry.requiredBy)) {\n const requiredByName = parseRequiredBy(requiredById).name;\n const linkedParentEntry = Object.values(linkMap[requiredByName] || {})[0];\n const requiredByKey = linkedParentEntry?.isLinked\n ? (`${linkedParentEntry.name}@${linkedParentEntry.version}` as const)\n : requiredById;\n linkedEntry.requiredBy[requiredByKey as `${string}@${string}`] = requirement;\n }\n }\n }\n\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n // We need to detach all existing entries from the appMap, along with their dependencies. Note - detaching just means that\n // we disconnect the entry from its parent and children. If the children have no other parents, we disconnect them as well\n // and recurse through their children.\n for (const existingEntry of existingEntries) {\n detachEntry({ appMap, entry: existingEntry });\n }\n\n // Attach the linked entry to the parents' dependencies.\n for (const requiredById of Object.keys(linkedEntry.requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n let requiredByEntry = appMap[requiredByName][requiredByVersion];\n\n // If we can't find the requiredBy entry, it likely means that the entry was already replaced with a linked entry\n // in the app map. Fall back to the first entry.\n requiredByEntry ??= Object.values(appMap[requiredByName])[0];\n\n requiredByEntry.dependencies[name] = linkedEntry.version;\n }\n\n // Add the linked entry\n appMap[linkedEntry.name] = { [linkedEntry.version]: linkedEntry };\n }\n\n const allDuplicates = [];\n\n // Once all linked entries have been added, ensure their dependencies are resolved.\n for (const linkedEntry of entriesToLink) {\n const { duplicates } = await addLinkedEntryDependencies(\n { linkedEntry, appMap: appMap, linkMap, resolutions },\n context,\n );\n allDuplicates.push(...duplicates);\n }\n\n if (linkedPath.resolveStrategy !== 'duplicate') {\n await dedupeLinkedPackages(\n { appMap, allDuplicates: new Set(allDuplicates), rootPath: appRootPath, linkMap },\n context,\n );\n }\n}\n\nfunction isContainedInPath(path: string, basePath: string): boolean {\n path = normalizePath(path);\n basePath = normalizePath(basePath);\n\n return path.startsWith(basePath);\n}\n\nfunction normalizePath(path: string): string {\n let normalizedPath = slash(path);\n\n if (!normalizedPath.endsWith('/')) {\n normalizedPath += '/';\n }\n\n return normalizedPath;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findProjectRoot } from '@ms-cloudpack/path-utilities';
|
|
2
2
|
import { findPackagesFromPath } from './createHelpers/findPackagesFromPath.js';
|
|
3
|
-
import { convertToLinkResolveMap } from './createHelpers/convertToLinkResolveMap.js';
|
|
3
|
+
import { convertToLinkResolveMap } from './createHelpers/link/convertToLinkResolveMap.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create a link resolve map for a given `appPath`.
|
|
6
6
|
* 1. Discover through the dependency tree to build a map of all packages and their dependencies.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLinkResolveMap.js","sourceRoot":"","sources":["../../src/resolveMap/createLinkResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createLinkResolveMap.js","sourceRoot":"","sources":["../../src/resolveMap/createLinkResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAYC,EACD,OAEC;IAED,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAElD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvF,kDAAkD;IAClD,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC;QACE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC;QAC1C,gBAAgB,EAAE,IAAI;QACtB,QAAQ;KACT,EACD,OAAO,CACR,CAAC;IAEF,OAAO,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { PackageDefinitionsCache, ResolveMap } from '@ms-cloudpack/common-types';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { findPackagesFromPath } from './createHelpers/findPackagesFromPath.js';\nimport { convertToLinkResolveMap } from './createHelpers/link/convertToLinkResolveMap.js';\n\n/**\n * Create a link resolve map for a given `appPath`.\n * 1. Discover through the dependency tree to build a map of all packages and their dependencies.\n * 2. For each dependency, sort the versions by the number of packages that depend on that version.\n * The most popular version will be considered the \"default\", to reduce the size of scoped versions.\n */\nexport async function createLinkResolveMap(\n options: {\n /** Path to the app whose dependencies we want to resolve. */\n appPath: string;\n\n /** Any additional packages whose dependencies we want to resolve. */\n additionalPaths?: string[];\n\n /**\n * Where to stop looking for packages (mainly used for testing).\n * If not specified, will look for the project/git root of the `appPath`.\n */\n rootPath?: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<ResolveMap> {\n const { appPath, additionalPaths = [] } = options;\n\n const rootPath = options.rootPath || findProjectRoot(appPath, { noPackageRoot: true });\n\n // First we discover the dependencies for the app.\n const appMap = await findPackagesFromPath(\n {\n searchPaths: [appPath, ...additionalPaths],\n discoverPackages: true,\n rootPath,\n },\n context,\n );\n\n return convertToLinkResolveMap({ appMap });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findProjectRoot } from '@ms-cloudpack/path-utilities';
|
|
2
2
|
import { convertToResolveMap } from './createHelpers/convertToResolveMap.js';
|
|
3
3
|
import { findPackagesFromPath } from './createHelpers/findPackagesFromPath.js';
|
|
4
|
-
import { linkPath } from './createHelpers/linkPath.js';
|
|
4
|
+
import { linkPath } from './createHelpers/link/linkPath.js';
|
|
5
5
|
/**
|
|
6
6
|
* Create a resolve map for a given `appPath`.
|
|
7
7
|
* 1. Walk the dependency tree to build a map of all packages and their dependencies.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createResolveMap.js","sourceRoot":"","sources":["../../src/resolveMap/createResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createResolveMap.js","sourceRoot":"","sources":["../../src/resolveMap/createResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAqBC,EACD,OAEC;IAED,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAE7F,IAAI,uBAAuB,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,+FAA+F;IAC/F,mDAAmD;IACnD,MAAM,QAAQ,GAAG,uBAAuB;QACtC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE1E,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEtF,kDAAkD;IAClD,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC;QACE,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC;QAC1C,QAAQ;QACR,uBAAuB;KACxB,EACD,OAAO,CACR,CAAC;IAEF,4EAA4E;IAC5E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,QAAQ,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5G,CAAC;IAED,0CAA0C;IAC1C,OAAO,mBAAmB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import type { LinkedPath, PackageDefinitionsCache, ResolveMap } from '@ms-cloudpack/common-types';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { convertToResolveMap } from './createHelpers/convertToResolveMap.js';\nimport { findPackagesFromPath } from './createHelpers/findPackagesFromPath.js';\nimport { linkPath } from './createHelpers/link/linkPath.js';\n\n/**\n * Create a resolve map for a given `appPath`.\n * 1. Walk the dependency tree to build a map of all packages and their dependencies.\n * 2. If `linkedPaths` are provided, for each one:\n * 1. Walk its dependency tree to build a map as above.\n * 2. Redirect any existing dependencies to the linked package.\n * 3. Ensure that any transitive dependencies of the linked package which aren't already\n * satisfied in the resolve map are added as scoped versions.\n * 3. For each dependency, sort the versions by the number of packages that depend on that version.\n * The most popular version will be considered the \"default\", to reduce the size of scoped versions.\n */\nexport async function createResolveMap(\n options: {\n /** Path to the app whose dependencies we want to resolve. */\n appPath: string;\n\n /** Any additional packages whose dependencies we want to resolve. */\n additionalPaths?: string[];\n\n /** See `createResolveMap` comment. */\n linkedPaths?: LinkedPath[];\n\n /**\n * Where to stop looking for packages (mainly used for testing).\n * If not specified, will look for the project/git root of the `appPath`.\n */\n rootPath?: string;\n\n /**\n * Skip the actual resolution of dependencies. The returned resolve map will only contain\n * the package(s) from the given path(s). Not compatible with `linkedPaths`.\n */\n skipResolveDependencies?: boolean;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<ResolveMap> {\n const { appPath, additionalPaths = [], linkedPaths = [], skipResolveDependencies } = options;\n\n if (skipResolveDependencies && linkedPaths.length) {\n throw new Error('Cannot use `linkedPaths` with `skipResolveDependencies`');\n }\n\n // rootPath is only used as the place to stop searching up for dependencies, so we can skip the\n // calculation if we're not resolving dependencies.\n const rootPath = skipResolveDependencies\n ? undefined\n : options.rootPath || findProjectRoot(appPath, { noPackageRoot: true });\n\n const repoDefinition = rootPath ? await context.packages.tryGet(rootPath) : undefined;\n\n // First we discover the dependencies for the app.\n const appMap = await findPackagesFromPath(\n {\n searchPaths: [appPath, ...additionalPaths],\n rootPath,\n skipResolveDependencies,\n },\n context,\n );\n\n // Next, we iterate through linked paths to inject them into the packageMap.\n for (const linkedPath of linkedPaths) {\n await linkPath({ linkedPath, appRootPath: rootPath, appMap, appRepoDefinition: repoDefinition }, context);\n }\n\n // Finally we condense into a resolve map.\n return convertToResolveMap({ appMap, rootPaths: [appPath, ...additionalPaths] });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.27.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.27.5",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
19
19
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
20
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
21
|
-
"@ms-cloudpack/task-reporter": "^0.17.
|
|
20
|
+
"@ms-cloudpack/path-utilities": "^3.1.20",
|
|
21
|
+
"@ms-cloudpack/task-reporter": "^0.17.3",
|
|
22
22
|
"acorn": "^8.11.2",
|
|
23
23
|
"acorn-walk": "^8.2.1",
|
|
24
24
|
"semver": "^7.6.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addLinkedEntryDependencies.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/addLinkedEntryDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAExG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE;IACP,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,eAAe,CAAC;IAC7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;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import type { PackageDefinitionsCache, PackageJson, ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport { satisfies } from 'semver';\nimport type { PackageMap } from './types/PackageMap.js';\nimport { getDependencies } from '../../packageJson/getDependencies.js';\n\n/**\n * Given a linkedEntry, iterates through dependencies to ensure they are added to the packageMap,\n * preferring packageMap dependencies over linkedMap dependencies.\n * Returns a list of duplicated packages that were added to the packageMap.\n */\nexport async function addLinkedEntryDependencies(\n options: {\n appMap: PackageMap;\n linkMap: PackageMap;\n linkedEntry: ResolveMapEntry;\n resolutions?: PackageJson['resolutions'];\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<{ duplicates: string[] }> {\n const { appMap, linkMap, linkedEntry, resolutions } = options;\n const { packages } = context;\n const visitedEntryPaths = new Set<string>(linkedEntry.path);\n const duplicates: string[] = [];\n const entriesToVisit: ResolveMapEntry[] = [linkedEntry];\n\n function enqueue(newEntry: ResolveMapEntry): void {\n if (!visitedEntryPaths.has(newEntry.path)) {\n visitedEntryPaths.add(newEntry.path);\n entriesToVisit.push(newEntry);\n }\n }\n\n while (entriesToVisit.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked the length\n const entry = entriesToVisit.pop()!;\n\n const { name, version, dependencies } = entry;\n\n const linkDefinition = await packages.tryGet(entry.path);\n if (!linkDefinition) {\n continue;\n }\n\n const versionRequirements = getDependencies(linkDefinition);\n\n // Iterate through the dependencies of the linked package.\n for (const [dependencyName, linkedDependencyVersion] of Object.entries(dependencies)) {\n const versionRequirement = versionRequirements[dependencyName];\n if (!versionRequirement) {\n continue;\n }\n\n const appVersions = appMap[dependencyName];\n\n if (!appVersions) {\n // The app does not have any version of this dependency, so we need to bring over the version\n // used by the linkedEntry.\n const dependencyEntry = linkMap[dependencyName]?.[linkedDependencyVersion];\n if (dependencyEntry) {\n appMap[dependencyName] = { [linkedDependencyVersion]: dependencyEntry };\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n\n // Recurse through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n } else {\n // We have one or more versions of this dependency already. If a sufficient version\n // of the dependency is already in the appMap, we we just need to update the linkedEntry's\n // dependency and the dependency's requiredBy record for the parent.\n const appDependencyVersions = Object.values(appVersions);\n\n if (appDependencyVersions.length === 1 && !appDependencyVersions[0]?.isExternal) {\n continue;\n }\n\n // See if an existing version of the dependency satisfies the semver.\n const appDependencyEntry = appDependencyVersions.find(\n (e) =>\n // If the dependency is linked, use that.\n e.isLinked ||\n // If the dependency version is required as a resolution, use that.\n resolutions?.[dependencyName] ||\n // If the dependency satisfies the semver, use that.\n satisfies(e.version, versionRequirement),\n );\n\n if (appDependencyEntry) {\n // If the dependency satisfies the semver, use that!\n entry.dependencies[dependencyName] = appDependencyEntry.version;\n appDependencyEntry.requiredBy[`${name}@${version}`] = versionRequirement;\n\n enqueue(appDependencyEntry);\n } else {\n // We have at least one version of this dependency but nothing satisfies the requirement.\n // We need to introduce a duplicate. During the final pass, we will remove non-required deps.\n const dependencyEntry = Object.values(linkMap[dependencyName] || {}).find((e) =>\n satisfies(e.version, versionRequirement),\n );\n if (dependencyEntry) {\n appVersions[dependencyEntry.version] = dependencyEntry;\n entry.dependencies[dependencyName] = linkedDependencyVersion;\n dependencyEntry.requiredBy = { [`${name}@${version}`]: versionRequirement };\n duplicates.push(`${dependencyName}@${dependencyEntry.version}`);\n // Recursive through the dependency's dependencies.\n enqueue(dependencyEntry);\n }\n }\n }\n }\n }\n\n return { duplicates };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertToLinkResolveMap.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/convertToLinkResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAoBnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertToLinkResolveMap.js","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/convertToLinkResolveMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA+B;IACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,UAAU,GAAe,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE7E,wFAAwF;QACxF,2EAA2E;QAC3E,IAAI,oBAAoB,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;YAElE,wDAAwD;YACxD,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { ResolveMap } from '@ms-cloudpack/common-types';\nimport { entrySorter } from './entrySorter.js';\nimport type { PackageMap } from './types/PackageMap.js';\n\n/**\n * Given a PackageMap returns a ResolveMap.\n */\nexport function convertToLinkResolveMap(options: { appMap: PackageMap }): ResolveMap {\n const { appMap } = options;\n const resolveMap: ResolveMap = {};\n\n for (const [packageName, packageEntries] of Object.entries(appMap)) {\n const sortedPackageEntries = Object.values(packageEntries).sort(entrySorter);\n\n // Get the sorted package entries based on the most to least requiredBy references. This\n // ends up reducing the size of the resolve map by minimizing scoped cases.\n if (sortedPackageEntries.length) {\n const entry = (resolveMap[packageName] = sortedPackageEntries[0]);\n\n // Update scoped versions (version to resolve map entry)\n if (sortedPackageEntries.length > 1) {\n entry.scopedVersions = Object.fromEntries(sortedPackageEntries.slice(1).map((e) => [e.version, e]));\n }\n }\n }\n\n return resolveMap;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dedupeLinkedPackages.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/dedupeLinkedPackages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,uBAAuB,EAAgC,MAAM,4BAA4B,CAAC;AAKxG;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACnG,OAAO,EAAE;IAAE,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GAC7C,OAAO,CAAC,IAAI,CAAC,CAmHf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dedupeLinkedPackages.js","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/dedupeLinkedPackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,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AAI,iBAAiB,EAAE,CAAC;YACxC,IAAI,OAAO,IAAI,gBAAgB,EAAE,CAAC;gBAChC,SAAS;YACX,CAAC;YACD,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACnD,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;YAC3F,MAAM,CAAC,cAAc,CAAC,CAAC,iBAAiB,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC;QACzF,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,wBAAwB,WAAW,iBAAiB,gBAAgB,IAAI,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC","sourcesContent":["import { satisfies, rcompare as semverReverseCompare } from 'semver';\nimport type { PackageMap } from './types/PackageMap.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { detachEntry } from './detachEntry.js';\nimport type { PackageDefinitionsCache, ResolveMapEntry, LinkOptions } from '@ms-cloudpack/common-types';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\n\ntype DuplicatedDependencyBehavior = NonNullable<LinkOptions['duplicatedDependencyBehavior']>;\n\n/**\n * Deduplicates linked packages by removing all but the highest version,\n * that satisfies the semver requirements of all the requiredBy entries.\n */\nexport async function dedupeLinkedPackages(\n options: { appMap: PackageMap; allDuplicates: Set<string>; remotePath?: string; rootPath?: string },\n context: { packages: PackageDefinitionsCache },\n): Promise<void> {\n const { rootPath, appMap, allDuplicates, remotePath } = options;\n const { packages } = context;\n console.debug(`The following packages were duplicated by linking:\\n ${Array.from(allDuplicates).join(', ')}`);\n for (const duplicate of allDuplicates) {\n const packageName = parseRequiredBy(duplicate).name;\n\n const entries = appMap[packageName] || {};\n\n // Sanity check to ensure that it is a duplicate.\n if (Object.keys(entries).length <= 1) {\n continue;\n }\n\n let dedupeStrategy: DuplicatedDependencyBehavior = 'allow-duplication';\n for (const entry of Object.values(entries)) {\n const packageJson = await packages.get(entry.path);\n if (packageJson.cloudpack?.link?.duplicatedDependencyBehavior) {\n dedupeStrategy = packageJson.cloudpack.link.duplicatedDependencyBehavior;\n }\n }\n\n const availableVersions = Object.keys(entries);\n\n const versionRequirements = new Set<string>();\n // Find if any of the duplicate entries satisfy the semver requirement of all the requiredBy entries.\n const requiredBy: ResolveMapEntry['requiredBy'] = {};\n for (const entry of Object.values(entries)) {\n for (const [requiredById, range] of Object.entries(entry.requiredBy) as [`${string}@${string}`, string][]) {\n requiredBy[requiredById] = range;\n // We only care about satisfying version requirements that are already satisfied.\n if (satisfies(entry.version, range)) {\n versionRequirements.add(range);\n }\n }\n }\n\n // Find the versions that satisfy the semver requirements of all the requiredBy entries.\n // Sort the versions in descending order.\n const satisfiedVersions = availableVersions\n .filter((v) => [...versionRequirements].every((range) => satisfies(v, range)))\n .sort(semverReverseCompare);\n\n let satisfiedVersion: string | undefined;\n\n if (dedupeStrategy === 'force-host-version') {\n if (!rootPath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-host-version\" dedupe strategy.',\n );\n continue;\n }\n // Use the app host's version of the package.\n // Find the version of the package that belongs to the host.\n // We assume that the host has a single version of the package.\n const hostVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(rootPath)));\n\n if (!hostVersion) {\n console.error(`Could not find a version of \"${packageName}\" that is belongs to the host.`);\n continue;\n }\n\n satisfiedVersion = hostVersion;\n } else if (dedupeStrategy === 'force-remote-version') {\n if (!remotePath) {\n console.error(\n 'Root path for project not found and is required when using the \"force-remote-version\" dedupe strategy.',\n );\n continue;\n }\n\n // Use the version of the package that is the remote.\n // Find the version of the package that does not belong to the host.\n // We assume that the remote has a single version of the package.\n const remoteVersion = availableVersions.find((v) => slash(entries[v].path).startsWith(slash(remotePath)));\n\n if (!remoteVersion) {\n console.error(`Could not find a version of \"${packageName}\" that is belongs to the remote.`);\n continue;\n }\n\n satisfiedVersion = remoteVersion;\n } else if (dedupeStrategy === 'allow-duplication' && satisfiedVersions.length > 0) {\n // Select the highest version that satisfies the semver requirements of all the requiredBy entries.\n satisfiedVersion = satisfiedVersions[0];\n console.debug(\n `Version \"${satisfiedVersion}\" of \"${packageName}\" satisfies the semver requirements of all the requiredBy entries.`,\n );\n } else {\n // If the deduplication strategy allows duplicates and\n // no version satisfies the semver requirements for all dependents,\n // then deduplication of this package is not possible.\n console.debug(\n `Could not find a version of \"${packageName}\" that satisfies the semver requirements of all the requiredBy entries.`,\n );\n continue;\n }\n\n entries[satisfiedVersion].requiredBy = requiredBy;\n\n for (const version of availableVersions) {\n if (version == satisfiedVersion) {\n continue;\n }\n detachEntry({ appMap, entry: entries[version] });\n delete appMap[packageName][version];\n }\n\n for (const requiredById of Object.keys(requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n appMap[requiredByName][requiredByVersion].dependencies[packageName] = satisfiedVersion;\n }\n\n console.debug(`Removed versions of \"${packageName}\" except for \"${satisfiedVersion}\".`);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detachEntry.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/detachEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,GAAG,IAAI,CAmCzF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":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ACpB,OAAO,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;gBACxD,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACzD,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { ResolveMapEntry } from '@ms-cloudpack/common-types';\nimport type { PackageMap } from './types/PackageMap.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\n\n/**\n * Removes requiredBy references for an entry being removed.\n */\nexport function detachEntry(options: { appMap: PackageMap; entry: ResolveMapEntry }): void {\n const { appMap } = options;\n const dependenciesToDetach: ResolveMapEntry[] = [options.entry];\n\n while (dependenciesToDetach.length) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- already checked length\n const entry = dependenciesToDetach.pop()!;\n const { name, version, requiredBy } = entry;\n\n if (entry.isLinked || !appMap[name]?.[version]) {\n continue;\n }\n\n // Disconnect the entry from consumers.\n for (const requiredByName of Object.keys(requiredBy)) {\n const { name: parentName, version: parentVersion } = parseRequiredBy(requiredByName);\n const parentEntry = appMap[parentName]?.[parentVersion];\n\n if (parentEntry) {\n delete parentEntry.dependencies[name];\n }\n }\n\n // Disconnect dependencies from the entry.\n for (const [dependencyName, dependencyVersion] of Object.entries(entry.dependencies)) {\n const dependencyEntry = appMap[dependencyName]?.[dependencyVersion];\n\n if (dependencyEntry) {\n delete dependencyEntry.requiredBy[`${name}@${version}`];\n if (Object.keys(dependencyEntry.requiredBy).length === 0) {\n dependenciesToDetach.push(dependencyEntry);\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flattenResolveMap.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/flattenResolveMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAqBjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flattenResolveMap.js","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/flattenResolveMap.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAmC;IACnE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,UAAU,GAAe,EAAE,CAAC;IAElC,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,mDAAmD;QACnD,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAE/B,qBAAqB;QACrB,MAAM,EAAE,cAAc,EAAE,GAAG,0BAA0B,EAAE,GAAG,KAAK,CAAC;QAEhE,gEAAgE;QAChE,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,0BAA0B,EAAE,CAAC;QAE3E,0BAA0B;QAC1B,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,CAAC;YAC1E,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { ResolveMap } from '@ms-cloudpack/common-types';\nimport type { PackageMap } from './types/PackageMap.js';\n\n/**\n * Flatten a ResolveMap into a PackageMap.\n * This is useful for converting a ResolveMap into a format that can be easily consumed by other parts of the system.\n * The main entry is added to the package map, and any scoped versions are added as well.\n */\nexport function flattenResolveMap(options: { resolveMap: ResolveMap }): PackageMap {\n const { resolveMap } = options;\n const packageMap: PackageMap = {};\n\n for (const [packageName, entry] of Object.entries(resolveMap)) {\n // Initialize the package entry if it doesn't exist\n packageMap[packageName] ??= {};\n\n // Add the main entry\n const { scopedVersions, ...entryWithoutScopedVersions } = entry;\n\n // Remove scopedVersions from the main entry to avoid redundancy\n packageMap[packageName][entry.version] = { ...entryWithoutScopedVersions };\n\n // Add any scoped versions\n for (const [version, scopedEntry] of Object.entries(scopedVersions || {})) {\n packageMap[packageName][version] = { ...scopedEntry };\n }\n }\n\n return packageMap;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.d.ts","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/linkPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMxD,OAAO,KAAK,EAAE,UAAU,EAAmB,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAKpH;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE;IACP,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,iBAAiB,EAAE,WAAW,GAAG,SAAS,CAAC;CAC5C,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,IAAI,CAAC,CA8Gf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"linkPath.js","sourceRoot":"","sources":["../../../src/resolveMap/createHelpers/linkPath.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,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} from './types/PackageMap.js';\nimport { addLinkedEntryDependencies } from './addLinkedEntryDependencies.js';\nimport { detachEntry } from './detachEntry.js';\nimport { findPackagesFromPath } from './findPackagesFromPath.js';\nimport { parseRequiredBy } from './parseRequiredBy.js';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport type { LinkedPath, ResolveMapEntry, PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';\nimport { dedupeLinkedPackages } from './dedupeLinkedPackages.js';\nimport { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport { flattenResolveMap } from './flattenResolveMap.js';\n\n/**\n * Find packages from `linkedPath` and add them to the `appMap`.\n */\nexport async function linkPath(\n options: {\n linkedPath: LinkedPath;\n appMap: PackageMap;\n appRootPath: string | undefined;\n appRepoDefinition: PackageJson | undefined;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<void> {\n const { linkedPath, appMap, appRootPath, appRepoDefinition } = options;\n\n const linkedRootPath = linkedPath.rootPath || findProjectRoot(linkedPath.path, { noPackageRoot: true });\n\n const linkMap = linkedPath?.remote\n ? flattenResolveMap({ resolveMap: linkedPath.remote.resolveMap })\n : await findPackagesFromPath(\n {\n searchPaths: [linkedPath.path],\n discoverPackages: true,\n rootPath: linkedRootPath,\n },\n context,\n );\n const entriesToLink: ResolveMapEntry[] = [];\n const { path, ignoredPackages = [], includeAll } = linkedPath;\n const resolutions = linkedPath.ignoreResolutions ? undefined : appRepoDefinition?.resolutions;\n\n // Iterate through the linkMap, looking for internal packages to link to the appMap.\n for (const [packageName, packageVersions] of Object.entries(linkMap)) {\n const appEntries = Object.values(appMap[packageName] || {});\n\n if (!appEntries.length) {\n continue;\n }\n\n const linkedEntries = Object.values(packageVersions);\n const linkedEntry = linkedEntries.length === 1 ? linkedEntries[0] : undefined;\n\n // For linked dependencies, we don't want multiple versions referenced. Remove them\n // all and add them in a second pass.\n if (\n linkedEntry &&\n !linkedEntry.isExternal &&\n ignoredPackages.indexOf(packageName) === -1 &&\n (includeAll || isContainedInPath(linkedEntry.path, path))\n ) {\n // Linked packages use an asterisk for the version description. This keeps it semver compatible with\n // anything.\n linkedEntry.version += '-linked';\n linkedEntry.isLinked = true;\n\n entriesToLink.push(linkedEntry);\n }\n }\n\n // We now have a list of paths to link. Iterate through them, add them to the appMap,\n // and ensure their dependencies are satisfied.\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n linkedEntry.requiredBy = {};\n for (const entry of existingEntries) {\n for (const [requiredById, requirement] of Object.entries(entry.requiredBy)) {\n const requiredByName = parseRequiredBy(requiredById).name;\n const linkedParentEntry = Object.values(linkMap[requiredByName] || {})[0];\n const requiredByKey = linkedParentEntry?.isLinked\n ? (`${linkedParentEntry.name}@${linkedParentEntry.version}` as const)\n : requiredById;\n linkedEntry.requiredBy[requiredByKey as `${string}@${string}`] = requirement;\n }\n }\n }\n\n for (const linkedEntry of entriesToLink) {\n const { name } = linkedEntry;\n const existingEntries = Object.values(appMap[name]);\n\n // We need to detach all existing entries from the appMap, along with their dependencies. Note - detaching just means that\n // we disconnect the entry from its parent and children. If the children have no other parents, we disconnect them as well\n // and recurse through their children.\n for (const existingEntry of existingEntries) {\n detachEntry({ appMap, entry: existingEntry });\n }\n\n // Attach the linked entry to the parents' dependencies.\n for (const requiredById of Object.keys(linkedEntry.requiredBy)) {\n const { name: requiredByName, version: requiredByVersion } = parseRequiredBy(requiredById);\n let requiredByEntry = appMap[requiredByName][requiredByVersion];\n\n // If we can't find the requiredBy entry, it likely means that the entry was already replaced with a linked entry\n // in the app map. Fall back to the first entry.\n requiredByEntry ??= Object.values(appMap[requiredByName])[0];\n\n requiredByEntry.dependencies[name] = linkedEntry.version;\n }\n\n // Add the linked entry\n appMap[linkedEntry.name] = { [linkedEntry.version]: linkedEntry };\n }\n\n const allDuplicates = [];\n\n // Once all linked entries have been added, ensure their dependencies are resolved.\n for (const linkedEntry of entriesToLink) {\n const { duplicates } = await addLinkedEntryDependencies(\n { linkedEntry, appMap: appMap, linkMap, resolutions },\n context,\n );\n allDuplicates.push(...duplicates);\n }\n\n if (linkedPath.resolveStrategy !== 'duplicate') {\n await dedupeLinkedPackages(\n { appMap, allDuplicates: new Set(allDuplicates), rootPath: appRootPath, remotePath: linkedPath.path },\n context,\n );\n }\n}\n\nfunction isContainedInPath(path: string, basePath: string): boolean {\n path = normalizePath(path);\n basePath = normalizePath(basePath);\n\n return path.startsWith(basePath);\n}\n\nfunction normalizePath(path: string): string {\n let normalizedPath = slash(path);\n\n if (!normalizedPath.endsWith('/')) {\n normalizedPath += '/';\n }\n\n return normalizedPath;\n}\n"]}
|
|
File without changes
|