remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/apps/remix-ide/ci/downloadsoljson.sh

52 lines
1.8 KiB

#!/usr/bin/env bash
8 months ago
echo "Downloading specified soljson.js version based on defaultVersion in package.json"
set -e
8 months ago
2 months ago
# Check if curl is installed
8 months ago
if ! command -v curl &> /dev/null; then
echo "curl could not be found"
8 months ago
exit 1
fi
# Read the defaultVersion from package.json
defaultVersion=$(grep '"defaultVersion"' package.json | awk -F '"' '{print $4}')
8 months ago
echo "Specified version from package.json: $defaultVersion"
2 months ago
# Fetch the list.json from the Solidity binaries
listJson=$(curl -s --connect-timeout 5 --max-time 5 https://binaries.soliditylang.org/wasm/list.json)
# Check if the download was successful
if [ -z "$listJson" ]; then
echo "Failed to fetch version list. No internet connection or the connection is too slow."
exit 0 # Silently exit
fi
2 months ago
# Overwrite the local list.json with the fetched content
echo "$listJson" > ./apps/remix-ide/src/assets/list.json
2 months ago
# Check if the specified version exists in the list
check=$(echo "$listJson" | grep "\"$defaultVersion\"")
8 months ago
if [ -z "$check" ]; then
8 months ago
echo "The specified version $defaultVersion could not be found in the list"
exit 1
fi
echo "Path for the specified version: $defaultVersion"
fullPath="https://binaries.soliditylang.org/bin/$defaultVersion"
8 months ago
echo "Download fullPath: $fullPath"
# Ensure the target directory exists
if [ ! -d "./apps/remix-ide/src/assets/js/soljson" ]; then
8 months ago
mkdir -p ./apps/remix-ide/src/assets/js/soljson
fi
8 months ago
2 months ago
# Download the soljson.js file to ./apps/remix-ide/src/assets/js/soljson.js
echo "Downloading soljson.js from $fullPath to ./apps/remix-ide/src/assets/js/soljson.js"
8 months ago
curl -s "$fullPath" > ./apps/remix-ide/src/assets/js/soljson.js
# Copy the downloaded soljson.js to the specific version directory
2 months ago
cp ./apps/remix-ide/src/assets/js/soljson.js "./apps/remix-ide/src/assets/js/soljson/$defaultVersion.js"
2 months ago
echo "Download and setup of soljson.js complete"