@packall/core 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +58 -0
- package/dist/archive-6sqTn1C4.js +274 -0
- package/dist/archive-6sqTn1C4.js.map +1 -0
- package/dist/archive.d.ts +64 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/{Bundle.d.ts → bundle.d.ts} +56 -38
- package/dist/bundle.d.ts.map +1 -0
- package/dist/{DependencyRange.d.ts → dependency-range.d.ts} +2 -2
- package/dist/dependency-range.d.ts.map +1 -0
- package/dist/{Download.d.ts → download.d.ts} +9 -8
- package/dist/download.d.ts.map +1 -0
- package/dist/enums/artifact-kind.d.ts +8 -0
- package/dist/enums/artifact-kind.d.ts.map +1 -0
- package/dist/enums/edge-kind.d.ts +29 -0
- package/dist/enums/edge-kind.d.ts.map +1 -0
- package/dist/enums/input-file-kind.d.ts +12 -0
- package/dist/enums/input-file-kind.d.ts.map +1 -0
- package/dist/enums/layout.d.ts +23 -0
- package/dist/enums/layout.d.ts.map +1 -0
- package/dist/enums/lockfile-format.d.ts +9 -0
- package/dist/enums/lockfile-format.d.ts.map +1 -0
- package/dist/enums/phase.d.ts +11 -0
- package/dist/enums/phase.d.ts.map +1 -0
- package/dist/{Errors.d.ts → errors.d.ts} +49 -7
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +46 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2121 -1060
- package/dist/index.js.map +1 -1
- package/dist/input-file.d.ts +77 -0
- package/dist/input-file.d.ts.map +1 -0
- package/dist/integrity.d.ts +80 -0
- package/dist/integrity.d.ts.map +1 -0
- package/dist/layout.d.ts +87 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/locked-resolve.d.ts +47 -0
- package/dist/locked-resolve.d.ts.map +1 -0
- package/dist/lockfile/bun.d.ts +3 -0
- package/dist/lockfile/bun.d.ts.map +1 -0
- package/dist/lockfile/detect.d.ts +31 -0
- package/dist/lockfile/detect.d.ts.map +1 -0
- package/dist/lockfile/json.d.ts +23 -0
- package/dist/lockfile/json.d.ts.map +1 -0
- package/dist/lockfile/names.d.ts +16 -0
- package/dist/lockfile/names.d.ts.map +1 -0
- package/dist/lockfile/npm.d.ts +3 -0
- package/dist/lockfile/npm.d.ts.map +1 -0
- package/dist/lockfile/parse.d.ts +23 -0
- package/dist/lockfile/parse.d.ts.map +1 -0
- package/dist/lockfile/pnpm.d.ts +20 -0
- package/dist/lockfile/pnpm.d.ts.map +1 -0
- package/dist/lockfile/tree-builder.d.ts +70 -0
- package/dist/lockfile/tree-builder.d.ts.map +1 -0
- package/dist/lockfile/types.d.ts +70 -0
- package/dist/lockfile/types.d.ts.map +1 -0
- package/dist/{Manifest.d.ts → manifest.d.ts} +7 -15
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/archiver.d.ts +5 -0
- package/dist/node/archiver.d.ts.map +1 -0
- package/dist/node/index.d.ts +13 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +55 -0
- package/dist/node/index.js.map +1 -0
- package/dist/{Options.d.ts → options.d.ts} +12 -30
- package/dist/options.d.ts.map +1 -0
- package/dist/{Platform.d.ts → platform.d.ts} +14 -19
- package/dist/platform.d.ts.map +1 -0
- package/dist/{Progress.d.ts → progress.d.ts} +10 -9
- package/dist/progress.d.ts.map +1 -0
- package/dist/{Registry.d.ts → registry.d.ts} +42 -44
- package/dist/registry.d.ts.map +1 -0
- package/dist/{Resolve.d.ts → resolve.d.ts} +25 -26
- package/dist/resolve.d.ts.map +1 -0
- package/dist/schemas/lenient.d.ts +38 -0
- package/dist/schemas/lenient.d.ts.map +1 -0
- package/dist/schemas/package-json.d.ts +44 -0
- package/dist/schemas/package-json.d.ts.map +1 -0
- package/dist/{Spec.d.ts → spec.d.ts} +4 -4
- package/dist/spec.d.ts.map +1 -0
- package/dist/types/value-of.d.ts +9 -0
- package/dist/types/value-of.d.ts.map +1 -0
- package/dist/utils/is-record.d.ts +8 -0
- package/dist/utils/is-record.d.ts.map +1 -0
- package/package.json +13 -11
- package/src/archive.ts +95 -0
- package/src/bundle.ts +736 -0
- package/src/dependency-range.ts +121 -0
- package/src/download.ts +155 -0
- package/src/enums/artifact-kind.ts +9 -0
- package/src/enums/edge-kind.ts +32 -0
- package/src/enums/input-file-kind.ts +13 -0
- package/src/enums/layout.ts +25 -0
- package/src/enums/lockfile-format.ts +10 -0
- package/src/enums/phase.ts +12 -0
- package/src/errors.ts +300 -0
- package/src/index.ts +146 -35
- package/src/input-file.ts +324 -0
- package/src/integrity.ts +165 -0
- package/src/layout.ts +137 -0
- package/src/locked-resolve.ts +471 -0
- package/src/lockfile/bun.ts +214 -0
- package/src/lockfile/detect.ts +80 -0
- package/src/lockfile/json.ts +131 -0
- package/src/lockfile/names.ts +20 -0
- package/src/lockfile/npm.ts +328 -0
- package/src/lockfile/parse.ts +56 -0
- package/src/lockfile/pnpm.ts +230 -0
- package/src/lockfile/tree-builder.ts +166 -0
- package/src/lockfile/types.ts +74 -0
- package/src/manifest.ts +129 -0
- package/src/node/archiver.ts +85 -0
- package/src/node/index.ts +13 -0
- package/src/options.ts +103 -0
- package/src/platform.ts +178 -0
- package/src/progress.ts +105 -0
- package/src/registry.ts +116 -0
- package/src/resolve.ts +560 -0
- package/src/schemas/lenient.ts +130 -0
- package/src/schemas/package-json.ts +28 -0
- package/src/spec.ts +182 -0
- package/src/types/value-of.ts +8 -0
- package/src/utils/is-record.ts +8 -0
- package/dist/Archive.d.ts +0 -32
- package/dist/Archive.d.ts.map +0 -1
- package/dist/Bundle.d.ts.map +0 -1
- package/dist/DependencyRange.d.ts.map +0 -1
- package/dist/Download.d.ts.map +0 -1
- package/dist/Errors.d.ts.map +0 -1
- package/dist/InputFile.d.ts +0 -46
- package/dist/InputFile.d.ts.map +0 -1
- package/dist/Integrity.d.ts +0 -48
- package/dist/Integrity.d.ts.map +0 -1
- package/dist/Layout.d.ts +0 -53
- package/dist/Layout.d.ts.map +0 -1
- package/dist/Manifest.d.ts.map +0 -1
- package/dist/Options.d.ts.map +0 -1
- package/dist/Platform.d.ts.map +0 -1
- package/dist/Progress.d.ts.map +0 -1
- package/dist/Registry.d.ts.map +0 -1
- package/dist/Resolve.d.ts.map +0 -1
- package/dist/Spec.d.ts.map +0 -1
- package/src/Archive.ts +0 -92
- package/src/Bundle.ts +0 -570
- package/src/DependencyRange.ts +0 -115
- package/src/Download.ts +0 -132
- package/src/Errors.ts +0 -216
- package/src/InputFile.ts +0 -229
- package/src/Integrity.ts +0 -122
- package/src/Layout.ts +0 -103
- package/src/Manifest.ts +0 -133
- package/src/Options.ts +0 -123
- package/src/Platform.ts +0 -182
- package/src/Progress.ts +0 -106
- package/src/Registry.ts +0 -121
- package/src/Resolve.ts +0 -528
- package/src/Spec.ts +0 -186
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--file` handling.
|
|
3
|
+
*
|
|
4
|
+
* One flag, three accepted shapes, detected from the content rather than the
|
|
5
|
+
* extension so that `--file deps.json` and `--file my-packages` both do the
|
|
6
|
+
* obvious thing:
|
|
7
|
+
*
|
|
8
|
+
* - a **package.json** — bundle everything it depends on
|
|
9
|
+
* - a **lockfile** — npm, pnpm or bun; bundle the exact versions it pins
|
|
10
|
+
* - a **newline-delimited list** — one spec per line, `#` and `//` comments
|
|
11
|
+
* allowed, blank lines ignored
|
|
12
|
+
*
|
|
13
|
+
* A lockfile is checked for first, because `package-lock.json` and
|
|
14
|
+
* `package.json` are both JSON objects and only the content tells them apart.
|
|
15
|
+
*/
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
import * as FileSystem from "effect/FileSystem";
|
|
18
|
+
import { InputFileKind } from "./enums/input-file-kind.js";
|
|
19
|
+
import type { LockfileError } from "./errors.js";
|
|
20
|
+
import { InvalidInputFileError } from "./errors.js";
|
|
21
|
+
import type { LockedTree } from "./lockfile/types.js";
|
|
22
|
+
import type { PackageSpec } from "./spec.js";
|
|
23
|
+
export type InputFileResult = {
|
|
24
|
+
readonly kind: InputFileKind;
|
|
25
|
+
readonly specs: ReadonlyArray<PackageSpec>;
|
|
26
|
+
/** Entries that were recognised but cannot be bundled from a registry. */
|
|
27
|
+
readonly warnings: ReadonlyArray<string>;
|
|
28
|
+
/**
|
|
29
|
+
* The pinned graph, set only for a lockfile.
|
|
30
|
+
*
|
|
31
|
+
* `specs` carries the same roots for display, but a lockfile run must resolve
|
|
32
|
+
* from this — see `locked-resolve` for why re-resolving the roots' ranges
|
|
33
|
+
* would quietly produce a different bundle.
|
|
34
|
+
*/
|
|
35
|
+
readonly lockfile?: LockedTree | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Names from the blocks a package.json always installs — `dependencies` and,
|
|
38
|
+
* unless `--prod`, `devDependencies`.
|
|
39
|
+
*
|
|
40
|
+
* Used to check a lockfile against the manifest beside it. Deliberately
|
|
41
|
+
* excludes optional and peer entries: both are legitimately absent from a
|
|
42
|
+
* lockfile (an optional dependency that failed to build, a peer the consumer
|
|
43
|
+
* is expected to supply), so including them would turn a useful staleness
|
|
44
|
+
* check into a false alarm.
|
|
45
|
+
*/
|
|
46
|
+
readonly required?: ReadonlyArray<string> | undefined;
|
|
47
|
+
};
|
|
48
|
+
/** Which dependency blocks of a package.json become root specs. */
|
|
49
|
+
export type InputFileOptions = {
|
|
50
|
+
/**
|
|
51
|
+
* Include `devDependencies`.
|
|
52
|
+
*
|
|
53
|
+
* On by default: if you are pointing this tool at a package.json, you are
|
|
54
|
+
* almost certainly trying to make that project installable behind the
|
|
55
|
+
* firewall, and a project without its dev tooling does not build. `--prod`
|
|
56
|
+
* turns it off.
|
|
57
|
+
*/
|
|
58
|
+
readonly includeDev: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* For a lockfile, which workspace member's dependencies are the roots.
|
|
61
|
+
*
|
|
62
|
+
* Set when a package.json found its lockfile by walking up: the file then
|
|
63
|
+
* covers the whole repository, and only one member of it was asked for.
|
|
64
|
+
*/
|
|
65
|
+
readonly importer?: string | undefined;
|
|
66
|
+
};
|
|
67
|
+
export declare const defaultInputFileOptions: InputFileOptions;
|
|
68
|
+
/** Reads and parses an input file. */
|
|
69
|
+
export declare const readInputFile: (filePath: string, options?: InputFileOptions) => Effect.Effect<InputFileResult, InvalidInputFileError | LockfileError, FileSystem.FileSystem>;
|
|
70
|
+
/**
|
|
71
|
+
* Parses file content that has already been read.
|
|
72
|
+
*
|
|
73
|
+
* Split out from the IO so the whole of this logic is testable with plain
|
|
74
|
+
* strings and no file system at all.
|
|
75
|
+
*/
|
|
76
|
+
export declare const parseInputFile: (filePath: string, content: string, options?: InputFileOptions) => InputFileResult;
|
|
77
|
+
//# sourceMappingURL=input-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-file.d.ts","sourceRoot":"","sources":["../src/input-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC3C,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC3C;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACtD,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,gBAAuC,CAAC;AAE9E,sCAAsC;AACtC,eAAO,MAAM,aAAa,aACf,MAAM,YACP,gBAAgB,KACvB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,qBAAqB,GAAG,aAAa,EAAE,UAAU,CAAC,UAAU,CAgC3F,CAAC;AAKJ;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAChB,MAAM,WACP,MAAM,YACN,gBAAgB,KACvB,eAoBF,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checksum verification for downloaded tarballs.
|
|
3
|
+
*
|
|
4
|
+
* A failed check discards the download rather than warning and carrying on —
|
|
5
|
+
* see `notes/requirements.md` § FR-9 for why that strictness is a requirement
|
|
6
|
+
* rather than a preference.
|
|
7
|
+
*
|
|
8
|
+
* Built on Effect's `Crypto` service rather than `node:crypto` directly. The
|
|
9
|
+
* four digests `Crypto` offers — SHA-1, SHA-256, SHA-384, SHA-512 — are exactly
|
|
10
|
+
* the four npm publishes, so nothing is given up, and the same verification
|
|
11
|
+
* then runs unchanged against WebCrypto in a browser. Parsing stays here
|
|
12
|
+
* because the subset of Subresource Integrity npm actually emits is small and
|
|
13
|
+
* entirely mechanical; `ssri` would be a dependency for a regex.
|
|
14
|
+
*/
|
|
15
|
+
import * as Crypto from "effect/Crypto";
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
import type { PlatformError } from "effect/PlatformError";
|
|
18
|
+
/**
|
|
19
|
+
* The digests npm publishes, mapped to what `Crypto.digest` calls them.
|
|
20
|
+
*
|
|
21
|
+
* Doubles as the supported-algorithm list: an SRI token whose algorithm is not
|
|
22
|
+
* a key here is one we cannot check, and is dropped during parsing.
|
|
23
|
+
*/
|
|
24
|
+
declare const digestAlgorithmByName: {
|
|
25
|
+
readonly sha512: "SHA-512";
|
|
26
|
+
readonly sha384: "SHA-384";
|
|
27
|
+
readonly sha256: "SHA-256";
|
|
28
|
+
readonly sha1: "SHA-1";
|
|
29
|
+
};
|
|
30
|
+
/** An algorithm this module can verify against. */
|
|
31
|
+
export type IntegrityAlgorithm = keyof typeof digestAlgorithmByName;
|
|
32
|
+
/** One parsed SRI hash. */
|
|
33
|
+
export type IntegrityHash = {
|
|
34
|
+
readonly algorithm: IntegrityAlgorithm;
|
|
35
|
+
/** Base64 digest, exactly as written in the SRI string. */
|
|
36
|
+
readonly digest: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Parses an SRI string such as `sha512-abc...==`.
|
|
40
|
+
*
|
|
41
|
+
* npm permits several space-separated hashes; we keep every one we can verify
|
|
42
|
+
* and ignore algorithms we cannot.
|
|
43
|
+
*/
|
|
44
|
+
export declare const parseIntegrity: (integrity: string) => ReadonlyArray<IntegrityHash>;
|
|
45
|
+
/** Computes the base64 digest of some bytes under one algorithm. */
|
|
46
|
+
export declare const digestOf: (data: Uint8Array, algorithm: IntegrityAlgorithm) => Effect.Effect<string, PlatformError, Crypto.Crypto>;
|
|
47
|
+
/** Computes the hex digest of some bytes — the form legacy `shasum` uses. */
|
|
48
|
+
export declare const hexDigestOf: (data: Uint8Array, algorithm: IntegrityAlgorithm) => Effect.Effect<string, PlatformError, Crypto.Crypto>;
|
|
49
|
+
/** Result of checking a download. */
|
|
50
|
+
export type VerificationResult =
|
|
51
|
+
/** Verified against at least one checksum. */
|
|
52
|
+
{
|
|
53
|
+
readonly _tag: "Verified";
|
|
54
|
+
readonly using: string;
|
|
55
|
+
}
|
|
56
|
+
/** The registry advertised no checksum we could use. */
|
|
57
|
+
| {
|
|
58
|
+
readonly _tag: "Unverifiable";
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
}
|
|
61
|
+
/** A checksum was present and did not match. */
|
|
62
|
+
| {
|
|
63
|
+
readonly _tag: "Mismatch";
|
|
64
|
+
readonly expected: string;
|
|
65
|
+
readonly actual: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Checks bytes against whichever checksums the registry supplied.
|
|
69
|
+
*
|
|
70
|
+
* SRI is preferred; `shasum` is the fallback for versions published before
|
|
71
|
+
* integrity strings existed. If the registry gave us neither, that is reported
|
|
72
|
+
* as `Unverifiable` rather than silently treated as a pass — the caller decides
|
|
73
|
+
* whether to tolerate it.
|
|
74
|
+
*/
|
|
75
|
+
export declare const verify: (data: Uint8Array, dist: {
|
|
76
|
+
readonly integrity?: string | undefined;
|
|
77
|
+
readonly shasum?: string | undefined;
|
|
78
|
+
}) => Effect.Effect<VerificationResult, PlatformError, Crypto.Crypto>;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=integrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrity.d.ts","sourceRoot":"","sources":["../src/integrity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;GAKG;AACH,QAAA,MAAM,qBAAqB;qBAClB,SAAS;qBACT,SAAS;qBACT,SAAS;mBACX,OAAO;CAC6C,CAAC;AAE5D,mDAAmD;AACnD,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,qBAAqB,CAAC;AAKpE,2BAA2B;AAC3B,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,KAAG,aAAa,CAAC,aAAa,CAY7E,CAAC;AAWF,oEAAoE;AACpE,eAAO,MAAM,QAAQ,SACd,UAAU,aACL,kBAAkB,KAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CACW,CAAC;AAEjE,6EAA6E;AAC7E,eAAO,MAAM,WAAW,SACjB,UAAU,aACL,kBAAkB,KAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CACQ,CAAC;AAE9D,qCAAqC;AACrC,MAAM,MAAM,kBAAkB;AAC7B,8CAA8C;AAC5C;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACvD,wDAAwD;GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5D,gDAAgD;GAC9C;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAmBrF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,SACZ,UAAU,QACV;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,KACrF,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAgC9D,CAAC"}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The on-disk shape of a bundle.
|
|
3
|
+
*
|
|
4
|
+
* Everything is laid out exactly the way a registry serves it:
|
|
5
|
+
*
|
|
6
|
+
* lodash/-/lodash-4.17.21.tgz
|
|
7
|
+
* @babel/core/-/core-7.24.0.tgz
|
|
8
|
+
*
|
|
9
|
+
* That is not an Artifactory convention — it is the path structure in every
|
|
10
|
+
* `dist.tarball` URL npm publishes. See `notes/requirements.md` § FR-12 for
|
|
11
|
+
* what that buys.
|
|
12
|
+
*
|
|
13
|
+
* The one shape worth noticing before editing anything here: a scoped
|
|
14
|
+
* package's file name drops the scope, so `@babel/core` becomes
|
|
15
|
+
* `core-7.24.0.tgz` under an `@babel/core/-/` directory.
|
|
16
|
+
*/
|
|
17
|
+
/** Splits `@scope/name` into its parts. `scope` is undefined when unscoped. */
|
|
18
|
+
export declare const splitName: (name: string) => {
|
|
19
|
+
readonly scope: string | undefined;
|
|
20
|
+
readonly bare: string;
|
|
21
|
+
};
|
|
22
|
+
/** `@babel/core` + `7.24.0` -> `core-7.24.0.tgz` */
|
|
23
|
+
export declare const tarballFileName: (name: string, version: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The path of one package tarball within a bundle, using `/` separators
|
|
26
|
+
* regardless of host platform — these become tar entry names, and tar entries
|
|
27
|
+
* are always POSIX.
|
|
28
|
+
*/
|
|
29
|
+
export declare const packagePath: (name: string, version: string) => string;
|
|
30
|
+
/** File name of the manifest that ships inside every bundle. */
|
|
31
|
+
export declare const MANIFEST_FILE = "bundle-manifest.json";
|
|
32
|
+
/** File name of the short import guide that ships inside every bundle. */
|
|
33
|
+
export declare const README_FILE = "IMPORT.md";
|
|
34
|
+
/**
|
|
35
|
+
* Name of the archive produced for one root spec in `per-spec` layout.
|
|
36
|
+
*
|
|
37
|
+
* It is the spec, with the one character a file name cannot hold taken out:
|
|
38
|
+
* `@types/react@19.2.18` becomes `@types-react@19.2.18.tgz`. So the name of the
|
|
39
|
+
* file answers the question somebody has when they are looking at a directory
|
|
40
|
+
* of them — which package, and which version — in the notation they would have
|
|
41
|
+
* typed to ask for it.
|
|
42
|
+
*
|
|
43
|
+
* The version is joined with `@` rather than `-` for the same reason. A
|
|
44
|
+
* hyphen made `foo-bar-1.0.0` ambiguous by eye: package `foo` at `bar-1.0.0`,
|
|
45
|
+
* or `foo-bar` at `1.0.0`? npm's own syntax has no such problem, because a
|
|
46
|
+
* package name may not contain `@` beyond its scope.
|
|
47
|
+
*
|
|
48
|
+
* **The scope's `@` stays**, and it is the difference between a correct bundle
|
|
49
|
+
* and a quietly incomplete one.
|
|
50
|
+
*
|
|
51
|
+
* Dropping it — which this did, matching what `npm pack` produces — meant
|
|
52
|
+
* `@something/somewhat` and `something-somewhat` were both
|
|
53
|
+
* `something-somewhat-1.0.0.tgz`. Two different packages, one path: the second
|
|
54
|
+
* landed on the first, and the run reported two artifacts for the one file that
|
|
55
|
+
* survived. A bundle short a package, called complete, found at the far end of
|
|
56
|
+
* an air gap.
|
|
57
|
+
*
|
|
58
|
+
* Keeping the `@` makes that impossible by construction rather than by a check,
|
|
59
|
+
* because an unscoped npm name may not begin with one. It is also the more
|
|
60
|
+
* honest name: the scope is part of what the package *is*, and a directory of
|
|
61
|
+
* archives that has forgotten which ones were scoped is a directory somebody
|
|
62
|
+
* has to cross-reference against a manifest.
|
|
63
|
+
*
|
|
64
|
+
* It does not make every collision impossible — `@a/b-c` and `@a-b/c` still
|
|
65
|
+
* meet — so `assertDistinctOutputs` still runs. That pair is pathological; the
|
|
66
|
+
* scoped-against-unscoped one is `@babel/core` beside `babel-core`, which is a
|
|
67
|
+
* real migration somebody could be bundling.
|
|
68
|
+
*
|
|
69
|
+
* The leading `@` is safe here in a way it is not inside the archive: tar's
|
|
70
|
+
* splice convention applies to the *file list* it is given, which is what
|
|
71
|
+
* `archive.ts` guards with `./`. This is the output path, not an entry.
|
|
72
|
+
*/
|
|
73
|
+
export declare const perSpecArchiveName: (name: string, version: string) => string;
|
|
74
|
+
/** Name of the archive produced in `single` layout. */
|
|
75
|
+
export declare const singleArchiveName: (base?: string) => string;
|
|
76
|
+
/**
|
|
77
|
+
* The import guide written into each bundle.
|
|
78
|
+
*
|
|
79
|
+
* Kept short and copy-pasteable on purpose: whoever opens this is mid-task on a
|
|
80
|
+
* restricted network and does not want prose.
|
|
81
|
+
*/
|
|
82
|
+
export declare const importGuide: (options: {
|
|
83
|
+
readonly packageCount: number;
|
|
84
|
+
readonly createdAt: string;
|
|
85
|
+
readonly toolVersion: string;
|
|
86
|
+
}) => string;
|
|
87
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,SAAS,SACf,MAAM,KACV;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAK7D,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,eAAe,SAAU,MAAM,WAAW,MAAM,KAAG,MAG/D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,WAAW,MAAM,KAAG,MACd,CAAC;AAE/C,gEAAgE;AAChE,eAAO,MAAM,aAAa,yBAAyB,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,kBAAkB,SAAU,MAAM,WAAW,MAAM,KAAG,MAIlE,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,qBAAsB,MAAuB,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B,KAAG,MA+BH,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolution driven by a lockfile instead of by semver.
|
|
3
|
+
*
|
|
4
|
+
* The distinction matters more than it first looks. Feeding a lockfile's
|
|
5
|
+
* versions in as exact root specs and letting the ordinary walk run would still
|
|
6
|
+
* produce the wrong bundle: every *transitive* edge is a range, and
|
|
7
|
+
* `Resolve.walk` answers a range with whatever is newest today. Lock `tslib` at
|
|
8
|
+
* 2.6.0 and let something depending on `tslib@^2` be re-resolved, and the
|
|
9
|
+
* bundle grows a second copy at 2.8.1 that CI never installed.
|
|
10
|
+
*
|
|
11
|
+
* So the lockfile is treated as the graph, not as a set of hints. The package
|
|
12
|
+
* set *is* what the file pins, and every edge is satisfied from inside it.
|
|
13
|
+
* Nothing here calls `selectVersions`; the only thing the registry is asked for
|
|
14
|
+
* is the metadata that a lockfile does not record — `dist`, and the `os`/`cpu`
|
|
15
|
+
* constraints that `--platform` narrows on.
|
|
16
|
+
*
|
|
17
|
+
* The result is an ordinary `Resolution`, so layout, archiving, the manifest
|
|
18
|
+
* and the summary cannot tell which path produced it.
|
|
19
|
+
*/
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import type { BundlerError } from "./errors.js";
|
|
22
|
+
import type { LockedTree } from "./lockfile/types.js";
|
|
23
|
+
import type { ResolveOptions } from "./options.js";
|
|
24
|
+
import * as Progress from "./progress.js";
|
|
25
|
+
import { Registry } from "./registry.js";
|
|
26
|
+
import type { Resolution } from "./resolve.js";
|
|
27
|
+
/** Options for a lockfile-pinned resolution. */
|
|
28
|
+
export type LockedResolveOptions = ResolveOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* Include the project's `devDependencies`.
|
|
31
|
+
*
|
|
32
|
+
* Matches `--file package.json`: on by default, because a project without its
|
|
33
|
+
* dev tooling does not build behind the firewall either.
|
|
34
|
+
*/
|
|
35
|
+
readonly includeDev: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Direct dependency names declared by the accompanying package.json.
|
|
38
|
+
*
|
|
39
|
+
* When present, anything declared there but absent from the lockfile's roots
|
|
40
|
+
* means the two have drifted — which is exactly the silent-mismatch case this
|
|
41
|
+
* whole feature exists to catch, so it is reported rather than papered over.
|
|
42
|
+
*/
|
|
43
|
+
readonly declared?: ReadonlyArray<string> | undefined;
|
|
44
|
+
};
|
|
45
|
+
/** Turns a parsed lockfile into a resolution, pinning every version. */
|
|
46
|
+
export declare const resolveLocked: (lock: LockedTree, options: LockedResolveOptions) => Effect.Effect<Resolution, BundlerError, Registry | Progress.Progress>;
|
|
47
|
+
//# sourceMappingURL=locked-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locked-resolve.d.ts","sourceRoot":"","sources":["../src/locked-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAGX,UAAU,EAIV,MAAM,cAAc,CAAC;AAKtB,gDAAgD;AAChD,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IACnD;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACtD,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,aAAa,SACnB,UAAU,WACP,oBAAoB,KAC3B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CA8EpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../src/lockfile/bun.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC;AAqBzD,eAAO,MAAM,gBAAgB,SACtB,MAAM,WACH,MAAM,YACL,MAAM,GAAG,SAAS,KAC1B,UAsBF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Working out which lockfile — if any — some content is.
|
|
3
|
+
*
|
|
4
|
+
* Detection is by content, matching how `--file` treats everything else: a
|
|
5
|
+
* lockfile renamed to `deps.txt` still parses, and a `package-lock.json` that
|
|
6
|
+
* is actually a package.json still gets read as one.
|
|
7
|
+
*/
|
|
8
|
+
import { LockfileFormat } from "../enums/lockfile-format.js";
|
|
9
|
+
/** What a blob of file content turned out to be. */
|
|
10
|
+
export type LockfileDetection = {
|
|
11
|
+
readonly _tag: "Supported";
|
|
12
|
+
readonly format: LockfileFormat;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Recognisably a lockfile, but not one we can read. Named explicitly so the
|
|
16
|
+
* error says "yarn.lock is not supported yet" rather than leaving somebody to
|
|
17
|
+
* work out why their file parsed as a spec list.
|
|
18
|
+
*/
|
|
19
|
+
| {
|
|
20
|
+
readonly _tag: "Unsupported";
|
|
21
|
+
readonly label: string;
|
|
22
|
+
readonly hint: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly _tag: "NotALockfile";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Deliberately cheap and total: it never throws, so `--file` can try this
|
|
28
|
+
* first and fall through to its other shapes when the answer is `NotALockfile`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const detectLockfile: (content: string) => LockfileDetection;
|
|
31
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/lockfile/detect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI7D,oDAAoD;AACpD,MAAM,MAAM,iBAAiB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE;AACjE;;;;GAIG;GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/E;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,iBA8BhD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const stringOr: (value: unknown, fallback: string) => string;
|
|
2
|
+
/** Keeps only the string-valued members of an untyped object. */
|
|
3
|
+
export declare const stringRecord: (value: unknown) => Readonly<Record<string, string>>;
|
|
4
|
+
/** Names a package marked its peers optional with. */
|
|
5
|
+
export declare const optionalPeerNames: (value: unknown) => ReadonlySet<string>;
|
|
6
|
+
export declare const parseJsonObject: (path: string, content: string) => Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Parses JSON, tolerating the comments and trailing commas bun writes.
|
|
9
|
+
*
|
|
10
|
+
* `bun.lock` is JSONC by design — bun puts explanatory comments in it — so
|
|
11
|
+
* plain `JSON.parse` rejects real lockfiles. Returns `undefined` rather than
|
|
12
|
+
* throwing so detection can use it as a probe.
|
|
13
|
+
*/
|
|
14
|
+
export declare const tryParseJsonc: (content: string) => unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Removes comments and trailing commas.
|
|
17
|
+
*
|
|
18
|
+
* String-aware, because a `//` inside a tarball URL is not a comment and an
|
|
19
|
+
* escaped quote does not end a string. Both appear in every real lockfile.
|
|
20
|
+
*/
|
|
21
|
+
export declare const stripJsonc: (content: string) => string;
|
|
22
|
+
export declare const describeError: (error: unknown) => string;
|
|
23
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/lockfile/json.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ,UAAW,OAAO,YAAY,MAAM,KAAG,MACf,CAAC;AAI9C,iEAAiE;AACjE,eAAO,MAAM,YAAY,UAAW,OAAO,KAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACG,CAAC;AAIjF,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,WAAW,CAAC,MAAM,CAMpE,CAAC;AAEF,eAAO,MAAM,eAAe,SAAU,MAAM,WAAW,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CASrF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,YAAa,MAAM,KAAG,OAU/C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,YAAa,MAAM,KAAG,MAuD5C,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,MACQ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LockfileFormat } from "../enums/lockfile-format.js";
|
|
2
|
+
/**
|
|
3
|
+
* The file name each supported manager writes, in detection order.
|
|
4
|
+
*
|
|
5
|
+
* Ordered: `package-lock.json` before `npm-shrinkwrap.json` before pnpm's and
|
|
6
|
+
* bun's, so a directory holding several is searched the way npm itself would.
|
|
7
|
+
*/
|
|
8
|
+
export declare const formatByLockfileName: {
|
|
9
|
+
readonly "package-lock.json": "npm";
|
|
10
|
+
readonly "npm-shrinkwrap.json": "npm";
|
|
11
|
+
readonly "pnpm-lock.yaml": "pnpm";
|
|
12
|
+
readonly "bun.lock": "bun";
|
|
13
|
+
};
|
|
14
|
+
/** The names a given manager writes. */
|
|
15
|
+
export declare const lockfileNamesFor: (format: LockfileFormat) => ReadonlyArray<string>;
|
|
16
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/lockfile/names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;CAKkB,CAAC;AAEpD,wCAAwC;AACxC,eAAO,MAAM,gBAAgB,WAAY,cAAc,KAAG,aAAa,CAAC,MAAM,CAG5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/lockfile/npm.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC;AAgCzD,eAAO,MAAM,gBAAgB,SACtB,MAAM,WACH,MAAM,YACL,MAAM,GAAG,SAAS,KAC1B,UAuBF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lockfile parsing — npm, pnpm and bun.
|
|
3
|
+
*
|
|
4
|
+
* `--file package.json` reads *ranges*, and a range resolves to whatever is
|
|
5
|
+
* newest at the moment the command runs. That is the right answer for "bundle
|
|
6
|
+
* me something installable" and the wrong one for "bundle exactly what CI
|
|
7
|
+
* installed" — which is what a lockfile records and what this module reads.
|
|
8
|
+
*
|
|
9
|
+
* Three formats, one output shape. Each parser's real job is the same: turn a
|
|
10
|
+
* manager-specific encoding of "package X at path P depends on Y" into a flat
|
|
11
|
+
* graph keyed by `name@version`, with every edge already pointing at a concrete
|
|
12
|
+
* version. Once that is done, nothing downstream has to know which manager
|
|
13
|
+
* wrote the file.
|
|
14
|
+
*/
|
|
15
|
+
import { LockfileFormat } from "../enums/lockfile-format.js";
|
|
16
|
+
import type { LockedTree, LockfileParseOptions } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Parses lockfile content into a flat graph.
|
|
19
|
+
*
|
|
20
|
+
* Throws `LockfileError`; the caller is expected to be inside an `Effect.try`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const parseLockfile: (path: string, content: string, format?: LockfileFormat, options?: LockfileParseOptions) => LockedTree;
|
|
23
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/lockfile/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAM7D,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,aAAa,SACnB,MAAM,WACH,MAAM,WACN,cAAc,YACd,oBAAoB,KAC3B,UAWF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LockedTree } from "./types.js";
|
|
2
|
+
/** `name@version`, as a snapshot or importer entry resolves to. */
|
|
3
|
+
type PnpmReference = {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly version: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const parsePnpmLockfile: (path: string, content: string, importer: string | undefined) => LockedTree;
|
|
8
|
+
/**
|
|
9
|
+
* Splits a package key into name and version.
|
|
10
|
+
*
|
|
11
|
+
* Three encodings across the versions still in the wild:
|
|
12
|
+
* v5 `/@babel/core/7.0.0`
|
|
13
|
+
* v6 `/@babel/core@7.0.0`
|
|
14
|
+
* v9 `@babel/core@7.0.0`
|
|
15
|
+
*
|
|
16
|
+
* plus an optional `(peer@1.0.0)` or `(patch_hash=…)` suffix on any of them.
|
|
17
|
+
*/
|
|
18
|
+
export declare const parsePnpmKey: (key: string) => PnpmReference | null;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=pnpm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../src/lockfile/pnpm.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD,mEAAmE;AACnE,KAAK,aAAa,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB,CAAC;AAKF,eAAO,MAAM,iBAAiB,SACvB,MAAM,WACH,MAAM,YACL,MAAM,GAAG,SAAS,KAC1B,UAgDF,CAAC;AAgGF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,aAAa,GAAG,IAc1D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { LockfileFormat } from "../enums/lockfile-format.js";
|
|
2
|
+
import type { LockedPackage, LockedRoot, LockedTree } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Which manifest block each root kind is declared in.
|
|
5
|
+
*
|
|
6
|
+
* The block names are the same across npm, pnpm and bun; only which of them a
|
|
7
|
+
* given format writes differs, which is why each parser supplies its own order
|
|
8
|
+
* rather than iterating this.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fieldByRootKind: {
|
|
11
|
+
readonly prod: "dependencies";
|
|
12
|
+
readonly optional: "optionalDependencies";
|
|
13
|
+
readonly dev: "devDependencies";
|
|
14
|
+
readonly peer: "peerDependencies";
|
|
15
|
+
};
|
|
16
|
+
export declare class TreeBuilder {
|
|
17
|
+
readonly packages: Map<string, LockedPackage>;
|
|
18
|
+
readonly roots: Array<LockedRoot>;
|
|
19
|
+
readonly warnings: Array<string>;
|
|
20
|
+
readonly incomplete: Array<string>;
|
|
21
|
+
/** Names dropped on purpose, so an edge into one is explained, not alarming. */
|
|
22
|
+
private readonly skipped;
|
|
23
|
+
private readonly seenWarnings;
|
|
24
|
+
add(pkg: LockedPackage): void;
|
|
25
|
+
addRoot(root: LockedRoot): void;
|
|
26
|
+
warn(message: string): void;
|
|
27
|
+
/** Notes an entry that is real but cannot come from a registry. */
|
|
28
|
+
skip(name: string, spec: string, reason: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Records a required edge that resolved to nothing.
|
|
31
|
+
*
|
|
32
|
+
* An edge into something skipped on purpose is expected — you cannot bundle a
|
|
33
|
+
* `workspace:` sibling from a registry — so it stays a warning. Anything else
|
|
34
|
+
* means the file does not pin what it claims to.
|
|
35
|
+
*/
|
|
36
|
+
dangling(from: string, name: string): void;
|
|
37
|
+
finish(input: {
|
|
38
|
+
readonly format: LockfileFormat;
|
|
39
|
+
readonly lockfileVersion: string;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly importer?: string | undefined;
|
|
42
|
+
}): LockedTree;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reads the right-hand side of a locked entry as an exact version.
|
|
46
|
+
*
|
|
47
|
+
* Returns the version when it is one, or the reason it is not — `file:../x`,
|
|
48
|
+
* `workspace:*`, a git URL. `parseDependencyTarget` already classifies every
|
|
49
|
+
* one of those for package.json parsing, so the vocabulary of skip reasons
|
|
50
|
+
* stays identical between the two paths.
|
|
51
|
+
*/
|
|
52
|
+
export declare const asExactVersion: (name: string, raw: string) => {
|
|
53
|
+
readonly _tag: "Version";
|
|
54
|
+
readonly version: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly _tag: "Unsupported";
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Raised when a lockfile found by walking up turns out not to cover the
|
|
61
|
+
* package.json that went looking for it.
|
|
62
|
+
*
|
|
63
|
+
* Worth distinguishing from "no lockfile at all": the file exists and is
|
|
64
|
+
* readable, it simply belongs to a different project, and bundling it would
|
|
65
|
+
* produce someone else's dependency set.
|
|
66
|
+
*/
|
|
67
|
+
export declare const notCovered: (path: string, importer: string, known: ReadonlyArray<string>) => never;
|
|
68
|
+
/** `""` is how npm and bun spell the project at the lockfile's own level. */
|
|
69
|
+
export declare const importerKey: (importer: string) => string;
|
|
70
|
+
//# sourceMappingURL=tree-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-builder.d.ts","sourceRoot":"","sources":["../../src/lockfile/tree-builder.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,KAAK,EAAc,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;mBACJ,cAAc;uBACV,sBAAsB;kBAC3B,iBAAiB;mBAChB,kBAAkB;CACS,CAAC;AAEpD,qBAAa,WAAW;IACvB,QAAQ,CAAC,QAAQ,6BAAoC;IACrD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAM;IACvC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IACtC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IACxC,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAElD,GAAG,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAc5B;IAED,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAG9B;IAED,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI1B;IAED,mEAAmE;IACnE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGrD;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAMzC;IAED,MAAM,CAAC,KAAK,EAAE;QACb,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;QAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;QACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACvC,GAAG,UAAU,CAcb;CACD;AAaD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,SACpB,MAAM,OACP,MAAM,KAET;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAOzD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,YAAY,MAAM,SAAS,aAAa,CAAC,MAAM,CAAC,KAAG,KAazF,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,WAAW,aAAc,MAAM,KAAG,MAA4C,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one output shape every lockfile parser produces.
|
|
3
|
+
*
|
|
4
|
+
* npm, pnpm and bun encode "package X at path P depends on Y" in three
|
|
5
|
+
* different ways; once flattened into this graph, nothing downstream has to
|
|
6
|
+
* know which manager wrote the file.
|
|
7
|
+
*/
|
|
8
|
+
import type { EdgeKind, LockedRootKind } from "../enums/edge-kind.js";
|
|
9
|
+
import type { LockfileFormat } from "../enums/lockfile-format.js";
|
|
10
|
+
/** One edge out of a locked package, already pinned to an exact version. */
|
|
11
|
+
export type LockedEdge = {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly version: string;
|
|
14
|
+
readonly kind: EdgeKind;
|
|
15
|
+
};
|
|
16
|
+
/** One package pinned by a lockfile. */
|
|
17
|
+
export type LockedPackage = {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
readonly dependencies: ReadonlyArray<LockedEdge>;
|
|
21
|
+
};
|
|
22
|
+
/** A direct dependency of the locked project. */
|
|
23
|
+
export type LockedRoot = {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly version: string;
|
|
26
|
+
readonly kind: LockedRootKind;
|
|
27
|
+
/** The range the manifest asked for, kept for reporting. */
|
|
28
|
+
readonly specifier?: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
/** Options for reading a lockfile. */
|
|
31
|
+
export type LockfileParseOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Which workspace member's dependencies become the roots, as a path relative
|
|
34
|
+
* to the lockfile in POSIX form — `"packages/core"`, or `"."` for the project
|
|
35
|
+
* at the lockfile's own level.
|
|
36
|
+
*
|
|
37
|
+
* Left undefined, every workspace member in the file contributes, which is
|
|
38
|
+
* what pointing `--file` straight at a lockfile should mean. It matters when
|
|
39
|
+
* a package.json found a lockfile by walking *up*: the file then pins the
|
|
40
|
+
* whole repository, and only one member of it was asked for.
|
|
41
|
+
*/
|
|
42
|
+
readonly importer?: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
/** A whole lockfile, flattened. */
|
|
45
|
+
export type LockedTree = {
|
|
46
|
+
readonly format: LockfileFormat;
|
|
47
|
+
/** As the file declares it: `3`, `'9.0'`, `1`. */
|
|
48
|
+
readonly lockfileVersion: string;
|
|
49
|
+
/** Where it was read from, for error messages. */
|
|
50
|
+
readonly path: string;
|
|
51
|
+
/** The workspace member the roots came from, when one was selected. */
|
|
52
|
+
readonly importer?: string | undefined;
|
|
53
|
+
/** Every pinned package, keyed by `name@version`. */
|
|
54
|
+
readonly packages: ReadonlyMap<string, LockedPackage>;
|
|
55
|
+
/** The project's direct dependencies. */
|
|
56
|
+
readonly roots: ReadonlyArray<LockedRoot>;
|
|
57
|
+
/** Entries that were recognised but cannot be fetched from a registry. */
|
|
58
|
+
readonly warnings: ReadonlyArray<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Required edges pointing at nothing the file pins.
|
|
61
|
+
*
|
|
62
|
+
* Distinct from `warnings`: a `workspace:` dependency that cannot be bundled
|
|
63
|
+
* is expected and gets a warning, while an ordinary registry dependency with
|
|
64
|
+
* no entry means the lockfile is genuinely partial and the bundle it produces
|
|
65
|
+
* would be missing a package. The caller decides what to do about it, but the
|
|
66
|
+
* two must not be confused.
|
|
67
|
+
*/
|
|
68
|
+
readonly incomplete: ReadonlyArray<string>;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lockfile/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACxB,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACjD,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,sCAAsC;AACtC,MAAM,MAAM,oBAAoB,GAAG;IAClC;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtD,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC1C,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC"}
|