@pnpm/building.policy 1100.0.16 → 1100.0.17
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/CHANGELOG.md +18 -0
- package/lib/index.js +47 -4
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pnpm/building.policy
|
|
2
2
|
|
|
3
|
+
## 1100.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `allowBuilds` entries can now approve git-hosted packages that pnpm downloads as a tarball, such as `github:` dependencies (which are fetched from `codeload.github.com` rather than cloned), by their repository URL without the resolved commit hash. This matches the hashless `git+` matching already supported for cloned git dependencies. For example:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
allowBuilds:
|
|
11
|
+
"foo@git+https://github.com/org/foo.git": true
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This approves the package whether pnpm clones it or downloads a tarball, so the entry no longer has to be updated every time the pinned commit changes. GitLab and Bitbucket tarball downloads are matched the same way. Approving or denying a specific resolved commit by its full tarball dep path continues to work.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- @pnpm/config.version-policy@1100.1.11
|
|
18
|
+
- @pnpm/deps.path@1100.0.13
|
|
19
|
+
- @pnpm/types@1101.8.0
|
|
20
|
+
|
|
3
21
|
## 1100.0.16
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -103,14 +103,57 @@ function isGitRepoAllowBuildKey(pkg) {
|
|
|
103
103
|
return !pkg.includes('#') && isGitRepoDepPath(pkg);
|
|
104
104
|
}
|
|
105
105
|
function getGitRepoAllowBuildKeyFromDepPath(depPath) {
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
if (isGitRepoDepPath(depPath)) {
|
|
107
|
+
const refStart = depPath.indexOf('#');
|
|
108
|
+
return refStart === -1 ? depPath : depPath.slice(0, refStart);
|
|
109
|
+
}
|
|
110
|
+
// Packages installed from a git host as a downloaded tarball (e.g. the
|
|
111
|
+
// `github:` shortcut, which pnpm fetches from codeload.github.com rather
|
|
112
|
+
// than cloning) have a depPath built from the tarball URL, not a `git+`
|
|
113
|
+
// clone URL, so the check above misses them. Normalize the tarball URL back
|
|
114
|
+
// to the same `git+https://<host>/<repo>.git` repo key that a clone of the
|
|
115
|
+
// same repository would produce, so a single hashless `allowBuilds` entry
|
|
116
|
+
// approves the package however pnpm happened to fetch it.
|
|
117
|
+
return gitHostedTarballRepoKey(depPath);
|
|
110
118
|
}
|
|
111
119
|
function isGitRepoDepPath(depPath) {
|
|
112
120
|
return depPath.startsWith('git+') || depPath.includes('@git+');
|
|
113
121
|
}
|
|
122
|
+
function gitHostedTarballRepoKey(pkgIdWithPatchHash) {
|
|
123
|
+
const { name, nonSemverVersion } = dp.parse(pkgIdWithPatchHash);
|
|
124
|
+
if (name == null || nonSemverVersion == null)
|
|
125
|
+
return undefined;
|
|
126
|
+
const repoUrl = gitHostedTarballRepoUrl(nonSemverVersion);
|
|
127
|
+
return repoUrl == null ? undefined : `${name}@${repoUrl}`;
|
|
128
|
+
}
|
|
129
|
+
// Reconstructs the committish-free repository URL from the download URL of a
|
|
130
|
+
// git host that pnpm fetches as a tarball instead of cloning. The patterns
|
|
131
|
+
// mirror the tarball templates in @pnpm/git-resolver (which come from
|
|
132
|
+
// hosted-git-info, except GitLab's, which that package overrides). The host of
|
|
133
|
+
// each known template is anchored so a look-alike download host (e.g.
|
|
134
|
+
// `codeload.github.com.example.com`) cannot be rewritten into an unrelated
|
|
135
|
+
// repo key, and each known download host claims its URLs exclusively: a URL on
|
|
136
|
+
// codeload.github.com or bitbucket.org that does not match that host's tarball
|
|
137
|
+
// pattern is rejected rather than falling through to the generic GitLab
|
|
138
|
+
// pattern, so a malformed URL on a known host cannot be rewritten into that
|
|
139
|
+
// host's trusted repo key either.
|
|
140
|
+
function gitHostedTarballRepoUrl(tarballUrl) {
|
|
141
|
+
// GitHub: https://codeload.github.com/<owner>/<repo>/tar.gz/<committish>
|
|
142
|
+
if (tarballUrl.startsWith('https://codeload.github.com/')) {
|
|
143
|
+
const match = /^https:\/\/codeload\.github\.com\/([^/]+)\/([^/]+)\/tar\.gz\//.exec(tarballUrl);
|
|
144
|
+
return match == null ? undefined : `git+https://github.com/${match[1]}/${match[2]}.git`;
|
|
145
|
+
}
|
|
146
|
+
// Bitbucket: https://bitbucket.org/<owner>/<repo>/get/<committish>.tar.gz
|
|
147
|
+
if (tarballUrl.startsWith('https://bitbucket.org/')) {
|
|
148
|
+
const match = /^https:\/\/bitbucket\.org\/([^/]+)\/([^/]+)\/get\//.exec(tarballUrl);
|
|
149
|
+
return match == null ? undefined : `git+https://bitbucket.org/${match[1]}/${match[2]}.git`;
|
|
150
|
+
}
|
|
151
|
+
// GitLab (incl. self-hosted): https://<host>/<group…>/<repo>/-/archive/<ref>/…
|
|
152
|
+
// The project path may contain nested groups, so match up to the
|
|
153
|
+
// `/-/archive/<ref>/` marker rather than a fixed number of path segments.
|
|
154
|
+
const match = /^https:\/\/([^/]+)\/(.+?)\/-\/archive\/[^/]+\//.exec(tarballUrl);
|
|
155
|
+
return match == null ? undefined : `git+https://${match[1]}/${match[2]}.git`;
|
|
156
|
+
}
|
|
114
157
|
function isDepPathAllowBuildKey(pkg) {
|
|
115
158
|
if (dp.removePeersSuffix(pkg) !== pkg)
|
|
116
159
|
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.17",
|
|
4
4
|
"description": "Create a function for filtering out dependencies that are not allowed to be built",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"!*.map"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pnpm/config.version-policy": "1100.1.
|
|
31
|
-
"@pnpm/deps.path": "1100.0.
|
|
32
|
-
"@pnpm/types": "1101.
|
|
30
|
+
"@pnpm/config.version-policy": "1100.1.11",
|
|
31
|
+
"@pnpm/deps.path": "1100.0.13",
|
|
32
|
+
"@pnpm/types": "1101.8.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jest/globals": "30.4.1",
|
|
36
|
-
"@pnpm/building.policy": "1100.0.
|
|
36
|
+
"@pnpm/building.policy": "1100.0.17"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=22.13"
|