@ac-kit/fixture-util 0.1.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 ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @ac-kit/fixture-util
2
+
3
+ Shared plumbing for packages whose tests run against a large, externally
4
+ published corpus of test vectors.
5
+
6
+ Such a corpus should not be committed: it is big, it is versioned upstream
7
+ already, and every clone would pay for it whether or not it runs those tests.
8
+ The alternative is fetching it on demand — which only works if the download is
9
+ pinned and checksummed, so a test run is reproducible and a swapped artifact is
10
+ detected.
11
+
12
+ ```ts
13
+ import { defaultVectorsRoot, fetchArtifact, verifyChecksum } from "@ac-kit/fixture-util";
14
+
15
+ const root = defaultVectorsRoot(import.meta.url);
16
+
17
+ const archive = await fetchArtifact(url);
18
+ verifyChecksum(archive, expectedSha256, url); // throws on a mismatch
19
+ ```
20
+
21
+ Also exposes `extractZip`, `resolveFixtureDir`, `runFixtureSetup` for driving a
22
+ whole manifest, and `setupArchiveFixture`/`setupGitSparseFixtureEntry` for the
23
+ two acquisition shapes.
24
+
25
+ Used by `@ac-kit/fixture-crypto` and `@ac-kit/fixture-x509`; each still owns its
26
+ own manifest data and domain-specific loaders.
27
+
28
+ Node only.
29
+
30
+ See the
31
+ [generated API docs](https://anthochamp.github.io/node-essentials/api/fixture-util/)
32
+ for the full reference.
@@ -0,0 +1,27 @@
1
+ import type { FixtureEntryBase } from "./setup.js";
2
+ /** A fixture acquired as a single downloadable, checksummed archive or file. */
3
+ export interface ArchiveFixtureEntry extends FixtureEntryBase {
4
+ /**
5
+ * Source URL. Pinned to a specific release, tag, or commit — never a moving
6
+ * branch — so a rebuild years from now fetches the same bytes.
7
+ */
8
+ readonly url: string;
9
+ /**
10
+ * Lowercase hex SHA-256 of the downloaded artifact, verified before any
11
+ * extraction. An unverified download is a supply-chain hole otherwise.
12
+ */
13
+ readonly sha256: string;
14
+ /**
15
+ * "raw": the downloaded file is the fixture itself. "zip": every entry in the
16
+ * archive is extracted under the fixture's directory.
17
+ */
18
+ readonly extract: "raw" | "zip";
19
+ }
20
+ /**
21
+ * Fetches, verifies and extracts (or writes) one {@link ArchiveFixtureEntry}.
22
+ *
23
+ * @throws {Error} When `entry.extract` is `"raw"` and no filename can be
24
+ * derived from `entry.url`.
25
+ */
26
+ export declare function setupArchiveFixture(entry: ArchiveFixtureEntry, destination: string): Promise<void>;
27
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,gFAAgF;AAChF,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC5D;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -0,0 +1,24 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { verifyChecksum } from "./checksum.js";
4
+ import { extractZip, fetchArtifact } from "./fetch.js";
5
+ /**
6
+ * Fetches, verifies and extracts (or writes) one {@link ArchiveFixtureEntry}.
7
+ *
8
+ * @throws {Error} When `entry.extract` is `"raw"` and no filename can be
9
+ * derived from `entry.url`.
10
+ */
11
+ export async function setupArchiveFixture(entry, destination) {
12
+ const data = await fetchArtifact(entry.url);
13
+ verifyChecksum(data, entry.sha256, entry.url);
14
+ if (entry.extract === "zip") {
15
+ await extractZip(data, destination);
16
+ return;
17
+ }
18
+ const filename = new URL(entry.url).pathname.split("/").pop();
19
+ if (!filename) {
20
+ throw new Error(`cannot derive a filename from ${entry.url}`);
21
+ }
22
+ await writeFile(join(destination, filename), data);
23
+ }
24
+ //# sourceMappingURL=archive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwBvD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,KAA0B,EAC1B,WAAmB;IAEnB,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9C,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC7B,MAAM,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACpC,OAAO;IACR,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IAE9D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @throws {Error} When `data`'s SHA-256 does not match `expectedSha256` — an
3
+ * unverified download is a supply-chain hole, never tolerated silently.
4
+ */
5
+ export declare function verifyChecksum(data: Uint8Array, expectedSha256: string, source: string): void;
6
+ //# sourceMappingURL=checksum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksum.d.ts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,GACZ,IAAI,CAQN"}
@@ -0,0 +1,12 @@
1
+ import { sha256Ts } from "@ac-kit/crypto-hash";
2
+ /**
3
+ * @throws {Error} When `data`'s SHA-256 does not match `expectedSha256` — an
4
+ * unverified download is a supply-chain hole, never tolerated silently.
5
+ */
6
+ export function verifyChecksum(data, expectedSha256, source) {
7
+ const actual = sha256Ts(data).toHex();
8
+ if (actual !== expectedSha256) {
9
+ throw new Error(`checksum mismatch for ${source}: expected ${expectedSha256}, got ${actual}`);
10
+ }
11
+ }
12
+ //# sourceMappingURL=checksum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksum.js","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAgB,EAChB,cAAsB,EACtB,MAAc;IAEd,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IAEtC,IAAI,MAAM,KAAK,cAAc,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACd,yBAAyB,MAAM,cAAc,cAAc,SAAS,MAAM,EAAE,CAC5E,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** Downloads `url` and returns its raw bytes. */
2
+ export declare function fetchArtifact(url: string): Promise<Uint8Array>;
3
+ /** Extracts every entry of a zip archive under `destination`. */
4
+ export declare function extractZip(data: Uint8Array, destination: string): Promise<void>;
5
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAKA,iDAAiD;AACjD,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAQpE;AAED,iEAAiE;AACjE,wBAAsB,UAAU,CAC/B,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAaf"}
package/dist/fetch.js ADDED
@@ -0,0 +1,25 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { unzipSync } from "fflate";
4
+ /** Downloads `url` and returns its raw bytes. */
5
+ export async function fetchArtifact(url) {
6
+ const response = await fetch(url);
7
+ if (!response.ok) {
8
+ throw new Error(`GET ${url} -> ${response.status} ${response.statusText}`);
9
+ }
10
+ return new Uint8Array(await response.arrayBuffer());
11
+ }
12
+ /** Extracts every entry of a zip archive under `destination`. */
13
+ export async function extractZip(data, destination) {
14
+ const entries = unzipSync(data);
15
+ for (const [name, content] of Object.entries(entries)) {
16
+ // fflate represents a directory entry as a zero-length file ending in "/".
17
+ if (content.length === 0 && (name + "").endsWith("/")) {
18
+ continue;
19
+ }
20
+ const target = join(destination, name + "");
21
+ await mkdir(dirname(target), { recursive: true });
22
+ await writeFile(target, content);
23
+ }
24
+ }
25
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW;IAC9C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAElC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,OAAO,GAAG,OAAO,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC/B,IAAgB,EAChB,WAAmB;IAEnB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAEhC,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,2EAA2E;QAC3E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACvD,SAAS;QACV,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5C,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;AACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { FixtureEntryBase } from "./setup.js";
2
+ /** A fixture acquired as a sparse checkout of one pinned git commit. */
3
+ export interface GitSparseFixtureEntry extends FixtureEntryBase {
4
+ /** Git remote URL. */
5
+ readonly url: string;
6
+ /** Full, pinned commit SHA — never a branch or tag that can move. */
7
+ readonly commit: string;
8
+ /** Cone-mode sparse-checkout paths, relative to the repository root. */
9
+ readonly sparsePaths: readonly string[];
10
+ }
11
+ /**
12
+ * Fetches one git-hosted corpus by cloning nothing but the pinned commit's
13
+ * object graph (`--filter=blob:none`) and checking out only the sparse paths
14
+ * that are actually needed, instead of the whole repository.
15
+ *
16
+ * The checked-out `.git` metadata is only needed to produce the worktree above,
17
+ * not to consume the fixture, so it is removed once the checkout is verified.
18
+ *
19
+ * @throws {Error} When the checked-out `HEAD` does not match
20
+ * {@link GitSparseFixtureEntry.commit} — defense in depth on top of git's own
21
+ * content-addressed verification of the fetched objects.
22
+ */
23
+ export declare function setupGitSparseFixtureEntry(entry: GitSparseFixtureEntry, destination: string): Promise<void>;
24
+ //# sourceMappingURL=git-sparse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-sparse.d.ts","sourceRoot":"","sources":["../src/git-sparse.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wEAAwE;AACxE,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC9D,sBAAsB;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,CAC/C,KAAK,EAAE,qBAAqB,EAC5B,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,34 @@
1
+ import { rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { gitCheckout, gitFetch, gitInit, gitRemoteAdd, gitRevParse, gitSparseCheckoutInit, gitSparseCheckoutSet, } from "@ac-kit/cmd-git";
4
+ /**
5
+ * Fetches one git-hosted corpus by cloning nothing but the pinned commit's
6
+ * object graph (`--filter=blob:none`) and checking out only the sparse paths
7
+ * that are actually needed, instead of the whole repository.
8
+ *
9
+ * The checked-out `.git` metadata is only needed to produce the worktree above,
10
+ * not to consume the fixture, so it is removed once the checkout is verified.
11
+ *
12
+ * @throws {Error} When the checked-out `HEAD` does not match
13
+ * {@link GitSparseFixtureEntry.commit} — defense in depth on top of git's own
14
+ * content-addressed verification of the fetched objects.
15
+ */
16
+ export async function setupGitSparseFixtureEntry(entry, destination) {
17
+ const execOptions = { cwd: destination };
18
+ await gitInit({ execOptions });
19
+ await gitRemoteAdd("origin", entry.url, { execOptions });
20
+ await gitFetch("origin", entry.commit, {
21
+ filter: "blob:none",
22
+ depth: 1,
23
+ execOptions,
24
+ });
25
+ await gitSparseCheckoutInit({ cone: true, execOptions });
26
+ await gitSparseCheckoutSet(entry.sparsePaths, { execOptions });
27
+ await gitCheckout(entry.commit, { execOptions });
28
+ const checkedOutCommit = await gitRevParse("HEAD", { execOptions });
29
+ if (checkedOutCommit !== entry.commit) {
30
+ throw new Error(`fixture "${entry.id}": checked out ${checkedOutCommit}, expected pinned commit ${entry.commit}`);
31
+ }
32
+ await rm(join(destination, ".git"), { recursive: true, force: true });
33
+ }
34
+ //# sourceMappingURL=git-sparse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-sparse.js","sourceRoot":"","sources":["../src/git-sparse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACN,WAAW,EACX,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,iBAAiB,CAAC;AAgBzB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,KAA4B,EAC5B,WAAmB;IAEnB,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;IAEzC,MAAM,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/B,MAAM,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACzD,MAAM,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE;QACtC,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,CAAC;QACR,WAAW;KACX,CAAC,CAAC;IACH,MAAM,qBAAqB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IACzD,MAAM,oBAAoB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/D,MAAM,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAEjD,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAEpE,IAAI,gBAAgB,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACd,YAAY,KAAK,CAAC,EAAE,kBAAkB,gBAAgB,4BAA4B,KAAK,CAAC,MAAM,EAAE,CAChG,CAAC;IACH,CAAC;IAED,MAAM,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./archive.js";
2
+ export * from "./checksum.js";
3
+ export * from "./fetch.js";
4
+ export * from "./git-sparse.js";
5
+ export * from "./paths.js";
6
+ export * from "./setup.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./archive.js";
2
+ export * from "./checksum.js";
3
+ export * from "./fetch.js";
4
+ export * from "./git-sparse.js";
5
+ export * from "./paths.js";
6
+ export * from "./setup.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Default fixture root for a package: `<package root>/.temp/vectors`,
3
+ * gitignored via the repository's existing `.temp/` pattern.
4
+ *
5
+ * @param packageMetaUrl `import.meta.url` of a module one directory level below
6
+ * the package root (e.g. the package's own `src/paths.ts`).
7
+ */
8
+ export declare function defaultVectorsRoot(packageMetaUrl: string | URL): string;
9
+ /**
10
+ * Resolves the on-disk directory for a fetched fixture.
11
+ *
12
+ * @param id Fixture id — also its directory name under `root`.
13
+ * @param root Root the fixture directories live under.
14
+ * @param packageName The consuming package's name, used in the error's "run
15
+ * setup" hint.
16
+ * @throws {Error} When `setup` has not been run for this id — a missing corpus
17
+ * must fail a consuming test, never silently skip it.
18
+ */
19
+ export declare function resolveFixtureDir(id: string, root: string, packageName: string): string;
20
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAGvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GACjB,MAAM,CAWR"}
package/dist/paths.js ADDED
@@ -0,0 +1,33 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /**
5
+ * Default fixture root for a package: `<package root>/.temp/vectors`,
6
+ * gitignored via the repository's existing `.temp/` pattern.
7
+ *
8
+ * @param packageMetaUrl `import.meta.url` of a module one directory level below
9
+ * the package root (e.g. the package's own `src/paths.ts`).
10
+ */
11
+ export function defaultVectorsRoot(packageMetaUrl) {
12
+ const packageRoot = fileURLToPath(new URL("..", packageMetaUrl));
13
+ return join(packageRoot, ".temp", "vectors");
14
+ }
15
+ /**
16
+ * Resolves the on-disk directory for a fetched fixture.
17
+ *
18
+ * @param id Fixture id — also its directory name under `root`.
19
+ * @param root Root the fixture directories live under.
20
+ * @param packageName The consuming package's name, used in the error's "run
21
+ * setup" hint.
22
+ * @throws {Error} When `setup` has not been run for this id — a missing corpus
23
+ * must fail a consuming test, never silently skip it.
24
+ */
25
+ export function resolveFixtureDir(id, root, packageName) {
26
+ const dir = join(root, id);
27
+ if (!existsSync(dir)) {
28
+ throw new Error(`fixture "${id}" is not present at ${dir} — run ` +
29
+ `"yarn workspace ${packageName} run setup" first`);
30
+ }
31
+ return dir;
32
+ }
33
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,cAA4B;IAC9D,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,EAAU,EACV,IAAY,EACZ,WAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACd,YAAY,EAAE,uBAAuB,GAAG,SAAS;YAChD,mBAAmB,WAAW,mBAAmB,CAClD,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** Minimal shape a fixture manifest entry must have. */
2
+ export interface FixtureEntryBase {
3
+ /** Unique id; also the directory name under the vectors root. */
4
+ readonly id: string;
5
+ /** Human-readable description, printed while `setup` fetches it. */
6
+ readonly description: string;
7
+ }
8
+ /**
9
+ * Runs `setupOne` for every entry in `manifest`, sequentially: logs progress,
10
+ * clears any stale directory, and recreates it before delegating.
11
+ *
12
+ * Each package supplies its own `setupOne` (fetch a plain file, fetch and
13
+ * extract a zip, or a git sparse checkout) — this only owns the repeated shell
14
+ * around that per-entry work.
15
+ *
16
+ * @param manifest Entries describing what to fetch.
17
+ * @param vectorsRoot Root directory every entry is extracted under.
18
+ * @param setupOne Fetches (and verifies, and extracts) one entry into its
19
+ * freshly-created destination directory.
20
+ */
21
+ export declare function runFixtureSetup<T extends FixtureEntryBase>(manifest: readonly T[], vectorsRoot: string, setupOne: (entry: T, destination: string) => Promise<void>): Promise<void>;
22
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAGA,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAChC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,CAAC,SAAS,gBAAgB,EAC/D,QAAQ,EAAE,SAAS,CAAC,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACxD,OAAO,CAAC,IAAI,CAAC,CAUf"}
package/dist/setup.js ADDED
@@ -0,0 +1,25 @@
1
+ import { mkdir, rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ /**
4
+ * Runs `setupOne` for every entry in `manifest`, sequentially: logs progress,
5
+ * clears any stale directory, and recreates it before delegating.
6
+ *
7
+ * Each package supplies its own `setupOne` (fetch a plain file, fetch and
8
+ * extract a zip, or a git sparse checkout) — this only owns the repeated shell
9
+ * around that per-entry work.
10
+ *
11
+ * @param manifest Entries describing what to fetch.
12
+ * @param vectorsRoot Root directory every entry is extracted under.
13
+ * @param setupOne Fetches (and verifies, and extracts) one entry into its
14
+ * freshly-created destination directory.
15
+ */
16
+ export async function runFixtureSetup(manifest, vectorsRoot, setupOne) {
17
+ for (const entry of manifest) {
18
+ console.log(`fetching ${entry.id} — ${entry.description}`);
19
+ const destination = join(vectorsRoot, entry.id);
20
+ await rm(destination, { recursive: true, force: true });
21
+ await mkdir(destination, { recursive: true });
22
+ await setupOne(entry, destination);
23
+ }
24
+ }
25
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,QAAsB,EACtB,WAAmB,EACnB,QAA0D;IAE1D,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAE3D,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,MAAM,KAAK,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE9C,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IACpC,CAAC;AACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@ac-kit/fixture-util",
3
+ "version": "0.1.0",
4
+ "description": "Infrastructure for packages that fetch a pinned, checksummed test-vector corpus: fetch-and-verify, zip extraction, a manifest-driven setup runner and fixture-directory resolution.",
5
+ "keywords": [
6
+ "checksum",
7
+ "fixtures",
8
+ "test-vectors",
9
+ "testing"
10
+ ],
11
+ "homepage": "https://anthochamp.github.io/node-essentials/api/fixture-util/",
12
+ "bugs": {
13
+ "url": "https://github.com/anthochamp/node-essentials/issues"
14
+ },
15
+ "license": "BSD-3-Clause",
16
+ "author": "Anthony Champagne <dev@anthonychampagne.fr>",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/anthochamp/node-essentials.git",
20
+ "directory": "packages/fixture-util"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "publishConfig": {
29
+ "main": "./dist/index.js",
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "compile": "tsc -p ./tsconfig.build.json --outDir dist",
34
+ "compile:check": "tsc -noEmit -p ./tsconfig.json",
35
+ "clean": "rimraf dist",
36
+ "build": "yarn clean && yarn compile",
37
+ "test": "yarn run -T vitest run",
38
+ "prepack": "yarn build"
39
+ },
40
+ "dependencies": {
41
+ "@ac-kit/cmd-git": "^0.1.0",
42
+ "@ac-kit/crypto-hash": "^0.1.0",
43
+ "fflate": "0.8.3"
44
+ },
45
+ "devDependencies": {
46
+ "@ac-kit/tsconfig": "0.1.0",
47
+ "@ac-kit/typedoc-config": "0.1.0",
48
+ "@ac-kit/vitest-config": "0.1.0",
49
+ "@types/node": "26.5.1",
50
+ "@typescript/native": "typescript@7.0.2",
51
+ "rimraf": "6.1.3",
52
+ "typedoc": "0.28.20",
53
+ "typescript": "@typescript/typescript6@6.0.2",
54
+ "vite": "8.3.0",
55
+ "vitest": "5.0.0"
56
+ },
57
+ "engines": {
58
+ "node": ">=24"
59
+ }
60
+ }