use std::collections::{BTreeMap, HashMap, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use crate::helpers::{first_positional, has_flag, option_value, parse_u64_option};
mod commands;
mod helpers;
mod severity;
use self::helpers::*;
use self::severity::{
load_error_severity_overrides, summarize_error_code, summarize_error_group,
summarize_error_severity,
};
pub use self::commands::{
sdk_init, sdk_migrate, sdk_migrate_batch, sdk_migrate_report, sdk_retry_failed, sdk_rollback,
sdk_rollback_batch,
};
const SDK_INIT_API_VERSION: &str = "robotrt.sdk.init.v1";
const SDK_MIGRATE_API_VERSION: &str = "robotrt.sdk.migrate.v1";
const SDK_MIGRATE_BATCH_API_VERSION: &str = "robotrt.sdk.migrate-batch.v1";
const SDK_MIGRATE_REPORT_API_VERSION: &str = "robotrt.sdk.migrate-report.v1";
const SDK_ROLLBACK_API_VERSION: &str = "robotrt.sdk.rollback.v1";
const SDK_ROLLBACK_BATCH_API_VERSION: &str = "robotrt.sdk.rollback-batch.v1";
const SDK_MIGRATE_RETRY_API_VERSION: &str = "robotrt.sdk.migrate-retry.v1";
const SDK_CONFIG_SCHEMA_VERSION: u64 = 2;
const SDK_LATEST_SCHEMA_VERSION: u64 = 4;
#[derive(Clone)]
struct SdkMigrateExecution {
project_dir: PathBuf,
config_path: PathBuf,
backup_path: Option<PathBuf>,
manifest_path: Option<PathBuf>,
applied_steps: Vec<String>,
from_schema_version: u64,
to_schema_version: u64,
updated: bool,
dry_run: bool,
}
enum SdkMigrateBatchOutcome {
Success(SdkMigrateExecution),
Failure {
project_dir: PathBuf,
error: String,
},
Skipped {
project_dir: PathBuf,
reason: String,
},
}
#[derive(Clone)]
struct SdkProjectProfile {
project_dir: PathBuf,
schema_version: Option<u64>,
template: Option<String>,
missing_config: bool,
backup_conflict: bool,
downgrade_risk: bool,
}
#[derive(Clone)]
struct BatchReportProject {
project_dir: PathBuf,
status: String,
backup_path: Option<PathBuf>,
error: Option<String>,
}
enum SdkRollbackBatchOutcome {
Success {
project_dir: PathBuf,
config_path: PathBuf,
rollback_backup_path: PathBuf,
},
Failure {
project_dir: PathBuf,
error: String,
},
Skipped {
project_dir: PathBuf,
reason: String,
},
}