diff --git a/CHANGELOG.md b/CHANGELOG.md index 607a5102..6824a2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +0.1.0 +=============== + +* Changed the env type setup to automatically include additional configuration based on $OSTYPE. +* Changed the environment template structure to utilize per-OSTYPE docker-compose config additions where environments differ from one host OS to another (such as `magento2` env type, which uses plain mounts on `linux-gnu` but sync sessions on `darwin`) +* Fixed a few error messages so they won't change shell text color permanently when they output. +* Fixed sync command to output error message when any sub-command is run on an env lacking a mutagen configuration. + 0.1.0-beta7 =============== diff --git a/commands/env-init.cmd b/commands/env-init.cmd index 2fbf3a87..059b73be 100644 --- a/commands/env-init.cmd +++ b/commands/env-init.cmd @@ -7,18 +7,13 @@ WARDEN_ENV_PATH="$(pwd)" # TODO: Provide argument (and prompt user) for environment type instead of assuming magento2 flavors WARDEN_ENV_NAME="${WARDEN_PARAMS[0]:-}" -WARDEN_ENV_CLASS="${WARDEN_PARAMS[1]:-magento2}" +WARDEN_ENV_TYPE="${WARDEN_PARAMS[1]:-magento2}" # Require the user inputs the required environment name parameter [[ ! ${WARDEN_ENV_NAME} ]] && >&2 echo -e "\033[31mMissing required argument. Please use --help to to print usage." && exit 1 -# Set type for magento2 class to auto-select type when starting based on current OS type -WARDEN_ENV_TYPE=${WARDEN_ENV_CLASS} -[[ "${WARDEN_ENV_CLASS}" = "magento2" ]] \ - && WARDEN_ENV_TYPE='magento2-mutagen && [ "$OSTYPE" = "linux-gnu" ] && WARDEN_ENV_TYPE=magento2-native || true' - # Verify the auto-select and/or type path resolves correctly before setting it -[[ ! -f "${WARDEN_DIR}/environments/$(eval "WARDEN_ENV_TYPE=${WARDEN_ENV_TYPE}"; echo ${WARDEN_ENV_TYPE}).yml" ]] \ +[[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.base.yml" ]] \ && >&2 echo -e "\033[31mInvalid environment type \"${WARDEN_ENV_TYPE}\" specified." && exit 1 # Write the .env file to current working directory @@ -26,5 +21,5 @@ cat > "${WARDEN_ENV_PATH}/.env" <&2 echo -e "\033[31mMutagen sync sessions are not used on \"${WARDEN_ENV_SUBT}\" host environments\033[0m" exit 1 fi @@ -16,13 +22,15 @@ if ! which mutagen >/dev/null; then brew install havoc-io/mutagen/mutagen fi +## if no mutagen configuration file exists for the environment type, exit with error +if [[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.mutagen.toml" ]]; then + >&2 echo -e "\033[31mMutagen configuration does not exist for environment type \"${WARDEN_ENV_TYPE}\"\033[0m" + exit 1 +fi + ## sub-command execution case "${WARDEN_PARAMS[0]}" in start) - ## if no mutagen configuration file exists for the environment type, exit with error - [[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.toml" ]] \ - && >&2 echo -e "\033[31mMutagen configuration does not exist for environment type \"${WARDEN_ENV_TYPE}\"" && exit 1 - ## start mutagen daemon if not already running mutagen daemon start @@ -30,7 +38,7 @@ case "${WARDEN_PARAMS[0]}" in mutagen terminate --label-selector "warden-sync=${WARDEN_ENV_NAME}" ## create sync session based on environment type configuration - mutagen create -c "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.toml" \ + mutagen create -c "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.mutagen.toml" \ --label "warden-sync=${WARDEN_ENV_NAME}" \ "${WARDEN_ENV_PATH}${WARDEN_WEB_ROOT:-}" "docker://$(warden env ps -q php-fpm)/var/www/html" diff --git a/commands/usage.help b/commands/usage.help index efc93b32..93326356 100755 --- a/commands/usage.help +++ b/commands/usage.help @@ -11,7 +11,7 @@ WARDEN_HEADER=' WARDEN_USAGE=$(cat <&2 echo -e "\033[31mEnvironment config could not be found. Please run \"warden env-init\" and try again!" + >&2 echo -e "\033[31mEnvironment config could not be found. Please run \"warden env-init\" and try again!\033[0m" return 1 fi @@ -28,8 +28,13 @@ function loadEnvConfig () { WARDEN_ENV_NAME="${WARDEN_ENV_NAME:-}" WARDEN_ENV_TYPE="${WARDEN_ENV_TYPE:-}" - if [[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.yml" ]]; then - >&2 echo -e "\033[31mInvalid environment type \"${WARDEN_ENV_TYPE}\" specified." + WARDEN_ENV_SUBT="${OSTYPE:-undefined}" + if [[ ${WARDEN_ENV_SUBT} =~ ^darwin ]]; then + WARDEN_ENV_SUBT=darwin + fi + + if [[ ! -f "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}.base.yml" ]]; then + >&2 echo -e "\033[31mInvalid environment type \"${WARDEN_ENV_TYPE}\" specified.\033[0m" return 1 fi }