@pnpm/resolving.resolver-base 1100.0.1 → 1100.1.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/index.d.ts +29 -1
- package/lib/index.js +39 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DependencyManifest, PackageVersionPolicy, PinnedVersion, PkgResolutionId, ProjectRootDir, TrustPolicy } from '@pnpm/types';
|
|
1
|
+
import type { DependencyManifest, PackageVersionPolicy, PinnedVersion, PkgResolutionId, ProjectRootDir, SupportedArchitectures, TrustPolicy } from '@pnpm/types';
|
|
2
2
|
export { type PkgResolutionId };
|
|
3
3
|
/**
|
|
4
4
|
* tarball hosted remotely
|
|
@@ -49,6 +49,34 @@ export interface VariationsResolution {
|
|
|
49
49
|
variants: PlatformAssetResolution[];
|
|
50
50
|
}
|
|
51
51
|
export type Resolution = AtomicResolution | VariationsResolution;
|
|
52
|
+
/** Concrete platform selector used when picking a variant from a VariationsResolution. */
|
|
53
|
+
export interface PlatformSelector {
|
|
54
|
+
os: string;
|
|
55
|
+
cpu: string;
|
|
56
|
+
/** Name of the libc family requested. Omit (or leave `null`) for the default (glibc on Linux, n/a elsewhere). */
|
|
57
|
+
libc?: string | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve a {@link PlatformSelector} from the user's supportedArchitectures config
|
|
61
|
+
* and the host's own platform/arch/libc. When `supportedArchitectures.xxx` is set
|
|
62
|
+
* and its first entry is not `"current"`, that entry wins; otherwise the host's
|
|
63
|
+
* value is used. Additional entries beyond the first are ignored — variant
|
|
64
|
+
* selection picks exactly one (os, cpu, libc) triplet per install.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolvePlatformSelector(supportedArchitectures: SupportedArchitectures | undefined, host: {
|
|
67
|
+
platform: string;
|
|
68
|
+
arch: string;
|
|
69
|
+
libc: string | null | undefined;
|
|
70
|
+
}): PlatformSelector;
|
|
71
|
+
/**
|
|
72
|
+
* Pick the variant whose target matches the given selector, or `undefined` if
|
|
73
|
+
* none does. A variant with no `libc` represents the "default" build — glibc on
|
|
74
|
+
* Linux, irrelevant on macOS/Windows. A non-default libc (e.g. `musl`) is a
|
|
75
|
+
* separate, non-interchangeable artifact; an exact libc match is required in
|
|
76
|
+
* that case so the glibc/default variant doesn't silently win (its `target.libc`
|
|
77
|
+
* is nullish).
|
|
78
|
+
*/
|
|
79
|
+
export declare function selectPlatformVariant(variants: PlatformAssetResolution[], selector: PlatformSelector): PlatformAssetResolution | undefined;
|
|
52
80
|
export interface ResolveResult {
|
|
53
81
|
id: PkgResolutionId;
|
|
54
82
|
latest?: string;
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a {@link PlatformSelector} from the user's supportedArchitectures config
|
|
4
|
+
* and the host's own platform/arch/libc. When `supportedArchitectures.xxx` is set
|
|
5
|
+
* and its first entry is not `"current"`, that entry wins; otherwise the host's
|
|
6
|
+
* value is used. Additional entries beyond the first are ignored — variant
|
|
7
|
+
* selection picks exactly one (os, cpu, libc) triplet per install.
|
|
8
|
+
*/
|
|
9
|
+
export function resolvePlatformSelector(supportedArchitectures, host) {
|
|
10
|
+
return {
|
|
11
|
+
os: pickFirstNonCurrent(supportedArchitectures?.os) ?? host.platform,
|
|
12
|
+
cpu: pickFirstNonCurrent(supportedArchitectures?.cpu) ?? host.arch,
|
|
13
|
+
libc: pickFirstNonCurrent(supportedArchitectures?.libc) ?? host.libc,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pick the variant whose target matches the given selector, or `undefined` if
|
|
18
|
+
* none does. A variant with no `libc` represents the "default" build — glibc on
|
|
19
|
+
* Linux, irrelevant on macOS/Windows. A non-default libc (e.g. `musl`) is a
|
|
20
|
+
* separate, non-interchangeable artifact; an exact libc match is required in
|
|
21
|
+
* that case so the glibc/default variant doesn't silently win (its `target.libc`
|
|
22
|
+
* is nullish).
|
|
23
|
+
*/
|
|
24
|
+
export function selectPlatformVariant(variants, selector) {
|
|
25
|
+
return variants.find((variant) => variant.targets.some((target) => target.os === selector.os &&
|
|
26
|
+
target.cpu === selector.cpu &&
|
|
27
|
+
libcMatches(target.libc, selector.libc)));
|
|
28
|
+
}
|
|
29
|
+
function libcMatches(variantLibc, requestedLibc) {
|
|
30
|
+
if (requestedLibc == null || requestedLibc === 'glibc') {
|
|
31
|
+
return variantLibc == null;
|
|
32
|
+
}
|
|
33
|
+
return variantLibc === requestedLibc;
|
|
34
|
+
}
|
|
35
|
+
function pickFirstNonCurrent(requirements) {
|
|
36
|
+
if (requirements?.length && requirements[0] !== 'current') {
|
|
37
|
+
return requirements[0];
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
2
41
|
// This weight is set for selectors that are used on direct dependencies.
|
|
3
42
|
// It is important to give a bigger weight to direct dependencies.
|
|
4
43
|
export const DIRECT_DEP_SELECTOR_WEIGHT = 1000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/resolving.resolver-base",
|
|
3
|
-
"version": "1100.0
|
|
3
|
+
"version": "1100.1.0",
|
|
4
4
|
"description": "Types for pnpm-compatible resolvers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@pnpm/types": "1101.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@pnpm/resolving.resolver-base": "1100.0
|
|
31
|
+
"@pnpm/resolving.resolver-base": "1100.1.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=22.13"
|