@vltpkg/package-info 1.8.0 → 1.8.2
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/dist/index.js +40 -3
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -207,6 +207,9 @@ export class PackageInfoClient {
|
|
|
207
207
|
// `${registry}${name}@${range}` for every spec that chose a version and
|
|
208
208
|
// `${registry}${name}@${version}` for the version itself.
|
|
209
209
|
#resolvedManifests = new Map();
|
|
210
|
+
// what each of those is cached as, taken when manifest() first hands it
|
|
211
|
+
// out: callers change the object after that
|
|
212
|
+
#resolvedJson = new WeakMap();
|
|
210
213
|
/**
|
|
211
214
|
* The resolve requests in flight against each registry, with when the
|
|
212
215
|
* registry last delivered a record: the grace a lookup gives the stream
|
|
@@ -856,6 +859,9 @@ export class PackageInfoClient {
|
|
|
856
859
|
if (options.arch) {
|
|
857
860
|
extra += `${delimiter}arch:${options.arch}`;
|
|
858
861
|
}
|
|
862
|
+
if (options.libc) {
|
|
863
|
+
extra += `${delimiter}libc:${options.libc}`;
|
|
864
|
+
}
|
|
859
865
|
return encodeURIComponent(`${spec.registry ?? ''}${delimiter}${spec}${extra}`);
|
|
860
866
|
}
|
|
861
867
|
/**
|
|
@@ -904,6 +910,25 @@ export class PackageInfoClient {
|
|
|
904
910
|
// failing to write the manifest cache is not an install failure
|
|
905
911
|
}
|
|
906
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* Cache a manifest the resolve stream delivered, as fromPackument caches
|
|
915
|
+
* a picked one, unless the file on disk is still fresh.
|
|
916
|
+
*/
|
|
917
|
+
#cacheResolved(cachePath, mani) {
|
|
918
|
+
let json = this.#resolvedJson.get(mani);
|
|
919
|
+
if (json === undefined) {
|
|
920
|
+
// a resolve record is a vlt manifest
|
|
921
|
+
json = JSON.stringify({ ...mani, __VLT_PACKUMENT: true });
|
|
922
|
+
this.#resolvedJson.set(mani, json);
|
|
923
|
+
}
|
|
924
|
+
if (!cachePath || this.#manifestWritePaths.has(cachePath))
|
|
925
|
+
return;
|
|
926
|
+
this.#manifestWritePaths.add(cachePath);
|
|
927
|
+
const write = () => this.#writeManifestCache(cachePath, json);
|
|
928
|
+
this.#inBackground(stat(cachePath).then(st => st.mtimeMs < this.#manifestCacheMinAge ?
|
|
929
|
+
write()
|
|
930
|
+
: undefined, write));
|
|
931
|
+
}
|
|
907
932
|
async tarball(spec, options = {}) {
|
|
908
933
|
if (typeof spec === 'string')
|
|
909
934
|
spec = Spec.parse(spec, this.options);
|
|
@@ -1166,7 +1191,8 @@ export class PackageInfoClient {
|
|
|
1166
1191
|
}
|
|
1167
1192
|
/**
|
|
1168
1193
|
* The manifest for `key` from an in-flight resolve, or from `fetch` when
|
|
1169
|
-
* the resolve is not carrying it. Undefined when
|
|
1194
|
+
* the resolve is not carrying it. Undefined when the key has not arrived
|
|
1195
|
+
* and nothing is in flight.
|
|
1170
1196
|
*
|
|
1171
1197
|
* A stream that is delivering gets a short grace to carry the key, since
|
|
1172
1198
|
* its records come in the order the build asks for them; one that has
|
|
@@ -1177,6 +1203,11 @@ export class PackageInfoClient {
|
|
|
1177
1203
|
* fails while the stream is still open waits for the stream's verdict.
|
|
1178
1204
|
*/
|
|
1179
1205
|
async #awaitResolved(registry, key, fetch) {
|
|
1206
|
+
// a record that landed since manifest() looked, on a stream that may
|
|
1207
|
+
// have settled since
|
|
1208
|
+
const landed = this.#resolvedManifests.get(key);
|
|
1209
|
+
if (landed)
|
|
1210
|
+
return landed;
|
|
1180
1211
|
const inflight = this.#resolveInflight.get(registry);
|
|
1181
1212
|
if (!inflight?.requests.size)
|
|
1182
1213
|
return undefined;
|
|
@@ -1255,8 +1286,10 @@ export class PackageInfoClient {
|
|
|
1255
1286
|
const resolveKey = `${f.registry ?? ''}${f.name}@${f.bareSpec}`;
|
|
1256
1287
|
if (!selecting) {
|
|
1257
1288
|
const resolved = this.#resolvedManifests.get(resolveKey);
|
|
1258
|
-
if (resolved)
|
|
1289
|
+
if (resolved) {
|
|
1290
|
+
this.#cacheResolved(this._manifestCachePath(spec, options), resolved);
|
|
1259
1291
|
return resolved;
|
|
1292
|
+
}
|
|
1260
1293
|
}
|
|
1261
1294
|
// Check if manifest is cached, if so just return it earlier
|
|
1262
1295
|
const cachePath = this._manifestCachePath(spec, options);
|
|
@@ -1310,8 +1343,12 @@ export class PackageInfoClient {
|
|
|
1310
1343
|
// key, so it gets a moment before the packument is fetched too
|
|
1311
1344
|
if (!selecting && f.registry) {
|
|
1312
1345
|
const resolved = await this.#awaitResolved(f.registry, resolveKey, fromPackument);
|
|
1313
|
-
if (resolved)
|
|
1346
|
+
if (resolved) {
|
|
1347
|
+
// the stream's answer; fromPackument caches its own
|
|
1348
|
+
if (resolved === this.#resolvedManifests.get(resolveKey))
|
|
1349
|
+
this.#cacheResolved(cachePath, resolved);
|
|
1314
1350
|
return resolved;
|
|
1351
|
+
}
|
|
1315
1352
|
}
|
|
1316
1353
|
return fromPackument();
|
|
1317
1354
|
}
|
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.8.
|
|
4
|
+
"version": "1.8.2",
|
|
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.8.
|
|
17
|
-
"@vltpkg/git": "1.8.
|
|
18
|
-
"@vltpkg/output": "1.8.
|
|
19
|
-
"@vltpkg/package-json": "1.8.
|
|
20
|
-
"@vltpkg/pick-manifest": "1.8.
|
|
21
|
-
"@vltpkg/registry-client": "1.8.
|
|
22
|
-
"@vltpkg/spec": "1.8.
|
|
23
|
-
"@vltpkg/tar": "1.8.
|
|
24
|
-
"@vltpkg/types": "1.8.
|
|
25
|
-
"@vltpkg/workspaces": "1.8.
|
|
26
|
-
"@vltpkg/xdg": "1.8.
|
|
16
|
+
"@vltpkg/error-cause": "1.8.2",
|
|
17
|
+
"@vltpkg/git": "1.8.2",
|
|
18
|
+
"@vltpkg/output": "1.8.2",
|
|
19
|
+
"@vltpkg/package-json": "1.8.2",
|
|
20
|
+
"@vltpkg/pick-manifest": "1.8.2",
|
|
21
|
+
"@vltpkg/registry-client": "1.8.2",
|
|
22
|
+
"@vltpkg/spec": "1.8.2",
|
|
23
|
+
"@vltpkg/tar": "1.8.2",
|
|
24
|
+
"@vltpkg/types": "1.8.2",
|
|
25
|
+
"@vltpkg/workspaces": "1.8.2",
|
|
26
|
+
"@vltpkg/xdg": "1.8.2",
|
|
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.8.
|
|
35
|
-
"@vltpkg/vlt-json": "1.8.
|
|
34
|
+
"@vltpkg/cache-unzip": "1.8.2",
|
|
35
|
+
"@vltpkg/vlt-json": "1.8.2",
|
|
36
36
|
"eslint": "^10.14.0",
|
|
37
37
|
"pacote": "^21.0.4",
|
|
38
38
|
"prettier": "^3.7.4",
|