@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,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package.json blocks `--file` reads, and what counts as readable.
|
|
3
|
+
*
|
|
4
|
+
* A narrow view on purpose: the only thing this tool wants from a package.json
|
|
5
|
+
* is which packages it declares. Everything else — `scripts`, `exports`, the
|
|
6
|
+
* half of the file that belongs to a bundler — is none of its business, and a
|
|
7
|
+
* schema that insisted on understanding it would reject files that are fine.
|
|
8
|
+
*
|
|
9
|
+
* Every block is optional and every wrongly-typed one is simply absent, so a
|
|
10
|
+
* hand-edited manifest produces a smaller spec list rather than a crash. That
|
|
11
|
+
* is what `tolerant` buys: a `dependencies: "all of them"` loses one block, not
|
|
12
|
+
* the file.
|
|
13
|
+
*/
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
export declare const PackageJsonSchema: Schema.Struct<{
|
|
16
|
+
readonly dependencies: Schema.optional<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.decodeTo<Schema.$Record<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.Unknown>, never, never>>, never>>;
|
|
17
|
+
readonly devDependencies: Schema.optional<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.decodeTo<Schema.$Record<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.Unknown>, never, never>>, never>>;
|
|
18
|
+
readonly optionalDependencies: Schema.optional<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.decodeTo<Schema.$Record<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.Unknown>, never, never>>, never>>;
|
|
19
|
+
readonly peerDependencies: Schema.optional<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.decodeTo<Schema.$Record<Schema.String, Schema.String>, Schema.$Record<Schema.String, Schema.Unknown>, never, never>>, never>>;
|
|
20
|
+
readonly peerDependenciesMeta: Schema.optional<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.decodeTo<Schema.$Record<Schema.String, Schema.Struct<{
|
|
21
|
+
readonly optional: Schema.Boolean;
|
|
22
|
+
}>>, Schema.$Record<Schema.String, Schema.Unknown>, never, never>>, never>>;
|
|
23
|
+
}>;
|
|
24
|
+
export type PackageJson = typeof PackageJsonSchema.Type;
|
|
25
|
+
export declare const decodePackageJson: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Option").Option<{
|
|
26
|
+
readonly dependencies?: {
|
|
27
|
+
readonly [x: string]: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
readonly devDependencies?: {
|
|
30
|
+
readonly [x: string]: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
readonly optionalDependencies?: {
|
|
33
|
+
readonly [x: string]: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
readonly peerDependencies?: {
|
|
36
|
+
readonly [x: string]: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
readonly peerDependenciesMeta?: {
|
|
39
|
+
readonly [x: string]: {
|
|
40
|
+
readonly optional: boolean;
|
|
41
|
+
};
|
|
42
|
+
} | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../src/schemas/package-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,eAAO,MAAM,iBAAiB;;;;;;;;EAM5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAExD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;EAAgD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvalidSpecError } from "./
|
|
1
|
+
import { InvalidSpecError } from "./errors.js";
|
|
2
2
|
/** How a spec narrows down which version(s) of a package we want. */
|
|
3
3
|
export type Selector =
|
|
4
4
|
/** An exact, fully-qualified version: `react@18.2.0`. */
|
|
@@ -17,14 +17,14 @@ export type Selector =
|
|
|
17
17
|
readonly tag: string;
|
|
18
18
|
};
|
|
19
19
|
/** A parsed, validated package spec. */
|
|
20
|
-
export
|
|
20
|
+
export type PackageSpec = {
|
|
21
21
|
/** The npm package name, including scope. */
|
|
22
22
|
readonly name: string;
|
|
23
23
|
/** What the user asked for after the `@`. */
|
|
24
24
|
readonly selector: Selector;
|
|
25
25
|
/** The original string, kept verbatim for error messages and the manifest. */
|
|
26
26
|
readonly raw: string;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
/** Renders a spec back into the canonical `name@selector` form. */
|
|
29
29
|
export declare const formatSpec: (spec: PackageSpec) => string;
|
|
30
30
|
/** Human-readable form of just the selector part. */
|
|
@@ -59,4 +59,4 @@ export declare const parseSpecs: (inputs: ReadonlyArray<string>) => {
|
|
|
59
59
|
* download React twice.
|
|
60
60
|
*/
|
|
61
61
|
export declare const dedupeSpecs: (specs: ReadonlyArray<PackageSpec>) => ReadonlyArray<PackageSpec>;
|
|
62
|
-
//# sourceMappingURL=
|
|
62
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,qEAAqE;AACrE,MAAM,MAAM,QAAQ;AACnB,yDAAyD;AACvD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACtD,gEAAgE;GAC9D;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACpD,qDAAqD;GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB,CAAC;AASF,mEAAmE;AACnE,eAAO,MAAM,UAAU,SAAU,WAAW,KAAG,MACC,CAAC;AAEjD,qDAAqD;AACrD,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,MASnD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,SAAU,MAAM,KAAG,MAAM,GAAG,IA0B3D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,WAqBvC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,aAAa,QAAS,MAAM,QAAQ,MAAM,KAAG,QAqBzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,WACd,aAAa,CAAC,MAAM,CAAC,KAC3B;IACF,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAgBjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,aAAa,CAAC,WAAW,CAAC,KAAG,aAAa,CAAC,WAAW,CAUxF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The union of an object's value types.
|
|
3
|
+
*
|
|
4
|
+
* The companion to the `as const` object-enum pattern used throughout this
|
|
5
|
+
* package: the object is the value, `ValueOf<typeof X>` is the type, and the two
|
|
6
|
+
* share one name.
|
|
7
|
+
*/
|
|
8
|
+
export type ValueOf<T> = T[keyof T];
|
|
9
|
+
//# sourceMappingURL=value-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-of.d.ts","sourceRoot":"","sources":["../../src/types/value-of.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrows an unknown value to a plain object.
|
|
3
|
+
*
|
|
4
|
+
* The entry point for reading anything the tool does not control — lockfiles,
|
|
5
|
+
* package.json files, registry responses — without reaching for a cast.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
8
|
+
//# sourceMappingURL=is-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-record.d.ts","sourceRoot":"","sources":["../../src/utils/is-record.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@packall/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Registry-agnostic engine for bundling npm packages and their full dependency closure for offline import.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
6
10
|
"type": "module",
|
|
7
11
|
"sideEffects": false,
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"module": "./dist/index.js",
|
|
8
14
|
"exports": {
|
|
9
15
|
".": "./dist/index.js",
|
|
16
|
+
"./node": "./dist/node/index.js",
|
|
10
17
|
"./package.json": "./package.json"
|
|
11
18
|
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"src"
|
|
15
|
-
],
|
|
16
19
|
"publishConfig": {
|
|
17
20
|
"access": "public"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
23
|
"semver": "^7.7.2",
|
|
21
|
-
"tar": "^7.5.1"
|
|
22
|
-
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"effect": "4.0.0-beta.103"
|
|
24
|
+
"tar": "^7.5.1",
|
|
25
|
+
"yaml": "^2.8.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@effect/platform-node": "4.0.0-beta.103",
|
|
28
29
|
"@types/semver": "^7.7.1",
|
|
29
30
|
"effect": "4.0.0-beta.103"
|
|
30
31
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"effect": "4.0.0-beta.103"
|
|
34
|
+
},
|
|
33
35
|
"scripts": {
|
|
34
36
|
"build": "tsdown && tsc -p tsconfig.build.json",
|
|
35
37
|
"check": "tsc -p tsconfig.json",
|
package/src/archive.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
});
|