fabric-samples/balance-transfer/typescript/runApp.sh
Kapil Sachdeva c4465100c4 [FAB-6550] Sample app written in typescript
This is a sample application that demonstrates usage of Fabric SDK typings.

Change-Id: I5b9b42c666de51a490043cafe0faac29e4f4a0a4
Signed-off-by: Kapil Sachdeva <ksachdeva17@gmail.com>
2017-12-07 02:08:54 +00:00

71 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
function dkcl(){
CONTAINER_IDS=$(docker ps -aq)
echo
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" = " " ]; then
echo "========== No containers available for deletion =========="
else
docker rm -f $CONTAINER_IDS
fi
echo
}
function dkrm(){
DOCKER_IMAGE_IDS=$(docker images | grep "dev\|none\|test-vp\|peer[0-9]-" | awk '{print $3}')
echo
if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" = " " ]; then
echo "========== No images available for deletion ==========="
else
docker rmi -f $DOCKER_IMAGE_IDS
fi
echo
}
function restartNetwork() {
echo
#teardown the network and clean the containers and intermediate images
docker-compose -f ../artifacts/docker-compose.yaml down
dkcl
dkrm
#Cleanup the material
rm -rf /tmp/hfc-test-kvs_peerOrg* $HOME/.hfc-key-store/ /tmp/fabric-client-kvs_peerOrg*
#Start the network
docker-compose -f ../artifacts/docker-compose.yaml up -d
echo
}
function installNodeModules() {
echo
if [ -d node_modules ]; then
echo "============== node modules installed already ============="
else
echo "============== Installing node modules ============="
npm install
fi
copyIndex fabric-client/index.d.ts
copyIndex fabric-ca-client/index.d.ts
echo
}
function copyIndex() {
if [ ! -f node_modules/$1 ]; then
cp types/$1 node_modules/$1
fi
}
restartNetwork
installNodeModules
PORT=4000 ts-node app.ts