Actualizar lib/steps/repos.sh
This commit is contained in:
parent
dd7edfa4ed
commit
fde1d35f17
1 changed files with 10 additions and 33 deletions
|
|
@ -3,73 +3,50 @@
|
||||||
step_repos() {
|
step_repos() {
|
||||||
print_section "Repositories"
|
print_section "Repositories"
|
||||||
log_step "Cloning repositories & configuring .env" 2 $TOTAL_STEPS
|
log_step "Cloning repositories & configuring .env" 2 $TOTAL_STEPS
|
||||||
|
|
||||||
mkdir -p "$HV_BASE"
|
mkdir -p "$HV_BASE"
|
||||||
chmod 700 "$HV_BASE"
|
chmod 700 "$HV_BASE"
|
||||||
|
|
||||||
_clone_repos
|
_clone_repos
|
||||||
_setup_env
|
_setup_env
|
||||||
}
|
}
|
||||||
|
|
||||||
_clone_repos() {
|
_clone_repos() {
|
||||||
echo "[DEBUG] ==============================="
|
|
||||||
echo "[DEBUG] HV_BASE=$HV_BASE"
|
|
||||||
echo "[DEBUG] HV_CORE=$HV_CORE"
|
|
||||||
echo "[DEBUG] REPO_URLS[core]=${REPO_URLS[core]}"
|
|
||||||
echo "[DEBUG] REPO_BRANCHES[core]=${REPO_BRANCHES[core]}"
|
|
||||||
echo "[DEBUG] REPO_DIRS[core]=${REPO_DIRS[core]}"
|
|
||||||
echo "[DEBUG] ==============================="
|
|
||||||
|
|
||||||
for name in core essentials cli gui; do
|
for name in core essentials cli gui; do
|
||||||
local url="${REPO_URLS[$name]}"
|
local url="${REPO_URLS[$name]}"
|
||||||
local branch="${REPO_BRANCHES[$name]}"
|
local branch="${REPO_BRANCHES[$name]}"
|
||||||
local dest="${REPO_DIRS[$name]}"
|
local dest="${REPO_DIRS[$name]}"
|
||||||
[ "$name" = "core" ] && dest="$HV_CORE"
|
|
||||||
[ "$name" = "cli" ] && dest="$HV_CLI"
|
|
||||||
[ "$name" = "essentials" ] && dest="$HV_ESSENTIALS"
|
|
||||||
[ "$name" = "gui" ] && dest="$HV_GUI"
|
|
||||||
|
|
||||||
echo "[DEBUG] --- name=$name"
|
|
||||||
echo "[DEBUG] url=$url"
|
|
||||||
echo "[DEBUG] branch=$branch"
|
|
||||||
echo "[DEBUG] dest=$dest"
|
|
||||||
|
|
||||||
if [ -d "$dest/.git" ]; then
|
if [ -d "$dest/.git" ]; then
|
||||||
echo "[DEBUG] .git EXISTS at $dest — asking re-clone"
|
log_warn "Repository already exists: ${dest}"
|
||||||
log_warn "Repo already exists: ${dest}"
|
|
||||||
if ask_confirm "Delete and re-clone ${name}?"; then
|
if ask_confirm "Delete and re-clone ${name}?"; then
|
||||||
rm -rf "$dest"
|
rm -rf "$dest"
|
||||||
else
|
else
|
||||||
log_skip "Re-clone skipped — using ${dest}"
|
log_skip "Re-clone skipped — using ${dest}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "[DEBUG] .git NOT found — proceeding to clone"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[DEBUG] running: git clone --branch $branch $url $dest"
|
start_spinner "Cloning ${name} (branch: ${branch})..."
|
||||||
if git clone --branch "$branch" "$url" "$dest"; then
|
if git clone --branch "$branch" "$url" "$dest" 2>&1 | grep -q "fatal\|error"; then
|
||||||
echo "[DEBUG] clone SUCCESS"
|
|
||||||
stop_spinner "${name} cloned → ${dest}"
|
|
||||||
else
|
|
||||||
echo "[DEBUG] clone FAILED (exit code $?)"
|
|
||||||
stop_spinner
|
stop_spinner
|
||||||
log_error "git clone failed: ${url}"
|
log_error "git clone failed: ${url}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
stop_spinner "${name} cloned → ${dest}"
|
||||||
chmod 700 "$dest"
|
chmod 700 "$dest"
|
||||||
echo "[DEBUG] chmod 700 done"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "[DEBUG] _clone_repos finished"
|
if [ ! -d "$HV_CORE/.git" ]; then
|
||||||
|
log_error "core repository not cloned successfully"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_setup_env() {
|
_setup_env() {
|
||||||
local env_file="$HV_CORE/.env"
|
local env_file="$HV_CORE/.env"
|
||||||
local example_file="$HV_CORE/.env.example"
|
local example_file="$HV_CORE/.env.example"
|
||||||
|
|
||||||
echo "[DEBUG] _setup_env: example_file=$example_file"
|
|
||||||
echo "[DEBUG] _setup_env: env_file=$env_file"
|
|
||||||
|
|
||||||
if [ ! -f "$example_file" ]; then
|
if [ ! -f "$example_file" ]; then
|
||||||
log_error ".env.example not found: ${example_file}"
|
log_error ".env.example not found: ${example_file}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue