pi-mono/scripts/release-packages.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

20 lines
921 B
JavaScript

import { existsSync, readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
/**
* The packages that are published: the non-private direct subfolders of `root`, the `packages/*` workspaces.
* Nested folders are never searched, so leftover build output such as `packages/coding-agent/binaries/<platform>`
* (which holds copies of the coding-agent's package.json) is not mistaken for a package.
*/
export function getPublicWorkspacePackages(root = "packages") {
return readdirSync(root, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, "package.json")))
.map((entry) => join(root, entry.name))
.sort()
.map((directory) => ({
directory,
...JSON.parse(readFileSync(join(directory, "package.json"), "utf8")),
}))
.filter((pkg) => pkg.private !== true)
.map(({ directory, name, version }) => ({ directory, name, version }));
}