Sync all local changes: docs, config, scripts, submodule refs, verification evidence
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Validate required config files and optional env vars before deployment/scripts
|
||||
# Recommendation: docs/10-best-practices/IMPLEMENTATION_CHECKLIST.md (Configuration validation)
|
||||
# Usage: ./scripts/validation/validate-config-files.sh [--dry-run]
|
||||
# --dry-run Print what would be validated and exit 0 (no file checks).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
|
||||
DRY_RUN=false
|
||||
for a in "$@"; do [[ "$a" == "--dry-run" ]] && DRY_RUN=true && break; done
|
||||
|
||||
log_info() { echo "[INFO] $1"; }
|
||||
log_ok() { echo "[OK] $1"; }
|
||||
log_warn() { echo "[WARN] $1"; }
|
||||
@@ -44,6 +49,13 @@ check_env() {
|
||||
fi
|
||||
}
|
||||
|
||||
if $DRY_RUN; then
|
||||
echo "=== Validation (--dry-run: would check) ==="
|
||||
echo " REQUIRED_FILES: ${REQUIRED_FILES:-<default: config/ip-addresses.conf, .env.example, token-mapping.json, smart-contracts-master.json>}"
|
||||
echo " OPTIONAL_ENV: $OPTIONAL_ENV"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n "$REQUIRED_FILES" ]]; then
|
||||
for f in $REQUIRED_FILES; do
|
||||
check_file "$f"
|
||||
@@ -52,6 +64,32 @@ else
|
||||
# Default: check common locations
|
||||
[[ -d "$PROJECT_ROOT/config" ]] && check_file "$PROJECT_ROOT/config/ip-addresses.conf" || true
|
||||
[[ -f "$PROJECT_ROOT/.env.example" ]] && log_ok ".env.example present (copy to .env and fill)" || true
|
||||
# Token mapping (Chain 138 ↔ Mainnet): optional but validate structure if present
|
||||
if [[ -f "$PROJECT_ROOT/config/token-mapping.json" ]]; then
|
||||
log_ok "Found: config/token-mapping.json"
|
||||
if command -v jq &>/dev/null; then
|
||||
if jq -e '.tokens | type == "array"' "$PROJECT_ROOT/config/token-mapping.json" &>/dev/null; then
|
||||
log_ok "token-mapping.json: valid JSON with .tokens array"
|
||||
else
|
||||
log_err "token-mapping.json: invalid or missing .tokens array"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
fi
|
||||
else
|
||||
log_warn "Optional config/token-mapping.json not found (relay uses fallback mapping)"
|
||||
fi
|
||||
if [[ -f "$PROJECT_ROOT/config/token-mapping-multichain.json" ]]; then
|
||||
log_ok "Found: config/token-mapping-multichain.json"
|
||||
if command -v jq &>/dev/null; then
|
||||
if jq -e '.pairs | type == "array"' "$PROJECT_ROOT/config/token-mapping-multichain.json" &>/dev/null; then
|
||||
log_ok "token-mapping-multichain.json: valid JSON with .pairs array"
|
||||
else
|
||||
log_err "token-mapping-multichain.json: invalid or missing .pairs array"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
[[ -f "$PROJECT_ROOT/config/smart-contracts-master.json" ]] && log_ok "Found: config/smart-contracts-master.json" || true
|
||||
fi
|
||||
|
||||
for v in $OPTIONAL_ENV; do
|
||||
|
||||
Reference in New Issue
Block a user