Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/build-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run Sphinx documentation build
uses: ammaraskar/sphinx-action@0.4
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
docs-folder: "docs/"
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Build documentation with Sphinx
run: |
cd docs
sphinx-build -b html . _build/html
- name: Upload documentation artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/_build/html/
24 changes: 16 additions & 8 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
paths:
- docs/**
- .github/workflows/build-documentation.yml
- .github/workflows/pages.yml
- CHANGELOG.md

# Allows you to run this workflow manually from the Actions tab
Expand All @@ -33,18 +34,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Run Sphinx documentation build
uses: ammaraskar/sphinx-action@0.4
uses: actions/configure-pages@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
docs-folder: "docs/"
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Build documentation with Sphinx
run: |
cd docs
sphinx-build -b html . _build/html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'docs/_build/html/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/push-release-to-brew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
update-homebrew:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
repository: dockergiant/homebrew-roll
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Files
env:
VERSION: ${{ inputs.version }}
Expand Down
40 changes: 10 additions & 30 deletions bin/roll
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ readonly ROLL_DIR="$(
&& pwd
)"
source "${ROLL_DIR}/utils/core.sh"
source "${ROLL_DIR}/utils/config.sh"
source "${ROLL_DIR}/utils/registry.sh"
source "${ROLL_DIR}/utils/env.sh"

## verify docker is installed
Expand Down Expand Up @@ -46,37 +48,15 @@ if (( "$#" )); then
ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)" || true
ROLL_ENV_TYPE="$(renderEnvType 2>/dev/null)" || true

if [[ -f "${ROLL_HOME_DIR}/reclu/${1}.cmd" ]]; then
# Use registry system for command discovery
COMMAND_RESULT="$(findCommand "$1")"

if [[ "$COMMAND_RESULT" =~ ^found: ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_EXEC="${ROLL_HOME_DIR}/reclu/${1}.cmd"
ROLL_CMD_HELP="${ROLL_HOME_DIR}/reclu/${1}.help"
shift
elif [[ -f "${ROLL_HOME_DIR}/reclu/${ROLL_ENV_TYPE}/${1}.cmd" ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_EXEC="${ROLL_HOME_DIR}/reclu/${ROLL_ENV_TYPE}/${1}.cmd"
ROLL_CMD_HELP="${ROLL_HOME_DIR}/reclu/${ROLL_ENV_TYPE}/${1}.help"
shift
elif [[ -f "${ROLL_DIR}/commands/${1}.cmd" ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_EXEC="${ROLL_DIR}/commands/${1}.cmd"
ROLL_CMD_HELP="${ROLL_DIR}/commands/${1}.help"
shift
elif [[ -f "${ROLL_DIR}/commands/${ROLL_ENV_TYPE}/${1}.cmd" ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_EXEC="${ROLL_DIR}/commands/${ROLL_ENV_TYPE}/${1}.cmd"
ROLL_CMD_HELP="${ROLL_DIR}/commands/${ROLL_ENV_TYPE}/${1}.help"
shift
elif [[ -f "${ROLL_ENV_PATH}/.roll/commands/${1}.cmd" ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_ANYARGS+=("$1")
ROLL_CMD_EXEC="${ROLL_ENV_PATH}/.roll/commands/${1}.cmd"
ROLL_CMD_HELP="${ROLL_ENV_PATH}/.roll/commands/${1}.help"
shift
elif [[ -f "${ROLL_HOME_DIR}/commands/${1}.cmd" ]]; then
ROLL_CMD_VERB="$1"
ROLL_CMD_ANYARGS+=("$1")
ROLL_CMD_EXEC="${ROLL_HOME_DIR}/commands/${1}.cmd"
ROLL_CMD_HELP="${ROLL_HOME_DIR}/commands/${1}.help"
# Extract cmd_path and help_path from "found:cmd_path:help_path"
COMMAND_RESULT="${COMMAND_RESULT#found:}"
ROLL_CMD_EXEC="${COMMAND_RESULT%%:*}"
ROLL_CMD_HELP="${COMMAND_RESULT#*:}"
shift
else
ROLL_HELP=1
Expand Down
238 changes: 238 additions & 0 deletions commands/config.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
#!/usr/bin/env bash
[[ ! ${ROLL_DIR} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!\033[0m" && exit 1

if (( ${#ROLL_PARAMS[@]} == 0 )) || [[ "${ROLL_PARAMS[0]}" == "help" ]]; then
roll config --help || exit $? && exit $?
fi

## Sub-command execution
case "${ROLL_PARAMS[0]}" in
show)
# Try to load configuration if in a project directory
if ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)"; then
loadRollConfig "${ROLL_ENV_PATH}" >/dev/null 2>&1 || {
error "Failed to load configuration from ${ROLL_ENV_PATH}/.env.roll"
exit 1
}
else
warning "Not in a Roll project directory"
exit 1
fi

# Filter configuration if specified
filter="${ROLL_PARAMS[1]:-}"
showConfig "$filter"
;;

validate)
config_file="${ROLL_PARAMS[1]:-}"

if [[ -z "$config_file" ]]; then
if ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)"; then
config_file="${ROLL_ENV_PATH}/.env.roll"
else
error "No configuration file specified and not in a Roll project directory"
exit 1
fi
fi

if [[ ! -f "$config_file" ]]; then
error "Configuration file not found: $config_file"
exit 1
fi

info "Validating configuration: $config_file"

if validateConfig "$config_file"; then
success "Configuration is valid"

# Also check for conflicts if we can load the config
if loadRollConfig "$(dirname "$config_file")" >/dev/null 2>&1; then
if checkConfigConflicts >/dev/null 2>&1; then
success "No configuration conflicts detected"
else
warning "Configuration conflicts detected (see above)"
exit 1
fi
fi
else
error "Configuration validation failed"
exit 1
fi
;;

conflicts)
# Check for configuration conflicts
if ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)"; then
loadRollConfig "${ROLL_ENV_PATH}" >/dev/null 2>&1 || {
error "Failed to load configuration from ${ROLL_ENV_PATH}/.env.roll"
exit 1
}
else
error "Not in a Roll project directory"
exit 1
fi

info "Checking for configuration conflicts..."

if checkConfigConflicts; then
success "No configuration conflicts detected"
else
error "Configuration conflicts detected (see above)"
exit 1
fi
;;

schema)
# Display configuration schema
initConfigSchema

echo -e "\033[33mRoll Configuration Schema:\033[0m"
echo ""

# Group configurations by category
echo -e "\033[36mCore Configuration:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
case "$key" in
ROLL_ENV_NAME|ROLL_ENV_TYPE|ROLL_ENV_SUBT)
printf " %-30s %s\n" "$key" "$value"
;;
esac
i=$((i + 1))
done

echo ""
echo -e "\033[36mService Toggles:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
if [[ "$key" =~ ^ROLL_(NGINX|DB|REDIS|DRAGONFLY|VARNISH|ELASTICSEARCH|OPENSEARCH|ELASTICVUE|RABBITMQ|MONGODB|BROWSERSYNC|SELENIUM|TEST_DB|ALLURE|MAGEPACK|INCLUDE_GIT) ]] && [[ ! "$key" =~ _VERSION$ ]]; then
printf " %-30s %s\n" "$key" "$value"
fi
i=$((i + 1))
done

echo ""
echo -e "\033[36mPHP/Node/Composer Configuration:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
if [[ "$key" =~ ^(PHP_|COMPOSER_|NODE_) ]] || [[ "$key" =~ ^XDEBUG ]]; then
printf " %-30s %s\n" "$key" "$value"
fi
i=$((i + 1))
done

echo ""
echo -e "\033[36mDatabase Configuration:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
if [[ "$key" =~ ^(DB_|MYSQL_|MARIADB_) ]]; then
printf " %-30s %s\n" "$key" "$value"
fi
i=$((i + 1))
done

echo ""
echo -e "\033[36mService Version Configuration:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
if [[ "$key" =~ _VERSION$ ]] && [[ ! "$key" =~ ^(PHP_|DB_|MYSQL_|MARIADB_|NODE_|XDEBUG_|COMPOSER_) ]]; then
printf " %-30s %s\n" "$key" "$value"
fi
i=$((i + 1))
done

echo ""
echo -e "\033[36mTraefik/Network Configuration:\033[0m"
i=0
while [[ $i -lt ${#ROLL_CONFIG_SCHEMA_KEYS[@]} ]]; do
key="${ROLL_CONFIG_SCHEMA_KEYS[$i]}"
value="${ROLL_CONFIG_SCHEMA_VALUES[$i]}"
if [[ "$key" =~ ^TRAEFIK_ ]]; then
printf " %-30s %s\n" "$key" "$value"
fi
i=$((i + 1))
done
;;

set)
if [[ ${#ROLL_PARAMS[@]} -lt 3 ]]; then
error "Usage: roll config set <key> <value>"
exit 1
fi

key="${ROLL_PARAMS[1]}"
value="${ROLL_PARAMS[2]}"

# Validate the configuration value
initConfigSchema
if ! validateConfigValue "$key" "$value"; then
error "Invalid value for $key: $value"
exit 1
fi

# Find configuration file
if ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)"; then
config_file="${ROLL_ENV_PATH}/.env.roll"
else
error "Not in a Roll project directory"
exit 1
fi

# Create backup
cp "$config_file" "${config_file}.backup.$(date +%Y%m%d_%H%M%S)"

# Update or add the configuration
if grep -q "^${key}=" "$config_file"; then
# Update existing key - use different approach for macOS compatibility
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/^${key}=.*/${key}=${value}/" "$config_file"
else
sed -i "s/^${key}=.*/${key}=${value}/" "$config_file"
fi
else
# Add new key
echo "${key}=${value}" >> "$config_file"
fi

success "Configuration updated: ${key}=${value}"
info "Backup created: ${config_file}.backup.$(date +%Y%m%d_%H%M%S)"
;;

get)
if [[ ${#ROLL_PARAMS[@]} -lt 2 ]]; then
error "Usage: roll config get <key> [default]"
exit 1
fi

key="${ROLL_PARAMS[1]}"
default_value="${ROLL_PARAMS[2]:-}"

# Load configuration if in project directory
if ROLL_ENV_PATH="$(locateEnvPath 2>/dev/null)"; then
loadRollConfig "${ROLL_ENV_PATH}" >/dev/null 2>&1 || {
error "Failed to load configuration"
exit 1
}
fi

value="$(getConfig "$key" "$default_value")"
echo "$value"
;;

*)
error "Unknown config command: ${ROLL_PARAMS[0]}"
echo "Available commands: show, validate, conflicts, schema, set, get"
exit 1
;;
esac
Loading
Loading