Files
open-design/tools/pack/tests/win-size-index.test.ts
PerishFireandGitHub 6efac8887e Improve Windows beta packaging and installer flow (#768)
* Optimize Windows packaged web output

* Fix packaged contracts runtime build

* Optimize Windows packaged size pruning

* Prune Windows root Next payload

* Remove Windows bundled Node runtime

* Prune Windows standalone duplicate Next

* Add tools-pack cache foundation

* Cache Windows packaged build layers

* Cache Windows workspace builds

* Cache Electron-ready Windows app

* Split Windows tools-pack module

* Cache Windows dir build outputs

* Split Windows pack build modules

* Document Windows NSIS smoke namespace limits

* Move Windows NSIS smoke note to agents guide

* Optimize Windows beta packaging

* Bump packaged beta base version

* Improve Windows installer namespace UX

* Improve Windows tools-pack cache keys

* Stabilize Windows beta cache version keys

* Cache Windows workspace build outputs

* Optimize windows release beta cache layers

* Cache windows release dependencies

* Trim windows release cache before save

* Refresh windows tools-pack cache key

* Improve windows installer preflight prompts

* Fallback NSIS installer strings to English

* Fix Windows installer cleanup and preflight

* Improve Windows NSIS state logging

* Fix system NSIS Persian language alias

* Use long-path removal for Windows uninstall

* Fix mac tools-pack tests on Windows

* Address Windows packaging review feedback

* Fix Windows installer cache namespace isolation

* Include web output mode in Windows tarball cache key

* Use unique Windows release cache save keys
2026-05-07 16:44:15 +08:00

42 lines
1.9 KiB
TypeScript

import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { PathSizeIndex } from "../src/win/fs.js";
describe("PathSizeIndex", () => {
it("indexes directory sizes and filtered file totals in a single tree", async () => {
const root = await mkdtemp(join(tmpdir(), "open-design-win-size-index-"));
try {
await mkdir(join(root, "app", "node_modules", "@next", "swc-win32-x64"), { recursive: true });
await mkdir(join(root, "app", "node_modules", "@next", "swc-linux-x64"), { recursive: true });
await writeFile(join(root, "app", "main.js"), "main\n", "utf8");
await writeFile(join(root, "app", "main.js.map"), "map-data\n", "utf8");
await writeFile(join(root, "app", "node_modules", "@next", "swc-win32-x64", "next-swc.node"), "win-swc\n", "utf8");
await writeFile(join(root, "app", "node_modules", "@next", "swc-linux-x64", "next-swc.node"), "linux-swc\n", "utf8");
const index = await PathSizeIndex.create(root);
expect(index.sizePathBytes(join(root, "missing"))).toBe(0);
expect(index.sizePathBytes(join(root, "app", "main.js"))).toBe(Buffer.byteLength("main\n"));
expect(index.sizePathBytes(join(root, "app"), { includeFile: (path) => path.endsWith(".map") })).toBe(
Buffer.byteLength("map-data\n"),
);
expect(index.sumChildDirectorySizes(join(root, "app", "node_modules", "@next"), (name) => name.startsWith("swc-win32-"))).toBe(
Buffer.byteLength("win-swc\n"),
);
expect(index.sizePathBytes(root)).toBe(
Buffer.byteLength("main\n") +
Buffer.byteLength("map-data\n") +
Buffer.byteLength("win-swc\n") +
Buffer.byteLength("linux-swc\n"),
);
} finally {
await rm(root, { force: true, recursive: true });
}
});
});