import { Logger } from '../../_dependencies/@hyperfrontend/logging/index.js'; import { Tree } from '../../_dependencies/@hyperfrontend/project-scope/vfs/index.js'; import { GitClient } from '../../git'; import { Registry } from '../../registry/models'; import { VersionFlow, FlowResult } from '../models'; /** * Output format for diff preview. */ type DiffFormat = 'unified' | 'summary'; /** * Options for flow execution. */ interface ExecuteOptions { /** Dry run - don't commit changes to disk */ dryRun?: boolean; /** Verbose logging */ verbose?: boolean; /** Show unified diff of changes before committing */ showDiff?: boolean; /** Output format for diff: 'unified' (full patch) or 'summary' (stats only) */ diffFormat?: DiffFormat; /** * Whether to rollback all pending changes on step failure. * * When true (default), pending VFS changes are discarded when a step fails * and `continueOnError` is false. This ensures no partial state remains. * * @default true */ rollbackOnFailure?: boolean; /** Custom logger (defaults to console) */ logger?: Logger; /** Custom Tree instance (for testing) */ tree?: Tree; /** Custom Registry instance (for testing) */ registry?: Registry; /** Custom GitClient instance (for testing) */ git?: GitClient; /** * Project root path (relative to workspace root, e.g., 'libs/utils/immutable-api'). * If provided, this is used directly instead of deriving from project name. * This is the recommended approach when calling from the Nx executor. */ projectRoot?: string; } /** * Executes a version flow. * * This is the main entry point for running a versioning workflow. * Steps are executed in order, with state accumulated between steps. * * @param flow - The version flow to execute * @param projectName - Name of the project to version (e.g., 'lib-versioning') * @param workspaceRoot - Absolute path to workspace root * @param options - Execution options * @returns Flow execution result * * @example Executing a conventional version flow * ```typescript * import { createConventionalFlow, executeFlow } from '@hyperfrontend/versioning' * * const flow = createConventionalFlow({ dryRun: true }) * const result = await executeFlow(flow, 'lib-utils', '/path/to/workspace') * * console.log(result.summary) * // "Flow success in 234ms: 8 completed, 0 skipped, 0 failed. Version: 1.2.3 → 1.3.0" * ``` */ declare function executeFlow(flow: VersionFlow, projectName: string, workspaceRoot: string, options?: ExecuteOptions): Promise; /** * Executes a flow in dry-run mode. * * Convenience wrapper that sets dryRun: true. * * @param flow - The version flow to execute * @param projectName - Name of the project to version * @param workspaceRoot - Absolute path to workspace root * @param options - Execution options (dryRun forced to true) * @returns Flow execution result (no actual changes made) * * @example Previewing version changes without modifying files * ```typescript * import { dryRun, createConventionalFlow } from '@hyperfrontend/versioning' * * const flow = createConventionalFlow() * const result = await dryRun(flow, 'my-lib', '/workspace') * * // Preview what would happen * console.log('Would bump to:', result.state.nextVersion) * // No files modified, no git operations performed * ``` */ declare function dryRun(flow: VersionFlow, projectName: string, workspaceRoot: string, options?: Omit): Promise; /** * Validates a flow before execution. * * Checks for: * - Duplicate step IDs * - Invalid dependency references * - Circular dependencies * * @param flow - The flow to validate * @returns Array of validation errors (empty if valid) * * @example Validating a flow before execution * ```typescript * import { validateFlow, createConventionalFlow } from '@hyperfrontend/versioning' * * const flow = createConventionalFlow() * const errors = validateFlow(flow) * * if (errors.length > 0) { * console.error('Invalid flow:', errors) * } * // => [] * ``` */ declare function validateFlow(flow: VersionFlow): readonly string[]; export { dryRun, executeFlow, validateFlow }; export type { ExecuteOptions };