@vltpkg/package-info 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -2
  2. package/package.json +14 -13
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
2
  import { clone, resolve as gitResolve, revs } from '@vltpkg/git';
3
+ import { logRequest } from '@vltpkg/output';
3
4
  import { PackageJson } from '@vltpkg/package-json';
4
5
  import { pickManifest } from '@vltpkg/pick-manifest';
5
6
  import { Spec } from '@vltpkg/spec';
@@ -10,8 +11,10 @@ import { XDG } from '@vltpkg/xdg';
10
11
  import { createHash, randomBytes } from 'node:crypto';
11
12
  import { mkdir, readFile, rm, stat, symlink, unlink, writeFile, } from 'node:fs/promises';
12
13
  import { basename, dirname, resolve as pathResolve, relative, } from 'node:path';
14
+ import { debuglog } from 'node:util';
13
15
  import { create as tarC } from 'tar';
14
16
  import { rename } from "./rename.js";
17
+ const debug = debuglog('vlt');
15
18
  const xdg = new XDG('vlt');
16
19
  export const delimiter = '~';
17
20
  // the maximum duration of a manifest cache file
@@ -129,6 +132,25 @@ export class PackageInfoClient {
129
132
  // fallthrough if a remote tarball url present
130
133
  }
131
134
  case 'registry': {
135
+ // if the tarball is already on disk, unpack it straight from
136
+ // the cache file: it never has to be held in the client's
137
+ // in-memory cache. anything unexpected falls through to the
138
+ // fetch path, which throws its own error if the body is
139
+ // genuinely bad.
140
+ const cached = (await this.getRegistryClient()).cachedBody(r.resolved, { integrity: r.integrity });
141
+ if (cached) {
142
+ try {
143
+ await (await this.getTarPool()).unpack(cached.body, target);
144
+ logRequest(r.resolved, 'cache');
145
+ return r;
146
+ }
147
+ catch (er) {
148
+ // a systematically failing fast path (every entry still
149
+ // gzipped, EACCES, ENOSPC...) doubles the IO of the fetch
150
+ // path, so leave a trace behind. NODE_DEBUG=vlt to see it.
151
+ debug('cached tarball unpack failed: %s: %s', cached.path, er);
152
+ }
153
+ }
132
154
  const fetchTarball = async (useCache) => {
133
155
  const trustIntegrity = this.#trustedIntegrities.get(r.resolved) === r.integrity;
134
156
  const response = await (await this.getRegistryClient()).request(r.resolved, {
@@ -244,7 +266,7 @@ export class PackageInfoClient {
244
266
  const st = await stat(path);
245
267
  if (st.isFile()) {
246
268
  try {
247
- await (await this.getTarPool()).unpack(await this.tarball(spec, options), target);
269
+ await (await this.getTarPool()).unpackFile(path, target);
248
270
  }
249
271
  catch (er) {
250
272
  throw this.#resolveError(spec, options, 'tar unpack failed', { cause: er });
@@ -586,7 +608,7 @@ export class PackageInfoClient {
586
608
  const s = spec;
587
609
  return await this.#tmpdir(async (dir) => {
588
610
  try {
589
- await (await this.getTarPool()).unpack(await readFile(path), dir);
611
+ await (await this.getTarPool()).unpackFile(path, dir);
590
612
  }
591
613
  catch (er) {
592
614
  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.0.8",
4
+ "version": "1.0.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,16 +13,17 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/error-cause": "1.0.8",
17
- "@vltpkg/git": "1.0.8",
18
- "@vltpkg/package-json": "1.0.8",
19
- "@vltpkg/pick-manifest": "1.0.8",
20
- "@vltpkg/registry-client": "1.0.8",
21
- "@vltpkg/spec": "1.0.8",
22
- "@vltpkg/tar": "1.0.8",
23
- "@vltpkg/types": "1.0.8",
24
- "@vltpkg/workspaces": "1.0.8",
25
- "@vltpkg/xdg": "1.0.8",
16
+ "@vltpkg/error-cause": "1.0.9",
17
+ "@vltpkg/git": "1.0.9",
18
+ "@vltpkg/output": "1.0.9",
19
+ "@vltpkg/package-json": "1.0.9",
20
+ "@vltpkg/pick-manifest": "1.0.9",
21
+ "@vltpkg/registry-client": "1.0.9",
22
+ "@vltpkg/spec": "1.0.9",
23
+ "@vltpkg/tar": "1.0.9",
24
+ "@vltpkg/types": "1.0.9",
25
+ "@vltpkg/workspaces": "1.0.9",
26
+ "@vltpkg/xdg": "1.0.9",
26
27
  "ssri": "^13.0.0",
27
28
  "tar": "^7.5.2"
28
29
  },
@@ -31,8 +32,8 @@
31
32
  "@types/node": "^22.19.2",
32
33
  "@types/pacote": "^11.1.8",
33
34
  "@vltpkg/benchmark": "0.0.0",
34
- "@vltpkg/cache-unzip": "1.0.8",
35
- "@vltpkg/vlt-json": "1.0.8",
35
+ "@vltpkg/cache-unzip": "1.0.9",
36
+ "@vltpkg/vlt-json": "1.0.9",
36
37
  "eslint": "^9.39.1",
37
38
  "pacote": "^21.0.4",
38
39
  "prettier": "^3.7.4",