pi-mono/scripts/release-packages.test.mjs
David Brailovsky 2930f5220c fix: release scripts find published packages only in packages/*
getPublicWorkspacePackages walked every folder under packages/, so leftover
build output (packages/coding-agent/binaries/<platform>, with copies of the
coding-agent's package.json and CHANGELOG.md) was packed as duplicate
packages. It now reads only the direct subfolders. The release's changelog
updates and sync-versions' lockstep check and version table use the same
list; with the copies counted, sync-versions failed the next version bump.
2026-11-10 15:42:52 +01:00

27 lines
1.3 KiB
JavaScript

import assert from "node:assert/strict";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import test from "node:test";
import { getPublicWorkspacePackages } from "./release-packages.mjs";
function writeManifest(directory, manifest) {
mkdirSync(directory, { recursive: true });
writeFileSync(join(directory, "package.json"), `${JSON.stringify(manifest)}\n`);
}
test("lists the non-private direct subfolders and ignores nested package.json files", (t) => {
const root = mkdtempSync(join(tmpdir(), "pi-release-packages-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
writeManifest(join(root, "tui"), { name: "@test/tui", version: "1.0.0" });
writeManifest(join(root, "ai"), { name: "@test/ai", version: "1.0.0" });
writeManifest(join(root, "evals"), { name: "@test/evals", version: "1.0.0", private: true });
mkdirSync(join(root, "notes"));
// Leftover build output, as scripts/build-binaries.sh writes it, with a copy of the package's manifest.
writeManifest(join(root, "ai", "binaries", "darwin-arm64"), { name: "@test/ai", version: "0.9.0" });
assert.deepEqual(getPublicWorkspacePackages(root), [
{ directory: join(root, "ai"), name: "@test/ai", version: "1.0.0" },
{ directory: join(root, "tui"), name: "@test/tui", version: "1.0.0" },
]);
});