Skip to content

Package Utils

Terminal window
pnpm add @theholocron/pkg-utils
import { dependencyNames, detectPackageManager, readPackageJson } from "@theholocron/pkg-utils";
const pkg = await readPackageJson(process.cwd());
dependencyNames(pkg).has("tsdown");
detectPackageManager(process.cwd()); // "pnpm" | "npm" | "yarn" | "bun"
  • A package’s manifest: readPackageJson, parsePackageJson and dependencyNames.
  • A workspace’s packages: listWorkspacePackagesSync scans fixed roots; discoverWorkspacePackages follows the repo’s pnpm-workspace.yaml (or, without one, the workspaces field of the root package.json) with pnpm’s *, ** and ! patterns, and reports a pattern it cannot read instead of throwing. Neither filters by name, version or private, so the caller decides.
  • pnpm-workspace.yaml itself: readWorkspaceGlobs, resolveWorkspaceGlobs, parseCatalogs, addWorkspaceMember and bumpCatalogPins. These read and edit the file line by line rather than parsing YAML, so the catalog: and overrides: blocks keep their formatting.
  • The package manager: detectPackageManager.

The full API reference is generated from the package’s TSDoc comments.