@pnpm/resolving.resolver-base 1100.4.2 → 1100.5.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 +12 -0
- package/lib/index.js +86 -0
- package/package.json +8 -6
package/lib/index.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ export interface VariationsResolution {
|
|
|
57
57
|
variants: PlatformAssetResolution[];
|
|
58
58
|
}
|
|
59
59
|
export type Resolution = AtomicResolution | VariationsResolution;
|
|
60
|
+
/**
|
|
61
|
+
* A tarball URL is git-hosted when it points at a known git provider's immutable
|
|
62
|
+
* archive endpoint. The result gates integrity exemptions, so the match is
|
|
63
|
+
* limited to provider-specific path shapes whose ref is a full commit SHA.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isGitHostedTarballUrl(url: string): boolean;
|
|
66
|
+
export type ResolutionKind = 'localTarball' | 'gitHostedTarball' | 'remoteTarball' | 'directory' | 'git' | 'binary' | 'custom';
|
|
67
|
+
/**
|
|
68
|
+
* Classifies a resolution for fetcher selection. Lockfile-provided flags are
|
|
69
|
+
* treated as hints; integrity exemptions depend on the resolved source shape.
|
|
70
|
+
*/
|
|
71
|
+
export declare function classifyResolution(resolution: Resolution): ResolutionKind;
|
|
60
72
|
/**
|
|
61
73
|
* Outcome of asking a `ResolutionVerifier` whether a (name, version,
|
|
62
74
|
* resolution) entry from a lockfile is acceptable under whatever policies
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,90 @@
|
|
|
1
1
|
export {};
|
|
2
|
+
const GIT_COMMIT_SHA = /^[0-9a-f]{40}$/i;
|
|
3
|
+
/**
|
|
4
|
+
* A tarball URL is git-hosted when it points at a known git provider's immutable
|
|
5
|
+
* archive endpoint. The result gates integrity exemptions, so the match is
|
|
6
|
+
* limited to provider-specific path shapes whose ref is a full commit SHA.
|
|
7
|
+
*/
|
|
8
|
+
export function isGitHostedTarballUrl(url) {
|
|
9
|
+
if (typeof url !== 'string')
|
|
10
|
+
return false;
|
|
11
|
+
let parsedUrl;
|
|
12
|
+
try {
|
|
13
|
+
parsedUrl = new URL(url);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (parsedUrl.protocol !== 'https:')
|
|
19
|
+
return false;
|
|
20
|
+
switch (parsedUrl.hostname.toLowerCase()) {
|
|
21
|
+
case 'codeload.github.com':
|
|
22
|
+
return isGitHubCodeloadArchive(parsedUrl);
|
|
23
|
+
case 'bitbucket.org':
|
|
24
|
+
return isBitbucketArchive(parsedUrl);
|
|
25
|
+
case 'gitlab.com':
|
|
26
|
+
return isGitLabArchive(parsedUrl);
|
|
27
|
+
default:
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function isGitHubCodeloadArchive(url) {
|
|
32
|
+
const segments = getPathSegments(url);
|
|
33
|
+
return segments.length === 4 && segments[2] === 'tar.gz' && GIT_COMMIT_SHA.test(segments[3]);
|
|
34
|
+
}
|
|
35
|
+
function isBitbucketArchive(url) {
|
|
36
|
+
const segments = getPathSegments(url);
|
|
37
|
+
if (segments.length !== 4 || segments[2] !== 'get' || !segments[3].endsWith('.tar.gz'))
|
|
38
|
+
return false;
|
|
39
|
+
return GIT_COMMIT_SHA.test(segments[3].slice(0, -'.tar.gz'.length));
|
|
40
|
+
}
|
|
41
|
+
function isGitLabArchive(url) {
|
|
42
|
+
const segments = getPathSegments(url);
|
|
43
|
+
if (segments.length === 6 &&
|
|
44
|
+
segments[0] === 'api' &&
|
|
45
|
+
segments[1] === 'v4' &&
|
|
46
|
+
segments[2] === 'projects' &&
|
|
47
|
+
segments[4] === 'repository' &&
|
|
48
|
+
segments[5] === 'archive.tar.gz') {
|
|
49
|
+
return GIT_COMMIT_SHA.test(url.searchParams.get('ref') ?? '');
|
|
50
|
+
}
|
|
51
|
+
const archiveMarkerIndex = segments.findIndex((segment, index) => segment === '-' && segments[index + 1] === 'archive');
|
|
52
|
+
if (archiveMarkerIndex < 2)
|
|
53
|
+
return false;
|
|
54
|
+
const ref = segments[archiveMarkerIndex + 2];
|
|
55
|
+
const archiveName = segments[archiveMarkerIndex + 3];
|
|
56
|
+
return segments.length === archiveMarkerIndex + 4 &&
|
|
57
|
+
archiveName?.endsWith('.tar.gz') === true &&
|
|
58
|
+
GIT_COMMIT_SHA.test(ref);
|
|
59
|
+
}
|
|
60
|
+
function getPathSegments(url) {
|
|
61
|
+
return url.pathname.split('/').filter(Boolean);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Classifies a resolution for fetcher selection. Lockfile-provided flags are
|
|
65
|
+
* treated as hints; integrity exemptions depend on the resolved source shape.
|
|
66
|
+
*/
|
|
67
|
+
export function classifyResolution(resolution) {
|
|
68
|
+
if (resolution.type == null) {
|
|
69
|
+
const tarball = typeof resolution.tarball === 'string'
|
|
70
|
+
? resolution.tarball
|
|
71
|
+
: undefined;
|
|
72
|
+
if (tarball?.startsWith('file:'))
|
|
73
|
+
return 'localTarball';
|
|
74
|
+
if (tarball != null && isGitHostedTarballUrl(tarball)) {
|
|
75
|
+
return 'gitHostedTarball';
|
|
76
|
+
}
|
|
77
|
+
return 'remoteTarball';
|
|
78
|
+
}
|
|
79
|
+
switch (resolution.type) {
|
|
80
|
+
case 'directory':
|
|
81
|
+
case 'git':
|
|
82
|
+
case 'binary':
|
|
83
|
+
return resolution.type;
|
|
84
|
+
default:
|
|
85
|
+
return 'custom';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
2
88
|
/**
|
|
3
89
|
* Resolve a {@link PlatformSelector} from the user's supportedArchitectures config
|
|
4
90
|
* and the host's own platform/arch/libc. When `supportedArchitectures.xxx` is set
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/resolving.resolver-base",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.5.0",
|
|
4
4
|
"description": "Types for pnpm-compatible resolvers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"funding": "https://opencollective.com/pnpm",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/pnpm/pnpm/tree/main/resolving/resolver-base"
|
|
14
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/resolving/resolver-base"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://github.com/pnpm/pnpm/tree/main/resolving/resolver-base#readme",
|
|
16
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/resolving/resolver-base#readme",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
19
19
|
},
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"@pnpm/types": "1101.3.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@
|
|
34
|
+
"@jest/globals": "30.4.1",
|
|
35
|
+
"@pnpm/resolving.resolver-base": "1100.5.0"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=22.13"
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"start": "tsgo --watch",
|
|
44
|
-
"lint": "eslint \"src/**/*.ts\"",
|
|
45
|
-
"test": "pn compile",
|
|
45
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
46
|
+
"test": "pn compile && pn .test",
|
|
47
|
+
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
|
|
46
48
|
"compile": "tsgo --build && pn lint --fix"
|
|
47
49
|
}
|
|
48
50
|
}
|