/** * A required script entry for conditional requirements. Can be either: * - A string (script name only, no default value) * - An object with a single key-value pair (script name → default value for auto-fix) * * @example * ```typescript * // Script must exist, no auto-fix available * "test" * * // Script must exist, auto-fix will add this value if missing * { clean: "rimraf dist" } * ``` * * @alpha */ export type ConditionalScriptEntry = string | Record; /** * Configuration for a conditional script requirement. * * @alpha */ export interface ConditionalScriptRule { /** * The script that triggers the requirement. * If this script exists, then `requires` must also exist. */ ifPresent: string; /** * Scripts that must be present if `ifPresent` script exists. * * @remarks * Each entry can be: * - A string: Script must exist, no auto-fix available * - An object `{ scriptName: "default value" }`: Script must exist, auto-fix adds the * default value if missing * * @example * ```typescript * requires: ["test", { clean: "rimraf dist" }] * ``` */ requires: ConditionalScriptEntry[]; } /** * Configuration for the ConditionalScripts policy. * * @alpha */ export interface ConditionalScriptsConfig { /** * Conditional script requirements. If a script is present, other scripts must also exist. * * @remarks * This is useful for enforcing that packages with a "build" script also have a "clean" script, * or packages with "test" also have "test:coverage". * * @example * ```typescript * rules: [ * { ifPresent: "build", requires: [{ clean: "rimraf dist" }] }, * { ifPresent: "test", requires: ["test:coverage"] }, * ] * ``` */ rules: ConditionalScriptRule[]; } /** * A policy that validates conditional script requirements in package.json. * * @remarks * Use this policy when you want to enforce that the presence of one script * requires other scripts to also exist. For example, if "build" exists, * then "clean" must also exist. * * @example * ```typescript * import { policy } from "repopo"; * import { ConditionalScripts } from "repopo/policies"; * * policy(ConditionalScripts, { * rules: [ * // If "build" exists, "clean" must also exist (with auto-fix default) * { ifPresent: "build", requires: [{ clean: "rimraf dist" }] }, * // If "test" exists, "test:coverage" must also exist (no auto-fix) * { ifPresent: "test", requires: ["test:coverage"] }, * ], * }) * ``` * * @alpha */ export declare const ConditionalScripts: import("../policy.js").PolicyShape; //# sourceMappingURL=ConditionalScripts.d.ts.map