import { CLIError } from '@oclif/errors'; import * as Context from './context'; declare type Options = { context: Context.Context; }; /** * * @example * * ```ts * guard(ctx) * .must(isTrunk()) * .check(flags.upToDate ? 'must' : 'prefer', upToDate()) * * if (flags.npmPublish) { * guard.must(publishRights()) * } * * guard.run() * ``` */ export declare function check(options: Options): { check(level: Requirement['level'], validator: Validator): any; stopUnless(checker: Validator): any; errorUnless(checker: Validator): any; run(): Report; }; /** * */ interface EnforceInput { context: Context.Context; report: Report; json?: boolean; } /** * Enforce the result of a report. Throws errors/stop-signal that will halt the * CLI if needed. */ export declare function guard(input: EnforceInput): void; interface Requirement { validator: Validator; level: 'prefer' | 'must'; } export interface ValidationResult { code: Validator['code']; summary: string; details: Record; } interface Report { errors: ValidationResult[]; stops: ValidationResult[]; passes: ValidationResult[]; } export declare class JSONCLIError extends CLIError { private errorObject; oclif: { exit: number; }; code: string; constructor(errorObject: object); render(): string; } export declare class PassthroughCLIError extends CLIError { private errorString; oclif: { exit: number; }; code: string; constructor(errorString: string); render(): string; } export declare class CLIStop extends CLIError { private input; oclif: { exit: number; }; code: string; constructor(input: { reasons: ValidationResult[]; json?: boolean; }); render(): string; } export interface Validator { code: string; summary: string; run(ctx: Context.Context): Pass | Fail | boolean; } interface Pass { kind: 'pass'; details: Record; } interface Fail { kind: 'fail'; details: Record; } export declare type Result = Pass | Fail; export declare function booleanResult(bool: boolean): Result; export {}; //# sourceMappingURL=contrext-guard.d.ts.map