morph-cli 0.1.0

AST-based codebase migration and codemod tool for JavaScript and TypeScript projects.
Documentation
use std::path::Path;
use anyhow::Result;
use crate::cli::ManifestAction;
use crate::core::manifest::MigrationManifest;
use crate::utils::terminal;

pub fn execute(action: ManifestAction, project_root: &Path) -> Result<()> {
    match action {
        ManifestAction::Create {
            file,
            profile,
            recipes,
            target,
            write,
            dry_run,
            allow_risky,
            strict,
            autofix,
        } => {
            let manifest = MigrationManifest {
                profile_name: profile,
                recipes,
                target_path: target,
                write,
                dry_run,
                allow_risky,
                strict,
                autofix,
                review: false,
                verbose: false,
                summary_only: false,
            };

            manifest.save_to_file(&file)?;
            println!(
                "{} Saved migration manifest to {}",
                terminal::success_prefix(),
                file.display()
            );
            Ok(())
        }
        ManifestAction::Run { file } => {
            println!("{} Loading manifest: {}", terminal::info_prefix(), file.display());
            let manifest = MigrationManifest::load_from_file(&file)?;

            println!(
                "{} Executing migration manifest targeting: {}",
                terminal::info_prefix(),
                manifest.target_path.display()
            );

            // Execute the pipeline using run::execute!
            crate::commands::run::execute(
                &manifest.recipes,
                &manifest.target_path,
                manifest.dry_run,
                manifest.write,
                manifest.review,
                manifest.autofix,
                manifest.verbose,
                manifest.summary_only,
                None, // max_preview_lines
                manifest.allow_risky,
                manifest.strict,
                false, // report_json
                false, // report_md
                Path::new(".morph-cli/reports"), // report_dir
                true,  // format
                false, // prettier
                false, // no_format
                None,  // jobs
                false, // sequential
                project_root,
                None,  // package
                manifest.profile_name.as_deref(),
                None,  // output_style
                None,  // tag
            )?;

            println!("{} Manifest execution completed!", terminal::success_prefix());
            Ok(())
        }
    }
}