github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/scripts/checks/check-foundry-install.sh (about) 1 #!/usr/bin/env bash 2 3 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 4 CONTRACTS_BASE=$(dirname "$(dirname "$SCRIPT_DIR")") 5 MONOREPO_BASE=$(dirname "$(dirname "$CONTRACTS_BASE")") 6 VERSIONS_FILE="${MONOREPO_BASE}/versions.json" 7 8 if ! command -v forge &> /dev/null 9 then 10 # shellcheck disable=SC2006 11 echo "Is Foundry not installed? Consider installing via pnpm install:foundry" >&2 12 exit 1 13 fi 14 15 # Check VERSIONS_FILE has expected foundry property 16 if ! jq -e '.foundry' "$VERSIONS_FILE" &> /dev/null; then 17 echo "'foundry' is missing from $VERSIONS_FILE" >&2 18 exit 1 19 fi 20 21 # Extract the expected foundry version from versions.json 22 EXPECTED_VERSION=$(jq -r '.foundry' "$VERSIONS_FILE" | cut -c 1-7) 23 if [ -z "$EXPECTED_VERSION" ]; then 24 echo "Unable to extract Foundry version from $VERSIONS_FILE" >&2 25 exit 1 26 fi 27 28 # Extract the installed forge version 29 INSTALLED_VERSION=$(forge --version | grep -o '[a-f0-9]\{7\}' | head -n 1) 30 31 # Compare the installed timestamp with the expected timestamp 32 if [ "$INSTALLED_VERSION" = "$EXPECTED_VERSION" ]; then 33 echo "Foundry version matches the expected version." 34 else 35 echo "Mismatch between installed Foundry version ($INSTALLED_VERSION) and expected version ($EXPECTED_VERSION)." 36 echo "Your version of Foundry may either not be up to date, or it could be a later version." 37 echo "Running pnpm update:foundry will install the expected version." 38 fi