PackagePrivateField
constPackagePrivateField:FilePolicyDefinition<PackagePrivateFieldConfig|undefined> &object
Defined in: policies/PackagePrivateField.ts:213
A policy that enforces the private field in package.json based on package scope or name.
This policy is essential for monorepos where publishing control is important:
- Prevent accidental publishing of internal packages
- Ensure public packages don’t have
private: trueblocking publishing - Allow experimental packages to choose their own publishing status
Type Declaration
Section titled “Type Declaration”requiresConfig
Section titled “requiresConfig”requiresConfig:
true
Remarks
Section titled “Remarks”The policy evaluates packages in the following order:
- If the package matches
mustPublish, it must NOT haveprivate: true - If the package matches
mustBePrivate, it MUST haveprivate: true - If the package matches
mayPublish, no enforcement is applied - Otherwise, the
unmatchedPackagessetting determines behavior (defaults to requiring private)
Example
Section titled “Example”import { makePolicy } from "repopo";import { PackagePrivateField } from "repopo/policies";
const config: RepopoConfig = { policies: [ makePolicy(PackagePrivateField, { config: { mustPublish: ["@myorg/*"], mustBePrivate: ["@internal/*"], mayPublish: ["@experimental/*"], unmatchedPackages: "private", }, }), ],};