From be644f8c54ff5d26c1252426ffd4da090c2e7396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Tue, 3 Nov 2026 14:40:14 +0500 Subject: [PATCH] fix(modules-preview): chain build on card click, fix MSVC definitions & include shadowing, humanize errors --- crates/coa-core/src/analyzer.rs | 10 +++ crates/coa-core/src/build_engine.rs | 42 +++++++-- src/lib/api.ts | 27 +++++- src/screens/ModulesPage.tsx | 131 +++++++++++++++++++--------- 4 files changed, 160 insertions(+), 50 deletions(-) diff --git a/crates/coa-core/src/analyzer.rs b/crates/coa-core/src/analyzer.rs index df61231..e0044e5 100644 --- a/crates/coa-core/src/analyzer.rs +++ b/crates/coa-core/src/analyzer.rs @@ -556,6 +556,16 @@ pub fn analyze_repository_with_contract(repo_path: &Path, contract: &SdkExportCo reasons.push("Compiled and linked successfully against CoA Plugin SDK v0.3; database review required for SQL scripts".into()); recommended_actions.push("Review SQL migration and deploy with active configuration".into()); CompatibilityClassification::SqlReviewRequired + } else if script_loaders.canonical_loader.is_none() { + if !sql_files.is_empty() { + reasons.push(format!("Database/SQL-only module (no C++ entrypoint detected; {} SQL files)", sql_files.len())); + recommended_actions.push("Review and apply SQL schema to database; no DLL compilation needed".into()); + CompatibilityClassification::SqlReviewRequired + } else { + reasons.push("No C++ script loader or entrypoint found in repository (Lua/Eluna, client addon, or non-C++ repository)".into()); + recommended_actions.push("Module contains no compilable C++ sources for dynamic DLL architecture".into()); + CompatibilityClassification::Inconclusive + } } else { reasons.push("Clean script hooks compatible with CoA Plugin SDK".into()); recommended_actions.push("Generate standalone CMakeLists.txt and compile against CoA Plugin SDK".into()); diff --git a/crates/coa-core/src/build_engine.rs b/crates/coa-core/src/build_engine.rs index 6917533..a494615 100644 --- a/crates/coa-core/src/build_engine.rs +++ b/crates/coa-core/src/build_engine.rs @@ -161,13 +161,28 @@ fn sha256_of_file(path: &Path) -> Result { Ok(format!("{:x}", hasher.finalize())) } -/// Recursively collects all files with specified extension. +/// Recursively collects all files with specified extension, skipping non-module directories. fn collect_files_with_ext(dir: &Path, ext: &str) -> Vec { let mut results = Vec::new(); if let Ok(entries) = fs::read_dir(dir) { for entry in entries.flatten() { let path = entry.path(); if path.is_dir() { + let name = path.file_name().and_then(|n| n.to_str()).unwrap_or(""); + let n_lower = name.to_ascii_lowercase(); + if n_lower == "tests" + || n_lower == "test" + || n_lower == "stubs" + || n_lower == "stub" + || n_lower == "pilot" + || n_lower == "tools" + || n_lower == "build" + || n_lower == ".git" + || n_lower == ".github" + || n_lower == "cmake" + { + continue; + } results.extend(collect_files_with_ext(&path, ext)); } else if let Some(e) = path.extension() { if e.to_string_lossy().eq_ignore_ascii_case(ext) { @@ -286,14 +301,17 @@ pub fn resolve_module_identity(source_dir: &Path) -> (String, String, Option Vec { let mut diagnostics = Vec::new(); for line in logs { - // MSVC C-error: filename(line,col): error Cxxxx: message - // or filename(line): error Cxxxx: message - if line.contains(": error C") { - let parts: Vec<&str> = line.split(": error ").collect(); - if parts.len() == 2 { - let left = parts[0].trim(); - let right = parts[1].trim(); + // MSVC C-error: filename(line,col): [fatal] error Cxxxx: message + if line.contains(": error C") || line.contains(": fatal error C") { + let (left, right) = if let Some(idx) = line.find(": fatal error ") { + (line[..idx].trim(), line[idx + 14..].trim()) + } else if let Some(idx) = line.find(": error ") { + (line[..idx].trim(), line[idx + 8..].trim()) + } else { + ("", line.trim()) + }; + if !right.is_empty() { let (file, line_num) = if let Some(idx) = left.rfind('(') { let f = left[..idx].trim().to_string(); let rest = &left[idx + 1..]; @@ -509,6 +527,14 @@ coa_add_plugin({safe_target_name} target_include_directories({safe_target_name} PRIVATE {includes_block} ) +target_compile_definitions({safe_target_name} PRIVATE + _WIN32_WINNT=0x0601 + WIN32_LEAN_AND_MEAN + NOMINMAX +) +if(MSVC) + target_compile_options({safe_target_name} PRIVATE /bigobj) +endif() "#, safe_target_name = safe_target_name, cmake_sdk_path = cmake_sdk_path, sources_block = sources_block, includes_block = includes_block); fs::write(staging_dir.join("CMakeLists.txt"), &controlled_cmake)?; diff --git a/src/lib/api.ts b/src/lib/api.ts index 7540984..490f7d8 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -870,8 +870,31 @@ export const api = { export function asUiError(e: unknown): UiError { if (e && typeof e === "object" && "human" in e) return e as UiError; + let text = ""; + if (typeof e === "string") { + text = e; + } else if (e instanceof Error) { + text = e.message; + } else if (e && typeof e === "object") { + const o = e as Record; + text = (typeof o.technical === "string" && o.technical !== "[object Object]" && o.technical) || + (typeof o.message === "string" && o.message !== "[object Object]" && o.message) || + (typeof o.error === "string" && o.error !== "[object Object]" && o.error) || + (typeof o.reason === "string" && o.reason !== "[object Object]" && o.reason) || + ""; + if (!text) { + try { + const json = JSON.stringify(e); + if (json && json !== "{}") text = json; + } catch {} + } + } + if (!text || text === "[object Object]") { + text = String(e); + if (text === "[object Object]") text = "Неизвестная системная ошибка (см. логи)"; + } return { - human: { code: "unknown", title: "Something went wrong", message: "See the technical details.", actions: ["show_details"] }, - technical: String(e), + human: { code: "unknown", title: "Что-то пошло не так", message: text, actions: ["show_details"] }, + technical: text, }; } diff --git a/src/screens/ModulesPage.tsx b/src/screens/ModulesPage.tsx index 481f7bd..45fc053 100644 --- a/src/screens/ModulesPage.tsx +++ b/src/screens/ModulesPage.tsx @@ -314,14 +314,14 @@ const VERIFIED_CATALOG: VerifiedCatalogModule[] = [ en: "Adjust the day and night cycle speed and starting game time.", }, qualification: "OPTIMIZED_COA", - tier: "Tier 1: Dynamic DLL", + tier: "Core Module", verificationLevel: "PRODUCTION_SUPPORTED", notes: { ru: "Оптимизированный модуль синхронизации игрового времени с сервером.", en: "Optimized world time synchronization module.", }, sqlRequired: false, - canInstall: true, + canInstall: false, isOfficial: true, icon: "sparkles", }, @@ -350,7 +350,7 @@ const VERIFIED_CATALOG: VerifiedCatalogModule[] = [ { id: "ah-bot", name: "Auction House Bot", - repo: "https://github.com/Corfirean/azerothcore-wotlk-coa/tree/coa-bots/modules/mod-ah-bot-plus", + repo: "https://github.com/azerothcore/mod-ah-bot", category: "official", description: { ru: "Наполняет аукцион реалистичными настраиваемыми лотами.", @@ -481,52 +481,81 @@ function CoaStatusBadge({ status, conflictReason }: { status: CoaCompatibilitySt } } +function humanizeRawError(raw: string, locale: string): string { + if (raw.includes("[NO_LOADER_FOUND]")) { + return locale === "ru" + ? "В репозитории не найдена C++ точка входа Add*Scripts. Модуль не содержит исходного кода C++ для компиляции в DLL (возможно, это скрипт Lua/Eluna или чистый SQL)." + : "No Add*Scripts entrypoint found. This repository contains no C++ source code to build into a DLL (it may be a Lua/Eluna script or SQL-only)."; + } + if (raw.includes("No C++ (.cpp) source files found")) { + return locale === "ru" + ? "В репозитории не найдено файлов C++ (.cpp). Модуль не может быть собран в бинарный DLL-плагин (возможно, это скрипт Lua/Eluna или клиентский аддон)." + : "No C++ source files (.cpp) found in repository. Module cannot be built into a dynamic DLL."; + } + if (raw.includes("Repository not found") || raw.includes("[REPOSITORY_NOT_FOUND]")) { + return locale === "ru" + ? "Репозиторий GitHub не найден или недоступен. Проверьте правильность URL-адреса." + : "GitHub repository not found or unreachable. Check the repository URL."; + } + if (raw.includes("Failed to locate cached repository sources")) { + return locale === "ru" + ? "Не удалось найти кэшированные исходные коды. Попробуйте нажать 'Анализировать' снова." + : "Failed to locate cached repository sources. Try analyzing the module again."; + } + if (raw.includes("[REPOSITORY_TOO_LARGE]")) { + return locale === "ru" + ? `Размер файла или репозитория превышает допустимый лимит: ${raw.replace(/^\[REPOSITORY_TOO_LARGE\]\s*/, "")}` + : `Repository or file exceeds size limit: ${raw.replace(/^\[REPOSITORY_TOO_LARGE\]\s*/, "")}`; + } + if (raw.includes("[MODULE_BLOCKED]")) { + return locale === "ru" + ? `Модуль заблокирован: ${raw}` + : `Module blocked: ${raw}`; + } + if (raw.includes("[MANUAL_ADAPTER_REQUIRED]")) { + return locale === "ru" + ? `Требуется ручной адаптер точки входа: ${raw}` + : `Manual adapter required: ${raw}`; + } + if (raw.includes("[TOOLCHAIN_ERROR]")) { + return locale === "ru" + ? `Ошибка среды сборки: ${raw}` + : `Toolchain error: ${raw}`; + } + return raw; +} + function formatErrorMessage(e: unknown, locale = "ru"): string { if (!e) return locale === "ru" ? "Неизвестная ошибка" : "Unknown error"; - if (typeof e === "string") return e; - if (e instanceof Error) return e.message; + if (typeof e === "string" && e !== "[object Object]") { + return humanizeRawError(e, locale); + } + if (e instanceof Error) return humanizeRawError(e.message, locale); if (typeof e === "object") { const obj = e as { - technical?: string; - human?: { title?: string; message?: string }; - message?: string; + technical?: unknown; + human?: { title?: unknown; message?: unknown }; + message?: unknown; + error?: unknown; + reason?: unknown; }; - const raw = obj.technical || obj.human?.message || obj.message || ""; + const raw = ( + (typeof obj.technical === "string" && obj.technical !== "[object Object]" && obj.technical) || + (obj.human && typeof obj.human.message === "string" && obj.human.message !== "[object Object]" && obj.human.message) || + (typeof obj.message === "string" && obj.message !== "[object Object]" && obj.message) || + (typeof obj.error === "string" && obj.error !== "[object Object]" && obj.error) || + (typeof obj.reason === "string" && obj.reason !== "[object Object]" && obj.reason) || + "" + ); if (raw) { - if (raw.includes("[NO_LOADER_FOUND]")) { - return locale === "ru" - ? "В репозитории не найдена C++ точка входа Add*Scripts. Модуль не содержит исходного кода C++ для компиляции в DLL (возможно, это скрипт Lua/Eluna или чистый SQL)." - : "No Add*Scripts entrypoint found. This repository contains no C++ source code to build into a DLL (it may be a Lua/Eluna script or SQL-only)."; - } - if (raw.includes("[REPOSITORY_TOO_LARGE]")) { - return locale === "ru" - ? `Размер файла или репозитория превышает допустимый лимит: ${raw.replace(/^\[REPOSITORY_TOO_LARGE\]\s*/, "")}` - : `Repository or file exceeds size limit: ${raw.replace(/^\[REPOSITORY_TOO_LARGE\]\s*/, "")}`; - } - if (raw.includes("[MODULE_BLOCKED]")) { - return locale === "ru" - ? `Модуль заблокирован: ${raw}` - : `Module blocked: ${raw}`; - } - if (raw.includes("[MANUAL_ADAPTER_REQUIRED]")) { - return locale === "ru" - ? `Требуется ручной адаптер точки входа: ${raw}` - : `Manual adapter required: ${raw}`; - } - if (raw.includes("[TOOLCHAIN_ERROR]")) { - return locale === "ru" - ? `Ошибка среды сборки: ${raw}` - : `Toolchain error: ${raw}`; - } - return raw; + return humanizeRawError(raw, locale); } try { - return JSON.stringify(e); - } catch { - return String(e); - } + const json = JSON.stringify(e); + if (json && json !== "{}" && json !== "[]") return json; + } catch {} } - return String(e); + return locale === "ru" ? "Неизвестная ошибка при сборке модуля" : "Unknown error during module build"; } function formatDate(dateStr?: string | null): string { @@ -1949,6 +1978,27 @@ export function ModulesPage({ {locale === "ru" ? "Включить" : "Enable"} ) + ) : item.id === "time-is-time" ? ( + ) : item.id === "custom-races" ? (