@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/archive.ts
CHANGED
|
@@ -1,92 +1,95 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turning a staged directory tree into a gzipped tarball.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Turning a staged directory tree into a gzipped tarball.
|
|
3
|
+
*
|
|
4
|
+
* A service rather than a function, because packing is the one step that has
|
|
5
|
+
* to be implemented differently per platform. Everywhere else the engine
|
|
6
|
+
* reaches the disk through `effect/FileSystem`, which is what lets an in-memory
|
|
7
|
+
* filesystem carry the whole pipeline — but a tar writer is not filesystem
|
|
8
|
+
* access, it is a format, and `node-tar` reads the paths it is given with
|
|
9
|
+
* Node's own `fs` rather than through the injected service. Left as a direct
|
|
10
|
+
* call, packing would quietly bypass the abstraction the rest of the engine
|
|
11
|
+
* depends on, which stays invisible until something other than Node provides
|
|
12
|
+
* the filesystem.
|
|
13
|
+
*
|
|
14
|
+
* The implementations live outside this module — `@packall/core/node` for
|
|
15
|
+
* Node, a Web Streams writer in the browser — so nothing platform-specific is
|
|
16
|
+
* reachable from the engine's own graph.
|
|
17
|
+
*/
|
|
18
|
+
import * as Context from "effect/Context";
|
|
19
|
+
import * as Effect from "effect/Effect";
|
|
20
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
21
|
+
import type { PlatformError } from "effect/PlatformError";
|
|
22
|
+
|
|
23
|
+
import type { ArchiveError } from "./errors.js";
|
|
24
|
+
import * as Progress from "./progress.js";
|
|
25
|
+
|
|
26
|
+
/** A finished archive. */
|
|
27
|
+
export type ArchiveResult = {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly bytes: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** What to pack, and where to put it. */
|
|
33
|
+
export type CreateArchiveOptions = {
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
/** Entry paths, relative to `cwd`. */
|
|
36
|
+
readonly entries: ReadonlyArray<string>;
|
|
37
|
+
readonly outPath: string;
|
|
38
|
+
readonly gzipLevel?: number | undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export declare namespace Archiver {
|
|
42
|
+
/** The packing backend. */
|
|
43
|
+
export type Service = {
|
|
44
|
+
/**
|
|
45
|
+
* Packs `entries` (paths relative to `cwd`) into a gzipped tar at
|
|
46
|
+
* `outPath`.
|
|
47
|
+
*
|
|
48
|
+
* Implementations must produce byte-identical output for identical inputs —
|
|
49
|
+
* normalised uid/gid/mtime, entries in a stable order — because a security
|
|
50
|
+
* team diffing two bundles, or re-deriving one from its manifest, is a
|
|
51
|
+
* thing that actually happens.
|
|
52
|
+
*/
|
|
53
|
+
readonly create: (
|
|
54
|
+
options: CreateArchiveOptions,
|
|
55
|
+
) => Effect.Effect<ArchiveResult, ArchiveError | PlatformError, FileSystem.FileSystem>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Service tag for archive creation. */
|
|
60
|
+
export class Archiver extends Context.Service<Archiver, Archiver.Service>()(
|
|
61
|
+
"@packall/core/Archiver",
|
|
62
|
+
) {}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Packs an archive with whichever backend is installed.
|
|
66
|
+
*
|
|
67
|
+
* The progress events are emitted here rather than inside the backends, so
|
|
68
|
+
* every implementation reports identically and a new one cannot forget to.
|
|
69
|
+
*/
|
|
70
|
+
export const createArchive = (
|
|
71
|
+
options: CreateArchiveOptions,
|
|
72
|
+
): Effect.Effect<
|
|
73
|
+
ArchiveResult,
|
|
74
|
+
ArchiveError | PlatformError,
|
|
75
|
+
Archiver | FileSystem.FileSystem | Progress.Progress
|
|
76
|
+
> =>
|
|
77
|
+
Effect.gen(function* () {
|
|
78
|
+
const archiver = yield* Archiver;
|
|
79
|
+
|
|
80
|
+
yield* Progress.emit({
|
|
81
|
+
_tag: "ArchiveStarted",
|
|
82
|
+
path: options.outPath,
|
|
83
|
+
entryCount: options.entries.length,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const result = yield* archiver.create(options);
|
|
87
|
+
|
|
88
|
+
yield* Progress.emit({
|
|
89
|
+
_tag: "ArchiveCompleted",
|
|
90
|
+
path: result.path,
|
|
91
|
+
bytes: result.bytes,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return result;
|
|
95
|
+
});
|