mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-12-05 05:45:00 +00:00
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.
20 lines
921 B
JavaScript
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 }));
|
|
}
|