Skip to content

Commit

Permalink
Reorganize scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Venzi <[email protected]>
  • Loading branch information
samuelvenzi committed Jul 10, 2024
1 parent 18dc1d1 commit 37e97a9
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 4 deletions.
83 changes: 83 additions & 0 deletions generatePackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/bash

# Default values for the flags
FLAG_CCAPI="none"
FLAG_LABEL="1.0"
SKIP_COLL_GEN=false

# You can change this if you want to avoid using the --name flag
FLAG_NAME="cc-tools-demo"

# Process command-line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--label | -l)
if [[ $# -gt 1 ]]; then
FLAG_LABEL=$2
shift 2
else
echo "Error: --label flag requires a value."
exit 1
fi
;;
--name | -n)
if [[ $# -gt 1 ]]; then
FLAG_NAME=$2
shift 2
else
echo "Error: --name flag requires a value."
exit 1
fi
;;
--org | -o)
if [[ $# -gt 1 ]]; then
orgs+=("$2")
shift 2
else
echo "Error: --org flag requires a value."
exit 1
fi
;;
--skip | -s)
SKIP_COLL_GEN=true
shift 1
;;
--help | -h)
echo "Usage: ./generateTar.sh [--label <label>] [--name <name>]"
echo " --help , -h: Show this help message."
echo " --label, -l: Label to be used for the chaincode package. Default is 1.0."
echo " --name , -n: Name of the chaincode package. Default is ${FLAG_NAME}."
echo " --org , -o: Include an organization in the collection configuration file"
echo " This option can be used multiple times to include multiple organizations"
echo " If no organizations are specified, the default is to include any organization found in the readers"
echo " --skip , -s: Skip the generation of the collections.json file"
exit 0
;;
*)
# Ignore unrecognized arguments
shift
;;
esac
done

# Generate collection configuration file
if [ "$SKIP_COLL_GEN" = false ]
then
if [ ${#orgs[@]} -gt 0 ]
then
cd ./chaincode; go run . -g --orgs ${orgs[@]}; cd ..
else
cd ./chaincode; go run . -g; cd ..
fi
fi

# Remove previous tar file
rm -f chaincode.tar.gz

# Make sure go mod is up to date
cd chaincode && GOWORK=off go mod vendor && cd ..

# Pack chaincode
export FABRIC_CFG_PATH=fabric/config
peer lifecycle chaincode package chaincode.tar.gz --path chaincode --lang golang --label ${FLAG_NAME}_${FLAG_LABEL}

File renamed without changes.
2 changes: 1 addition & 1 deletion godog.sh → scripts/godog.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ echo "Starting development network ..."

echo "Running GoDog tests..."
echo "Tests may take a few minutes to complete..."
cd ./chaincode/tests; go test;
cd ../chaincode/tests; go test;
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions reloadCCAPI.sh → scripts/reloadCCAPI.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
## This brings up API in Go
if [ $ORG_QNTY == 1 ]
then
cd ./ccapi; docker-compose -f docker-compose-1org.yaml down; docker-compose -f docker-compose-1org.yaml up -d --build; cd ..
cd ../ccapi; docker-compose -f docker-compose-1org.yaml down; docker-compose -f docker-compose-1org.yaml up -d --build; cd ..
else
cd ./ccapi; docker-compose down; docker-compose up -d --build; cd ..
cd ../ccapi; docker-compose down; docker-compose up -d --build; cd ..
fi
2 changes: 1 addition & 1 deletion renameProject.sh → scripts/renameProject.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ if [ $# -lt 1 ] ; then
exit
fi

grep -rl cc-tools-demo . --exclude-dir={.git,node_modules} | xargs sed -i s/cc-tools-demo/$1/g
grep -rl cc-tools-demo ../ --exclude-dir={.git,node_modules} | xargs sed -i s/cc-tools-demo/$1/g
File renamed without changes.
File renamed without changes.

0 comments on commit 37e97a9

Please sign in to comment.