@pnpm/worker 1100.0.2 → 1100.1.1
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/README.md +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -0
- package/lib/start.js +19 -2
- package/lib/types.d.ts +6 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> A worker for extracting package tarballs to the store
|
|
4
4
|
|
|
5
|
-
[](https://
|
|
5
|
+
[](https://npmx.dev/package/@pnpm/worker)
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
package/lib/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class TarballIntegrityError extends PnpmError {
|
|
|
31
31
|
url: string;
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
type AddFilesFromTarballOptions = Pick<TarballExtractMessage, 'buffer' | 'storeDir' | 'filesIndexFile' | 'integrity' | 'readManifest' | 'pkg' | 'appendManifest'> & {
|
|
34
|
+
type AddFilesFromTarballOptions = Pick<TarballExtractMessage, 'buffer' | 'storeDir' | 'filesIndexFile' | 'integrity' | 'readManifest' | 'pkg' | 'appendManifest' | 'ignoreFilePattern'> & {
|
|
35
35
|
storeIndex: StoreIndex;
|
|
36
36
|
url: string;
|
|
37
37
|
};
|
package/lib/index.js
CHANGED
package/lib/start.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import util from 'node:util';
|
|
4
5
|
import { parentPort } from 'node:worker_threads';
|
|
5
6
|
import { pkgRequiresBuild } from '@pnpm/building.pkg-requires-build';
|
|
6
7
|
import { formatIntegrity, parseIntegrity } from '@pnpm/crypto.integrity';
|
|
@@ -141,7 +142,7 @@ async function handleMessage(message) {
|
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
|
-
function addTarballToStore({ buffer, storeDir, integrity, filesIndexFile, appendManifest }) {
|
|
145
|
+
function addTarballToStore({ buffer, storeDir, integrity, filesIndexFile, appendManifest, ignoreFilePattern }) {
|
|
145
146
|
if (integrity) {
|
|
146
147
|
const { algorithm, hexDigest } = parseIntegrity(integrity);
|
|
147
148
|
const calculatedHash = crypto.hash(algorithm, buffer, 'hex');
|
|
@@ -161,7 +162,8 @@ function addTarballToStore({ buffer, storeDir, integrity, filesIndexFile, append
|
|
|
161
162
|
cafsCache.set(storeDir, createCafs(storeDir));
|
|
162
163
|
}
|
|
163
164
|
const cafs = cafsCache.get(storeDir);
|
|
164
|
-
|
|
165
|
+
const ignore = ignoreFilePattern ? makeIgnoreFromPattern(ignoreFilePattern) : undefined;
|
|
166
|
+
let { filesIndex, manifest } = cafs.addFilesFromTarball(buffer, true, ignore);
|
|
165
167
|
if (appendManifest && manifest == null) {
|
|
166
168
|
manifest = appendManifest;
|
|
167
169
|
addManifestToCafs(cafs, filesIndex, appendManifest);
|
|
@@ -193,6 +195,21 @@ function calcIntegrity(buffer) {
|
|
|
193
195
|
const calculatedHash = crypto.hash('sha512', buffer, 'hex');
|
|
194
196
|
return formatIntegrity('sha512', calculatedHash);
|
|
195
197
|
}
|
|
198
|
+
function makeIgnoreFromPattern(pattern) {
|
|
199
|
+
// `ignoreFilePattern` is a public field on FetchOptions, so callers that don't go
|
|
200
|
+
// through the binary-fetcher's validated `archiveFilters` path could still supply a
|
|
201
|
+
// bad regex. Convert the SyntaxError into a PnpmError with a stable code so it's
|
|
202
|
+
// actionable for users.
|
|
203
|
+
let regex;
|
|
204
|
+
try {
|
|
205
|
+
regex = new RegExp(pattern);
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
const detail = util.types.isNativeError(err) ? `: ${err.message}` : '';
|
|
209
|
+
throw new PnpmError('INVALID_IGNORE_FILE_PATTERN', `Invalid ignoreFilePattern regex${detail}: ${pattern}`);
|
|
210
|
+
}
|
|
211
|
+
return (filename) => regex.test(filename);
|
|
212
|
+
}
|
|
196
213
|
function packToShared(data) {
|
|
197
214
|
const packed = packForStorage(data);
|
|
198
215
|
const shared = new SharedArrayBuffer(packed.byteLength);
|
package/lib/types.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export interface TarballExtractMessage {
|
|
|
17
17
|
readManifest?: boolean;
|
|
18
18
|
pkg?: PkgNameVersion;
|
|
19
19
|
appendManifest?: DependencyManifest;
|
|
20
|
+
/**
|
|
21
|
+
* Regex source matching the normalized relative path of files inside the tarball that
|
|
22
|
+
* should be skipped. Matching happens after the tar parser strips the top-level directory
|
|
23
|
+
* segment — i.e. against the same path form that is written to `filesIndex`.
|
|
24
|
+
*/
|
|
25
|
+
ignoreFilePattern?: string;
|
|
20
26
|
}
|
|
21
27
|
export interface LinkPkgMessage {
|
|
22
28
|
type: 'link';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/worker",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.1.1",
|
|
4
4
|
"description": "A worker for extracting package taralls to the store",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -30,26 +30,27 @@
|
|
|
30
30
|
"is-windows": "^1.0.2",
|
|
31
31
|
"p-limit": "^7.1.0",
|
|
32
32
|
"semver": "^7.7.2",
|
|
33
|
-
"@pnpm/building.pkg-requires-build": "1100.0.
|
|
34
|
-
"@pnpm/error": "1100.0.0",
|
|
33
|
+
"@pnpm/building.pkg-requires-build": "1100.0.2",
|
|
35
34
|
"@pnpm/crypto.integrity": "1100.0.0",
|
|
36
|
-
"@pnpm/fs.graceful-fs": "1100.
|
|
37
|
-
"@pnpm/fs.hard-link-dir": "1100.0.
|
|
38
|
-
"@pnpm/
|
|
39
|
-
"@pnpm/store.cafs": "1100.
|
|
40
|
-
"@pnpm/
|
|
41
|
-
"@pnpm/store.create-cafs-store": "1100.0.
|
|
35
|
+
"@pnpm/fs.graceful-fs": "1100.1.0",
|
|
36
|
+
"@pnpm/fs.hard-link-dir": "1100.0.1",
|
|
37
|
+
"@pnpm/error": "1100.0.0",
|
|
38
|
+
"@pnpm/store.cafs": "1100.1.1",
|
|
39
|
+
"@pnpm/fs.symlink-dependency": "1100.0.2",
|
|
40
|
+
"@pnpm/store.create-cafs-store": "1100.0.4",
|
|
41
|
+
"@pnpm/store.cafs-types": "1100.0.1",
|
|
42
42
|
"@pnpm/store.index": "1100.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@jest/globals": "30.3.0",
|
|
48
49
|
"@types/is-windows": "^1.0.2",
|
|
49
50
|
"@types/semver": "7.7.1",
|
|
50
51
|
"@pnpm/logger": "1100.0.0",
|
|
51
52
|
"@pnpm/types": "1101.0.0",
|
|
52
|
-
"@pnpm/worker": "1100.
|
|
53
|
+
"@pnpm/worker": "1100.1.1"
|
|
53
54
|
},
|
|
54
55
|
"engines": {
|
|
55
56
|
"node": ">=22.13"
|