From 64da5de1ae31581b231a2c2d4a9a2c3a5ce5b982 Mon Sep 17 00:00:00 2001 From: anten-ka Date: Mon, 6 Apr 2026 23:03:49 +0300 Subject: [PATCH] fix: download_template - handle StartBootstrap dist/ structure + fallback index.html search StartBootstrap templates store production files in dist/ subdirectory. Added: dist/ detection, recursive index.html fallback, ls output to stderr. --- lib/templates_catalog.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/templates_catalog.sh b/lib/templates_catalog.sh index f44e5fa..c3524e5 100644 --- a/lib/templates_catalog.sh +++ b/lib/templates_catalog.sh @@ -238,9 +238,28 @@ download_template() { # Для StartBootstrap — каждый шаблон в своём репо elif [ "$source" = "startbootstrap" ]; then - git clone --depth 1 "$repo_url" "$clone_dir" 2>/dev/null - # Убираем .git - rm -rf "$clone_dir/.git" + local sb_tmp="/tmp/sb_clone_$$" + rm -rf "$sb_tmp" + git clone --depth 1 "$repo_url" "$sb_tmp" 2>/dev/null + if [ -d "$sb_tmp" ]; then + rm -rf "$sb_tmp/.git" + # StartBootstrap хранит production-файлы в dist/ + if [ -f "$sb_tmp/dist/index.html" ]; then + cp -r "$sb_tmp/dist/"* "$clone_dir/" + elif [ -f "$sb_tmp/index.html" ]; then + cp -r "$sb_tmp/"* "$clone_dir/" + else + # fallback: ищем index.html рекурсивно + local found_index + found_index=$(find "$sb_tmp" -name "index.html" -type f 2>/dev/null | head -1) + if [ -n "$found_index" ]; then + local found_dir + found_dir=$(dirname "$found_index") + cp -r "$found_dir/"* "$clone_dir/" + fi + fi + fi + rm -rf "$sb_tmp" fi # Проверяем результат @@ -249,9 +268,22 @@ download_template() { echo "$clone_dir" return 0 else + # fallback: ищем index.html в подпапках (нестандартная структура) + local fallback_index + fallback_index=$(find "$clone_dir" -name "index.html" -type f 2>/dev/null | head -1) + if [ -n "$fallback_index" ]; then + local fallback_dir + fallback_dir=$(dirname "$fallback_index") + if [ "$fallback_dir" != "$clone_dir" ]; then + cp -r "$fallback_dir/"* "$clone_dir/" + log_success "Шаблон \"$name\" скачан (из подпапки)" + echo "$clone_dir" + return 0 + fi + fi log_error "Шаблон не содержит index.html" log_dim "Путь: $clone_dir" - ls -la "$clone_dir" 2>/dev/null + ls -la "$clone_dir" 2>/dev/null >&2 return 1 fi }