Commit 51fe62be authored by tom's avatar tom

dev script

parent 50ebcd2d
......@@ -9,17 +9,17 @@ if [ -z "$MASTER_URL" ]; then
exit 1
fi
# Check if API_KEY is provided
if [ -z "$API_KEY" ]; then
echo "Error: API_KEY variable is not provided."
# Check if NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY is provided
if [ -z "$NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY" ]; then
echo "Error: NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY variable is not provided."
exit 1
fi
# Mask the API_KEY to display only the first 4 characters
API_KEY_MASKED="${API_KEY:0:8}***"
# Mask the NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY to display only the first 8 characters
API_KEY_MASKED="${NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY:0:8}***"
echo "🆗 The following variables are provided:"
echo " MASTER_URL: $MASTER_URL"
echo " API_KEY: $API_KEY_MASKED"
echo " NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY: $API_KEY_MASKED"
echo
# RealFaviconGenerator API endpoint URL
......@@ -35,13 +35,16 @@ CONFIG_TEMPLATE_FILE="config.template.json"
CONFIG_FILE="config.json"
# Replace <api_key> and <master_url> placeholders in the JSON template file
API_KEY_VALUE="$API_KEY"
API_KEY_VALUE="$NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY"
sed -e "s|<api_key>|$API_KEY_VALUE|" -e "s|<master_url>|$MASTER_URL|" "$CONFIG_TEMPLATE_FILE" > "$CONFIG_FILE"
# Make the API POST request with JSON data from the config file
echo "⏳ Making request to API..."
API_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" -d @"$CONFIG_FILE" "$API_URL")
# Create the response.json file with the API response
echo "$API_RESPONSE" > response.json
# Check if the API response is valid JSON and contains success status
if ! jq -e '.favicon_generation_result.result.status == "success"' <<< "$API_RESPONSE" >/dev/null; then
echo "🛑 Error: API response does not contain the expected structure or has an error status."
......@@ -49,9 +52,6 @@ if ! jq -e '.favicon_generation_result.result.status == "success"' <<< "$API_RES
fi
echo "🆗 API responded with success status."
# Create the response.json file with the API response
echo "$API_RESPONSE" > response.json
# Parse the JSON response to extract the file URL and remove backslashes
FILE_URL=$(echo "$API_RESPONSE" | jq -r '.favicon_generation_result.favicon.package_url' | tr -d '\\')
PREVIEW_URL=$(echo "$API_RESPONSE" | jq -r '.favicon_generation_result.preview_picture_url' | tr -d '\\')
......
......@@ -25,7 +25,8 @@
"test:pw:docker": "docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.35.1-focal ./playwright/run-tests.sh",
"test:pw:ci": "yarn test:pw --project=$PW_PROJECT",
"test:jest": "jest",
"test:jest:watch": "jest --watch"
"test:jest:watch": "jest --watch",
"favicon:generate:dev": "./tools/scripts/favicon-generator.dev.sh"
},
"dependencies": {
"@chakra-ui/react": "2.7.1",
......
secrets_file="./configs/envs/.env.secrets"
favicon_folder="./public/favicon/"
master_url="https://raw.githubusercontent.com/blockscout/frontend/main/tools/scripts/favicon.svg"
if [ ! -f "$secrets_file" ]; then
echo "Error: File '$secrets_file' not found."
exit 1
fi
dotenv \
-v MASTER_URL=$master_url \
-e $secrets_file \
-- bash -c 'cd ./deploy/tools/favicon-generator && ./script.sh'
if [ -d "$favicon_folder" ]; then
rm -r "$favicon_folder"
fi
mkdir -p "$favicon_folder"
cp -r ./deploy/tools/favicon-generator/output/* "$favicon_folder"
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 30 30">
<path fill="#2B6CB0" fill-rule="evenodd" d="M12.703 5.6a1.6 1.6 0 0 0-1.6-1.6H9.575a1.6 1.6 0 0 0-1.6 1.6v1.383a1.6 1.6 0 0 1-1.6 1.6H5.6a1.6 1.6 0 0 0-1.6 1.6V24.4A1.6 1.6 0 0 0 5.6 26h1.528a1.6 1.6 0 0 0 1.6-1.6V10.183a1.6 1.6 0 0 1 1.6-1.6h.775a1.6 1.6 0 0 0 1.6-1.6V5.6Zm9.487 0a1.6 1.6 0 0 0-1.6-1.6h-1.528a1.6 1.6 0 0 0-1.6 1.6v1.383a1.6 1.6 0 0 0 1.6 1.6h.61a1.6 1.6 0 0 1 1.6 1.6V24.4a1.6 1.6 0 0 0 1.6 1.6H24.4a1.6 1.6 0 0 0 1.6-1.6V10.183a1.6 1.6 0 0 0-1.6-1.6h-.61a1.6 1.6 0 0 1-1.6-1.6V5.6Zm-4.793 8.774a1.6 1.6 0 0 0-1.6-1.6h-1.528a1.6 1.6 0 0 0-1.6 1.6v5.705a1.6 1.6 0 0 0 1.6 1.6h1.528a1.6 1.6 0 0 0 1.6-1.6v-5.705Z" clip-rule="evenodd"/>
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment