@packall/core 0.1.0 → 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 +47 -15
- package/dist/archive.d.ts.map +1 -1
- package/dist/bundle.d.ts +6 -3
- package/dist/bundle.d.ts.map +1 -1
- package/dist/dependency-range.d.ts.map +1 -1
- package/dist/download.d.ts +2 -1
- package/dist/download.d.ts.map +1 -1
- package/dist/enums/artifact-kind.d.ts.map +1 -1
- package/dist/enums/edge-kind.d.ts.map +1 -1
- package/dist/enums/input-file-kind.d.ts.map +1 -1
- package/dist/enums/layout.d.ts.map +1 -1
- package/dist/enums/lockfile-format.d.ts.map +1 -1
- package/dist/enums/phase.d.ts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -344
- package/dist/index.js.map +1 -1
- package/dist/input-file.d.ts.map +1 -1
- package/dist/integrity.d.ts +37 -5
- package/dist/integrity.d.ts.map +1 -1
- package/dist/layout.d.ts +41 -7
- package/dist/layout.d.ts.map +1 -1
- package/dist/locked-resolve.d.ts.map +1 -1
- package/dist/lockfile/bun.d.ts.map +1 -1
- package/dist/lockfile/detect.d.ts.map +1 -1
- package/dist/lockfile/json.d.ts.map +1 -1
- package/dist/lockfile/names.d.ts.map +1 -1
- package/dist/lockfile/npm.d.ts.map +1 -1
- package/dist/lockfile/parse.d.ts.map +1 -1
- package/dist/lockfile/pnpm.d.ts.map +1 -1
- package/dist/lockfile/tree-builder.d.ts.map +1 -1
- package/dist/lockfile/types.d.ts.map +1 -1
- package/dist/manifest.d.ts.map +1 -1
- 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 +3 -3
- package/dist/options.d.ts.map +1 -1
- package/dist/platform.d.ts +5 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/schemas/lenient.d.ts.map +1 -1
- package/dist/schemas/package-json.d.ts.map +1 -1
- package/dist/spec.d.ts.map +1 -1
- package/dist/types/value-of.d.ts.map +1 -1
- package/dist/utils/is-record.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/archive.ts +95 -92
- package/src/bundle.ts +736 -616
- package/src/dependency-range.ts +121 -115
- package/src/download.ts +155 -133
- package/src/enums/artifact-kind.ts +5 -5
- package/src/enums/edge-kind.ts +13 -13
- package/src/enums/input-file-kind.ts +9 -9
- package/src/enums/layout.ts +20 -20
- package/src/enums/lockfile-format.ts +6 -6
- package/src/enums/phase.ts +8 -8
- package/src/errors.ts +200 -198
- package/src/index.ts +126 -113
- package/src/input-file.ts +246 -234
- package/src/integrity.ts +165 -121
- package/src/layout.ts +63 -29
- package/src/locked-resolve.ts +471 -461
- package/src/lockfile/bun.ts +214 -207
- package/src/lockfile/detect.ts +80 -80
- package/src/lockfile/json.ts +91 -92
- package/src/lockfile/names.ts +9 -9
- package/src/lockfile/npm.ts +328 -308
- package/src/lockfile/parse.ts +32 -32
- package/src/lockfile/pnpm.ts +230 -225
- package/src/lockfile/tree-builder.ts +116 -116
- package/src/lockfile/types.ts +52 -52
- package/src/manifest.ts +129 -133
- package/src/node/archiver.ts +85 -0
- package/src/node/index.ts +13 -0
- package/src/options.ts +84 -84
- package/src/platform.ts +97 -101
- package/src/progress.ts +105 -106
- package/src/registry.ts +116 -115
- package/src/resolve.ts +560 -537
- package/src/schemas/lenient.ts +67 -60
- package/src/schemas/package-json.ts +11 -10
- package/src/spec.ts +123 -119
- package/src/types/value-of.ts +1 -1
- package/src/utils/is-record.ts +1 -1
package/src/registry.ts
CHANGED
|
@@ -1,115 +1,116 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The registry seam.
|
|
3
|
-
*
|
|
4
|
-
* This is the **only** place in the engine that knows a registry exists.
|
|
5
|
-
* Everything downstream — range resolution, the dependency walk, layout,
|
|
6
|
-
* archiving — is expressed against these three operations, so swapping npm for
|
|
7
|
-
* something else means implementing this interface and nothing more.
|
|
8
|
-
*
|
|
9
|
-
* `@packall/registry-npm` provides the implementation that speaks the plain
|
|
10
|
-
* npm registry protocol, which is what Artifactory, Nexus, Verdaccio, GitHub
|
|
11
|
-
* Packages and registry.npmjs.org all serve.
|
|
12
|
-
*/
|
|
13
|
-
import * as Context from "effect/Context"
|
|
14
|
-
import type * as Effect from "effect/Effect"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* metadata
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* import {
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The registry seam.
|
|
3
|
+
*
|
|
4
|
+
* This is the **only** place in the engine that knows a registry exists.
|
|
5
|
+
* Everything downstream — range resolution, the dependency walk, layout,
|
|
6
|
+
* archiving — is expressed against these three operations, so swapping npm for
|
|
7
|
+
* something else means implementing this interface and nothing more.
|
|
8
|
+
*
|
|
9
|
+
* `@packall/registry-npm` provides the implementation that speaks the plain
|
|
10
|
+
* npm registry protocol, which is what Artifactory, Nexus, Verdaccio, GitHub
|
|
11
|
+
* Packages and registry.npmjs.org all serve.
|
|
12
|
+
*/
|
|
13
|
+
import * as Context from "effect/Context";
|
|
14
|
+
import type * as Effect from "effect/Effect";
|
|
15
|
+
|
|
16
|
+
import type { BundlerError } from "./errors.js";
|
|
17
|
+
|
|
18
|
+
/** Where the tarball lives and how to prove it arrived intact. */
|
|
19
|
+
export type PackageDist = {
|
|
20
|
+
readonly tarball: string;
|
|
21
|
+
/** SRI string, e.g. `sha512-...`. Preferred over `shasum`. */
|
|
22
|
+
readonly integrity?: string | undefined;
|
|
23
|
+
/** Legacy hex sha1. Still the only checksum on very old versions. */
|
|
24
|
+
readonly shasum?: string | undefined;
|
|
25
|
+
readonly unpackedSize?: number | undefined;
|
|
26
|
+
readonly fileCount?: number | undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A single published version, as the registry describes it.
|
|
31
|
+
*
|
|
32
|
+
* This is a narrowed view of a package.json — only the fields that affect what
|
|
33
|
+
* has to be downloaded. Unknown fields are ignored rather than rejected,
|
|
34
|
+
* because registries add metadata over time and a bundler that breaks on new
|
|
35
|
+
* metadata is worse than useless.
|
|
36
|
+
*/
|
|
37
|
+
export type PackageManifest = {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly version: string;
|
|
40
|
+
|
|
41
|
+
readonly dependencies?: Readonly<Record<string, string>> | undefined;
|
|
42
|
+
readonly optionalDependencies?: Readonly<Record<string, string>> | undefined;
|
|
43
|
+
readonly peerDependencies?: Readonly<Record<string, string>> | undefined;
|
|
44
|
+
readonly peerDependenciesMeta?:
|
|
45
|
+
| Readonly<Record<string, { readonly optional?: boolean | undefined }>>
|
|
46
|
+
| undefined;
|
|
47
|
+
readonly devDependencies?: Readonly<Record<string, string>> | undefined;
|
|
48
|
+
readonly bundleDependencies?: ReadonlyArray<string> | undefined;
|
|
49
|
+
|
|
50
|
+
/** Platform constraints, used when `--platform` narrows optional deps. */
|
|
51
|
+
readonly os?: ReadonlyArray<string> | undefined;
|
|
52
|
+
readonly cpu?: ReadonlyArray<string> | undefined;
|
|
53
|
+
readonly libc?: ReadonlyArray<string> | undefined;
|
|
54
|
+
|
|
55
|
+
readonly deprecated?: string | undefined;
|
|
56
|
+
|
|
57
|
+
readonly dist: PackageDist;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Everything the registry knows about one package. */
|
|
61
|
+
export type Packument = {
|
|
62
|
+
readonly name: string;
|
|
63
|
+
/** `{ latest: "1.2.3", next: "2.0.0-beta.1" }` */
|
|
64
|
+
readonly distTags: Readonly<Record<string, string>>;
|
|
65
|
+
/** Every published version, keyed by version string. */
|
|
66
|
+
readonly versions: Readonly<Record<string, PackageManifest>>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export declare namespace Registry {
|
|
70
|
+
/** The set of operations a registry backend has to provide. */
|
|
71
|
+
export type Service = {
|
|
72
|
+
/** Short identifier for the manifest and for error messages, e.g. `"npm"`. */
|
|
73
|
+
readonly kind: string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The registry URL that will actually be used for a given package, after
|
|
77
|
+
* per-scope configuration is applied. Used for reporting only.
|
|
78
|
+
*/
|
|
79
|
+
readonly registryFor: (packageName: string) => string;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Cheap liveness check, run once before any real work.
|
|
83
|
+
*
|
|
84
|
+
* This is what turns "hangs forever behind a dead VPN" into a five-second
|
|
85
|
+
* error naming the host we could not reach.
|
|
86
|
+
*/
|
|
87
|
+
readonly preflight: Effect.Effect<void, BundlerError>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Full metadata for a package. Implementations are expected to memoise:
|
|
91
|
+
* the dependency walk asks for the same popular packages repeatedly.
|
|
92
|
+
*/
|
|
93
|
+
readonly packument: (packageName: string) => Effect.Effect<Packument, BundlerError>;
|
|
94
|
+
|
|
95
|
+
/** Fetches the tarball bytes for one published version. */
|
|
96
|
+
readonly download: (manifest: PackageManifest) => Effect.Effect<Uint8Array, BundlerError>;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Service tag for the registry backend.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { Effect } from "effect"
|
|
106
|
+
* import { Registry } from "@packall/core"
|
|
107
|
+
*
|
|
108
|
+
* const program = Effect.gen(function*() {
|
|
109
|
+
* const registry = yield* Registry
|
|
110
|
+
* return yield* registry.packument("lodash")
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export class Registry extends Context.Service<Registry, Registry.Service>()(
|
|
115
|
+
"@packall/core/Registry",
|
|
116
|
+
) {}
|