@vltpkg/package-info 1.3.8 → 1.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/README.md +10 -7
- package/dist/index.js +15 -9
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -39,20 +39,23 @@ const { resolved, integrity } = await resolve('bar@latest')
|
|
|
39
39
|
|
|
40
40
|
## Global store
|
|
41
41
|
|
|
42
|
-
With the `store-linker` option set to `auto`, `hardlink` or
|
|
43
|
-
`extract()` places a registry package from its global store
|
|
44
|
-
(`<storeRoot>/<integrity hex>`, `storeRoot` defaults to
|
|
42
|
+
With the `store-linker` option set to `auto`, `hardlink`, `clone` or
|
|
43
|
+
`copy`, `extract()` places a registry package from its global store
|
|
44
|
+
entry (`<storeRoot>/<integrity hex>`, `storeRoot` defaults to
|
|
45
45
|
`<cache>/store/v1`) when there is one. On a miss it unpacks the cached
|
|
46
46
|
tarball as usual and queues it for the background child, so the next
|
|
47
47
|
install finds it in the global store. Missing or unknown
|
|
48
48
|
`store-linker` means `unpack`. The vlt CLI defaults to `auto`, which
|
|
49
|
-
it resolves to `
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
it resolves to `clone` on macOS with a Node that can load `node:ffi`
|
|
50
|
+
and to `unpack` on other platforms than Linux, so `extract()` only
|
|
51
|
+
ever sees `auto` from the CLI on Linux. A gzipped cached tarball that
|
|
52
|
+
is not store-linked (`unpack`, git or remote tarballs, no sha512
|
|
52
53
|
integrity) is queued too, so the child un-gzips it.
|
|
53
54
|
|
|
54
55
|
Packages with install scripts are linked too; reify copies them in
|
|
55
|
-
place right before their scripts run.
|
|
56
|
+
place right before their scripts run. A clone is copy-on-write, so
|
|
57
|
+
with `clone` they are cloned like any other package, and reify finds
|
|
58
|
+
nothing to copy.
|
|
56
59
|
|
|
57
60
|
A store link logs its request as `store`, a copy from the store as
|
|
58
61
|
`cache`. Both also return `manifest` (the package.json as JSON text,
|
package/dist/index.js
CHANGED
|
@@ -120,7 +120,12 @@ const isStableSelector = (f) => {
|
|
|
120
120
|
return !range.isAny && !range.raw.includes('-');
|
|
121
121
|
};
|
|
122
122
|
// anything else, eg an unvalidated env value, means `unpack`
|
|
123
|
-
const storeLinkers = new Set([
|
|
123
|
+
const storeLinkers = new Set([
|
|
124
|
+
'auto',
|
|
125
|
+
'hardlink',
|
|
126
|
+
'clone',
|
|
127
|
+
'copy',
|
|
128
|
+
]);
|
|
124
129
|
// the hash a response answers for. a network body's is the hash of its
|
|
125
130
|
// bytes: the registry client already checked it against the expected
|
|
126
131
|
// hash, or recorded it when there was none, and memoized it, so this
|
|
@@ -159,13 +164,13 @@ export class PackageInfoClient {
|
|
|
159
164
|
#cachePath;
|
|
160
165
|
#storeRoot;
|
|
161
166
|
#storeLinker;
|
|
162
|
-
#storeHits = { link: 0, copy: 0 };
|
|
167
|
+
#storeHits = { link: 0, clone: 0, copy: 0 };
|
|
163
168
|
#storeMisses = 0;
|
|
164
169
|
#storeHitRateLogged = false;
|
|
165
170
|
#logStoreHitRate = () => {
|
|
166
|
-
const { link, copy } = this.#storeHits;
|
|
167
|
-
const n = Math.max(1, link + copy + this.#storeMisses);
|
|
168
|
-
debug('global store: linked=%d copied=%d missed=%d hit rate=%s%%', link, copy, this.#storeMisses, (((link + copy) / n) * 100).toFixed(1));
|
|
171
|
+
const { link, clone, copy } = this.#storeHits;
|
|
172
|
+
const n = Math.max(1, link + clone + copy + this.#storeMisses);
|
|
173
|
+
debug('global store: linked=%d cloned=%d copied=%d missed=%d hit rate=%s%%', link, clone, copy, this.#storeMisses, (((link + clone + copy) / n) * 100).toFixed(1));
|
|
169
174
|
};
|
|
170
175
|
// In-flight coalescing key is `${registry}${name}` — no representation
|
|
171
176
|
// component. Safe only because every caller requests the same full
|
|
@@ -383,6 +388,7 @@ export class PackageInfoClient {
|
|
|
383
388
|
// git tarballs keep the unpack path
|
|
384
389
|
const storeOn = f.type === 'registry' && this.#storeLinker !== 'unpack';
|
|
385
390
|
const copy = this.#storeLinker === 'copy';
|
|
391
|
+
const clone = this.#storeLinker === 'clone';
|
|
386
392
|
// If we already have a hash, that is the store key. Some
|
|
387
393
|
// tarballs arrive without one: a `.tar.br`, or anything a
|
|
388
394
|
// registry serves with no `dist.integrity`. For those, read the
|
|
@@ -397,12 +403,12 @@ export class PackageInfoClient {
|
|
|
397
403
|
this.#storeHitRateLogged = true;
|
|
398
404
|
process.once('beforeExit', this.#logStoreHitRate);
|
|
399
405
|
}
|
|
400
|
-
const linked = await pool.linkFromStore(pathResolve(this.#storeRoot, hex), target, { copy });
|
|
406
|
+
const linked = await pool.linkFromStore(pathResolve(this.#storeRoot, hex), target, { copy, clone });
|
|
401
407
|
if (linked) {
|
|
402
408
|
const { how, index } = linked;
|
|
403
409
|
this.#storeHits[how]++;
|
|
404
410
|
// a copy is no link: report it as a cache hit
|
|
405
|
-
logRequest(r.resolved, how === '
|
|
411
|
+
logRequest(r.resolved, how === 'copy' ? 'cache' : 'store');
|
|
406
412
|
return {
|
|
407
413
|
...r,
|
|
408
414
|
manifest: index.manifest,
|
|
@@ -637,7 +643,7 @@ export class PackageInfoClient {
|
|
|
637
643
|
r.integrity = found;
|
|
638
644
|
const buf = response.buffer();
|
|
639
645
|
try {
|
|
640
|
-
await (await this.getTarPool()).unpack(buf, target);
|
|
646
|
+
await (await this.getTarPool()).unpack(buf, target, tarballFormat(r.resolved));
|
|
641
647
|
}
|
|
642
648
|
catch (er) {
|
|
643
649
|
throw this.#resolveError(spec, options, 'remote tar unpack failed', { cause: er });
|
|
@@ -1173,7 +1179,7 @@ export class PackageInfoClient {
|
|
|
1173
1179
|
// fetches again and records
|
|
1174
1180
|
const integrity = storedIntegrity(response);
|
|
1175
1181
|
try {
|
|
1176
|
-
await (await this.getTarPool()).unpack(buf, dir);
|
|
1182
|
+
await (await this.getTarPool()).unpack(buf, dir, tarballFormat(remoteURL));
|
|
1177
1183
|
}
|
|
1178
1184
|
catch (er) {
|
|
1179
1185
|
throw this.#resolveError(s, options, 'tar unpack failed', { cause: er });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/package-info",
|
|
3
3
|
"description": "Resolve and fetch package metadata and tarballs",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/error-cause": "1.
|
|
17
|
-
"@vltpkg/git": "1.
|
|
18
|
-
"@vltpkg/output": "1.
|
|
19
|
-
"@vltpkg/package-json": "1.
|
|
20
|
-
"@vltpkg/pick-manifest": "1.
|
|
21
|
-
"@vltpkg/registry-client": "1.
|
|
22
|
-
"@vltpkg/spec": "1.
|
|
23
|
-
"@vltpkg/tar": "1.
|
|
24
|
-
"@vltpkg/types": "1.
|
|
25
|
-
"@vltpkg/workspaces": "1.
|
|
26
|
-
"@vltpkg/xdg": "1.
|
|
16
|
+
"@vltpkg/error-cause": "1.5.0",
|
|
17
|
+
"@vltpkg/git": "1.5.0",
|
|
18
|
+
"@vltpkg/output": "1.5.0",
|
|
19
|
+
"@vltpkg/package-json": "1.5.0",
|
|
20
|
+
"@vltpkg/pick-manifest": "1.5.0",
|
|
21
|
+
"@vltpkg/registry-client": "1.5.0",
|
|
22
|
+
"@vltpkg/spec": "1.5.0",
|
|
23
|
+
"@vltpkg/tar": "1.5.0",
|
|
24
|
+
"@vltpkg/types": "1.5.0",
|
|
25
|
+
"@vltpkg/workspaces": "1.5.0",
|
|
26
|
+
"@vltpkg/xdg": "1.5.0",
|
|
27
27
|
"tar": "^7.5.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@types/node": "^22.19.2",
|
|
32
32
|
"@types/pacote": "^11.1.8",
|
|
33
33
|
"@vltpkg/benchmark": "0.0.0",
|
|
34
|
-
"@vltpkg/cache-unzip": "1.
|
|
35
|
-
"@vltpkg/vlt-json": "1.
|
|
34
|
+
"@vltpkg/cache-unzip": "1.5.0",
|
|
35
|
+
"@vltpkg/vlt-json": "1.5.0",
|
|
36
36
|
"eslint": "^9.39.1",
|
|
37
37
|
"pacote": "^21.0.4",
|
|
38
38
|
"prettier": "^3.7.4",
|