@vltpkg/package-info 0.0.0-0.1730239248325

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright (c) vlt technology, Inc.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
7
+ Subject to the terms and conditions of this license, each copyright holder and contributor hereby grants to those receiving rights under this license a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except for failure to satisfy the conditions of this license) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer this software, where such license applies only to those patent claims, already acquired or hereafter acquired, licensable by such copyright holder or contributor that are necessarily infringed by:
8
+
9
+ (a) their Contribution(s) (the licensed copyrights of copyright holders and non-copyrightable additions of contributors, in source or binary form) alone; or
10
+ (b) combination of their Contribution(s) with the work of authorship to which such Contribution(s) was added by such copyright holder or contributor, if, at the time the Contribution is added, such addition causes such combination to be necessarily infringed. The patent license shall not apply to any other combinations which include the Contribution.
11
+ Except as expressly stated above, no rights or licenses from any copyright holder or contributor is granted under this license, whether expressly, by implication, estoppel or otherwise.
12
+
13
+ DISCLAIMER
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # `@vltpkg/package-info`
2
+
3
+ Get information about packages.
4
+
5
+ Spiritual descendant of [pacote](http://npm.im/pacote).
6
+
7
+ ## USAGE
8
+
9
+ ```js
10
+ import {
11
+ manifest,
12
+ tarball,
13
+ packument,
14
+ resolve,
15
+ } from '@vltpkg/packge-info'
16
+
17
+ // get the full packument for the named package
18
+ // note that the '@2' part of the spec is irrelevant here,
19
+ // if it's a semver range.
20
+ console.log(await packument('bar@2'))
21
+ // get the manifest for a single version, resolving it.
22
+ console.log(await manifest('foo@latest'))
23
+ // get the tarball as a Buffer
24
+ const tarballBuffer = await tarball('foo@1.x')
25
+ // just figure out what it resolves to
26
+ const { resolved, integrity } = await resolve('bar@latest')
27
+ ```
@@ -0,0 +1,49 @@
1
+ import { PackageJson } from '@vltpkg/package-json';
2
+ import { PickManifestOptions } from '@vltpkg/pick-manifest';
3
+ import { RegistryClient, RegistryClientOptions } from '@vltpkg/registry-client';
4
+ import { Spec, type SpecOptions } from '@vltpkg/spec';
5
+ import { Pool } from '@vltpkg/tar';
6
+ import { Integrity, Manifest, Packument } from '@vltpkg/types';
7
+ import { Monorepo } from '@vltpkg/workspaces';
8
+ export type Resolution = {
9
+ resolved: string;
10
+ integrity?: Integrity;
11
+ signatures?: Exclude<Manifest['dist'], undefined>['signatures'];
12
+ spec: Spec;
13
+ };
14
+ export type PackageInfoClientOptions = RegistryClientOptions & SpecOptions & {
15
+ /** root of the project. Defaults to process.cwd() */
16
+ projectRoot?: string;
17
+ /** PackageJson object */
18
+ packageJson?: PackageJson;
19
+ monorepo?: Monorepo;
20
+ /** workspace groups to load, irrelevant if Monorepo provided */
21
+ 'workspace-group'?: string[];
22
+ /** workspace paths to load, irrelevant if Monorepo provided */
23
+ workspace?: string[];
24
+ };
25
+ export type PackageInfoClientRequestOptions = PickManifestOptions & {
26
+ /** dir to resolve `file://` specifiers against. Defaults to projectRoot. */
27
+ from?: string;
28
+ };
29
+ export type PackageInfoClientAllOptions = PackageInfoClientOptions & PackageInfoClientRequestOptions;
30
+ export declare const packument: (spec: Spec | string, options?: PackageInfoClientAllOptions) => Promise<Packument>;
31
+ export declare const manifest: (spec: Spec | string, options?: PackageInfoClientAllOptions) => Promise<Manifest>;
32
+ export declare const resolve: (spec: Spec | string, options?: PackageInfoClientAllOptions) => Promise<Resolution>;
33
+ export declare const tarball: (spec: Spec | string, options?: PackageInfoClientAllOptions) => Promise<Buffer>;
34
+ export declare const extract: (spec: Spec | string, target: string, options?: PackageInfoClientAllOptions) => Promise<Resolution>;
35
+ export declare class PackageInfoClient {
36
+ #private;
37
+ options: PackageInfoClientOptions;
38
+ packageJson: PackageJson;
39
+ monorepo?: Monorepo;
40
+ get registryClient(): RegistryClient;
41
+ get tarPool(): Pool;
42
+ constructor(options?: PackageInfoClientOptions);
43
+ extract(spec: Spec | string, target: string, options?: PackageInfoClientRequestOptions): Promise<Resolution>;
44
+ tarball(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Buffer>;
45
+ manifest(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Manifest>;
46
+ packument(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Packument>;
47
+ resolve(spec: Spec | string, options?: PackageInfoClientRequestOptions): Promise<Resolution>;
48
+ }
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAs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from '@vltpkg/package-json';
4
+ import { pickManifest, } from '@vltpkg/pick-manifest';
5
+ import { RegistryClient, } from '@vltpkg/registry-client';
6
+ import { Spec } from '@vltpkg/spec';
7
+ import { Pool } from '@vltpkg/tar';
8
+ import { asPackument, } from '@vltpkg/types';
9
+ import { Monorepo } from '@vltpkg/workspaces';
10
+ import { XDG } from '@vltpkg/xdg';
11
+ import { randomBytes } from 'crypto';
12
+ import { readFile, rm, stat, symlink } from 'fs/promises';
13
+ import { basename, dirname, relative, resolve as pathResolve, } from 'path';
14
+ import { create as tarC } from 'tar';
15
+ import { rename } from './rename.js';
16
+ const xdg = new XDG('vlt');
17
+ // provide some helper methods at the top level. Re-use the client if
18
+ // the same options are provided.
19
+ const clients = new Map();
20
+ const client = (o = {}) => {
21
+ const { from: _from, packageJson: _packageJson, workspace: _workspace, 'workspace-group': _workspaceGroup, ...opts } = o;
22
+ const key = JSON.stringify(Object.entries(opts).sort(([a], [b]) => a.localeCompare(b, 'en')));
23
+ const c = clients.get(key) ?? new PackageInfoClient(opts);
24
+ clients.set(key, c);
25
+ return c;
26
+ };
27
+ export const packument = async (spec, options = {}) => client(options).packument(spec, options);
28
+ export const manifest = async (spec, options = {}) => client(options).manifest(spec, options);
29
+ export const resolve = async (spec, options = {}) => client(options).resolve(spec, options);
30
+ export const tarball = async (spec, options = {}) => client(options).tarball(spec, options);
31
+ export const extract = async (spec, target, options = {}) => client(options).extract(spec, target, options);
32
+ export class PackageInfoClient {
33
+ #registryClient;
34
+ #projectRoot;
35
+ #tarPool;
36
+ options;
37
+ #resolutions = new Map();
38
+ packageJson;
39
+ monorepo;
40
+ get registryClient() {
41
+ if (!this.#registryClient) {
42
+ this.#registryClient = new RegistryClient(this.options);
43
+ }
44
+ return this.#registryClient;
45
+ }
46
+ get tarPool() {
47
+ if (!this.#tarPool)
48
+ this.#tarPool = new Pool();
49
+ return this.#tarPool;
50
+ }
51
+ constructor(options = {}) {
52
+ this.options = options;
53
+ this.#projectRoot = options.projectRoot || process.cwd();
54
+ this.packageJson = options.packageJson ?? new PackageJson();
55
+ const wsLoad = {
56
+ ...(options.workspace?.length && { paths: options.workspace }),
57
+ ...(options['workspace-group']?.length && {
58
+ groups: options['workspace-group'],
59
+ }),
60
+ };
61
+ this.monorepo =
62
+ options.monorepo ??
63
+ Monorepo.maybeLoad(this.#projectRoot, {
64
+ load: wsLoad,
65
+ packageJson: this.packageJson,
66
+ });
67
+ }
68
+ async extract(spec, target, options = {}) {
69
+ if (typeof spec === 'string')
70
+ spec = Spec.parse(spec, this.options);
71
+ const f = spec.final;
72
+ const r = await this.resolve(spec, options);
73
+ const { from = this.#projectRoot } = options;
74
+ switch (f.type) {
75
+ case 'git': {
76
+ const { gitRemote, gitCommittish, remoteURL, gitSelectorParsed, } = f;
77
+ if (!remoteURL) {
78
+ /* c8 ignore start - Impossible, would throw on the resolve */
79
+ if (!gitRemote)
80
+ throw this.#resolveError(spec, options, 'no remote on git: specifier');
81
+ /* c8 ignore stop */
82
+ const { path } = gitSelectorParsed ?? {};
83
+ if (path !== undefined) {
84
+ // use obvious name because it's in node_modules
85
+ const tmp = pathResolve(dirname(target), `.TEMP.${basename(target)}-${randomBytes(6).toString('hex')}`);
86
+ await clone(gitRemote, gitCommittish, tmp, { spec });
87
+ const src = pathResolve(tmp, path);
88
+ await rename(src, target);
89
+ // intentionally not awaited
90
+ void rm(tmp, { recursive: true, force: true });
91
+ }
92
+ else {
93
+ await clone(gitRemote, gitCommittish, target, { spec });
94
+ // intentionally not awaited
95
+ void rm(target + '/.git', { recursive: true });
96
+ }
97
+ return r;
98
+ }
99
+ // fallthrough if a remote tarball url present
100
+ }
101
+ case 'registry':
102
+ case 'remote': {
103
+ const response = await this.registryClient.request(r.resolved, {
104
+ integrity: r.integrity,
105
+ });
106
+ if (response.statusCode !== 200) {
107
+ throw this.#resolveError(spec, options, 'failed to fetch tarball', {
108
+ url: r.resolved,
109
+ response,
110
+ });
111
+ }
112
+ try {
113
+ await this.tarPool.unpack(response.buffer(), target);
114
+ }
115
+ catch (er) {
116
+ throw this.#resolveError(spec, options, 'tar unpack failed', { cause: er });
117
+ }
118
+ return r;
119
+ }
120
+ case 'file': {
121
+ // if it's a directory, then "extract" means "symlink"
122
+ const { file } = f;
123
+ /* c8 ignore start - asserted in resolve() */
124
+ if (file === undefined)
125
+ throw this.#resolveError(spec, options, 'no file path');
126
+ /* c8 ignore stop */
127
+ const path = pathResolve(from, file);
128
+ const st = await stat(path);
129
+ if (st.isFile()) {
130
+ try {
131
+ await this.tarPool.unpack(await this.tarball(spec, options), target);
132
+ }
133
+ catch (er) {
134
+ throw this.#resolveError(spec, options, 'tar unpack failed', { cause: er });
135
+ }
136
+ }
137
+ else if (st.isDirectory()) {
138
+ const rel = relative(dirname(target), path);
139
+ await symlink(rel, target, 'dir');
140
+ /* c8 ignore start */
141
+ }
142
+ else {
143
+ throw this.#resolveError(spec, options, 'file: specifier does not resolve to directory or tarball');
144
+ }
145
+ /* c8 ignore stop */
146
+ return r;
147
+ }
148
+ case 'workspace': {
149
+ const ws = this.#getWS(spec, options);
150
+ const rel = relative(dirname(target), ws.fullpath);
151
+ await symlink(rel, target, 'dir');
152
+ return r;
153
+ }
154
+ }
155
+ }
156
+ #getWS(spec, options) {
157
+ const { workspace } = spec;
158
+ /* c8 ignore start - asserted in resolve() */
159
+ if (workspace === undefined)
160
+ throw this.#resolveError(spec, options, 'no workspace ID');
161
+ /* c8 ignore stop */
162
+ if (!this.monorepo) {
163
+ throw this.#resolveError(spec, options, 'Not in a monorepo, cannot resolve workspace spec');
164
+ }
165
+ const ws = this.monorepo.get(workspace);
166
+ if (!ws) {
167
+ throw this.#resolveError(spec, options, 'workspace not found', {
168
+ wanted: workspace,
169
+ });
170
+ }
171
+ return ws;
172
+ }
173
+ async tarball(spec, options = {}) {
174
+ if (typeof spec === 'string')
175
+ spec = Spec.parse(spec, this.options);
176
+ const f = spec.final;
177
+ switch (f.type) {
178
+ case 'registry': {
179
+ const { dist } = await this.manifest(spec, options);
180
+ if (!dist)
181
+ throw this.#resolveError(spec, options, 'no dist object found in manifest');
182
+ //TODO: handle signatures as well as integrity
183
+ const { tarball, integrity } = dist;
184
+ if (!tarball)
185
+ throw this.#resolveError(spec, options, 'no tarball found in manifest.dist');
186
+ const response = await this.registryClient.request(tarball, {
187
+ integrity,
188
+ });
189
+ if (response.statusCode !== 200) {
190
+ throw this.#resolveError(spec, options, 'failed to fetch tarball', { response, url: tarball });
191
+ }
192
+ return response.buffer();
193
+ }
194
+ case 'git': {
195
+ const { remoteURL, gitRemote, gitCommittish, gitSelectorParsed, } = f;
196
+ const s = spec;
197
+ if (!remoteURL) {
198
+ if (!gitRemote) {
199
+ throw this.#resolveError(spec, options, 'no remote on git: specifier');
200
+ }
201
+ const { path } = gitSelectorParsed ?? {};
202
+ return await this.#tmpdir(async (dir) => {
203
+ await clone(gitRemote, gitCommittish, dir + '/package', {
204
+ spec: s,
205
+ });
206
+ let cwd = dir;
207
+ if (path !== undefined) {
208
+ const src = pathResolve(dir, 'package', path);
209
+ cwd = dirname(src);
210
+ const pkg = pathResolve(cwd, 'package');
211
+ if (src !== pkg) {
212
+ const rand = randomBytes(6).toString('hex');
213
+ // faster than deleting
214
+ await rename(pkg, pkg + rand).catch(() => { });
215
+ await rename(src, pkg);
216
+ }
217
+ }
218
+ return tarC({ cwd, gzip: true }, ['package']).concat();
219
+ });
220
+ }
221
+ // fallthrough if remoteURL set
222
+ }
223
+ case 'remote': {
224
+ const { remoteURL } = f;
225
+ if (!remoteURL) {
226
+ throw this.#resolveError(spec, options);
227
+ }
228
+ const response = await this.registryClient.request(remoteURL);
229
+ if (response.statusCode !== 200) {
230
+ throw this.#resolveError(spec, options, 'failed to fetch URL', { response, url: remoteURL });
231
+ }
232
+ return response.buffer();
233
+ }
234
+ case 'file': {
235
+ const { file } = f;
236
+ if (file === undefined)
237
+ throw this.#resolveError(spec, options, 'no file path');
238
+ const { from = this.#projectRoot } = options;
239
+ const path = pathResolve(from, file);
240
+ const st = await stat(path);
241
+ if (st.isDirectory()) {
242
+ const p = dirname(path);
243
+ const b = basename(path);
244
+ // TODO: Pack properly, ignore stuff, bundleDeps, etc
245
+ return tarC({ cwd: p, gzip: true }, [b]).concat();
246
+ }
247
+ return readFile(path);
248
+ }
249
+ case 'workspace': {
250
+ // TODO: Pack properly, ignore stuff, bundleDeps, etc
251
+ const ws = this.#getWS(spec, options);
252
+ const p = dirname(ws.fullpath);
253
+ const b = basename(ws.fullpath);
254
+ return tarC({ cwd: p, gzip: true }, [b]).concat();
255
+ }
256
+ }
257
+ }
258
+ async manifest(spec, options = {}) {
259
+ const { from = this.#projectRoot } = options;
260
+ if (typeof spec === 'string')
261
+ spec = Spec.parse(spec, this.options);
262
+ const f = spec.final;
263
+ switch (f.type) {
264
+ case 'registry': {
265
+ const mani = pickManifest(await this.packument(f, options), spec, options);
266
+ if (!mani)
267
+ throw this.#resolveError(spec, options);
268
+ return mani;
269
+ }
270
+ case 'git': {
271
+ const { gitRemote, gitCommittish, remoteURL, gitSelectorParsed, } = f;
272
+ if (!remoteURL) {
273
+ const s = spec;
274
+ if (!gitRemote)
275
+ throw this.#resolveError(spec, options, 'no git remote');
276
+ return await this.#tmpdir(async (dir) => {
277
+ await clone(gitRemote, gitCommittish, dir, { spec: s });
278
+ const { path } = gitSelectorParsed ?? {};
279
+ const pkgDir = path !== undefined ? pathResolve(dir, path) : dir;
280
+ return this.packageJson.read(pkgDir);
281
+ });
282
+ }
283
+ // fallthrough to remote
284
+ }
285
+ case 'remote': {
286
+ const { remoteURL } = f;
287
+ if (!remoteURL) {
288
+ throw this.#resolveError(spec, options, 'no remoteURL on remote specifier');
289
+ }
290
+ const s = spec;
291
+ return await this.#tmpdir(async (dir) => {
292
+ const response = await this.registryClient.request(remoteURL);
293
+ if (response.statusCode !== 200) {
294
+ throw this.#resolveError(s, options, 'failed to fetch URL', { response, url: remoteURL });
295
+ }
296
+ const buf = response.buffer();
297
+ try {
298
+ await this.tarPool.unpack(buf, dir);
299
+ }
300
+ catch (er) {
301
+ throw this.#resolveError(s, options, 'tar unpack failed', { cause: er });
302
+ }
303
+ return this.packageJson.read(dir);
304
+ });
305
+ }
306
+ case 'file': {
307
+ const { file } = f;
308
+ if (file === undefined)
309
+ throw this.#resolveError(spec, options, 'no file path');
310
+ const path = pathResolve(from, file);
311
+ const st = await stat(path);
312
+ if (st.isDirectory()) {
313
+ return this.packageJson.read(path);
314
+ }
315
+ const s = spec;
316
+ return await this.#tmpdir(async (dir) => {
317
+ try {
318
+ await this.tarPool.unpack(await readFile(path), dir);
319
+ }
320
+ catch (er) {
321
+ throw this.#resolveError(s, options, 'tar unpack failed', { cause: er });
322
+ }
323
+ return this.packageJson.read(dir);
324
+ });
325
+ }
326
+ case 'workspace': {
327
+ return this.#getWS(spec, options).manifest;
328
+ }
329
+ }
330
+ }
331
+ async packument(spec, options = {}) {
332
+ if (typeof spec === 'string')
333
+ spec = Spec.parse(spec, this.options);
334
+ const f = spec.final;
335
+ switch (f.type) {
336
+ // RevDoc is the equivalent of a packument for a git repo
337
+ case 'git': {
338
+ const { gitRemote } = f;
339
+ if (!gitRemote) {
340
+ throw this.#resolveError(spec, options, 'git remote could not be determined');
341
+ }
342
+ const revDoc = await revs(gitRemote, {
343
+ cwd: this.options.projectRoot,
344
+ });
345
+ if (!revDoc)
346
+ throw this.#resolveError(spec, options);
347
+ return asPackument(revDoc);
348
+ }
349
+ // these are all faked packuments
350
+ case 'file':
351
+ case 'workspace':
352
+ case 'remote': {
353
+ const manifest = await this.manifest(f, options);
354
+ return {
355
+ name: manifest.name ?? '',
356
+ 'dist-tags': {
357
+ latest: manifest.version ?? '',
358
+ },
359
+ versions: {
360
+ [manifest.version ?? '']: manifest,
361
+ },
362
+ };
363
+ }
364
+ case 'registry': {
365
+ const { registry, name } = f;
366
+ const pakuURL = new URL(name, registry);
367
+ const response = await this.registryClient.request(pakuURL, {
368
+ headers: {
369
+ accept: 'application/json',
370
+ },
371
+ });
372
+ if (response.statusCode !== 200) {
373
+ throw this.#resolveError(spec, options, 'failed to fetch packument', {
374
+ url: pakuURL,
375
+ response,
376
+ });
377
+ }
378
+ return response.json();
379
+ }
380
+ }
381
+ }
382
+ async resolve(spec, options = {}) {
383
+ const memoKey = String(spec);
384
+ if (typeof spec === 'string')
385
+ spec = Spec.parse(spec, this.options);
386
+ const memo = this.#resolutions.get(memoKey);
387
+ if (memo)
388
+ return memo;
389
+ const f = spec.final;
390
+ switch (f.type) {
391
+ case 'file': {
392
+ const { file } = f;
393
+ if (!file || !spec.file) {
394
+ throw this.#resolveError(spec, options, 'no path on file: specifier');
395
+ }
396
+ const { from = this.#projectRoot } = options;
397
+ const resolved = pathResolve(from, spec.file);
398
+ const r = { resolved, spec };
399
+ this.#resolutions.set(memoKey, r);
400
+ return r;
401
+ }
402
+ case 'remote': {
403
+ const { remoteURL } = f;
404
+ if (!remoteURL)
405
+ throw this.#resolveError(spec, options, 'no URL in remote specifier');
406
+ const r = { resolved: remoteURL, spec };
407
+ this.#resolutions.set(memoKey, r);
408
+ return r;
409
+ }
410
+ case 'workspace': {
411
+ const ws = this.#getWS(spec, options);
412
+ return {
413
+ resolved: ws.fullpath,
414
+ spec,
415
+ };
416
+ }
417
+ case 'registry': {
418
+ const mani = await this.manifest(spec, options);
419
+ if (mani.dist) {
420
+ const { integrity, tarball, signatures } = mani.dist;
421
+ if (tarball) {
422
+ const r = {
423
+ resolved: tarball,
424
+ integrity,
425
+ signatures,
426
+ spec,
427
+ };
428
+ this.#resolutions.set(memoKey, r);
429
+ return r;
430
+ }
431
+ }
432
+ throw this.#resolveError(spec, options);
433
+ }
434
+ case 'git': {
435
+ const { gitRemote, remoteURL, gitSelectorParsed } = f;
436
+ if (remoteURL && gitSelectorParsed?.path === undefined) {
437
+ // known git host with a tarball download endpoint
438
+ const r = { resolved: remoteURL, spec };
439
+ this.#resolutions.set(memoKey, r);
440
+ return r;
441
+ }
442
+ if (!gitRemote) {
443
+ throw this.#resolveError(spec, options, 'no remote on git specifier');
444
+ }
445
+ const rev = await gitResolve(gitRemote, spec.gitCommittish, {
446
+ spec,
447
+ });
448
+ if (rev) {
449
+ const r = {
450
+ resolved: `${gitRemote}#${rev.sha}`,
451
+ spec,
452
+ };
453
+ if (gitSelectorParsed) {
454
+ r.resolved += Object.entries(gitSelectorParsed)
455
+ .filter(([_, v]) => v)
456
+ .map(([k, v]) => `::${k}:${v}`)
457
+ .join('');
458
+ }
459
+ this.#resolutions.set(memoKey, r);
460
+ return r;
461
+ }
462
+ // have to actually clone somewhere
463
+ const s = spec;
464
+ return this.#tmpdir(async (tmpdir) => {
465
+ const sha = await clone(gitRemote, s.gitCommittish, tmpdir, {
466
+ spec: s,
467
+ });
468
+ const r = {
469
+ resolved: `${gitRemote}#${sha}`,
470
+ spec: s,
471
+ };
472
+ this.#resolutions.set(memoKey, r);
473
+ return r;
474
+ });
475
+ }
476
+ }
477
+ }
478
+ async #tmpdir(fn) {
479
+ const p = `package-info/${randomBytes(6).toString('hex')}`;
480
+ const dir = xdg.runtime(p);
481
+ try {
482
+ return await fn(dir);
483
+ }
484
+ finally {
485
+ // intentionally do not await
486
+ void rm(dir, { recursive: true, force: true });
487
+ }
488
+ }
489
+ // error resolving
490
+ #resolveError(spec, options = {}, message = 'Could not resolve', extra = {}) {
491
+ const { from = this.#projectRoot } = options;
492
+ const er = error(message, {
493
+ code: 'ERESOLVE',
494
+ spec,
495
+ from,
496
+ ...extra,
497
+ }, this.#resolveError);
498
+ return er;
499
+ }
500
+ }
501
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EACL,YA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AA;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 { error, ErrorCauseObject } from '@vltpkg/error-cause'\nimport { clone, resolve as gitResolve, revs } from '@vltpkg/git'\nimport { PackageJson } from '@vltpkg/package-json'\nimport {\n pickManifest,\n PickManifestOptions,\n} from '@vltpkg/pick-manifest'\nimport {\n RegistryClient,\n RegistryClientOptions,\n} from '@vltpkg/registry-client'\nimport { Spec, type SpecOptions } from '@vltpkg/spec'\nimport { Pool } from '@vltpkg/tar'\nimport {\n asPackument,\n Integrity,\n Manifest,\n Packument,\n} from '@vltpkg/types'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { XDG } from '@vltpkg/xdg'\nimport { randomBytes } from 'crypto'\nimport { readFile, rm, stat, symlink } from 'fs/promises'\nimport {\n basename,\n dirname,\n relative,\n resolve as pathResolve,\n} from 'path'\nimport { create as tarC } from 'tar'\nimport { rename } from './rename.js'\n\nconst xdg = new XDG('vlt')\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 /** dir to resolve `file://` specifiers against. Defaults to projectRoot. */\n from?: string\n}\n\nexport type PackageInfoClientAllOptions = PackageInfoClientOptions &\n PackageInfoClientRequestOptions\n\n// provide some helper methods at the top level. Re-use the client if\n// the same options are provided.\nconst clients = new Map<string, PackageInfoClient>()\nconst client = (o: PackageInfoClientAllOptions = {}) => {\n const {\n from: _from,\n packageJson: _packageJson,\n workspace: _workspace,\n 'workspace-group': _workspaceGroup,\n ...opts\n } = o\n const key = JSON.stringify(\n Object.entries(opts).sort(([a], [b]) => a.localeCompare(b, 'en')),\n )\n const c = clients.get(key) ?? new PackageInfoClient(opts)\n clients.set(key, c)\n return c\n}\n\nexport const packument = async (\n spec: Spec | string,\n options: PackageInfoClientAllOptions = {},\n): Promise<Packument> => client(options).packument(spec, options)\n\nexport const manifest = async (\n spec: Spec | string,\n options: PackageInfoClientAllOptions = {},\n): Promise<Manifest> => client(options).manifest(spec, options)\n\nexport const resolve = async (\n spec: Spec | string,\n options: PackageInfoClientAllOptions = {},\n): Promise<Resolution> => client(options).resolve(spec, options)\n\nexport const tarball = async (\n spec: Spec | string,\n options: PackageInfoClientAllOptions = {},\n): Promise<Buffer> => client(options).tarball(spec, options)\n\nexport const extract = async (\n spec: Spec | string,\n target: string,\n options: PackageInfoClientAllOptions = {},\n): Promise<Resolution> =>\n client(options).extract(spec, target, options)\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\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 }\n\n async extract(\n spec: Spec | string,\n target: string,\n options: PackageInfoClientRequestOptions = {},\n ): Promise<Resolution> {\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const f = spec.final\n const r = await this.resolve(spec, options)\n const { from = this.#projectRoot } = options\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 case 'registry':\n case 'remote': {\n const response = await this.registryClient.request(\n r.resolved,\n {\n integrity: r.integrity,\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 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 as Error },\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 as Error },\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 async tarball(\n spec: Spec | string,\n options: PackageInfoClientRequestOptions = {},\n ): Promise<Buffer> {\n if (typeof spec === 'string')\n spec = Spec.parse(spec, this.options)\n const f = spec.final\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 //TODO: handle signatures as well as integrity\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 const response = await this.registryClient.request(tarball, {\n integrity,\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 return response.buffer()\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 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 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 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 const mani = pickManifest(\n await this.packument(f, options),\n spec,\n options,\n )\n if (!mani) throw this.#resolveError(spec, options)\n return mani\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 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 as Error },\n )\n }\n return this.packageJson.read(dir)\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 as Error },\n )\n }\n return this.packageJson.read(dir)\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 // 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,\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 const memo = this.#resolutions.get(memoKey)\n if (memo) return memo\n const f = spec.final\n switch (f.type) {\n case 'file': {\n const { file } = f\n if (!file || !spec.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, spec.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, spec.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: ErrorCauseObject = {},\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"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,3 @@
1
+ import { rename as fsRename } from 'node:fs/promises';
2
+ export declare const rename: typeof fsRename;
3
+ //# sourceMappingURL=rename.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../src/rename.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAM,MAAM,kBAAkB,CAAA;AACzD,eAAO,MAAM,MAAM,iBAqBhB,CAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * On posix systems, rename is atomic and will clobber anything in its way
3
+ * However, on Windows, it can fail with the rather unhelpful EPERM error if
4
+ * the target directory is not removed in time or is currently in use.
5
+ *
6
+ * While true atomic semantics is not available on Windows in this case, we can
7
+ * at least implement the posix overwrite semantics by explicitly removing the
8
+ * target when this error occurs.
9
+ *
10
+ * This is only relevant when renaming *directories*, since files will
11
+ * generally not raise problems. When/if we rename directories outside of
12
+ * package-info, this can be moved to its own shared module.
13
+ *
14
+ * @module
15
+ */
16
+ const { platform } = process;
17
+ import { rename as fsRename, rm } from 'node:fs/promises';
18
+ export const rename = platform !== 'win32' ? fsRename : (async function (oldPath, newPath) {
19
+ let retries = 3;
20
+ const retry = async (er) => {
21
+ if (retries > 0 &&
22
+ er.code === 'EPERM') {
23
+ retries--;
24
+ await rm(newPath, { recursive: true, force: true });
25
+ return fsRename(oldPath, newPath).then(() => { }, retry);
26
+ }
27
+ else {
28
+ throw er;
29
+ }
30
+ };
31
+ return fsRename(oldPath, newPath).then(() => { }, retry);
32
+ });
33
+ //# sourceMappingURL=rename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/rename.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;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 *\n * @module\n */\nconst { platform } = process\nimport { 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"]}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@vltpkg/package-info",
3
+ "description": "Resolve and fetch package metadata and tarballs",
4
+ "version": "0.0.0-0.1730239248325",
5
+ "tshy": {
6
+ "selfLink": false,
7
+ "dialects": [
8
+ "esm"
9
+ ],
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ ".": "./src/index.ts"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "tar": "^7.4.3",
17
+ "@vltpkg/error-cause": "0.0.0-0.1730239248325",
18
+ "@vltpkg/pick-manifest": "0.0.0-0.1730239248325",
19
+ "@vltpkg/git": "0.0.0-0.1730239248325",
20
+ "@vltpkg/package-json": "0.0.0-0.1730239248325",
21
+ "@vltpkg/registry-client": "0.0.0-0.1730239248325",
22
+ "@vltpkg/spec": "0.0.0-0.1730239248325",
23
+ "@vltpkg/types": "0.0.0-0.1730239248325",
24
+ "@vltpkg/workspaces": "0.0.0-0.1730239248325",
25
+ "@vltpkg/xdg": "0.0.0-0.1730239248325",
26
+ "@vltpkg/tar": "0.0.0-0.1730239248325"
27
+ },
28
+ "devDependencies": {
29
+ "@eslint/js": "^9.8.0",
30
+ "@types/eslint__js": "^8.42.3",
31
+ "@types/node": "^22.4.1",
32
+ "eslint": "^9.8.0",
33
+ "pacote": "^18.0.6",
34
+ "prettier": "^3.3.2",
35
+ "tap": "^21.0.1",
36
+ "tshy": "^3.0.2",
37
+ "typescript": "^5.5.4",
38
+ "typescript-eslint": "^8.0.1",
39
+ "@vltpkg/benchmark": "0.0.0-0",
40
+ "@vltpkg/cache-unzip": "0.0.0-0.1730239248325"
41
+ },
42
+ "license": "BSD-2-Clause-Patent",
43
+ "engines": {
44
+ "node": "20 || >=22"
45
+ },
46
+ "tap": {
47
+ "extends": "../../tap-config.yaml"
48
+ },
49
+ "prettier": "../../.prettierrc.js",
50
+ "module": "./dist/esm/index.js",
51
+ "type": "module",
52
+ "exports": {
53
+ "./package.json": "./package.json",
54
+ ".": {
55
+ "import": {
56
+ "types": "./dist/esm/index.d.ts",
57
+ "default": "./dist/esm/index.js"
58
+ }
59
+ }
60
+ },
61
+ "files": [
62
+ "dist"
63
+ ],
64
+ "scripts": {
65
+ "benchmark": "node scripts/benchmark.js",
66
+ "format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
67
+ "format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
68
+ "lint": "eslint . --fix",
69
+ "lint:check": "eslint .",
70
+ "presnap": "tshy",
71
+ "snap": "tap",
72
+ "pretest": "tshy",
73
+ "test": "tap"
74
+ }
75
+ }