@pnpm/building.policy 1100.0.10 → 1100.0.12
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.js +27 -0
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -11,17 +11,21 @@ export function createAllowBuildFunction(opts) {
|
|
|
11
11
|
const disallowedPackageBuilds = new Set();
|
|
12
12
|
const allowedDepPathBuilds = new Set();
|
|
13
13
|
const disallowedDepPathBuilds = new Set();
|
|
14
|
+
const allowedGitRepoBuilds = new Set();
|
|
15
|
+
const disallowedGitRepoBuilds = new Set();
|
|
14
16
|
for (const [pkg, value] of Object.entries(opts.allowBuilds)) {
|
|
15
17
|
switch (value) {
|
|
16
18
|
case true:
|
|
17
19
|
addAllowBuildRule(pkg, {
|
|
18
20
|
depPaths: allowedDepPathBuilds,
|
|
21
|
+
gitRepos: allowedGitRepoBuilds,
|
|
19
22
|
packageSpecs: allowedPackageBuilds,
|
|
20
23
|
});
|
|
21
24
|
break;
|
|
22
25
|
case false:
|
|
23
26
|
addAllowBuildRule(pkg, {
|
|
24
27
|
depPaths: disallowedDepPathBuilds,
|
|
28
|
+
gitRepos: disallowedGitRepoBuilds,
|
|
25
29
|
packageSpecs: disallowedPackageBuilds,
|
|
26
30
|
});
|
|
27
31
|
break;
|
|
@@ -34,6 +38,10 @@ export function createAllowBuildFunction(opts) {
|
|
|
34
38
|
if (disallowedDepPathBuilds.has(pkgIdWithPatchHash)) {
|
|
35
39
|
return false;
|
|
36
40
|
}
|
|
41
|
+
const gitRepoKey = getGitRepoAllowBuildKeyFromDepPath(pkgIdWithPatchHash);
|
|
42
|
+
if (gitRepoKey != null && disallowedGitRepoBuilds.has(gitRepoKey)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
37
45
|
const { name, version, nonSemverVersion } = dp.parse(depPath);
|
|
38
46
|
const nameAtVersion = name != null && version != null ? `${name}@${version}` : undefined;
|
|
39
47
|
if ((name != null && expandedDisallowed.has(name)) ||
|
|
@@ -43,6 +51,9 @@ export function createAllowBuildFunction(opts) {
|
|
|
43
51
|
if (allowedDepPathBuilds.has(pkgIdWithPatchHash)) {
|
|
44
52
|
return true;
|
|
45
53
|
}
|
|
54
|
+
if (gitRepoKey != null && allowedGitRepoBuilds.has(gitRepoKey)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
46
57
|
// Package-name rules require a trusted package identity. A
|
|
47
58
|
// registry-style depPath (name@semver) is the trust signal: the
|
|
48
59
|
// lockfile verification gate rejects lockfiles where such a key is
|
|
@@ -77,6 +88,10 @@ export function allowBuildKeyFromIgnoredBuild(depPath) {
|
|
|
77
88
|
return parsed.name;
|
|
78
89
|
}
|
|
79
90
|
function addAllowBuildRule(pkg, target) {
|
|
91
|
+
if (isGitRepoAllowBuildKey(pkg)) {
|
|
92
|
+
target.gitRepos.add(pkg);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
80
95
|
if (isDepPathAllowBuildKey(pkg)) {
|
|
81
96
|
target.depPaths.add(dp.removePeersSuffix(pkg));
|
|
82
97
|
}
|
|
@@ -84,6 +99,18 @@ function addAllowBuildRule(pkg, target) {
|
|
|
84
99
|
target.packageSpecs.add(pkg);
|
|
85
100
|
}
|
|
86
101
|
}
|
|
102
|
+
function isGitRepoAllowBuildKey(pkg) {
|
|
103
|
+
return !pkg.includes('#') && isGitRepoDepPath(pkg);
|
|
104
|
+
}
|
|
105
|
+
function getGitRepoAllowBuildKeyFromDepPath(depPath) {
|
|
106
|
+
if (!isGitRepoDepPath(depPath))
|
|
107
|
+
return undefined;
|
|
108
|
+
const refStart = depPath.indexOf('#');
|
|
109
|
+
return refStart === -1 ? depPath : depPath.slice(0, refStart);
|
|
110
|
+
}
|
|
111
|
+
function isGitRepoDepPath(depPath) {
|
|
112
|
+
return depPath.startsWith('git+') || depPath.includes('@git+');
|
|
113
|
+
}
|
|
87
114
|
function isDepPathAllowBuildKey(pkg) {
|
|
88
115
|
if (dp.removePeersSuffix(pkg) !== pkg)
|
|
89
116
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/building.policy",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.12",
|
|
4
4
|
"description": "Create a function for filtering out dependencies that are not allowed to be built",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"funding": "https://opencollective.com/pnpm",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/pnpm/pnpm/tree/main/building/policy"
|
|
13
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/building/policy"
|
|
14
14
|
},
|
|
15
|
-
"homepage": "https://github.com/pnpm/pnpm/tree/main/building/policy#readme",
|
|
15
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/building/policy#readme",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
18
18
|
},
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"!*.map"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pnpm/config.version-policy": "1100.1.
|
|
31
|
-
"@pnpm/
|
|
32
|
-
"@pnpm/
|
|
30
|
+
"@pnpm/config.version-policy": "1100.1.6",
|
|
31
|
+
"@pnpm/deps.path": "1100.0.8",
|
|
32
|
+
"@pnpm/types": "1101.3.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jest/globals": "30.4.1",
|
|
36
|
-
"@pnpm/building.policy": "1100.0.
|
|
36
|
+
"@pnpm/building.policy": "1100.0.12"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22.13"
|