Actualizar lib/steps/repos.sh
This commit is contained in:
parent
24dacb2e33
commit
2d958f9145
1 changed files with 16 additions and 74 deletions
|
|
@ -12,85 +12,27 @@ step_repos() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_clone_repos() {
|
_clone_repos() {
|
||||||
echo ""
|
|
||||||
log_info "REPOS CONFIG:"
|
|
||||||
for name in core essentials cli gui; do
|
|
||||||
local url="${REPO_URLS[$name]}"
|
|
||||||
local branch="${REPO_BRANCHES[$name]}"
|
|
||||||
local dest="${REPO_DIRS[$name]}"
|
|
||||||
echo " $name:"
|
|
||||||
echo " URL: $url"
|
|
||||||
echo " Branch: $branch"
|
|
||||||
echo " Dest: $dest"
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
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]}"
|
||||||
|
|
||||||
log_info "Processing ${name}..."
|
if [ -d "$dest" ]; then
|
||||||
log_info " Checking if exists: $dest/.git"
|
log_warn "Repo ya existe: ${dest}"
|
||||||
|
|
||||||
if [ -d "$dest/.git" ]; then
|
|
||||||
log_warn "Repository already exists: ${dest}"
|
|
||||||
if ask_confirm "Delete and re-clone ${name}?"; then
|
|
||||||
log_info "Deleting: $dest"
|
|
||||||
rm -rf "$dest"
|
rm -rf "$dest"
|
||||||
else
|
|
||||||
log_skip "Re-clone skipped — using ${dest}"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "Starting clone..."
|
if ! git clone --branch "$branch" "$url" "$dest" 2>&1; then
|
||||||
log_info " git clone --branch $branch $url $dest"
|
log_error "git clone FAILED: $name"
|
||||||
|
|
||||||
start_spinner "Cloning ${name} (branch: ${branch})..."
|
|
||||||
|
|
||||||
local clone_log="/tmp/clone_${name}_$$.log"
|
|
||||||
if ! git clone --branch "$branch" "$url" "$dest" > "$clone_log" 2>&1; then
|
|
||||||
stop_spinner
|
|
||||||
log_error "git clone FAILED for ${name}"
|
|
||||||
log_error " URL: $url"
|
log_error " URL: $url"
|
||||||
log_error " Branch: $branch"
|
log_error " Branch: $branch"
|
||||||
log_error " Dest: $dest"
|
log_error " Dest: $dest"
|
||||||
log_error "Output:"
|
|
||||||
cat "$clone_log" | sed 's/^/ /'
|
|
||||||
rm -f "$clone_log"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -f "$clone_log"
|
|
||||||
|
|
||||||
log_info "Checking if clone succeeded: ls -la $dest/.git"
|
|
||||||
if [ ! -d "$dest/.git" ]; then
|
|
||||||
stop_spinner
|
|
||||||
log_error "${name} clone directory exists but no .git found"
|
|
||||||
ls -la "$dest" 2>&1 | sed 's/^/ /'
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
stop_spinner "${name} cloned → ${dest}"
|
|
||||||
chmod 700 "$dest"
|
chmod 700 "$dest"
|
||||||
log_ok "${name} OK"
|
log_ok "${name} clonado → ${dest}"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
|
||||||
log_info "FINAL CHECK:"
|
|
||||||
for name in core essentials cli gui; do
|
|
||||||
local dest="${REPO_DIRS[$name]}"
|
|
||||||
if [ -d "$dest/.git" ]; then
|
|
||||||
log_ok "$name: ✓ cloned at $dest"
|
|
||||||
else
|
|
||||||
log_error "$name: ✗ NOT cloned — $dest/.git missing"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
if [ ! -d "$HV_CORE/.git" ]; then
|
|
||||||
log_error "core repository not cloned"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setup_env() {
|
_setup_env() {
|
||||||
|
|
@ -98,12 +40,12 @@ _setup_env() {
|
||||||
local example_file="$HV_CORE/.env.example"
|
local example_file="$HV_CORE/.env.example"
|
||||||
|
|
||||||
if [ ! -f "$example_file" ]; then
|
if [ ! -f "$example_file" ]; then
|
||||||
log_error ".env.example not found: ${example_file}"
|
log_error ".env.example no encontrado: ${example_file}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$env_file" ]; then
|
if [ -f "$env_file" ]; then
|
||||||
log_warn ".env already exists — overwriting"
|
log_warn ".env ya existe — sobreescribiendo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -127,19 +69,19 @@ _setup_env() {
|
||||||
printf " ${BCYAN}›${RESET} "
|
printf " ${BCYAN}›${RESET} "
|
||||||
read -r _api_url < /dev/tty
|
read -r _api_url < /dev/tty
|
||||||
|
|
||||||
cat > "$env_file" << EOF
|
cat > "$env_file" << ENVEOF
|
||||||
APP_ENV=${_app_env}
|
APP_ENV=${_app_env}
|
||||||
SP_API_BASE_URL_LOCAL=http://simplifiedprivacy.test/api/v1
|
SP_API_BASE_URL_LOCAL=http://simplifiedprivacy.test/api/v1
|
||||||
SP_API_BASE_URL_PRODUCTION=${_api_url}
|
SP_API_BASE_URL_PRODUCTION=${_api_url}
|
||||||
HV_CORE_HOME=${HV_CORE}
|
HV_CORE_HOME=${HV_CORE}
|
||||||
INSTALL_DIR=${HOME}
|
INSTALL_DIR=${HOME}
|
||||||
CORE_DIR=${HV_CORE}
|
CORE_DIR=${HV_CORE}
|
||||||
EOF
|
ENVEOF
|
||||||
|
|
||||||
chmod 600 "$env_file"
|
chmod 600 "$env_file"
|
||||||
|
|
||||||
log_ok "APP_ENV=${_app_env}"
|
log_ok "APP_ENV=${_app_env}"
|
||||||
[ -n "$_api_url" ] && log_ok "SP_API_BASE_URL_PRODUCTION=${_api_url}" || label_skip "SP_API_BASE_URL_PRODUCTION — empty"
|
[ -n "$_api_url" ] && log_ok "SP_API_BASE_URL_PRODUCTION=${_api_url}" || label_skip "SP_API_BASE_URL_PRODUCTION — vacío"
|
||||||
log_ok "INSTALL_DIR=${HOME}"
|
log_ok "INSTALL_DIR=${HOME}"
|
||||||
log_ok ".env written → ${env_file}"
|
log_ok ".env escrito → ${env_file}"
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue