-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (symfony): #15 migration symfony setup environment
- Efde.Tasks - Generic element to manage the installation of any environment - Symfony.Tasks - New projects - Cloning of existing project - PHP, Symfony, Webapp version selection - Docker.Tasks: basic service management - General common task settings - Add common.tasks.command_line - Add common.tasks.env_variable - Fix core - Fix common.tasks.menu - Fix common.tasks.messages - Fix generals
- Loading branch information
Showing
33 changed files
with
698 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
_mod_.run() { | ||
if [ "$#" -ne 3 ]; then | ||
local USED="" | ||
USED+="Error: Three parameters are required:\n" | ||
USED+=" - FORCE_SHOW_CLI FORCE_SHOW_OUTPUT COMMAND_LINE\n" | ||
USED+="\n parameters:\n ${@}\n" | ||
USED+="\n Example:\n" | ||
USED+=" - $FUNCNAME FORCE_SHOW_CLI=true FORCE_SHOW_OUTPUT=true COMMAND_LINE\n" | ||
USED+=" - $FUNCNAME 1 0 'cd folder'" | ||
common.tasks.message.danger $USED | ||
return 1 | ||
fi | ||
|
||
local FORCE_SHOW_CLI FORCE_SHOW_OUTPUT COMMAND_LINE | ||
|
||
FORCE_SHOW_CLI=$1 | ||
FORCE_SHOW_OUTPUT=$2 | ||
COMMAND_LINE="$3" | ||
|
||
if [ "${GLOBAL_EFDE_CONFIG['CLI_SHOW_DEFAULT']}" = "true" ]; then | ||
FORCE_SHOW_CLI=${GLOBAL_EFDE_CONFIG['CLI_SHOW_CLI']} | ||
FORCE_SHOW_OUTPUT=${GLOBAL_EFDE_CONFIG['CLI_SHOW_OUTPUT']} | ||
#[ "${GLOBAL_EFDE_CONFIG['CLI_SHOW_CLI']}" = "true" ] && FORCE_SHOW_CLI=true | ||
#[ "${GLOBAL_EFDE_CONFIG['CLI_SHOW_OUTPUT']}" = "true" ] && FORCE_SHOW_OUTPUT=true | ||
fi | ||
|
||
if [ "${FORCE_SHOW_CLI}" = "true" ]; then | ||
common.tasks.message.info "# RUN CLI > ${COMMAND_LINE}" | ||
fi | ||
|
||
if [ "${FORCE_SHOW_OUTPUT}" = "false" ]; then | ||
${COMMAND_LINE} > /dev/null 2>&1 | ||
else | ||
${COMMAND_LINE} | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
_mod_.set_variable() { | ||
|
||
if [ "$#" -ne 3 ]; then | ||
echo "Error: Se requieren tres parámetros: key, value, file" | ||
return 1 | ||
fi | ||
|
||
local key="$1" | ||
local value="$2" | ||
local file="$3" | ||
|
||
key=$(echo "$key" | tr '[:lower:]' '[:upper:]' | tr ' ' '_') | ||
|
||
if [ ! -e "$file" ]; then | ||
touch "$file" | ||
fi | ||
|
||
if grep -q "^$key=" "$file"; then | ||
# Update existing | ||
sed -i "s/^$key=.*/$key=\"$value\"/" "$file" | ||
else | ||
# add new | ||
echo "$key=\"$value\"" >> "$file" | ||
fi | ||
} | ||
|
||
_mod_.get_variable() { | ||
if [ "$#" -ne 2 ]; then | ||
echo "Error: Se requieren dos parámetros: key, file" | ||
return 1 | ||
fi | ||
|
||
local key="$1" | ||
local file="$2" | ||
|
||
key=$(echo "$key" | tr '[:lower:]' '[:upper:]' | tr ' ' '_') | ||
|
||
if [ -e "$file" ]; then | ||
local value=$(grep "^$key=" "$file" | sed "s/^$key=//") | ||
if [ -n "$value" ]; then | ||
value=$(echo "$value" | sed 's/^"\(.*\)"$/\1/') | ||
echo -n "$value" | ||
else | ||
echo "No encontrado" | ||
fi | ||
else | ||
echo "Error: El archivo $file no existe." | ||
return 1 | ||
fi | ||
} | ||
# | ||
# | ||
## USAGED | ||
## Call: | ||
## SETUP_ENVIRONMENT=( | ||
## [NAME]="MyName" | ||
## [CREATE_AT]="2000-01-01" | ||
## [IMPLEMENTION]="efde" | ||
## ) | ||
## VAR_STRING="$(_mod_.prepare_string_to_env SETUP_ENVIRONMENT)" | ||
## | ||
## echo -e "$VAR_STRING" > "$PATH_FILE" | ||
## | ||
## Response: | ||
## 'NAME="MyName"\nCREATE_AT="2000-01-01"\nIMPLEMENTION="efde"' | ||
#_mod_.prepare_string_to_env(){ | ||
# local -n env_array=$1 | ||
# local env_str="" | ||
# | ||
# for key in "${!env_array[@]}"; do | ||
# value="${env_array[$key]}" | ||
# env_str+="\n$key=\"$value\"" | ||
# done | ||
# | ||
# env_str="${env_str:2}" # Remove firts \n | ||
# | ||
# echo "$env_str" | ||
#} | ||
# | ||
#_mod_.load_variables_from_file() { | ||
# local file_path="$1" | ||
# local variables="" | ||
# | ||
# if [ -f "$file_path" ]; then | ||
# # Leer el archivo y construir la cadena de variables | ||
# while IFS='=' read -r key value; do | ||
# # Eliminar espacios en blanco alrededor de la clave y el valor | ||
# key=$(echo "$key" | sed 's/^[ \t]*//;s/[ \t]*$//') | ||
# value=$(echo "$value" | sed 's/^[ \t]*//;s/[ \t]*$//') | ||
# | ||
# # Agregar la variable a la cadena | ||
# variables+="$key=\"$value\" " | ||
# done < "$file_path" | ||
# | ||
# # Eliminar posibles espacios en blanco al final | ||
# variables=$(echo "$variables" | sed 's/[ \t]*$//') | ||
# | ||
# # Devolver la cadena de variables | ||
# echo "$variables" | ||
# else | ||
# echo "Error: El archivo $file_path no existe." | ||
# return 1 | ||
# fi | ||
#} |
Oops, something went wrong.