@pnpm/hooks.read-package-hook 1100.0.6 → 1100.0.8
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/createReadPackageHook.d.ts +5 -1
- package/lib/createReadPackageHook.js +49 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +9 -9
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { PackageExtension, ReadPackageHook } from '@pnpm/types';
|
|
2
2
|
import { type VersionOverrideWithoutRawSelector } from './createVersionsOverrider.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getEffectivePackageExtensions({ ignoreCompatibilityDb, packageExtensions, }: {
|
|
4
|
+
ignoreCompatibilityDb?: boolean;
|
|
5
|
+
packageExtensions?: Record<string, PackageExtension>;
|
|
6
|
+
}): Record<string, PackageExtension> | undefined;
|
|
7
|
+
export declare function createReadPackageHook({ ignoreCompatibilityDb, lockfileDir, overrides, ignoredOptionalDependencies, packageExtensions, readPackageHook, }: {
|
|
4
8
|
ignoreCompatibilityDb?: boolean;
|
|
5
9
|
lockfileDir: string;
|
|
6
10
|
overrides?: VersionOverrideWithoutRawSelector[];
|
|
@@ -3,13 +3,30 @@ import { isEmpty, pipeWith } from 'ramda';
|
|
|
3
3
|
import { createOptionalDependenciesRemover } from './createOptionalDependenciesRemover.js';
|
|
4
4
|
import { createPackageExtender } from './createPackageExtender.js';
|
|
5
5
|
import { createVersionsOverrider } from './createVersionsOverrider.js';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const PACKAGE_EXTENSION_FIELDS = [
|
|
7
|
+
'dependencies',
|
|
8
|
+
'optionalDependencies',
|
|
9
|
+
'peerDependencies',
|
|
10
|
+
'peerDependenciesMeta',
|
|
11
|
+
];
|
|
12
|
+
export function getEffectivePackageExtensions({ ignoreCompatibilityDb, packageExtensions, }) {
|
|
13
|
+
const effectivePackageExtensions = {};
|
|
8
14
|
if (!ignoreCompatibilityDb) {
|
|
9
|
-
|
|
15
|
+
mergePackageExtensions(effectivePackageExtensions, compatPackageExtensions);
|
|
10
16
|
}
|
|
11
17
|
if (!isEmpty(packageExtensions ?? {})) {
|
|
12
|
-
|
|
18
|
+
mergePackageExtensions(effectivePackageExtensions, Object.entries(packageExtensions));
|
|
19
|
+
}
|
|
20
|
+
return isEmpty(effectivePackageExtensions) ? undefined : effectivePackageExtensions;
|
|
21
|
+
}
|
|
22
|
+
export function createReadPackageHook({ ignoreCompatibilityDb, lockfileDir, overrides, ignoredOptionalDependencies, packageExtensions, readPackageHook, }) {
|
|
23
|
+
const hooks = [];
|
|
24
|
+
const effectivePackageExtensions = getEffectivePackageExtensions({
|
|
25
|
+
ignoreCompatibilityDb,
|
|
26
|
+
packageExtensions,
|
|
27
|
+
});
|
|
28
|
+
if (effectivePackageExtensions != null) {
|
|
29
|
+
hooks.push(createPackageExtender(effectivePackageExtensions));
|
|
13
30
|
}
|
|
14
31
|
if (Array.isArray(readPackageHook)) {
|
|
15
32
|
hooks.push(...readPackageHook);
|
|
@@ -31,4 +48,32 @@ export function createReadPackageHook({ ignoreCompatibilityDb, lockfileDir, over
|
|
|
31
48
|
: ((pkg, dir) => pipeWith(async (f, res) => f(await res, dir), hooks)(pkg, dir)); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
32
49
|
return readPackageAndExtend;
|
|
33
50
|
}
|
|
51
|
+
function mergePackageExtensions(target, entries) {
|
|
52
|
+
for (const [selector, packageExtension] of entries) {
|
|
53
|
+
target[selector] = mergePackageExtension(target[selector], packageExtension);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function mergePackageExtension(previous, next) {
|
|
57
|
+
if (previous == null)
|
|
58
|
+
return clonePackageExtension(next);
|
|
59
|
+
const merged = clonePackageExtension(previous);
|
|
60
|
+
for (const field of PACKAGE_EXTENSION_FIELDS) {
|
|
61
|
+
if (next[field] == null)
|
|
62
|
+
continue;
|
|
63
|
+
merged[field] = {
|
|
64
|
+
...next[field],
|
|
65
|
+
...merged[field],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return merged;
|
|
69
|
+
}
|
|
70
|
+
function clonePackageExtension(packageExtension) {
|
|
71
|
+
const cloned = {};
|
|
72
|
+
for (const field of PACKAGE_EXTENSION_FIELDS) {
|
|
73
|
+
if (packageExtension[field] == null)
|
|
74
|
+
continue;
|
|
75
|
+
cloned[field] = { ...packageExtension[field] };
|
|
76
|
+
}
|
|
77
|
+
return cloned;
|
|
78
|
+
}
|
|
34
79
|
//# sourceMappingURL=createReadPackageHook.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createReadPackageHook } from './createReadPackageHook.js';
|
|
1
|
+
export { createReadPackageHook, getEffectivePackageExtensions } from './createReadPackageHook.js';
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createReadPackageHook } from './createReadPackageHook.js';
|
|
1
|
+
export { createReadPackageHook, getEffectivePackageExtensions } from './createReadPackageHook.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/hooks.read-package-hook",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.8",
|
|
4
4
|
"description": "Creates the default package reader hook used by pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
"@yarnpkg/extensions": "2.0.6",
|
|
31
31
|
"normalize-path": "^3.0.0",
|
|
32
32
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
33
|
-
"semver": "^7.8.
|
|
34
|
-
"@pnpm/deps.peer-range": "1100.0.1",
|
|
35
|
-
"@pnpm/config.matcher": "1100.0.1",
|
|
36
|
-
"@pnpm/types": "1101.3.0",
|
|
33
|
+
"semver": "^7.8.4",
|
|
37
34
|
"@pnpm/config.parse-overrides": "1100.0.1",
|
|
38
35
|
"@pnpm/error": "1100.0.0",
|
|
39
|
-
"@pnpm/
|
|
36
|
+
"@pnpm/deps.peer-range": "1100.0.2",
|
|
37
|
+
"@pnpm/resolving.parse-wanted-dependency": "1100.0.1",
|
|
38
|
+
"@pnpm/types": "1101.3.2",
|
|
39
|
+
"@pnpm/config.matcher": "1100.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@jest/globals": "30.
|
|
42
|
+
"@jest/globals": "30.4.1",
|
|
43
43
|
"@types/normalize-path": "^3.0.2",
|
|
44
44
|
"@types/ramda": "0.31.1",
|
|
45
45
|
"@types/semver": "7.7.1",
|
|
46
|
-
"@yarnpkg/core": "4.
|
|
47
|
-
"@pnpm/hooks.read-package-hook": "1100.0.
|
|
46
|
+
"@yarnpkg/core": "4.8.0",
|
|
47
|
+
"@pnpm/hooks.read-package-hook": "1100.0.8"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=22.13"
|