From 59d8c34136f1b9b2806c485bd7615747724f791f Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Wed, 12 Mar 2025 20:46:05 -0500 Subject: [PATCH] [IMPROVED] Agregar selector de tipo de servidor git al crear proyectos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 馃 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bin/project_new.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/bin/project_new.sh b/bin/project_new.sh index d88d33d..b85bb35 100755 --- a/bin/project_new.sh +++ b/bin/project_new.sh @@ -40,7 +40,9 @@ PROJECT_TYPE="" PROJECT_DESCRIPTION="" PROJECT_LICENSE="" PROJECT_LICENSE_TEXT="" +PROJECT_GIT_SERVER="" VALID_TYPES=("ansible" "odoo" "sp32home" "nodejs" "python" "cobol" "php" "c" "cpp" "csharp" "rust" "otros") +VALID_GIT_SERVERS=("github" "gitlab" "gitea" "forgejo" "none") # Estructura de datos para licencias: nombre, badge, texto corto declare -A LICENSE_BADGES @@ -274,6 +276,43 @@ function request_project_description() { fi } +# Funci贸n para solicitar el tipo de servidor git +function request_git_server() { + # Construir las opciones para el di谩logo + OPTIONS="" + for i in "${!VALID_GIT_SERVERS[@]}"; do + if [ "${VALID_GIT_SERVERS[$i]}" == "github" ]; then + # Seleccionar "github" como opci贸n por defecto + OPTIONS="$OPTIONS ${VALID_GIT_SERVERS[$i]} ${VALID_GIT_SERVERS[$i]} on" + else + OPTIONS="$OPTIONS ${VALID_GIT_SERVERS[$i]} ${VALID_GIT_SERVERS[$i]} off" + fi + done + + dialog_input_radio "Seleccione el servidor Git" "Elija el tipo de servidor Git que utilizar谩 para este proyecto" "$OPTIONS" 15 15 50 + + if [ $codex -ne 0 ]; then + echo "${head_canceled}" + exit 1 + fi + + PROJECT_GIT_SERVER="$value" + + # Validar que el servidor seleccionado sea v谩lido + VALID_SERVER=0 + for s in "${VALID_GIT_SERVERS[@]}"; do + if [ "$s" == "$PROJECT_GIT_SERVER" ]; then + VALID_SERVER=1 + break + fi + done + + if [ $VALID_SERVER -eq 0 ]; then + dialog_error_box "$head_error" "El tipo de servidor Git seleccionado no es v谩lido" + request_git_server + fi +} + # Funci贸n para crear la estructura del proyecto function create_project_structure() { # Crear la carpeta del proyecto @@ -771,6 +810,9 @@ EOF # Guardar informaci贸n de la licencia en un archivo echo "$PROJECT_LICENSE" > "$PROJECT_PATH/.license" + # Guardar informaci贸n del servidor git en un archivo + echo "$PROJECT_GIT_SERVER" > "$PROJECT_PATH/.gittype" + # Hacer commit inicial del proyecto cd "$PROJECT_PATH" git add . @@ -799,6 +841,9 @@ function main() { # Solicitar descripci贸n del proyecto request_project_description + # Solicitar tipo de servidor git + request_git_server + # Crear estructura del proyecto create_project_structure }