Release Package Tools 0.1.0

This commit is contained in:
2026-09-01 13:04:50 +02:00
commit e42943e689
66 changed files with 11321 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
import { describe, expect, it } from "vitest";
import { compareInventories } from "../../src/package/compare";
import type { ArchiveEntryRecord } from "../../src/archive/types";
import type { PackageDocument } from "../../src/package/types";
const entry = (
path: string,
size: number,
crc32: string,
): ArchiveEntryRecord => ({
id: path,
sourceIndex: 0,
rawPath: path,
path,
collisionKey: path.toLowerCase(),
kind: "file",
size,
compressedSize: size,
crc32,
extractable: true,
issues: [],
});
function document(entries: ArchiveEntryRecord[]): PackageDocument {
return { entries } as PackageDocument;
}
describe("inventory comparison", () => {
it("separates unchanged, changed and one-sided entries", () => {
const result = compareInventories(
document([
entry("same", 1, "a"),
entry("changed", 2, "b"),
entry("left", 1, "c"),
]),
document([
entry("same", 1, "a"),
entry("changed", 3, "d"),
entry("right", 1, "e"),
]),
);
expect(
Object.fromEntries(result.map((item) => [item.path, item.status])),
).toEqual({
changed: "changed",
left: "only-left",
right: "only-right",
same: "same",
});
});
});