-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish_beta.bash
40 lines (30 loc) · 1.18 KB
/
publish_beta.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Trap the SIGINT signal (Ctrl + C) to handle termination
trap 'handle_exit' SIGINT
# Function to handle script termination
handle_exit() {
echo "Restoring original configs..."
mv package.json.temp package.json
mv forta.config.json.temp forta.config.json
exit
}
echo "Building beta version of the bot..."
cp -f package.json package.json.temp
cp -f forta.config.json forta.config.json.temp
echo "Modifying package.json, forta.config.json, Dockerfile..."
npm pkg set 'name'='spam-detector-experimental'
npm pkg set 'displayName'='Token Spam Detector / Sandbox'
npm pkg set 'description'='This is an experimental version of the spam detector bot.'
npm pkg delete "chainSettings"
npm pkg set 'chainSettings.default.shards'=1 --json
npm pkg set 'chainSettings.default.target'=3 --json
SOURCE_KEY="agentIdBeta"
DESTINATION_KEY="agentId"
JSON=$(cat forta.config.json)
SOURCE_VALUE=$(echo "$JSON" | jq -r ".$SOURCE_KEY")
# Use jq to insert the source value into the destination key
JSON=$(echo "$JSON" | jq --arg key "$DESTINATION_KEY" --arg value "$SOURCE_VALUE" '. + { ($key): $value }')
# Write the updated JSON back to the file
echo "$JSON" >forta.config.json
npm run publish
handle_exit