@pnpm/lockfile.utils 1100.0.3 → 1100.0.5
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,13 +1,23 @@
|
|
|
1
1
|
import url from 'node:url';
|
|
2
|
-
import
|
|
2
|
+
import * as dp from '@pnpm/deps.path';
|
|
3
3
|
import getNpmTarballUrl from 'get-npm-tarball-url';
|
|
4
4
|
import { nameVerFromPkgSnapshot } from './nameVerFromPkgSnapshot.js';
|
|
5
5
|
export function pkgSnapshotToResolution(depPath, pkgSnapshot, registries) {
|
|
6
6
|
if (Boolean(pkgSnapshot.resolution.type) ||
|
|
7
7
|
pkgSnapshot.resolution.tarball?.startsWith('file:') ||
|
|
8
|
-
|
|
8
|
+
pkgSnapshot.resolution.gitHosted === true) {
|
|
9
9
|
return pkgSnapshot.resolution;
|
|
10
10
|
}
|
|
11
|
+
// Recover the tarball field for `file:` snapshots whose resolution lost
|
|
12
|
+
// its tarball (e.g. lockfiles written by an earlier pnpm 11 version that
|
|
13
|
+
// dropped the tarball under `lockfile-include-tarball-url=false`).
|
|
14
|
+
const nonSemverVersion = dp.parse(depPath).nonSemverVersion;
|
|
15
|
+
if (nonSemverVersion?.startsWith('file:')) {
|
|
16
|
+
return {
|
|
17
|
+
...pkgSnapshot.resolution,
|
|
18
|
+
tarball: nonSemverVersion,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
11
21
|
const { name, version } = nameVerFromPkgSnapshot(depPath, pkgSnapshot);
|
|
12
22
|
let registry = '';
|
|
13
23
|
if (name != null) {
|
|
@@ -3,11 +3,27 @@ export function toLockfileResolution(pkg, resolution, registry, lockfileIncludeT
|
|
|
3
3
|
if (resolution.type !== undefined || !resolution['integrity']) {
|
|
4
4
|
return resolution;
|
|
5
5
|
}
|
|
6
|
+
const tarball = resolution['tarball'];
|
|
7
|
+
// Honor the resolver-supplied flag, with a URL fallback for resolutions
|
|
8
|
+
// that didn't go through the git resolver (e.g. config-dep migrations or
|
|
9
|
+
// legacy lockfiles read by callers that don't enrich the field).
|
|
10
|
+
const gitHosted = resolution.gitHosted === true ||
|
|
11
|
+
(tarball != null && isGitHostedTarballUrl(tarball));
|
|
6
12
|
if (lockfileIncludeTarballUrl) {
|
|
7
|
-
return {
|
|
13
|
+
return preservingGitHosted({
|
|
8
14
|
integrity: resolution['integrity'],
|
|
9
|
-
tarball
|
|
10
|
-
};
|
|
15
|
+
tarball,
|
|
16
|
+
}, gitHosted);
|
|
17
|
+
}
|
|
18
|
+
// Tarball URLs that cannot be reconstructed from the package name, version,
|
|
19
|
+
// and registry must always stay in the lockfile, otherwise the package can
|
|
20
|
+
// no longer be re-fetched. This covers local `file:` tarballs and tarballs
|
|
21
|
+
// served by git providers (GitHub, GitLab, Bitbucket).
|
|
22
|
+
if (tarball != null && (tarball.startsWith('file:') || gitHosted)) {
|
|
23
|
+
return preservingGitHosted({
|
|
24
|
+
integrity: resolution['integrity'],
|
|
25
|
+
tarball,
|
|
26
|
+
}, gitHosted);
|
|
11
27
|
}
|
|
12
28
|
if (lockfileIncludeTarballUrl === false) {
|
|
13
29
|
return {
|
|
@@ -18,17 +34,28 @@ export function toLockfileResolution(pkg, resolution, registry, lockfileIncludeT
|
|
|
18
34
|
// For instance, when they are hosted on npm Enterprise. See https://github.com/pnpm/pnpm/issues/867
|
|
19
35
|
// Or in other weird cases, like https://github.com/pnpm/pnpm/issues/1072
|
|
20
36
|
const expectedTarball = getNpmTarballUrl(pkg.name, pkg.version, { registry });
|
|
21
|
-
const actualTarball =
|
|
37
|
+
const actualTarball = tarball.replaceAll('%2f', '/');
|
|
22
38
|
if (removeProtocol(expectedTarball) !== removeProtocol(actualTarball)) {
|
|
23
|
-
return {
|
|
39
|
+
return preservingGitHosted({
|
|
24
40
|
integrity: resolution['integrity'],
|
|
25
|
-
tarball
|
|
26
|
-
};
|
|
41
|
+
tarball,
|
|
42
|
+
}, gitHosted);
|
|
27
43
|
}
|
|
28
44
|
return {
|
|
29
45
|
integrity: resolution['integrity'],
|
|
30
46
|
};
|
|
31
47
|
}
|
|
48
|
+
function preservingGitHosted(resolution, gitHosted) {
|
|
49
|
+
return gitHosted ? { ...resolution, gitHosted: true } : resolution;
|
|
50
|
+
}
|
|
51
|
+
// Inlined to avoid pulling @pnpm/fetching.pick-fetcher into the lockfile-utils
|
|
52
|
+
// dep graph. Used as a fallback when callers haven't pre-set the
|
|
53
|
+
// `gitHosted` field on TarballResolution.
|
|
54
|
+
function isGitHostedTarballUrl(url) {
|
|
55
|
+
return (url.startsWith('https://codeload.github.com/') ||
|
|
56
|
+
url.startsWith('https://bitbucket.org/') ||
|
|
57
|
+
url.startsWith('https://gitlab.com/')) && url.includes('tar.gz');
|
|
58
|
+
}
|
|
32
59
|
function removeProtocol(url) {
|
|
33
60
|
return url.split('://')[1];
|
|
34
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.utils",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.5",
|
|
4
4
|
"description": "Utils for dealing with pnpm-lock.yaml",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"get-npm-tarball-url": "^2.1.0",
|
|
30
30
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
31
|
-
"@pnpm/deps.path": "1100.0.1",
|
|
32
31
|
"@pnpm/error": "1100.0.0",
|
|
33
|
-
"@pnpm/hooks.types": "1100.0.
|
|
34
|
-
"@pnpm/lockfile.types": "1100.0.
|
|
35
|
-
"@pnpm/
|
|
36
|
-
"@pnpm/
|
|
37
|
-
"@pnpm/
|
|
32
|
+
"@pnpm/hooks.types": "1100.0.5",
|
|
33
|
+
"@pnpm/lockfile.types": "1100.0.4",
|
|
34
|
+
"@pnpm/deps.path": "1100.0.2",
|
|
35
|
+
"@pnpm/resolving.resolver-base": "1100.1.2",
|
|
36
|
+
"@pnpm/types": "1101.0.0"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
39
|
+
"@jest/globals": "30.3.0",
|
|
40
40
|
"@types/ramda": "0.31.1",
|
|
41
41
|
"tempy": "3.0.0",
|
|
42
42
|
"write-yaml-file": "^6.0.0",
|
|
43
43
|
"yaml-tag": "1.1.0",
|
|
44
|
-
"@pnpm/lockfile.utils": "1100.0.
|
|
44
|
+
"@pnpm/lockfile.utils": "1100.0.5"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22.13"
|