@ms-cloudpack/package-utilities 7.8.6 → 7.8.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureResolveMapEntry.d.ts","sourceRoot":"","sources":["../src/ensureResolveMapEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ensureResolveMapEntry.d.ts","sourceRoot":"","sources":["../src/ensureResolveMapEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIvF;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE;IACN,UAAU,EAAE,WAAW,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,EACD,OAAO,EAAE;IACP,QAAQ,EAAE,uBAAuB,CAAC;CACnC,GACA,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAiF7B"}
|
|
@@ -19,8 +19,8 @@ export async function ensureResolveMapEntry(params, context) {
|
|
|
19
19
|
const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });
|
|
20
20
|
let dependencyPath = resolveEntry?.path;
|
|
21
21
|
let dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined;
|
|
22
|
-
// If the dependency is already in the resolve map
|
|
23
|
-
if (dependencyPath && dependencyDefinition) {
|
|
22
|
+
// If the dependency is already in the resolve map and required by the parent, return the path.
|
|
23
|
+
if (dependencyPath && dependencyDefinition && resolveEntry?.requiredBy[`${definition.name}@${definition.version}`]) {
|
|
24
24
|
return dependencyPath;
|
|
25
25
|
}
|
|
26
26
|
const rootPath = findProjectRoot(appPath, { noPackageRoot: true });
|
|
@@ -30,29 +30,44 @@ export async function ensureResolveMapEntry(params, context) {
|
|
|
30
30
|
rootPath,
|
|
31
31
|
}, context);
|
|
32
32
|
dependencyPath = dependencyPackage?.packagePath;
|
|
33
|
-
dependencyDefinition = dependencyPackage?.definition
|
|
33
|
+
dependencyDefinition = dependencyPackage?.definition;
|
|
34
|
+
const version = dependencyDefinition?.version;
|
|
34
35
|
// If we can't find the dependency, we can't add it to the resolve map.
|
|
35
|
-
if (!dependencyPath || !dependencyDefinition || !
|
|
36
|
+
if (!dependencyPath || !dependencyDefinition || !version) {
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
// Check if the dependency is already in the resolve map.
|
|
40
|
+
let dependencyEntry = [resolveMap[dependencyName], ...Object.values(resolveMap[dependencyName]?.scopedVersions || {})]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.find((e) => e.version === version && e.path === dependencyPath);
|
|
43
|
+
// If it already exists, add the requiredBy entry and return the path.
|
|
44
|
+
if (dependencyEntry) {
|
|
45
|
+
parentEntry.dependencies[dependencyName] = version;
|
|
46
|
+
dependencyEntry.requiredBy[`${definition.name}@${definition.version}`] = version;
|
|
47
|
+
return dependencyPath;
|
|
48
|
+
}
|
|
49
|
+
// If it is missing from the resolve map, add it.
|
|
50
|
+
dependencyEntry = {
|
|
39
51
|
name: dependencyName,
|
|
40
|
-
version
|
|
52
|
+
version,
|
|
41
53
|
path: dependencyPath,
|
|
42
54
|
dependencies: {},
|
|
43
|
-
requiredBy: {
|
|
55
|
+
requiredBy: {
|
|
56
|
+
[`${definition.name}@${definition.version}`]: version,
|
|
57
|
+
},
|
|
44
58
|
};
|
|
45
59
|
if (isExternalPackage(dependencyPath)) {
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
parentEntry.dependencies[dependencyName] =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
dependencyEntry.isExternal = true;
|
|
61
|
+
}
|
|
62
|
+
parentEntry.dependencies[dependencyName] = version;
|
|
63
|
+
// Add the dependency to the resolve map.
|
|
64
|
+
if (!resolveMap[dependencyName]) {
|
|
65
|
+
resolveMap[dependencyName] = dependencyEntry;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
resolveMap[dependencyName].scopedVersions ??= {};
|
|
69
|
+
resolveMap[dependencyName].scopedVersions[version] = dependencyEntry;
|
|
70
|
+
}
|
|
56
71
|
return dependencyPath;
|
|
57
72
|
}
|
|
58
73
|
//# sourceMappingURL=ensureResolveMapEntry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureResolveMapEntry.js","sourceRoot":"","sources":["../src/ensureResolveMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ensureResolveMapEntry.js","sourceRoot":"","sources":["../src/ensureResolveMapEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAMC,EACD,OAEC;IAED,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,OAA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AC,cAAc,CAAC,GAAG,eAAe,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,KAAK,EAAE,CAAC;QACjD,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC;IACvE,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { findProjectRoot } from './findProjectRoot.js';\nimport { findResolveMapEntry } from './findResolveMapEntry.js';\nimport type { ResolveMap } from './types/ResolveMap.js';\nimport type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/common-types';\nimport { findPackage } from './findPackage.js';\nimport { isExternalPackage } from './isExternalPackage.js';\n\n/**\n * Ensure that a package is in the resolve map and return the path to the package.\n */\nexport async function ensureResolveMapEntry(\n params: {\n definition: PackageJson;\n packagePath: string;\n dependencyName: string;\n resolveMap: ResolveMap;\n appPath: string;\n },\n context: {\n packages: PackageDefinitionsCache;\n },\n): Promise<string | undefined> {\n const { dependencyName, resolveMap, packagePath, appPath, definition } = params;\n const { packages } = context;\n if (!definition.name || !definition.version) {\n throw new Error(`Package definition at \"${packagePath}\" is missing a name or version.`);\n }\n\n const parentEntry = findResolveMapEntry({ packageName: definition.name, version: definition.version, resolveMap });\n\n // If we can't find the parent entry, we can't add the dependency.\n if (!parentEntry) {\n return undefined;\n }\n\n const resolveEntry = findResolveMapEntry({ definition, packageName: dependencyName, resolveMap });\n let dependencyPath = resolveEntry?.path;\n let dependencyDefinition = dependencyPath ? await packages.get(dependencyPath) : undefined;\n\n // If the dependency is already in the resolve map and required by the parent, return the path.\n if (dependencyPath && dependencyDefinition && resolveEntry?.requiredBy[`${definition.name}@${definition.version}`]) {\n return dependencyPath;\n }\n\n const rootPath = findProjectRoot(appPath, { noPackageRoot: true });\n\n const dependencyPackage = await findPackage(\n {\n dependencyName,\n startPath: packagePath,\n rootPath,\n },\n context,\n );\n\n dependencyPath = dependencyPackage?.packagePath;\n dependencyDefinition = dependencyPackage?.definition;\n const version = dependencyDefinition?.version;\n\n // If we can't find the dependency, we can't add it to the resolve map.\n if (!dependencyPath || !dependencyDefinition || !version) {\n return undefined;\n }\n\n // Check if the dependency is already in the resolve map.\n let dependencyEntry = [resolveMap[dependencyName], ...Object.values(resolveMap[dependencyName]?.scopedVersions || {})]\n .filter(Boolean)\n .find((e) => e.version === version && e.path === dependencyPath);\n\n // If it already exists, add the requiredBy entry and return the path.\n if (dependencyEntry) {\n parentEntry.dependencies[dependencyName] = version;\n dependencyEntry.requiredBy[`${definition.name}@${definition.version}`] = version;\n return dependencyPath;\n }\n\n // If it is missing from the resolve map, add it.\n dependencyEntry = {\n name: dependencyName,\n version,\n path: dependencyPath,\n dependencies: {},\n requiredBy: {\n [`${definition.name}@${definition.version}`]: version,\n },\n };\n\n if (isExternalPackage(dependencyPath)) {\n dependencyEntry.isExternal = true;\n }\n\n parentEntry.dependencies[dependencyName] = version;\n\n // Add the dependency to the resolve map.\n if (!resolveMap[dependencyName]) {\n resolveMap[dependencyName] = dependencyEntry;\n } else {\n resolveMap[dependencyName].scopedVersions ??= {};\n resolveMap[dependencyName].scopedVersions[version] = dependencyEntry;\n }\n\n return dependencyPath;\n}\n"]}
|
package/lib/findProjectRoot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// eslint-disable-next-line no-restricted-imports -- this is the definition of the wrapper
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- this is the definition of the wrapper
|
|
2
2
|
import { findProjectRoot as wsToolsFindProjectRoot, findPackageRoot } from 'workspace-tools';
|
|
3
3
|
/**
|
|
4
4
|
* Find the project root:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findProjectRoot.js","sourceRoot":"","sources":["../src/findProjectRoot.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"findProjectRoot.js","sourceRoot":"","sources":["../src/findProjectRoot.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,GAAW,EACX,UAGI,EAAE;IAEN,IAAI,CAAC;QACH,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;AACH,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- this is the definition of the wrapper\nimport { findProjectRoot as wsToolsFindProjectRoot, findPackageRoot } from 'workspace-tools';\n\n/**\n * Find the project root:\n * - Current workspace root (for multi-workspace monorepo)\n * - Git root\n * - Package root (unless `options.noPackageRoot` is true)\n * - undefined if not found\n */\nexport function findProjectRoot(\n cwd: string,\n options: {\n /** Skip the package root fallback */\n noPackageRoot?: boolean;\n } = {},\n): string | undefined {\n try {\n return wsToolsFindProjectRoot(cwd);\n } catch {\n return options.noPackageRoot ? undefined : findPackageRoot(cwd);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-utilities",
|
|
3
|
-
"version": "7.8.
|
|
3
|
+
"version": "7.8.7",
|
|
4
4
|
"description": "Utilities for resolving/parsing packages and their imports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.13.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.13.1",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
19
|
-
"@ms-cloudpack/package-overrides": "^0.9.
|
|
19
|
+
"@ms-cloudpack/package-overrides": "^0.9.12",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.2.3",
|
|
21
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
22
|
-
"@ms-cloudpack/task-reporter": "^0.14.
|
|
21
|
+
"@ms-cloudpack/path-utilities": "^2.7.27",
|
|
22
|
+
"@ms-cloudpack/task-reporter": "^0.14.3",
|
|
23
23
|
"acorn": "^8.11.2",
|
|
24
24
|
"acorn-walk": "^8.2.1",
|
|
25
25
|
"fast-glob": "^3.2.12",
|