@vltpkg/package-info 1.0.0-rc.9 → 1.0.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/{esm/index.d.ts → index.d.ts} +8 -2
- package/dist/{esm/index.js → index.js} +219 -86
- package/dist/{esm/rename.d.ts → rename.d.ts} +0 -1
- package/dist/{esm/rename.js → rename.js} +0 -1
- package/package.json +50 -51
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/rename.d.ts.map +0 -1
- package/dist/esm/rename.js.map +0 -1
|
@@ -7,7 +7,7 @@ import { Spec } from '@vltpkg/spec';
|
|
|
7
7
|
import { Pool } from '@vltpkg/tar';
|
|
8
8
|
import type { Integrity, Manifest, Packument } from '@vltpkg/types';
|
|
9
9
|
import { Monorepo } from '@vltpkg/workspaces';
|
|
10
|
-
export declare const delimiter = "
|
|
10
|
+
export declare const delimiter = "~";
|
|
11
11
|
export type Resolution = {
|
|
12
12
|
resolved: string;
|
|
13
13
|
integrity?: Integrity;
|
|
@@ -32,6 +32,13 @@ export type PackageInfoClientRequestOptions = PickManifestOptions & RegistryClie
|
|
|
32
32
|
export type PackageInfoClientExtractOptions = PackageInfoClientRequestOptions & {
|
|
33
33
|
integrity?: Integrity;
|
|
34
34
|
resolved?: string;
|
|
35
|
+
/**
|
|
36
|
+
* When true, indicates that integrity + resolved came from a
|
|
37
|
+
* lockfile (i.e. they were already verified on first install).
|
|
38
|
+
* Skips the client-side tarball integrity check.
|
|
39
|
+
* Defaults to false — fresh installs always verify integrity.
|
|
40
|
+
*/
|
|
41
|
+
fromLockfile?: boolean;
|
|
35
42
|
};
|
|
36
43
|
export declare class PackageInfoClient {
|
|
37
44
|
#private;
|
|
@@ -53,4 +60,3 @@ export declare class PackageInfoClient {
|
|
|
53
60
|
packument(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Packument>;
|
|
54
61
|
resolve(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Resolution>;
|
|
55
62
|
}
|
|
56
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,18 +5,26 @@ import { pickManifest } from '@vltpkg/pick-manifest';
|
|
|
5
5
|
import { RegistryClient } from '@vltpkg/registry-client';
|
|
6
6
|
import { Spec } from '@vltpkg/spec';
|
|
7
7
|
import { Pool } from '@vltpkg/tar';
|
|
8
|
-
import { asPackument
|
|
8
|
+
import { asPackument } from '@vltpkg/types';
|
|
9
|
+
import ssri from 'ssri';
|
|
9
10
|
import { Monorepo } from '@vltpkg/workspaces';
|
|
10
11
|
import { XDG } from '@vltpkg/xdg';
|
|
11
|
-
import { randomBytes } from 'node:crypto';
|
|
12
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
12
13
|
import { mkdir, readFile, rm, stat, symlink, unlink, writeFile, } from 'node:fs/promises';
|
|
13
14
|
import { basename, dirname, resolve as pathResolve, relative, } from 'node:path';
|
|
14
15
|
import { create as tarC } from 'tar';
|
|
15
16
|
import { rename } from "./rename.js";
|
|
16
17
|
const xdg = new XDG('vlt');
|
|
17
|
-
export const delimiter = '
|
|
18
|
+
export const delimiter = '~';
|
|
18
19
|
// the maximum duration of a manifest cache file
|
|
19
20
|
const manifestCacheMaxAge = 5 * 60 * 1000;
|
|
21
|
+
/**
|
|
22
|
+
* There is no default registry. Anything that needs to build a registry
|
|
23
|
+
* URL fails with a `ECONFIG` error when none has been configured.
|
|
24
|
+
*/
|
|
25
|
+
const noRegistryError = (spec) => error('No registry configured to resolve this spec. Set "registry" in ' +
|
|
26
|
+
'vlt.json, pass --registry, or run `vlt login --registry=<url>`. ' +
|
|
27
|
+
'See https://docs.vlt.sh/cli', { code: 'ECONFIG', spec });
|
|
20
28
|
export class PackageInfoClient {
|
|
21
29
|
#registryClient;
|
|
22
30
|
#projectRoot;
|
|
@@ -28,6 +36,7 @@ export class PackageInfoClient {
|
|
|
28
36
|
#trustedIntegrities = new Map();
|
|
29
37
|
#manifestCacheMinAge = Date.now() - manifestCacheMaxAge;
|
|
30
38
|
#cachePath;
|
|
39
|
+
#packumentPromises = new Map();
|
|
31
40
|
get registryClient() {
|
|
32
41
|
if (!this.#registryClient) {
|
|
33
42
|
this.#registryClient = new RegistryClient(this.options);
|
|
@@ -64,9 +73,12 @@ export class PackageInfoClient {
|
|
|
64
73
|
async extract(spec, target, options = {}) {
|
|
65
74
|
if (typeof spec === 'string')
|
|
66
75
|
spec = Spec.parse(spec, this.options);
|
|
67
|
-
const { from = this.#projectRoot, integrity, resolved } = options;
|
|
76
|
+
const { from = this.#projectRoot, integrity, resolved, fromLockfile = false, } = options;
|
|
68
77
|
const f = spec.final;
|
|
69
|
-
|
|
78
|
+
// If the caller already provides both integrity and resolved
|
|
79
|
+
// (from lockfile or prior resolution), skip re-resolving.
|
|
80
|
+
const alreadyResolved = !!(integrity && resolved);
|
|
81
|
+
const r = alreadyResolved ?
|
|
70
82
|
{ resolved, integrity, spec }
|
|
71
83
|
: await this.resolve(spec, options);
|
|
72
84
|
switch (f.type) {
|
|
@@ -96,29 +108,111 @@ export class PackageInfoClient {
|
|
|
96
108
|
}
|
|
97
109
|
// fallthrough if a remote tarball url present
|
|
98
110
|
}
|
|
99
|
-
case 'registry':
|
|
111
|
+
case 'registry': {
|
|
112
|
+
const fetchTarball = async (useCache) => {
|
|
113
|
+
const trustIntegrity = this.#trustedIntegrities.get(r.resolved) === r.integrity;
|
|
114
|
+
const response = await this.registryClient.request(r.resolved, {
|
|
115
|
+
integrity: r.integrity,
|
|
116
|
+
trustIntegrity,
|
|
117
|
+
...(useCache === false ? { useCache } : {}),
|
|
118
|
+
});
|
|
119
|
+
if (response.statusCode !== 200) {
|
|
120
|
+
throw this.#resolveError(spec, options, `Registry returned HTTP ${response.statusCode} when ` +
|
|
121
|
+
`fetching the tarball for ${spec}. The resolved version ` +
|
|
122
|
+
`may have been unpublished, or the registry may be ` +
|
|
123
|
+
`misconfigured or unreachable.`, {
|
|
124
|
+
url: r.resolved,
|
|
125
|
+
response,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// if it's not trusted already, but valid, start trusting
|
|
129
|
+
if (!trustIntegrity &&
|
|
130
|
+
response.checkIntegrity({ spec, url: resolved })) {
|
|
131
|
+
this.#trustedIntegrities.set(r.resolved, response.integrity);
|
|
132
|
+
}
|
|
133
|
+
const buf = response.buffer();
|
|
134
|
+
// Verify tarball integrity against the manifest's
|
|
135
|
+
// dist.integrity. This is a supply-chain security measure:
|
|
136
|
+
// the registry may not validate integrity, so we do it
|
|
137
|
+
// client-side on every fresh download. Skip when integrity
|
|
138
|
+
// came from lockfile/cache (it was already verified on
|
|
139
|
+
// first install).
|
|
140
|
+
/* c8 ignore start - defense-in-depth: registry client's
|
|
141
|
+
* checkIntegrity() usually catches mismatches first since
|
|
142
|
+
* it checks the same gzip bytes. This fires only when the
|
|
143
|
+
* registry client check is skipped (trustIntegrity=true). */
|
|
144
|
+
if (r.integrity && !fromLockfile) {
|
|
145
|
+
const hash = createHash('sha512');
|
|
146
|
+
hash.update(buf);
|
|
147
|
+
const computed = `sha512-${hash.digest('base64')}`;
|
|
148
|
+
if (computed !== r.integrity) {
|
|
149
|
+
throw error('Tarball integrity check failed', {
|
|
150
|
+
code: 'EINTEGRITY',
|
|
151
|
+
spec,
|
|
152
|
+
url: r.resolved,
|
|
153
|
+
wanted: r.integrity,
|
|
154
|
+
found: computed,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/* c8 ignore stop */
|
|
159
|
+
return buf;
|
|
160
|
+
};
|
|
161
|
+
let buf;
|
|
162
|
+
try {
|
|
163
|
+
buf = await fetchTarball();
|
|
164
|
+
}
|
|
165
|
+
catch (er) {
|
|
166
|
+
// On EINTEGRITY, retry once bypassing cache. This handles
|
|
167
|
+
// transient issues such as corrupted downloads or CDN
|
|
168
|
+
// inconsistencies that cause the cached tarball to not
|
|
169
|
+
// match the expected integrity hash.
|
|
170
|
+
if (er instanceof Error &&
|
|
171
|
+
'cause' in er &&
|
|
172
|
+
er.cause
|
|
173
|
+
?.code === 'EINTEGRITY') {
|
|
174
|
+
buf = await fetchTarball(false);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
throw er;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
await this.tarPool.unpack(buf, target);
|
|
182
|
+
}
|
|
183
|
+
catch (er) {
|
|
184
|
+
throw this.#resolveError(spec, options, 'tar unpack failed', { cause: er });
|
|
185
|
+
}
|
|
186
|
+
return r;
|
|
187
|
+
}
|
|
100
188
|
case 'remote': {
|
|
101
|
-
const
|
|
102
|
-
const response = await this.registryClient.request(r.resolved, {
|
|
103
|
-
integrity: r.integrity,
|
|
104
|
-
trustIntegrity,
|
|
105
|
-
});
|
|
189
|
+
const response = await this.registryClient.request(r.resolved);
|
|
106
190
|
if (response.statusCode !== 200) {
|
|
107
|
-
throw this.#resolveError(spec, options, 'failed to fetch tarball', {
|
|
191
|
+
throw this.#resolveError(spec, options, 'failed to fetch remote tarball', {
|
|
108
192
|
url: r.resolved,
|
|
109
193
|
response,
|
|
110
194
|
});
|
|
111
195
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
196
|
+
const buf = response.buffer();
|
|
197
|
+
// Compute integrity for remote/git-with-tarball deps
|
|
198
|
+
const computed = ssri
|
|
199
|
+
.fromData(buf, { algorithms: ['sha512'] })
|
|
200
|
+
.toString();
|
|
201
|
+
if (r.integrity && r.integrity !== computed) {
|
|
202
|
+
throw error('Integrity check failure', {
|
|
203
|
+
code: 'EINTEGRITY',
|
|
204
|
+
spec,
|
|
205
|
+
url: r.resolved,
|
|
206
|
+
wanted: r.integrity,
|
|
207
|
+
found: computed,
|
|
208
|
+
});
|
|
116
209
|
}
|
|
210
|
+
r.integrity = computed;
|
|
117
211
|
try {
|
|
118
|
-
await this.tarPool.unpack(
|
|
212
|
+
await this.tarPool.unpack(buf, target);
|
|
119
213
|
}
|
|
120
214
|
catch (er) {
|
|
121
|
-
throw this.#resolveError(spec, options, 'tar unpack failed', { cause: er });
|
|
215
|
+
throw this.#resolveError(spec, options, 'remote tar unpack failed', { cause: er });
|
|
122
216
|
}
|
|
123
217
|
return r;
|
|
124
218
|
}
|
|
@@ -189,7 +283,7 @@ export class PackageInfoClient {
|
|
|
189
283
|
if (options.arch) {
|
|
190
284
|
extra += `${delimiter}arch:${options.arch}`;
|
|
191
285
|
}
|
|
192
|
-
return encodeURIComponent(`${spec.registry}${delimiter}${spec}${extra}`);
|
|
286
|
+
return encodeURIComponent(`${spec.registry ?? ''}${delimiter}${spec}${extra}`);
|
|
193
287
|
}
|
|
194
288
|
/**
|
|
195
289
|
* Conditionally return the path to the manifest cache file. The logic
|
|
@@ -210,30 +304,6 @@ export class PackageInfoClient {
|
|
|
210
304
|
const key = this.#manifestCacheKey(f, options);
|
|
211
305
|
return pathResolve(this.#cachePath, 'package-info', key);
|
|
212
306
|
}
|
|
213
|
-
async #registryManifestRequest(spec, options) {
|
|
214
|
-
const { registry, name, registrySpec } = spec.final;
|
|
215
|
-
/* c8 ignore start */
|
|
216
|
-
if (!spec.range?.isSingle || !registrySpec) {
|
|
217
|
-
throw this.#resolveError(spec, options, 'failed to request manifest', { spec });
|
|
218
|
-
}
|
|
219
|
-
/* c8 ignore stop */
|
|
220
|
-
const possibleLeadingChars = ['=', '^', '~', 'v'];
|
|
221
|
-
const hasLeadingRange = possibleLeadingChars.some(char => registrySpec.startsWith(char));
|
|
222
|
-
const version = hasLeadingRange ? registrySpec.slice(1) : registrySpec;
|
|
223
|
-
const pakuURL = new URL(`${name}/${version}`, registry);
|
|
224
|
-
const response = await this.registryClient.request(pakuURL, {
|
|
225
|
-
headers: {
|
|
226
|
-
accept: 'application/json',
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
if (response.statusCode !== 200) {
|
|
230
|
-
throw this.#resolveError(spec, options, 'failed to fetch manifest', {
|
|
231
|
-
url: pakuURL,
|
|
232
|
-
response,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
return response.json();
|
|
236
|
-
}
|
|
237
307
|
async tarball(spec, options = {}) {
|
|
238
308
|
if (typeof spec === 'string')
|
|
239
309
|
spec = Spec.parse(spec, this.options);
|
|
@@ -242,26 +312,68 @@ export class PackageInfoClient {
|
|
|
242
312
|
case 'registry': {
|
|
243
313
|
const { dist } = await this.manifest(spec, options);
|
|
244
314
|
if (!dist)
|
|
245
|
-
throw this.#resolveError(spec, options,
|
|
315
|
+
throw this.#resolveError(spec, options, `The registry manifest for ${spec} has no "dist" section, ` +
|
|
316
|
+
`so no tarball can be resolved. The package version may be ` +
|
|
317
|
+
`malformed or unpublished.`);
|
|
246
318
|
const { tarball, integrity } = dist;
|
|
247
319
|
if (!tarball) {
|
|
248
|
-
throw this.#resolveError(spec, options,
|
|
320
|
+
throw this.#resolveError(spec, options, `The registry manifest for ${spec} is missing a tarball URL ` +
|
|
321
|
+
`(dist.tarball). The package version may be malformed or ` +
|
|
322
|
+
`unpublished in this registry.`);
|
|
249
323
|
}
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
324
|
+
const fetchTarball = async (useCache) => {
|
|
325
|
+
const trustIntegrity = this.#trustedIntegrities.get(tarball) === integrity;
|
|
326
|
+
const response = await this.registryClient.request(tarball, {
|
|
327
|
+
...options,
|
|
328
|
+
integrity,
|
|
329
|
+
trustIntegrity,
|
|
330
|
+
...(useCache === false ? { useCache } : {}),
|
|
331
|
+
});
|
|
332
|
+
if (response.statusCode !== 200) {
|
|
333
|
+
throw this.#resolveError(spec, options, `Registry returned HTTP ${response.statusCode} when ` +
|
|
334
|
+
`fetching the tarball for ${spec} at ${tarball}. The ` +
|
|
335
|
+
`version may have been unpublished, or the registry may ` +
|
|
336
|
+
`be misconfigured or unreachable.`, { response, url: tarball });
|
|
337
|
+
}
|
|
338
|
+
// if we don't already trust it, but it's valid, start
|
|
339
|
+
// trusting it
|
|
340
|
+
if (!trustIntegrity &&
|
|
341
|
+
response.checkIntegrity({ spec, url: tarball })) {
|
|
342
|
+
this.#trustedIntegrities.set(tarball, response.integrity);
|
|
343
|
+
}
|
|
344
|
+
const buf = response.buffer();
|
|
345
|
+
// Verify tarball integrity against the manifest's
|
|
346
|
+
// dist.integrity.
|
|
347
|
+
/* c8 ignore start - defense-in-depth (see extract) */
|
|
348
|
+
if (integrity) {
|
|
349
|
+
const hash = createHash('sha512');
|
|
350
|
+
hash.update(buf);
|
|
351
|
+
const computed = `sha512-${hash.digest('base64')}`;
|
|
352
|
+
if (computed !== integrity) {
|
|
353
|
+
throw error('Tarball integrity check failed', {
|
|
354
|
+
code: 'EINTEGRITY',
|
|
355
|
+
spec,
|
|
356
|
+
url: tarball,
|
|
357
|
+
wanted: integrity,
|
|
358
|
+
found: computed,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/* c8 ignore stop */
|
|
363
|
+
return buf;
|
|
364
|
+
};
|
|
365
|
+
try {
|
|
366
|
+
return await fetchTarball();
|
|
258
367
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
368
|
+
catch (er) {
|
|
369
|
+
if (er instanceof Error &&
|
|
370
|
+
'cause' in er &&
|
|
371
|
+
er.cause
|
|
372
|
+
?.code === 'EINTEGRITY') {
|
|
373
|
+
return await fetchTarball(false);
|
|
374
|
+
}
|
|
375
|
+
throw er;
|
|
263
376
|
}
|
|
264
|
-
return response.buffer();
|
|
265
377
|
}
|
|
266
378
|
case 'git': {
|
|
267
379
|
const { remoteURL, gitRemote, gitCommittish, gitSelectorParsed, } = f;
|
|
@@ -356,20 +468,9 @@ export class PackageInfoClient {
|
|
|
356
468
|
// Cache miss, fetch from packument
|
|
357
469
|
}
|
|
358
470
|
}
|
|
359
|
-
const mani =
|
|
360
|
-
await this.#registryManifestRequest(spec, options)
|
|
361
|
-
: pickManifest(await this.packument(f, options), spec, options);
|
|
471
|
+
const mani = pickManifest(await this.packument(f, options), spec, options);
|
|
362
472
|
if (!mani)
|
|
363
473
|
throw this.#resolveError(spec, options);
|
|
364
|
-
const { integrity, tarball } = mani.dist ?? /* c8 ignore next */ {};
|
|
365
|
-
if (isIntegrity(integrity) && tarball) {
|
|
366
|
-
const registryOrigin = new URL(String(f.registry)).origin;
|
|
367
|
-
const tgzOrigin = new URL(tarball).origin;
|
|
368
|
-
// if it comes from the same origin, trust the integrity
|
|
369
|
-
if (tgzOrigin === registryOrigin) {
|
|
370
|
-
this.#trustedIntegrities.set(tarball, integrity);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
474
|
// Cache the manifest data
|
|
374
475
|
if (cachePath) {
|
|
375
476
|
const json = JSON.stringify({
|
|
@@ -404,7 +505,7 @@ export class PackageInfoClient {
|
|
|
404
505
|
await clone(gitRemote, gitCommittish, dir, { spec: s });
|
|
405
506
|
const { path } = gitSelectorParsed ?? {};
|
|
406
507
|
const pkgDir = path !== undefined ? pathResolve(dir, path) : dir;
|
|
407
|
-
return this
|
|
508
|
+
return this.#readExtracted(pkgDir, s, options);
|
|
408
509
|
});
|
|
409
510
|
}
|
|
410
511
|
// fallthrough to remote
|
|
@@ -421,13 +522,20 @@ export class PackageInfoClient {
|
|
|
421
522
|
throw this.#resolveError(s, options, 'failed to fetch URL', { response, url: remoteURL });
|
|
422
523
|
}
|
|
423
524
|
const buf = response.buffer();
|
|
525
|
+
// Compute integrity for remote/git-with-tarball deps
|
|
526
|
+
const computed = ssri
|
|
527
|
+
.fromData(buf, { algorithms: ['sha512'] })
|
|
528
|
+
.toString();
|
|
424
529
|
try {
|
|
425
530
|
await this.tarPool.unpack(buf, dir);
|
|
426
531
|
}
|
|
427
532
|
catch (er) {
|
|
428
533
|
throw this.#resolveError(s, options, 'tar unpack failed', { cause: er });
|
|
429
534
|
}
|
|
430
|
-
return
|
|
535
|
+
// return manifest with computed integrity
|
|
536
|
+
const mani = this.#readExtracted(dir, s, options);
|
|
537
|
+
mani.dist = { integrity: computed };
|
|
538
|
+
return mani;
|
|
431
539
|
});
|
|
432
540
|
}
|
|
433
541
|
case 'file': {
|
|
@@ -447,7 +555,7 @@ export class PackageInfoClient {
|
|
|
447
555
|
catch (er) {
|
|
448
556
|
throw this.#resolveError(s, options, 'tar unpack failed', { cause: er });
|
|
449
557
|
}
|
|
450
|
-
return this
|
|
558
|
+
return this.#readExtracted(dir, s, options);
|
|
451
559
|
});
|
|
452
560
|
}
|
|
453
561
|
case 'workspace': {
|
|
@@ -490,22 +598,35 @@ export class PackageInfoClient {
|
|
|
490
598
|
}
|
|
491
599
|
case 'registry': {
|
|
492
600
|
const { registry, name } = f;
|
|
601
|
+
if (!registry)
|
|
602
|
+
throw noRegistryError(spec);
|
|
603
|
+
const packumentKey = `${registry}${name}`;
|
|
604
|
+
const inflight = this.#packumentPromises.get(packumentKey);
|
|
605
|
+
if (inflight)
|
|
606
|
+
return inflight;
|
|
493
607
|
const pakuURL = new URL(name, registry);
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
url: pakuURL,
|
|
502
|
-
response,
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
return response.json();
|
|
608
|
+
const promise = this.#fetchPackument(spec, options, pakuURL);
|
|
609
|
+
this.#packumentPromises.set(packumentKey, promise);
|
|
610
|
+
// Clean up once settled so we don't leak memory.
|
|
611
|
+
// Use .then/.catch instead of .finally to avoid creating
|
|
612
|
+
// an unhandled rejection from the derived promise.
|
|
613
|
+
promise.then(() => this.#packumentPromises.delete(packumentKey), () => this.#packumentPromises.delete(packumentKey));
|
|
614
|
+
return promise;
|
|
506
615
|
}
|
|
507
616
|
}
|
|
508
617
|
}
|
|
618
|
+
async #fetchPackument(spec, options, pakuURL) {
|
|
619
|
+
const response = await this.registryClient.request(pakuURL, {
|
|
620
|
+
headers: { accept: 'application/json' },
|
|
621
|
+
});
|
|
622
|
+
if (response.statusCode !== 200) {
|
|
623
|
+
throw this.#resolveError(spec, options, 'failed to fetch packument', {
|
|
624
|
+
url: pakuURL,
|
|
625
|
+
response,
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return response.json();
|
|
629
|
+
}
|
|
509
630
|
async resolve(spec, options = {}) {
|
|
510
631
|
const memoKey = String(spec);
|
|
511
632
|
if (typeof spec === 'string')
|
|
@@ -602,6 +723,19 @@ export class PackageInfoClient {
|
|
|
602
723
|
}
|
|
603
724
|
}
|
|
604
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Read the manifest out of a directory we cloned or unpacked. Failures are
|
|
728
|
+
* labeled with the spec, because the internal directory says nothing about
|
|
729
|
+
* which dependency is at fault.
|
|
730
|
+
*/
|
|
731
|
+
#readExtracted(dir, spec, options) {
|
|
732
|
+
try {
|
|
733
|
+
return this.packageJson.read(dir);
|
|
734
|
+
}
|
|
735
|
+
catch (er) {
|
|
736
|
+
throw this.#resolveError(spec, options, 'invalid package manifest', { cause: er });
|
|
737
|
+
}
|
|
738
|
+
}
|
|
605
739
|
async #tmpdir(fn) {
|
|
606
740
|
const p = `package-info/${randomBytes(6).toString('hex')}`;
|
|
607
741
|
const dir = xdg.runtime(p);
|
|
@@ -625,4 +759,3 @@ export class PackageInfoClient {
|
|
|
625
759
|
return er;
|
|
626
760
|
}
|
|
627
761
|
}
|
|
628
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,85 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/package-info",
|
|
3
3
|
"description": "Resolve and fetch package metadata and tarballs",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/package-info"
|
|
9
9
|
},
|
|
10
|
-
"author":
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"dialects": [
|
|
15
|
-
"esm"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
"./package.json": "./package.json",
|
|
19
|
-
".": "./src/index.ts"
|
|
20
|
-
}
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh",
|
|
13
|
+
"url": "http://vlt.sh"
|
|
21
14
|
},
|
|
22
15
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"@vltpkg/
|
|
25
|
-
"@vltpkg/package-json": "1.0.
|
|
26
|
-
"@vltpkg/pick-manifest": "1.0.
|
|
27
|
-
"@vltpkg/registry-client": "1.0.
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/
|
|
30
|
-
"@vltpkg/types": "1.0.
|
|
31
|
-
"@vltpkg/
|
|
32
|
-
"@vltpkg/
|
|
33
|
-
"
|
|
16
|
+
"@vltpkg/error-cause": "1.0.2",
|
|
17
|
+
"@vltpkg/git": "1.0.2",
|
|
18
|
+
"@vltpkg/package-json": "1.0.2",
|
|
19
|
+
"@vltpkg/pick-manifest": "1.0.2",
|
|
20
|
+
"@vltpkg/registry-client": "1.0.2",
|
|
21
|
+
"@vltpkg/spec": "1.0.2",
|
|
22
|
+
"@vltpkg/tar": "1.0.2",
|
|
23
|
+
"@vltpkg/types": "1.0.2",
|
|
24
|
+
"@vltpkg/workspaces": "1.0.2",
|
|
25
|
+
"@vltpkg/xdg": "1.0.2",
|
|
26
|
+
"ssri": "^13.0.0",
|
|
27
|
+
"tar": "^7.5.2"
|
|
34
28
|
},
|
|
35
29
|
"devDependencies": {
|
|
36
|
-
"@eslint/js": "^9.
|
|
37
|
-
"@types/node": "^22.
|
|
30
|
+
"@eslint/js": "^9.39.1",
|
|
31
|
+
"@types/node": "^22.19.2",
|
|
38
32
|
"@types/pacote": "^11.1.8",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
33
|
+
"@vltpkg/benchmark": "0.0.0",
|
|
34
|
+
"@vltpkg/cache-unzip": "1.0.2",
|
|
35
|
+
"@vltpkg/vlt-json": "1.0.2",
|
|
36
|
+
"eslint": "^9.39.1",
|
|
37
|
+
"pacote": "^21.0.4",
|
|
38
|
+
"prettier": "^3.7.4",
|
|
39
|
+
"tap": "^21.5.0",
|
|
44
40
|
"typedoc": "~0.27.9",
|
|
45
41
|
"typescript": "5.7.3",
|
|
46
|
-
"typescript-eslint": "^8.
|
|
47
|
-
"@vltpkg/benchmark": "0.0.0",
|
|
48
|
-
"@vltpkg/cache-unzip": "1.0.0-rc.9",
|
|
49
|
-
"@vltpkg/vlt-json": "1.0.0-rc.9"
|
|
42
|
+
"typescript-eslint": "^8.49.0"
|
|
50
43
|
},
|
|
51
44
|
"license": "BSD-2-Clause-Patent",
|
|
52
45
|
"engines": {
|
|
53
|
-
"node": ">=22"
|
|
46
|
+
"node": ">=22.22.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"benchmark": "./scripts/benchmark.ts",
|
|
50
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
51
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
52
|
+
"lint": "eslint . --fix",
|
|
53
|
+
"lint:check": "eslint .",
|
|
54
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
55
|
+
"snap": "tap",
|
|
56
|
+
"test": "tap",
|
|
57
|
+
"posttest": "tsc --noEmit",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
54
59
|
},
|
|
55
60
|
"tap": {
|
|
56
61
|
"extends": "../../tap-config.yaml"
|
|
57
62
|
},
|
|
58
63
|
"prettier": "../../.prettierrc.js",
|
|
59
|
-
"module": "./dist/
|
|
64
|
+
"module": "./dist/index.js",
|
|
60
65
|
"type": "module",
|
|
61
66
|
"exports": {
|
|
62
67
|
"./package.json": "./package.json",
|
|
63
68
|
".": {
|
|
64
69
|
"import": {
|
|
65
|
-
"
|
|
66
|
-
"default": "./dist/esm/index.js"
|
|
70
|
+
"default": "./dist/index.js"
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
74
|
"files": [
|
|
71
75
|
"dist"
|
|
72
76
|
],
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"posttest": "tsc --noEmit",
|
|
82
|
-
"tshy": "tshy",
|
|
83
|
-
"typecheck": "tsc --noEmit"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
77
|
+
"bugs": [
|
|
78
|
+
{
|
|
79
|
+
"type": "link",
|
|
80
|
+
"url": "https://github.com/vltpkg/vltpkg/issues"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"homepage": "https://github.com/vltpkg/vltpkg/tree/main/src/package-info#readme"
|
|
84
|
+
}
|
package/dist/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,OAAO,KAAK,EACV,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,KAAK,EACV,S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;IAED,kBAAkB;IAClB,aAAa,CACX,IAAW,EACX,UAA2C,EAAE,EAC7C,OAAO,GAAG,mBAAmB,EAC7B,QAA2B,EAAE;QAE7B,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,OAAO,CAAA;QAC5C,MAAM,EAAE,GAAG,KAAK,CACd,OAAO,EACP;YACE,IAAI,EAAE,UAAU;YAChB,IAAI;YACJ,IAAI;YACJ,GAAG,KAAK;SACT,EACD,IAAI,CAAC,aAAa,CACnB,CAAA;QACD,OAAO,EAAE,CAAA;IACX,CAAC;CACF","sourcesContent":["import type { ErrorCauseOptions } from '@vltpkg/error-cause'\nimport { error } from '@vltpkg/error-cause'\nimport { clone, resolve as gitResolve, revs } from '@vltpkg/git'\nimport { PackageJson } from '@vltpkg/package-json'\nimport type { PickManifestOptions } from '@vltpkg/pick-manifest'\nimport { pickManifest } from '@vltpkg/pick-manifest'\nimport type {\n RegistryClientOptions,\n RegistryClientRequestOptions,\n} from '@vltpkg/registry-client'\nimport { RegistryClient } from '@vltpkg/registry-client'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { Spec } from '@vltpkg/spec'\nimport { Pool } from '@vltpkg/tar'\nimport type {\n Integrity,\n Manifest,\n Packument,\n ManifestRegistry,\n} from '@vltpkg/types'\nimport { asPackument, isIntegrity } from '@vltpkg/types'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { XDG } from '@vltpkg/xdg'\nimport { randomBytes } from 'node:crypto'\nimport {\n mkdir,\n readFile,\n rm,\n stat,\n symlink,\n unlink,\n writeFile,\n} from 'node:fs/promises'\nimport {\n basename,\n dirname,\n resolve as pathResolve,\n relative,\n} from 'node:path'\nimport { create as tarC } from 'tar'\nimport { rename } from './rename.ts'\n\nconst xdg = new XDG('vlt')\nexport const delimiter = '·'\n\nexport type Resolution = {\n resolved: string\n integrity?: Integrity\n signatures?: Exclude<Manifest['dist'], undefined>['signatures']\n spec: Spec\n}\n\nexport type PackageInfoClientOptions = RegistryClientOptions &\n SpecOptions & {\n /** root of the project. Defaults to process.cwd() */\n projectRoot?: string\n /** PackageJson object */\n packageJson?: PackageJson\n\n monorepo?: Monorepo\n\n /** workspace groups to load, irrelevant if Monorepo provided */\n 'workspace-group'?: string[]\n\n /** workspace paths to load, irrelevant if Monorepo provided */\n workspace?: string[]\n }\n\nexport type PackageInfoClientRequestOptions = PickManifestOptions &\n RegistryClientRequestOptions & {\n /** dir to resolve `file://` specifiers against. Defaults to projectRoot. */\n from?: string\n }\n\nexport type PackageInfoClientExtractOptions =\n PackageInfoClientRequestOptions & {\n integrity?: Integrity\n resolved?: string\n }\n\n// the maximum duration of a manifest cache file\nconst manifestCacheMaxAge = 5 * 60 * 1000\n\nexport class PackageInfoClient {\n #registryClient?: RegistryClient\n #projectRoot: string\n #tarPool?: Pool\n options: PackageInfoClientOptions\n #resolutions = new Map<string, Resolution>()\n packageJson: PackageJson\n monorepo?: Monorepo\n #trustedIntegrities = new Map<string, Integrity>()\n #manifestCacheMinAge = Date.now() - manifestCacheMaxAge\n #cachePath: string\n\n get registryClient() {\n if (!this.#registryClient) {\n this.#registryClient = new RegistryClient(this.options)\n }\n return this.#registryClient\n }\n\n get tarPool() {\n if (!this.#tarPool) this.#tarPool = new Pool()\n return this.#tarPool\n }\n\n constructor(options: PackageInfoClientOptions = {}) {\n this.options = options\n this.#projectRoot = options.projectRoot || process.cwd()\n this.packageJson = options.packageJson ?? new PackageJson()\n const wsLoad = {\n ...(options.workspace?.length && { paths: options.workspace }),\n ...(options['workspace-group']?.length && {\n groups: options['workspace-group'],\n }),\n }\n this.monorepo =\n options.monorepo ??\n Monorepo.maybeLoad(this.#projectRoot, {\n load: wsLoad,\n packageJson: this.packageJson,\n })\n this.#cachePath = options.cache ?? xdg.cache()\n // optionally create its cache directory if it doesn't exist\n void mkdir(pathResolve(this.#cachePath, 'package-info'), {\n recursive: true,\n }).catch(() => {})\n }\n\n async extract(\n spec: Spec | string,\n target: string,\n options: PackageInfoClientExtractOptions = {},\n ): Promise<Resolution> {\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const { from = this.#projectRoot, integrity, resolved } = options\n const f = spec.final\n const r =\n integrity && resolved ?\n { resolved, integrity, spec }\n : await this.resolve(spec, options)\n\n switch (f.type) {\n case 'git': {\n const {\n gitRemote,\n gitCommittish,\n remoteURL,\n gitSelectorParsed,\n } = f\n if (!remoteURL) {\n /* c8 ignore start - Impossible, would throw on the resolve */\n if (!gitRemote)\n throw this.#resolveError(\n spec,\n options,\n 'no remote on git: specifier',\n )\n /* c8 ignore stop */\n const { path } = gitSelectorParsed ?? {}\n if (path !== undefined) {\n // use obvious name because it's in node_modules\n const tmp = pathResolve(\n dirname(target),\n `.TEMP.${basename(target)}-${randomBytes(6).toString('hex')}`,\n )\n await clone(gitRemote, gitCommittish, tmp, { spec })\n const src = pathResolve(tmp, path)\n await rename(src, target)\n // intentionally not awaited\n void rm(tmp, { recursive: true, force: true })\n } else {\n await clone(gitRemote, gitCommittish, target, { spec })\n // intentionally not awaited\n void rm(target + '/.git', { recursive: true })\n }\n return r\n }\n // fallthrough if a remote tarball url present\n }\n\n case 'registry':\n case 'remote': {\n const trustIntegrity =\n this.#trustedIntegrities.get(r.resolved) === r.integrity\n\n const response = await this.registryClient.request(\n r.resolved,\n {\n integrity: r.integrity,\n trustIntegrity,\n },\n )\n\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to fetch tarball',\n {\n url: r.resolved,\n response,\n },\n )\n }\n\n // if it's not trusted already, but valid, start trusting\n if (\n !trustIntegrity &&\n response.checkIntegrity({ spec, url: resolved })\n ) {\n this.#trustedIntegrities.set(r.resolved, response.integrity)\n }\n\n try {\n await this.tarPool.unpack(response.buffer(), target)\n } catch (er) {\n throw this.#resolveError(\n spec,\n options,\n 'tar unpack failed',\n { cause: er },\n )\n }\n return r\n }\n case 'file': {\n // if it's a directory, then \"extract\" means \"symlink\"\n const { file } = f\n /* c8 ignore start - asserted in resolve() */\n if (file === undefined)\n throw this.#resolveError(spec, options, 'no file path')\n /* c8 ignore stop */\n const path = pathResolve(from, file)\n const st = await stat(path)\n if (st.isFile()) {\n try {\n await this.tarPool.unpack(\n await this.tarball(spec, options),\n target,\n )\n } catch (er) {\n throw this.#resolveError(\n spec,\n options,\n 'tar unpack failed',\n { cause: er },\n )\n }\n } else if (st.isDirectory()) {\n const rel = relative(dirname(target), path)\n await symlink(rel, target, 'dir')\n /* c8 ignore start */\n } else {\n throw this.#resolveError(\n spec,\n options,\n 'file: specifier does not resolve to directory or tarball',\n )\n }\n /* c8 ignore stop */\n return r\n }\n case 'workspace': {\n const ws = this.#getWS(spec, options)\n const rel = relative(dirname(target), ws.fullpath)\n await symlink(rel, target, 'dir')\n return r\n }\n }\n }\n\n #getWS(spec: Spec, options: PackageInfoClientRequestOptions) {\n const { workspace } = spec\n /* c8 ignore start - asserted in resolve() */\n if (workspace === undefined)\n throw this.#resolveError(spec, options, 'no workspace ID')\n /* c8 ignore stop */\n if (!this.monorepo) {\n throw this.#resolveError(\n spec,\n options,\n 'Not in a monorepo, cannot resolve workspace spec',\n )\n }\n const ws = this.monorepo.get(workspace)\n if (!ws) {\n throw this.#resolveError(spec, options, 'workspace not found', {\n wanted: workspace,\n })\n }\n return ws\n }\n\n /**\n * Return the manifest cache key for a spec and the current options.\n */\n #manifestCacheKey(\n spec: Spec,\n options: PackageInfoClientRequestOptions,\n ): string {\n let extra = ''\n if (options['node-version']) {\n extra += `${delimiter}node-version:${options['node-version']}`\n }\n if (options.os) {\n extra += `${delimiter}os:${options.os}`\n }\n if (options.arch) {\n extra += `${delimiter}arch:${options.arch}`\n }\n return encodeURIComponent(\n `${spec.registry}${delimiter}${spec}${extra}`,\n )\n }\n\n /**\n * Conditionally return the path to the manifest cache file. The logic\n * to determine if caching should be skipped aligns with `pickManifest`\n * and is used to avoid caching manifest results that can be variable.\n */\n _manifestCachePath(\n spec: Spec,\n options: PackageInfoClientRequestOptions,\n ): string | undefined {\n if (options.before) {\n return\n }\n // if the final resolved spec is either a dist tag or something that\n // matches any range (such as a semver range of `*` or empty string)\n // then we skip caching\n const f = spec.final\n if (f.distTag || f.range?.isAny) {\n return\n }\n const key = this.#manifestCacheKey(f, options)\n return pathResolve(this.#cachePath, 'package-info', key)\n }\n\n async #registryManifestRequest(\n spec: Spec,\n options: PackageInfoClientRequestOptions,\n ): Promise<ManifestRegistry> {\n const { registry, name, registrySpec } = spec.final\n /* c8 ignore start */\n if (!spec.range?.isSingle || !registrySpec) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to request manifest',\n { spec },\n )\n }\n /* c8 ignore stop */\n const possibleLeadingChars = ['=', '^', '~', 'v']\n const hasLeadingRange = possibleLeadingChars.some(char =>\n registrySpec.startsWith(char),\n )\n const version =\n hasLeadingRange ? registrySpec.slice(1) : registrySpec\n const pakuURL = new URL(`${name}/${version}`, registry)\n const response = await this.registryClient.request(pakuURL, {\n headers: {\n accept: 'application/json',\n },\n })\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to fetch manifest',\n {\n url: pakuURL,\n response,\n },\n )\n }\n return response.json() as ManifestRegistry\n }\n\n async tarball(\n spec: Spec | string,\n options: PackageInfoClientExtractOptions = {},\n ): Promise<Buffer> {\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const f = spec.final\n\n switch (f.type) {\n case 'registry': {\n const { dist } = await this.manifest(spec, options)\n if (!dist)\n throw this.#resolveError(\n spec,\n options,\n 'no dist object found in manifest',\n )\n\n const { tarball, integrity } = dist\n if (!tarball) {\n throw this.#resolveError(\n spec,\n options,\n 'no tarball found in manifest.dist',\n )\n }\n\n const trustIntegrity =\n this.#trustedIntegrities.get(tarball) === integrity\n\n const response = await this.registryClient.request(tarball, {\n ...options,\n integrity,\n trustIntegrity,\n })\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to fetch tarball',\n { response, url: tarball },\n )\n }\n\n // if we don't already trust it, but it's valid, start trusting it\n if (\n !trustIntegrity &&\n response.checkIntegrity({ spec, url: tarball })\n ) {\n this.#trustedIntegrities.set(tarball, response.integrity)\n }\n\n return response.buffer()\n }\n\n case 'git': {\n const {\n remoteURL,\n gitRemote,\n gitCommittish,\n gitSelectorParsed,\n } = f\n const s: Spec = spec\n if (!remoteURL) {\n if (!gitRemote) {\n throw this.#resolveError(\n spec,\n options,\n 'no remote on git: specifier',\n )\n }\n const { path } = gitSelectorParsed ?? {}\n return await this.#tmpdir(async dir => {\n await clone(gitRemote, gitCommittish, dir + '/package', {\n spec: s,\n })\n let cwd = dir\n if (path !== undefined) {\n const src = pathResolve(dir, 'package', path)\n cwd = dirname(src)\n const pkg = pathResolve(cwd, 'package')\n if (src !== pkg) {\n const rand = randomBytes(6).toString('hex')\n // faster than deleting\n await rename(pkg, pkg + rand).catch(() => {})\n await rename(src, pkg)\n }\n }\n return tarC({ cwd, gzip: true }, ['package']).concat()\n })\n }\n // fallthrough if remoteURL set\n }\n\n case 'remote': {\n const { remoteURL } = f\n if (!remoteURL) {\n throw this.#resolveError(spec, options)\n }\n const response = await this.registryClient.request(remoteURL)\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to fetch URL',\n { response, url: remoteURL },\n )\n }\n return response.buffer()\n }\n\n case 'file': {\n const { file } = f\n if (file === undefined)\n throw this.#resolveError(spec, options, 'no file path')\n const { from = this.#projectRoot } = options\n const path = pathResolve(from, file)\n const st = await stat(path)\n if (st.isDirectory()) {\n const p = dirname(path)\n const b = basename(path)\n // TODO: Pack properly, ignore stuff, bundleDeps, etc\n return tarC({ cwd: p, gzip: true }, [b]).concat()\n }\n return readFile(path)\n }\n\n case 'workspace': {\n // TODO: Pack properly, ignore stuff, bundleDeps, etc\n const ws = this.#getWS(spec, options)\n const p = dirname(ws.fullpath)\n const b = basename(ws.fullpath)\n return tarC({ cwd: p, gzip: true }, [b]).concat()\n }\n }\n }\n\n async manifest(\n spec: Spec | string,\n options: PackageInfoClientRequestOptions = {},\n ) {\n const { from = this.#projectRoot } = options\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const f = spec.final\n\n switch (f.type) {\n case 'registry': {\n // Check if manifest is cached, if so just return it earlier\n const cachePath = this._manifestCachePath(spec, options)\n if (cachePath) {\n try {\n // Cache file exists, read and return it\n const cached = await readFile(cachePath, 'utf8')\n const json = JSON.parse(cached) as Manifest & {\n __VLT_MANIFEST_CACHE_TIMESTAMP?: number\n }\n // retrieve timestamp to check if cache is still valid\n const timestamp = json.__VLT_MANIFEST_CACHE_TIMESTAMP\n delete json.__VLT_MANIFEST_CACHE_TIMESTAMP\n // removes the cache file if older than its maximum age\n if (\n timestamp != null &&\n timestamp < this.#manifestCacheMinAge\n ) {\n void unlink(cachePath).catch(() => {})\n throw new Error('manifest cache expired')\n }\n return json\n } catch {\n // Cache miss, fetch from packument\n }\n }\n\n const mani =\n spec.range?.isSingle ?\n await this.#registryManifestRequest(spec, options)\n : pickManifest(\n await this.packument(f, options),\n spec,\n options,\n )\n if (!mani) throw this.#resolveError(spec, options)\n const { integrity, tarball } =\n mani.dist ?? /* c8 ignore next */ {}\n if (isIntegrity(integrity) && tarball) {\n const registryOrigin = new URL(String(f.registry)).origin\n const tgzOrigin = new URL(tarball).origin\n // if it comes from the same origin, trust the integrity\n if (tgzOrigin === registryOrigin) {\n this.#trustedIntegrities.set(tarball, integrity)\n }\n }\n\n // Cache the manifest data\n if (cachePath) {\n const json = JSON.stringify({\n ...mani,\n // append a timestamp to the manifest so that we can quickly\n // check if the cache is still valid when loading it\n __VLT_MANIFEST_CACHE_TIMESTAMP: Date.now(),\n })\n void writeFile(cachePath, json, 'utf8').catch(\n (err: unknown) => {\n // in case the cache directory doesn't exist\n // just create it and retry\n if (\n err instanceof Error &&\n 'code' in err &&\n err.code === 'ENOENT'\n ) {\n void mkdir(dirname(cachePath), {\n recursive: true,\n }).then(() => {\n void writeFile(cachePath, json, 'utf8')\n })\n }\n },\n )\n }\n\n return mani\n }\n\n case 'git': {\n const {\n gitRemote,\n gitCommittish,\n remoteURL,\n gitSelectorParsed,\n } = f\n if (!remoteURL) {\n const s = spec\n if (!gitRemote)\n throw this.#resolveError(spec, options, 'no git remote')\n return await this.#tmpdir(async dir => {\n await clone(gitRemote, gitCommittish, dir, { spec: s })\n const { path } = gitSelectorParsed ?? {}\n const pkgDir =\n path !== undefined ? pathResolve(dir, path) : dir\n return this.packageJson.read(pkgDir)\n })\n }\n // fallthrough to remote\n }\n\n case 'remote': {\n const { remoteURL } = f\n if (!remoteURL) {\n throw this.#resolveError(\n spec,\n options,\n 'no remoteURL on remote specifier',\n )\n }\n const s = spec\n return await this.#tmpdir(async dir => {\n const response =\n await this.registryClient.request(remoteURL)\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n s,\n options,\n 'failed to fetch URL',\n { response, url: remoteURL },\n )\n }\n const buf = response.buffer()\n try {\n await this.tarPool.unpack(buf, dir)\n } catch (er) {\n throw this.#resolveError(\n s,\n options,\n 'tar unpack failed',\n { cause: er },\n )\n }\n return this.packageJson.read(dir)\n })\n }\n\n case 'file': {\n const { file } = f\n if (file === undefined)\n throw this.#resolveError(spec, options, 'no file path')\n const path = pathResolve(from, file)\n const st = await stat(path)\n if (st.isDirectory()) {\n return this.packageJson.read(path)\n }\n const s = spec\n return await this.#tmpdir(async dir => {\n try {\n await this.tarPool.unpack(await readFile(path), dir)\n } catch (er) {\n throw this.#resolveError(\n s,\n options,\n 'tar unpack failed',\n { cause: er },\n )\n }\n return this.packageJson.read(dir)\n })\n }\n\n case 'workspace': {\n return this.#getWS(spec, options).manifest\n }\n }\n }\n\n async packument(\n spec: Spec | string,\n options: PackageInfoClientRequestOptions = {},\n ): Promise<Packument> {\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const f = spec.final\n switch (f.type) {\n // RevDoc is the equivalent of a packument for a git repo\n case 'git': {\n const { gitRemote } = f\n if (!gitRemote) {\n throw this.#resolveError(\n spec,\n options,\n 'git remote could not be determined',\n )\n }\n const revDoc = await revs(gitRemote, {\n cwd: this.options.projectRoot,\n })\n if (!revDoc) throw this.#resolveError(spec, options)\n return asPackument(revDoc)\n }\n\n // these are all faked packuments\n case 'file':\n case 'workspace':\n case 'remote': {\n const manifest = await this.manifest(f, options)\n return {\n name: manifest.name ?? '',\n 'dist-tags': {\n latest: manifest.version ?? '',\n },\n versions: {\n [manifest.version ?? '']: manifest as Manifest,\n },\n }\n }\n\n case 'registry': {\n const { registry, name } = f\n const pakuURL = new URL(name, registry)\n const response = await this.registryClient.request(pakuURL, {\n headers: {\n accept: 'application/json',\n },\n })\n if (response.statusCode !== 200) {\n throw this.#resolveError(\n spec,\n options,\n 'failed to fetch packument',\n {\n url: pakuURL,\n response,\n },\n )\n }\n return response.json() as Packument\n }\n }\n }\n\n async resolve(\n spec: Spec | string,\n options: PackageInfoClientRequestOptions = {},\n ): Promise<Resolution> {\n const memoKey = String(spec)\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n\n const memo = this.#resolutions.get(memoKey)\n if (memo) return memo\n const f = spec.final\n\n switch (f.type) {\n case 'file': {\n const { file } = f\n if (!file || !f.file) {\n throw this.#resolveError(\n spec,\n options,\n 'no path on file: specifier',\n )\n }\n const { from = this.#projectRoot } = options\n const resolved = pathResolve(from, f.file)\n const r = { resolved, spec }\n this.#resolutions.set(memoKey, r)\n return r\n }\n\n case 'remote': {\n const { remoteURL } = f\n if (!remoteURL)\n throw this.#resolveError(\n spec,\n options,\n 'no URL in remote specifier',\n )\n const r = { resolved: remoteURL, spec }\n this.#resolutions.set(memoKey, r)\n return r\n }\n\n case 'workspace': {\n const ws = this.#getWS(spec, options)\n return {\n resolved: ws.fullpath,\n spec,\n }\n }\n\n case 'registry': {\n const mani = await this.manifest(spec, options)\n if (mani.dist) {\n const { integrity, tarball, signatures } = mani.dist\n if (tarball) {\n const r = {\n resolved: tarball,\n integrity,\n signatures,\n spec,\n }\n this.#resolutions.set(memoKey, r)\n return r\n }\n }\n throw this.#resolveError(spec, options)\n }\n\n case 'git': {\n const { gitRemote, remoteURL, gitSelectorParsed } = f\n if (remoteURL && gitSelectorParsed?.path === undefined) {\n // known git host with a tarball download endpoint\n const r = { resolved: remoteURL, spec }\n this.#resolutions.set(memoKey, r)\n return r\n }\n if (!gitRemote) {\n throw this.#resolveError(\n spec,\n options,\n 'no remote on git specifier',\n )\n }\n const rev = await gitResolve(gitRemote, f.gitCommittish, {\n spec,\n })\n if (rev) {\n const r = {\n resolved: `${gitRemote}#${rev.sha}`,\n spec,\n }\n if (gitSelectorParsed) {\n r.resolved += Object.entries(gitSelectorParsed)\n .filter(([_, v]) => v)\n .map(([k, v]) => `::${k}:${v}`)\n .join('')\n }\n this.#resolutions.set(memoKey, r)\n return r\n }\n // have to actually clone somewhere\n const s: Spec = spec\n return this.#tmpdir(async tmpdir => {\n const sha = await clone(\n gitRemote,\n s.gitCommittish,\n tmpdir,\n {\n spec: s,\n },\n )\n const r = {\n resolved: `${gitRemote}#${sha}`,\n spec: s,\n }\n this.#resolutions.set(memoKey, r)\n return r\n })\n }\n }\n }\n\n async #tmpdir<T>(fn: (dir: string) => Promise<T>): Promise<T> {\n const p = `package-info/${randomBytes(6).toString('hex')}`\n const dir = xdg.runtime(p)\n try {\n return await fn(dir)\n } finally {\n // intentionally do not await\n void rm(dir, { recursive: true, force: true })\n }\n }\n\n // error resolving\n #resolveError(\n spec?: Spec,\n options: PackageInfoClientRequestOptions = {},\n message = 'Could not resolve',\n extra: ErrorCauseOptions = {},\n ) {\n const { from = this.#projectRoot } = options\n const er = error(\n message,\n {\n code: 'ERESOLVE',\n spec,\n from,\n ...extra,\n },\n this.#resolveError,\n )\n return er\n }\n}\n"]}
|
package/dist/esm/package.json
DELETED
package/dist/esm/rename.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../src/rename.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAM,MAAM,kBAAkB,CAAA;AACzD,eAAO,MAAM,MAAM,iBAqBhB,CAAA"}
|
package/dist/esm/rename.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/rename.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;AAE5B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACzD,MAAM,CAAC,MAAM,MAAM,GACjB,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAChC,KAAK,WACH,OAAiB,EACjB,OAAiB;IAEjB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,MAAM,KAAK,GAAG,KAAK,EAAE,EAAW,EAAiB,EAAE;QACjD,IACE,OAAO,GAAG,CAAC;YACV,EAA4B,CAAC,IAAI,KAAK,OAAO,EAC9C,CAAC;YACD,OAAO,EAAE,CAAA;YACT,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YACnD,OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,KAAK,CAAC,CAAA;QACzD,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC,CAAA;IACD,OAAO,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,KAAK,CAAC,CAAA;AACzD,CAAC,CACF,CAAA","sourcesContent":["/**\n * On posix systems, rename is atomic and will clobber anything in its way\n * However, on Windows, it can fail with the rather unhelpful EPERM error if\n * the target directory is not removed in time or is currently in use.\n *\n * While true atomic semantics is not available on Windows in this case, we can\n * at least implement the posix overwrite semantics by explicitly removing the\n * target when this error occurs.\n *\n * This is only relevant when renaming *directories*, since files will\n * generally not raise problems. When/if we rename directories outside of\n * package-info, this can be moved to its own shared module.\n * @module\n */\nconst { platform } = process\nimport type { PathLike } from 'node:fs'\nimport { rename as fsRename, rm } from 'node:fs/promises'\nexport const rename =\n platform !== 'win32' ? fsRename : (\n async function (\n oldPath: PathLike,\n newPath: PathLike,\n ): Promise<void> {\n let retries = 3\n const retry = async (er: unknown): Promise<void> => {\n if (\n retries > 0 &&\n (er as NodeJS.ErrnoException).code === 'EPERM'\n ) {\n retries--\n await rm(newPath, { recursive: true, force: true })\n return fsRename(oldPath, newPath).then(() => {}, retry)\n } else {\n throw er\n }\n }\n return fsRename(oldPath, newPath).then(() => {}, retry)\n }\n )\n"]}
|