@packall/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Archive.d.ts +32 -0
- package/dist/Archive.d.ts.map +1 -0
- package/dist/Bundle.d.ts +123 -0
- package/dist/Bundle.d.ts.map +1 -0
- package/dist/DependencyRange.d.ts +26 -0
- package/dist/DependencyRange.d.ts.map +1 -0
- package/dist/Download.d.ts +35 -0
- package/dist/Download.d.ts.map +1 -0
- package/dist/Errors.d.ts +124 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/InputFile.d.ts +46 -0
- package/dist/InputFile.d.ts.map +1 -0
- package/dist/Integrity.d.ts +48 -0
- package/dist/Integrity.d.ts.map +1 -0
- package/dist/Layout.d.ts +53 -0
- package/dist/Layout.d.ts.map +1 -0
- package/dist/Manifest.d.ts +82 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Options.d.ts +100 -0
- package/dist/Options.d.ts.map +1 -0
- package/dist/Platform.d.ts +69 -0
- package/dist/Platform.d.ts.map +1 -0
- package/dist/Progress.d.ts +107 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Registry.d.ts +106 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Resolve.d.ts +105 -0
- package/dist/Resolve.d.ts.map +1 -0
- package/dist/Spec.d.ts +62 -0
- package/dist/Spec.d.ts.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1766 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
- package/src/Archive.ts +92 -0
- package/src/Bundle.ts +570 -0
- package/src/DependencyRange.ts +115 -0
- package/src/Download.ts +132 -0
- package/src/Errors.ts +216 -0
- package/src/InputFile.ts +229 -0
- package/src/Integrity.ts +122 -0
- package/src/Layout.ts +103 -0
- package/src/Manifest.ts +133 -0
- package/src/Options.ts +123 -0
- package/src/Platform.ts +182 -0
- package/src/Progress.ts +106 -0
- package/src/Registry.ts +121 -0
- package/src/Resolve.ts +528 -0
- package/src/Spec.ts +186 -0
- package/src/index.ts +44 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a staged directory tree into a gzipped tarball.
|
|
3
|
+
*
|
|
4
|
+
* Uses `node-tar`, the same library npm itself packs with. Writing a USTAR
|
|
5
|
+
* encoder by hand would be a fun afternoon and a bad idea: scoped package
|
|
6
|
+
* paths routinely exceed the 100-byte name field, so correctness depends on
|
|
7
|
+
* prefix-splitting and PAX headers that `tar` already gets right.
|
|
8
|
+
*/
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as FileSystem from "effect/FileSystem";
|
|
11
|
+
import type { PlatformError } from "effect/PlatformError";
|
|
12
|
+
import { ArchiveError } from "./Errors.js";
|
|
13
|
+
import * as Progress from "./Progress.js";
|
|
14
|
+
/** A finished archive. */
|
|
15
|
+
export interface ArchiveResult {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly bytes: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Packs `entries` (paths relative to `cwd`) into a gzipped tar at `outPath`.
|
|
21
|
+
*
|
|
22
|
+
* `portable` normalises uid/gid/mtime so the same inputs produce byte-identical
|
|
23
|
+
* output — which matters when a security team wants to diff two bundles or
|
|
24
|
+
* re-derive one from a manifest.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createArchive: (options: {
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
readonly entries: ReadonlyArray<string>;
|
|
29
|
+
readonly outPath: string;
|
|
30
|
+
readonly gzipLevel?: number | undefined;
|
|
31
|
+
}) => Effect.Effect<ArchiveResult, ArchiveError | PlatformError, FileSystem.FileSystem | Progress.Progress>;
|
|
32
|
+
//# sourceMappingURL=Archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Archive.d.ts","sourceRoot":"","sources":["../src/Archive.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,0BAA0B;AAC1B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,YAAa;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACxC,KAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,GAAG,aAAa,EAAE,UAAU,CAAC,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAoCpG,CAAA"}
|
package/dist/Bundle.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-end orchestration: specs in, tarballs out.
|
|
3
|
+
*
|
|
4
|
+
* Two properties this module is responsible for, both of them fixes for how
|
|
5
|
+
* the original tool behaved:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Nothing is written outside the output directory.** Every intermediate
|
|
8
|
+
* file lives in a scoped temp directory obtained from
|
|
9
|
+
* `makeTempDirectoryScoped`, so the scope closing — on success, on failure,
|
|
10
|
+
* or on Ctrl-C — takes the whole staging tree with it. The working
|
|
11
|
+
* directory is never touched.
|
|
12
|
+
*
|
|
13
|
+
* 2. **Each package is downloaded exactly once**, no matter how many bundles
|
|
14
|
+
* it ends up in. Per-spec archives are assembled by hard-linking out of one
|
|
15
|
+
* shared download tree, so `per-spec` costs extra disk in the *output*, not
|
|
16
|
+
* extra network.
|
|
17
|
+
*/
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import * as FileSystem from "effect/FileSystem";
|
|
20
|
+
import * as Path from "effect/Path";
|
|
21
|
+
import type { PlatformError } from "effect/PlatformError";
|
|
22
|
+
import type { BundlerError } from "./Errors.js";
|
|
23
|
+
import type { BundleOptions, Layout } from "./Options.js";
|
|
24
|
+
import * as Progress from "./Progress.js";
|
|
25
|
+
import { Registry } from "./Registry.js";
|
|
26
|
+
import type { Resolution } from "./Resolve.js";
|
|
27
|
+
import type { PackageSpec } from "./Spec.js";
|
|
28
|
+
/** One thing written to the output directory. */
|
|
29
|
+
export interface BundleArtifact {
|
|
30
|
+
readonly kind: "archive" | "directory";
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly bytes: number;
|
|
33
|
+
readonly packageCount: number;
|
|
34
|
+
/** Which spec this artifact covers. Absent for `single` and `dir`. */
|
|
35
|
+
readonly spec?: string | undefined;
|
|
36
|
+
readonly version?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** The outcome of a bundle run. */
|
|
39
|
+
export interface BundleResult {
|
|
40
|
+
readonly resolution: Resolution;
|
|
41
|
+
readonly artifacts: ReadonlyArray<BundleArtifact>;
|
|
42
|
+
/** Total bytes downloaded from the registry. */
|
|
43
|
+
readonly downloadedBytes: number;
|
|
44
|
+
/** Packages the registry advertised no usable checksum for. */
|
|
45
|
+
readonly unverified: ReadonlyArray<string>;
|
|
46
|
+
readonly dryRun: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Everything `bundle` needs beyond the user-facing options. */
|
|
49
|
+
export interface BundleContext extends BundleOptions {
|
|
50
|
+
/** Recorded in the manifest so a bundle can be traced to the tool that built it. */
|
|
51
|
+
readonly toolVersion: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A summary of what a resolution would produce, for deciding whether the
|
|
55
|
+
* chosen layout is still the right one.
|
|
56
|
+
*/
|
|
57
|
+
export interface PlanSummary {
|
|
58
|
+
/** Distinct packages in the deduplicated union. */
|
|
59
|
+
readonly uniquePackages: number;
|
|
60
|
+
/** How many archives `per-spec` layout would emit. */
|
|
61
|
+
readonly perSpecArchives: number;
|
|
62
|
+
/**
|
|
63
|
+
* Total package entries across all per-spec archives, counting shared
|
|
64
|
+
* dependencies once per archive they appear in. The gap between this and
|
|
65
|
+
* `uniquePackages` is exactly what `single` layout would save.
|
|
66
|
+
*/
|
|
67
|
+
readonly perSpecEntries: number;
|
|
68
|
+
}
|
|
69
|
+
/** Computes the plan summary for a resolution. */
|
|
70
|
+
export declare const summarize: (resolution: Resolution) => PlanSummary;
|
|
71
|
+
/** Replaces the layout on a set of options. */
|
|
72
|
+
export declare const withLayout: <T extends BundleOptions>(options: T, layout: Layout) => T;
|
|
73
|
+
type BundleEnv = Registry | Progress.Progress | FileSystem.FileSystem | Path.Path;
|
|
74
|
+
/**
|
|
75
|
+
* Checks the registry is reachable, then resolves every spec.
|
|
76
|
+
*
|
|
77
|
+
* Split out from `bundle` so a caller can inspect the plan — how many packages,
|
|
78
|
+
* how many archives — and act on it before any bytes move. The CLI uses this to
|
|
79
|
+
* offer a different layout when a run turns out to be much larger than
|
|
80
|
+
* expected.
|
|
81
|
+
*/
|
|
82
|
+
export declare const plan: (specs: ReadonlyArray<PackageSpec>, options: BundleOptions) => Effect.Effect<Resolution, BundlerError, Registry | Progress.Progress>;
|
|
83
|
+
/**
|
|
84
|
+
* Resolves, downloads and packages a set of specs.
|
|
85
|
+
*
|
|
86
|
+
* Under `dryRun` this stops after resolution and reports the plan — useful for
|
|
87
|
+
* checking what a command *would* pull before committing to a multi-gigabyte
|
|
88
|
+
* download over a slow VPN.
|
|
89
|
+
*/
|
|
90
|
+
export declare const bundle: (specs: ReadonlyArray<PackageSpec>, options: BundleContext) => Effect.Effect<BundleResult, BundlerError | PlatformError, BundleEnv>;
|
|
91
|
+
/**
|
|
92
|
+
* Downloads and packages an already-computed resolution.
|
|
93
|
+
*
|
|
94
|
+
* Everything from here on touches the disk, and all of it happens inside
|
|
95
|
+
* `Effect.scoped` — so the staging tree's lifetime is exactly this call,
|
|
96
|
+
* including when it fails partway through or the user hits Ctrl-C.
|
|
97
|
+
*/
|
|
98
|
+
export declare const bundleResolved: (resolution: Resolution, options: BundleContext) => Effect.Effect<BundleResult, BundlerError | PlatformError, BundleEnv>;
|
|
99
|
+
/**
|
|
100
|
+
* Creates the output directory, refusing to clobber an existing non-empty one
|
|
101
|
+
* unless `--force` was passed.
|
|
102
|
+
*
|
|
103
|
+
* Silently overwriting somebody's previous bundle is the kind of thing a tool
|
|
104
|
+
* only gets forgiven for once.
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* The files a run will write, known before anything is downloaded.
|
|
108
|
+
*
|
|
109
|
+
* `dir` layout is the odd one: it merges a package tree into `outDir`, and
|
|
110
|
+
* package paths are `name/-/name-version.tgz` — the same package at the same
|
|
111
|
+
* version is the same bytes, so an overlap there is idempotent rather than
|
|
112
|
+
* destructive. Only the two summary files are genuinely replaced, and those are
|
|
113
|
+
* the ones worth guarding.
|
|
114
|
+
*/
|
|
115
|
+
export interface PlannedOutput {
|
|
116
|
+
readonly file: string;
|
|
117
|
+
/** The root this file belongs to, when one file corresponds to one spec. */
|
|
118
|
+
readonly name?: string | undefined;
|
|
119
|
+
readonly version?: string | undefined;
|
|
120
|
+
}
|
|
121
|
+
export declare const plannedOutputs: (resolution: Resolution, options: BundleContext) => ReadonlyArray<PlannedOutput>;
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=Bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bundle.d.ts","sourceRoot":"","sources":["../src/Bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA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,SAAS,CAAA;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AAED,eAAO,MAAM,cAAc,eACb,UAAU,WACb,aAAa,KACrB,aAAa,CAAC,aAAa,CAY7B,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Selector } from "./Spec.js";
|
|
2
|
+
/** What a dependency edge points at. */
|
|
3
|
+
export type DependencyTarget =
|
|
4
|
+
/** A normal registry dependency. `name` may differ from the key under an alias. */
|
|
5
|
+
{
|
|
6
|
+
readonly _tag: "Registry";
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly selector: Selector;
|
|
9
|
+
/** Set when the edge is an `npm:` alias, e.g. `"lodash4": "npm:lodash@^4"`. */
|
|
10
|
+
readonly aliasOf?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Something we cannot fetch from a registry. */
|
|
13
|
+
| {
|
|
14
|
+
readonly _tag: "Unsupported";
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly raw: string;
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Classifies one `name -> range` entry.
|
|
21
|
+
*
|
|
22
|
+
* An empty range, `*`, and `latest` all mean "any published version"; npm
|
|
23
|
+
* treats them interchangeably and so do we.
|
|
24
|
+
*/
|
|
25
|
+
export declare const parseDependencyTarget: (name: string, raw: string) => DependencyTarget;
|
|
26
|
+
//# sourceMappingURL=DependencyRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyRange.d.ts","sourceRoot":"","sources":["../src/DependencyRange.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,wCAAwC;AACxC,MAAM,MAAM,gBAAgB;AAC1B,mFAAmF;AACjF;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AACH,iDAAiD;GAC/C;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAiB1G;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SAAU,MAAM,OAAO,MAAM,KAAG,gBAuCjE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetching tarballs into the staging tree.
|
|
3
|
+
*
|
|
4
|
+
* Downloads run concurrently, every one is checksum-verified before it is
|
|
5
|
+
* written, and the destination is always the scoped temp directory — nothing
|
|
6
|
+
* lands next to the user's own files.
|
|
7
|
+
*/
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as FileSystem from "effect/FileSystem";
|
|
10
|
+
import * as Path from "effect/Path";
|
|
11
|
+
import type { PlatformError } from "effect/PlatformError";
|
|
12
|
+
import type { BundlerError } from "./Errors.js";
|
|
13
|
+
import * as Progress from "./Progress.js";
|
|
14
|
+
import { Registry } from "./Registry.js";
|
|
15
|
+
import type { ResolvedPackage } from "./Resolve.js";
|
|
16
|
+
/** What a completed download run produced. */
|
|
17
|
+
export interface DownloadReport {
|
|
18
|
+
/** `name@version` -> bytes written. */
|
|
19
|
+
readonly sizes: ReadonlyMap<string, number>;
|
|
20
|
+
/** Packages the registry advertised no usable checksum for. */
|
|
21
|
+
readonly unverified: ReadonlyArray<string>;
|
|
22
|
+
readonly totalBytes: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Downloads every package into `destDir`, laid out the way a registry serves
|
|
26
|
+
* them.
|
|
27
|
+
*
|
|
28
|
+
* `verifyIntegrity` defaulting to on is deliberate: a corrupt tarball that
|
|
29
|
+
* makes it into a corporate registry is far more expensive than a failed run.
|
|
30
|
+
*/
|
|
31
|
+
export declare const downloadAll: (packages: ReadonlyArray<ResolvedPackage>, destDir: string, options: {
|
|
32
|
+
readonly concurrency: number;
|
|
33
|
+
readonly verifyIntegrity: boolean;
|
|
34
|
+
}) => Effect.Effect<DownloadReport, BundlerError | PlatformError, Registry | Progress.Progress | FileSystem.FileSystem | Path.Path>;
|
|
35
|
+
//# sourceMappingURL=Download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Download.d.ts","sourceRoot":"","sources":["../src/Download.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,aAAa,CAAC,eAAe,CAAC,WAC/B,MAAM,WACN;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAAE,KAC3E,MAAM,CAAC,MAAM,CACd,cAAc,EACd,YAAY,GAAG,aAAa,EAC5B,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAyF9D,CAAA"}
|
package/dist/Errors.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure types for the bundler.
|
|
3
|
+
*
|
|
4
|
+
* These are deliberately plain classes carrying a literal `_tag` rather than
|
|
5
|
+
* `Data.TaggedError`. They work with `Effect.catchTag` / `Effect.catchTags`
|
|
6
|
+
* exactly the same way, and they keep the public error surface independent of
|
|
7
|
+
* any single Effect release — useful while Effect v4 is still in beta.
|
|
8
|
+
*
|
|
9
|
+
* Every error carries enough context to be actionable without a stack trace,
|
|
10
|
+
* because the primary consumer is somebody staring at a terminal on a
|
|
11
|
+
* locked-down network trying to work out why a download did not happen.
|
|
12
|
+
*/
|
|
13
|
+
/** Discriminant union of every failure the bundler can produce. */
|
|
14
|
+
export type BundlerError = InvalidSpecError | InvalidInputFileError | RegistryUnreachableError | PackageNotFoundError | VersionNotFoundError | NoMatchingVersionsError | RegistryResponseError | AuthenticationError | IntegrityError | ArchiveError | OutputError;
|
|
15
|
+
declare abstract class BundlerErrorBase extends Error {
|
|
16
|
+
abstract readonly _tag: string;
|
|
17
|
+
constructor(message: string, options?: {
|
|
18
|
+
cause?: unknown;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** A package spec on the command line or in an input file could not be parsed. */
|
|
22
|
+
export declare class InvalidSpecError extends BundlerErrorBase {
|
|
23
|
+
readonly _tag: "InvalidSpecError";
|
|
24
|
+
readonly spec: string;
|
|
25
|
+
readonly reason: string;
|
|
26
|
+
constructor(spec: string, reason: string);
|
|
27
|
+
}
|
|
28
|
+
/** `--file` pointed at something that is neither a usable package.json nor a spec list. */
|
|
29
|
+
export declare class InvalidInputFileError extends BundlerErrorBase {
|
|
30
|
+
readonly _tag: "InvalidInputFileError";
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly reason: string;
|
|
33
|
+
constructor(path: string, reason: string, options?: {
|
|
34
|
+
cause?: unknown;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The registry could not be reached at all — DNS failure, refused connection,
|
|
39
|
+
* proxy blackhole, or a preflight that timed out.
|
|
40
|
+
*
|
|
41
|
+
* This is the error that fixes "hangs forever with no network": we surface it
|
|
42
|
+
* quickly and say which host we could not reach.
|
|
43
|
+
*/
|
|
44
|
+
export declare class RegistryUnreachableError extends BundlerErrorBase {
|
|
45
|
+
readonly _tag: "RegistryUnreachableError";
|
|
46
|
+
readonly registry: string;
|
|
47
|
+
readonly timeoutMillis: number | undefined;
|
|
48
|
+
constructor(registry: string, detail: string, options?: {
|
|
49
|
+
cause?: unknown;
|
|
50
|
+
timeoutMillis?: number;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** The registry answered, but has never heard of this package. */
|
|
54
|
+
export declare class PackageNotFoundError extends BundlerErrorBase {
|
|
55
|
+
readonly _tag: "PackageNotFoundError";
|
|
56
|
+
readonly packageName: string;
|
|
57
|
+
readonly registry: string;
|
|
58
|
+
constructor(packageName: string, registry: string);
|
|
59
|
+
}
|
|
60
|
+
/** The package exists but the exact version requested does not. */
|
|
61
|
+
export declare class VersionNotFoundError extends BundlerErrorBase {
|
|
62
|
+
readonly _tag: "VersionNotFoundError";
|
|
63
|
+
readonly packageName: string;
|
|
64
|
+
readonly version: string;
|
|
65
|
+
readonly available: ReadonlyArray<string>;
|
|
66
|
+
constructor(packageName: string, version: string, available: ReadonlyArray<string>);
|
|
67
|
+
}
|
|
68
|
+
/** A range (or dist-tag) matched nothing that is actually published. */
|
|
69
|
+
export declare class NoMatchingVersionsError extends BundlerErrorBase {
|
|
70
|
+
readonly _tag: "NoMatchingVersionsError";
|
|
71
|
+
readonly packageName: string;
|
|
72
|
+
readonly selector: string;
|
|
73
|
+
readonly available: ReadonlyArray<string>;
|
|
74
|
+
constructor(packageName: string, selector: string, available: ReadonlyArray<string>);
|
|
75
|
+
}
|
|
76
|
+
/** The registry responded, but with something we cannot use. */
|
|
77
|
+
export declare class RegistryResponseError extends BundlerErrorBase {
|
|
78
|
+
readonly _tag: "RegistryResponseError";
|
|
79
|
+
readonly url: string;
|
|
80
|
+
readonly status: number | undefined;
|
|
81
|
+
constructor(url: string, detail: string, options?: {
|
|
82
|
+
cause?: unknown;
|
|
83
|
+
status?: number;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** 401/403 — almost always a missing or stale token in `.npmrc`. */
|
|
87
|
+
export declare class AuthenticationError extends BundlerErrorBase {
|
|
88
|
+
readonly _tag: "AuthenticationError";
|
|
89
|
+
readonly registry: string;
|
|
90
|
+
readonly status: number;
|
|
91
|
+
constructor(registry: string, status: number, packageName?: string);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A downloaded tarball did not match the checksum the registry advertised.
|
|
95
|
+
*
|
|
96
|
+
* Never soft-fail this: a bundle is a supply-chain artifact and a corrupt or
|
|
97
|
+
* substituted tarball is exactly what integrity checking exists to catch.
|
|
98
|
+
*/
|
|
99
|
+
export declare class IntegrityError extends BundlerErrorBase {
|
|
100
|
+
readonly _tag: "IntegrityError";
|
|
101
|
+
readonly packageName: string;
|
|
102
|
+
readonly version: string;
|
|
103
|
+
readonly expected: string;
|
|
104
|
+
readonly actual: string;
|
|
105
|
+
constructor(packageName: string, version: string, expected: string, actual: string);
|
|
106
|
+
}
|
|
107
|
+
/** Something went wrong writing the `.tgz`. */
|
|
108
|
+
export declare class ArchiveError extends BundlerErrorBase {
|
|
109
|
+
readonly _tag: "ArchiveError";
|
|
110
|
+
readonly path: string;
|
|
111
|
+
constructor(path: string, detail: string, options?: {
|
|
112
|
+
cause?: unknown;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Something went wrong preparing or writing to the output directory. */
|
|
116
|
+
export declare class OutputError extends BundlerErrorBase {
|
|
117
|
+
readonly _tag: "OutputError";
|
|
118
|
+
readonly path: string;
|
|
119
|
+
constructor(path: string, detail: string, options?: {
|
|
120
|
+
cause?: unknown;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mEAAmE;AACnE,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,qBAAqB,GACrB,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,uBAAuB,GACvB,qBAAqB,GACrB,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,WAAW,CAAA;AAEf,uBAAe,gBAAiB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAC9B,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGzD;CACF;AAED,kFAAkF;AAClF,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,IAAI,EAAG,kBAAkB,CAAS;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAIvC;CACF;AAED,2FAA2F;AAC3F,qBAAa,qBAAsB,SAAQ,gBAAgB;IACzD,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAS;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,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AE,MAAM,EAAE,MAAM,EAAE,MAAM,EAWjF;CACF;AAED,+CAA+C;AAC/C,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,QAAQ,CAAC,IAAI,EAAG,cAAc,CAAS;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGtE;CACF;AAED,yEAAyE;AACzE,qBAAa,WAAY,SAAQ,gBAAgB;IAC/C,QAAQ,CAAC,IAAI,EAAG,aAAa,CAAS;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGtE;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--file` handling.
|
|
3
|
+
*
|
|
4
|
+
* One flag, two 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 **newline-delimited list** — one spec per line, `#` and `//` comments
|
|
10
|
+
* allowed, blank lines ignored
|
|
11
|
+
*/
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as FileSystem from "effect/FileSystem";
|
|
14
|
+
import { InvalidInputFileError } from "./Errors.js";
|
|
15
|
+
import type { PackageSpec } from "./Spec.js";
|
|
16
|
+
/** Which of the two shapes a file turned out to be. */
|
|
17
|
+
export type InputFileKind = "package.json" | "list";
|
|
18
|
+
export interface InputFileResult {
|
|
19
|
+
readonly kind: InputFileKind;
|
|
20
|
+
readonly specs: ReadonlyArray<PackageSpec>;
|
|
21
|
+
/** Entries that were recognised but cannot be bundled from a registry. */
|
|
22
|
+
readonly warnings: ReadonlyArray<string>;
|
|
23
|
+
}
|
|
24
|
+
/** Which dependency blocks of a package.json become root specs. */
|
|
25
|
+
export interface InputFileOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Include `devDependencies`.
|
|
28
|
+
*
|
|
29
|
+
* On by default: if you are pointing this tool at a package.json, you are
|
|
30
|
+
* almost certainly trying to make that project installable behind the
|
|
31
|
+
* firewall, and a project without its dev tooling does not build. `--prod`
|
|
32
|
+
* turns it off.
|
|
33
|
+
*/
|
|
34
|
+
readonly includeDev: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const defaultInputFileOptions: InputFileOptions;
|
|
37
|
+
/** Reads and parses an input file. */
|
|
38
|
+
export declare const readInputFile: (filePath: string, options?: InputFileOptions) => Effect.Effect<InputFileResult, InvalidInputFileError, FileSystem.FileSystem>;
|
|
39
|
+
/**
|
|
40
|
+
* Parses file content that has already been read.
|
|
41
|
+
*
|
|
42
|
+
* Split out from the IO so the whole of this logic is testable with plain
|
|
43
|
+
* strings and no file system at all.
|
|
44
|
+
*/
|
|
45
|
+
export declare const parseInputFile: (filePath: string, content: string, options?: InputFileOptions) => InputFileResult;
|
|
46
|
+
//# sourceMappingURL=InputFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InputFile.d.ts","sourceRoot":"","sources":["../src/InputFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAG5C,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,MAAM,CAAA;AAEnD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;IAC1C,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACzC;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC7B;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAAuC,CAAA;AAE7E,sCAAsC;AACtC,eAAO,MAAM,aAAa,aACd,MAAM,YACP,gBAAgB,KACxB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,qBAAqB,EAAE,UAAU,CAAC,UAAU,CAsB1E,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aACf,MAAM,WACP,MAAM,YACN,gBAAgB,KACxB,eASF,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** One parsed SRI hash. */
|
|
2
|
+
export interface IntegrityHash {
|
|
3
|
+
readonly algorithm: string;
|
|
4
|
+
/** Base64 digest, exactly as written in the SRI string. */
|
|
5
|
+
readonly digest: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses an SRI string such as `sha512-abc...==`.
|
|
9
|
+
*
|
|
10
|
+
* npm permits several space-separated hashes; we keep every one we can verify
|
|
11
|
+
* and ignore algorithms Node does not implement.
|
|
12
|
+
*/
|
|
13
|
+
export declare const parseIntegrity: (integrity: string) => ReadonlyArray<IntegrityHash>;
|
|
14
|
+
/** Computes the base64 digest of some bytes under one algorithm. */
|
|
15
|
+
export declare const digestOf: (data: Uint8Array, algorithm: string) => string;
|
|
16
|
+
/** Computes the hex digest of some bytes — the form legacy `shasum` uses. */
|
|
17
|
+
export declare const hexDigestOf: (data: Uint8Array, algorithm: string) => string;
|
|
18
|
+
/** Result of checking a download. */
|
|
19
|
+
export type VerificationResult =
|
|
20
|
+
/** Verified against at least one checksum. */
|
|
21
|
+
{
|
|
22
|
+
readonly _tag: "Verified";
|
|
23
|
+
readonly using: string;
|
|
24
|
+
}
|
|
25
|
+
/** The registry advertised no checksum we could use. */
|
|
26
|
+
| {
|
|
27
|
+
readonly _tag: "Unverifiable";
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
}
|
|
30
|
+
/** A checksum was present and did not match. */
|
|
31
|
+
| {
|
|
32
|
+
readonly _tag: "Mismatch";
|
|
33
|
+
readonly expected: string;
|
|
34
|
+
readonly actual: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Checks bytes against whichever checksums the registry supplied.
|
|
38
|
+
*
|
|
39
|
+
* SRI is preferred; `shasum` is the fallback for versions published before
|
|
40
|
+
* integrity strings existed. If the registry gave us neither, that is reported
|
|
41
|
+
* as `Unverifiable` rather than silently treated as a pass — the caller decides
|
|
42
|
+
* whether to tolerate it.
|
|
43
|
+
*/
|
|
44
|
+
export declare const verify: (data: Uint8Array, dist: {
|
|
45
|
+
readonly integrity?: string | undefined;
|
|
46
|
+
readonly shasum?: string | undefined;
|
|
47
|
+
}) => VerificationResult;
|
|
48
|
+
//# sourceMappingURL=Integrity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Integrity.d.ts","sourceRoot":"","sources":["../src/Integrity.ts"],"names":[],"mappings":"AAcA,2BAA2B;AAC3B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAID;;;;;GAKG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,KAAG,aAAa,CAAC,aAAa,CAY7E,CAAA;AAED,oEAAoE;AACpE,eAAO,MAAM,QAAQ,SAAU,UAAU,aAAa,MAAM,KAAG,MACV,CAAA;AAErD,6EAA6E;AAC7E,eAAO,MAAM,WAAW,SAAU,UAAU,aAAa,MAAM,KAAG,MAChB,CAAA;AAElD,qCAAqC;AACrC,MAAM,MAAM,kBAAkB;AAC5B,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,CAAA;AAUrF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,SACX,UAAU,QACV;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,KACtF,kBA6BF,CAAA"}
|
package/dist/Layout.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
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, which is why the same tree imports into
|
|
11
|
+
* Artifactory, Nexus and Verdaccio without translation. Note that a scoped
|
|
12
|
+
* package's file name drops the scope: `@babel/core` becomes `core-7.24.0.tgz`
|
|
13
|
+
* under an `@babel/core/-/` directory.
|
|
14
|
+
*/
|
|
15
|
+
/** Splits `@scope/name` into its parts. `scope` is undefined when unscoped. */
|
|
16
|
+
export declare const splitName: (name: string) => {
|
|
17
|
+
readonly scope: string | undefined;
|
|
18
|
+
readonly bare: string;
|
|
19
|
+
};
|
|
20
|
+
/** `@babel/core` + `7.24.0` -> `core-7.24.0.tgz` */
|
|
21
|
+
export declare const tarballFileName: (name: string, version: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* The path of one package tarball within a bundle, using `/` separators
|
|
24
|
+
* regardless of host platform — these become tar entry names, and tar entries
|
|
25
|
+
* are always POSIX.
|
|
26
|
+
*/
|
|
27
|
+
export declare const packagePath: (name: string, version: string) => string;
|
|
28
|
+
/** File name of the manifest that ships inside every bundle. */
|
|
29
|
+
export declare const MANIFEST_FILE = "bundle-manifest.json";
|
|
30
|
+
/** File name of the short import guide that ships inside every bundle. */
|
|
31
|
+
export declare const README_FILE = "IMPORT.md";
|
|
32
|
+
/**
|
|
33
|
+
* Name of the archive produced for one root spec in `per-spec` layout.
|
|
34
|
+
*
|
|
35
|
+
* Scoped names are flattened (`@babel/core` -> `babel-core`) because a `/` in a
|
|
36
|
+
* file name is not a thing, and `@` confuses enough shells and web UIs to be
|
|
37
|
+
* worth avoiding.
|
|
38
|
+
*/
|
|
39
|
+
export declare const perSpecArchiveName: (name: string, version: string) => string;
|
|
40
|
+
/** Name of the archive produced in `single` layout. */
|
|
41
|
+
export declare const singleArchiveName: (base?: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* The import guide written into each bundle.
|
|
44
|
+
*
|
|
45
|
+
* Kept short and copy-pasteable on purpose: whoever opens this is mid-task on a
|
|
46
|
+
* restricted network and does not want prose.
|
|
47
|
+
*/
|
|
48
|
+
export declare const importGuide: (options: {
|
|
49
|
+
readonly packageCount: number;
|
|
50
|
+
readonly createdAt: string;
|
|
51
|
+
readonly toolVersion: string;
|
|
52
|
+
}) => string;
|
|
53
|
+
//# sourceMappingURL=Layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,SAAS,SACd,MAAM,KACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAK7D,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,eAAe,SAAU,MAAM,WAAW,MAAM,KAAG,MAG/D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,WAAW,MAAM,KAAG,MACb,CAAA;AAE/C,gEAAgE;AAChE,eAAO,MAAM,aAAa,yBAAyB,CAAA;AAEnD,0EAA0E;AAC1E,eAAO,MAAM,WAAW,cAAc,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SAAU,MAAM,WAAW,MAAM,KAAG,MAIlE,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,qBAAsB,MAAuB,CAAA;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B,KAAG,MA+BH,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The manifest written into every bundle.
|
|
3
|
+
*
|
|
4
|
+
* This is the audit trail. Before anything is imported into a corporate
|
|
5
|
+
* registry somebody is usually required to answer "what exactly is in here and
|
|
6
|
+
* where did it come from" — this file answers that without unpacking a single
|
|
7
|
+
* tarball.
|
|
8
|
+
*/
|
|
9
|
+
import type { Resolution, ResolvedPackage } from "./Resolve.js";
|
|
10
|
+
import type { BundleOptions } from "./Options.js";
|
|
11
|
+
/** Schema version, bumped when the shape changes incompatibly. */
|
|
12
|
+
export declare const MANIFEST_VERSION = 1;
|
|
13
|
+
export interface ManifestEntry {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly version: string;
|
|
16
|
+
/** Path of this tarball inside the bundle. */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
/** The URL it was downloaded from. */
|
|
19
|
+
readonly tarball: string;
|
|
20
|
+
/** SRI integrity string as advertised by the source registry, when present. */
|
|
21
|
+
readonly integrity?: string | undefined;
|
|
22
|
+
/** Legacy sha1, present on older published versions. */
|
|
23
|
+
readonly shasum?: string | undefined;
|
|
24
|
+
/** Actual size on disk, in bytes. */
|
|
25
|
+
readonly bytes?: number | undefined;
|
|
26
|
+
/** Human-readable justifications: `root:react@18.2.0`, `prod:scheduler@0.23.0`. */
|
|
27
|
+
readonly reasons: ReadonlyArray<string>;
|
|
28
|
+
}
|
|
29
|
+
export interface BundleManifest {
|
|
30
|
+
readonly manifestVersion: number;
|
|
31
|
+
readonly tool: {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly version: string;
|
|
34
|
+
};
|
|
35
|
+
readonly createdAt: string;
|
|
36
|
+
readonly registry: {
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
readonly url: string;
|
|
39
|
+
};
|
|
40
|
+
/** What the user asked for, verbatim. */
|
|
41
|
+
readonly requested: ReadonlyArray<string>;
|
|
42
|
+
/** What each request expanded to. */
|
|
43
|
+
readonly roots: ReadonlyArray<{
|
|
44
|
+
readonly spec: string;
|
|
45
|
+
readonly versions: ReadonlyArray<string>;
|
|
46
|
+
readonly packageCount: number;
|
|
47
|
+
}>;
|
|
48
|
+
readonly options: {
|
|
49
|
+
readonly layout: string;
|
|
50
|
+
readonly optionalDependencies: boolean;
|
|
51
|
+
readonly peerDependencies: boolean;
|
|
52
|
+
readonly platforms: string;
|
|
53
|
+
readonly allVersions: boolean;
|
|
54
|
+
readonly includePrerelease: boolean;
|
|
55
|
+
readonly integrityVerified: boolean;
|
|
56
|
+
};
|
|
57
|
+
readonly packages: ReadonlyArray<ManifestEntry>;
|
|
58
|
+
readonly warnings: ReadonlyArray<string>;
|
|
59
|
+
readonly totals: {
|
|
60
|
+
readonly packages: number;
|
|
61
|
+
readonly bytes: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Renders a package's reasons into short, greppable strings. */
|
|
65
|
+
export declare const formatReasons: (pkg: ResolvedPackage) => ReadonlyArray<string>;
|
|
66
|
+
/** Builds the manifest for a completed (or dry) run. */
|
|
67
|
+
export declare const buildManifest: (input: {
|
|
68
|
+
readonly resolution: Resolution;
|
|
69
|
+
/** Only the packages actually included in *this* archive. */
|
|
70
|
+
readonly included: ReadonlyArray<ResolvedPackage>;
|
|
71
|
+
readonly options: BundleOptions;
|
|
72
|
+
readonly registry: {
|
|
73
|
+
readonly kind: string;
|
|
74
|
+
readonly url: string;
|
|
75
|
+
};
|
|
76
|
+
readonly toolVersion: string;
|
|
77
|
+
readonly sizes: ReadonlyMap<string, number>;
|
|
78
|
+
readonly createdAt?: Date | undefined;
|
|
79
|
+
}) => BundleManifest;
|
|
80
|
+
/** Serialises a manifest with stable key order and a trailing newline. */
|
|
81
|
+
export declare const serializeManifest: (manifest: BundleManifest) => string;
|
|
82
|
+
//# sourceMappingURL=Manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../src/Manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,IAAI,CAAA;AAEjC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sCAAsC;IACtC,QAAQ,CA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