Actualizar lib/steps/repos.sh
This commit is contained in:
parent
55f2515874
commit
594f6a8d4b
1 changed files with 17 additions and 21 deletions
|
|
@ -1,41 +1,39 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# lib/steps/repos.sh — clonar repositorios + generar .env
|
|
||||||
|
|
||||||
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() {
|
||||||
for name in 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]}"
|
||||||
|
|
||||||
if [ -d "$dest/.git" ]; then
|
if [ -d "$dest/.git" ]; then
|
||||||
log_warn "Repo ya existe: ${dest}"
|
log_warn "Repo already exists: ${dest}"
|
||||||
if ask_confirm "Eliminar y re-clonar ${name}?"; then
|
if ask_confirm "Delete and re-clone ${name}?"; then
|
||||||
rm -rf "$dest"
|
rm -rf "$dest"
|
||||||
else
|
else
|
||||||
log_skip "Re-clone omitido — usando ${dest}"
|
log_skip "Re-clone skipped — using ${dest}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
start_spinner "Clonando ${name} (branch: ${branch})..."
|
start_spinner "Cloning ${name} (branch: ${branch})..."
|
||||||
if git clone --branch "$branch" "$url" "$dest" &>/dev/null; then
|
if git clone --branch "$branch" "$url" "$dest" &>/dev/null; then
|
||||||
stop_spinner "${name} clonado → ${dest}"
|
stop_spinner "${name} cloned → ${dest}"
|
||||||
else
|
else
|
||||||
stop_spinner
|
stop_spinner
|
||||||
log_error "git clone falló: ${url}"
|
log_error "git clone failed: ${url}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 700 "$dest"
|
chmod 700 "$dest"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
@ -45,24 +43,23 @@ _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 no encontrado: ${example_file}"
|
log_error ".env.example not found: ${example_file}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$env_file" ]; then
|
if [ -f "$env_file" ]; then
|
||||||
log_warn ".env ya existe — sobreescribiendo"
|
log_warn ".env already exists — overwriting"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
printf " ${DIM}Completá las variables. ENTER = dejar vacío.${RESET}\n"
|
printf " ${DIM}Fill in the variables. ENTER = leave empty.${RESET}\n"
|
||||||
print_divider
|
print_divider
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# APP_ENV
|
|
||||||
select_option \
|
select_option \
|
||||||
"APP_ENV — entorno de la aplicación" \
|
"APP_ENV — application environment" \
|
||||||
"local desarrollo / testing" \
|
"local development / testing" \
|
||||||
"production producción / dominio real"
|
"production production / real domain"
|
||||||
|
|
||||||
case "$SELECT_RESULT" in
|
case "$SELECT_RESULT" in
|
||||||
0) _app_env="local" ;;
|
0) _app_env="local" ;;
|
||||||
|
|
@ -79,16 +76,15 @@ _setup_env() {
|
||||||
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}
|
||||||
|
|
||||||
# ── Generado por el installer ─────────────────────────────────────────────
|
|
||||||
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
|
EOF
|
||||||
|
|
||||||
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 — vacío"
|
[ -n "$_api_url" ] && log_ok "SP_API_BASE_URL_PRODUCTION=${_api_url}" || label_skip "SP_API_BASE_URL_PRODUCTION — empty"
|
||||||
log_ok "INSTALL_DIR=${HOME}"
|
log_ok "INSTALL_DIR=${HOME}"
|
||||||
log_ok ".env escrito → ${env_file}"
|
log_ok ".env written → ${env_file}"
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue