Skip to content

Commit

Permalink
Standalone repo: cli installed working in 3 cases of installation wit…
Browse files Browse the repository at this point in the history
…h locating correct dependencies folder. Add yarn.lock. Change package scope to @ptb1. Git ignore updates with local config.
  • Loading branch information
terrylks committed May 3, 2019
1 parent 61b596b commit 6a9f72e
Show file tree
Hide file tree
Showing 10 changed files with 12,082 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local config
config.file.local
2 changes: 2 additions & 0 deletions config.file
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ NODEOS_VOLUME_NAME=eosio_volume

APP_DEV_PORT=3000
APP_SERVE_PORT=5111

DEPENDENCIES_SCOPE_NAME=@eosio-toppings
2 changes: 2 additions & 0 deletions init_config.file
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ CDT_IMAGE_NAME=$CDT_IMAGE_PREFIX:$CDT_VERSION-$CDT_DOCKERFILE_VERSION

APP_DEV_PORT=3000
APP_SERVE_PORT=5111

DEPENDENCIES_SCOPE_NAME=@eosio-toppings
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@eosio-toppings/eosio-explorer",
"version": "0.2.0",
"private": true,
"name": "@ptb1/eosio-explorer",
"version": "0.2.1",
"publishConfig": {
"access": "private"
},
"license": "MIT",
"dependencies": {
"@coreui/coreui": "^2.1.8",
"@coreui/react": "^2.1.5",
"@eosio-toppings/api-eosio-compiler": "^0.2.0",
"@eosio-toppings/api-mongodb-plugin": "^0.2.0",
"@eosio-toppings/api-rpc": "^0.2.0",
"@eosio-toppings/docker-eosio-nodeos": "^0.2.0",
"@eosio-toppings/docker-mongodb": "^0.2.0",
"@eosio-toppings/api-eosio-compiler": "^0.2.1",
"@eosio-toppings/api-mongodb-plugin": "^0.2.1",
"@eosio-toppings/api-rpc": "^0.2.1",
"@eosio-toppings/docker-eosio-nodeos": "^0.2.1",
"@eosio-toppings/docker-mongodb": "^0.2.1",
"axios": "^0.18.0",
"cogo-toast": "^1.0.4",
"connected-react-router": "^6.3.2",
Expand Down Expand Up @@ -55,7 +57,8 @@
"postbuild": "react-snap",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject",
"serve": "node serve.js"
"serve": "node serve.js",
"eosio-explorer": "./cli.sh"
},
"browserslist": [
">0.2%",
Expand Down
50 changes: 33 additions & 17 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,35 @@ set -o errexit
# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source $APP/init_config.file

RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'

SCRIPTPATH="$( pwd -P )/../.."
EOSDOCKER="$SCRIPTPATH/docker-eosio-nodeos"
MONGODOCKER="$SCRIPTPATH/docker-mongodb"
LOCALSERVICE="$SCRIPTPATH/api-eosio-compiler"
if [ 'node_modules' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally, dependencies are installed as siblings directory
DEPENDENCIES_ROOT="$(dirname "$(dirname "$( pwd -P )")")/$DEPENDENCIES_SCOPE_NAME"

elif [ '@ptb1' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally with scope, dependencies are installed as siblings directory of one level upper
DEPENDENCIES_ROOT="$(dirname "$(dirname "$(dirname "$( pwd -P )")")")/$DEPENDENCIES_SCOPE_NAME"
else

# yarn installed locally, dependencies are installed under current's project directory
DEPENDENCIES_ROOT="$(dirname "$( pwd -P )")/node_modules/$DEPENDENCIES_SCOPE_NAME"
fi

EOSDOCKER="$DEPENDENCIES_ROOT/docker-eosio-nodeos"
MONGODOCKER="$DEPENDENCIES_ROOT/docker-mongodb"
LOCALSERVICE="$DEPENDENCIES_ROOT/api-eosio-compiler"
COMPILER="$LOCALSERVICE/docker-eosio-cdt"
GUI="$SCRIPTPATH/eosio-explorer"
ISDEV=false
MAKESAMPLEDATA=false

Expand All @@ -34,21 +53,18 @@ echo "=============================="
echo "INITIALISING CONFIG IN PACKAGES"
echo "=============================="

# sourcing variable from config file
source ../init_config.file

# copy init config into different packages
cp -f ../init_config.file $EOSDOCKER/config.file.local
cp -f ../init_config.file $EOSDOCKER/scripts/config.file.local
cp -f ../init_config.file $MONGODOCKER/config.file.local
cp -f ../init_config.file $COMPILER/config.file.local
cp -f ../init_config.file $GUI/config.file.local
cp -f $APP/init_config.file $EOSDOCKER/config.file.local
cp -f $APP/init_config.file $EOSDOCKER/scripts/config.file.local
cp -f $APP/init_config.file $MONGODOCKER/config.file.local
cp -f $APP/init_config.file $COMPILER/config.file.local
cp -f $APP/init_config.file $APP/config.file.local

# print init config and save it as .env.local into different packages
echo "REACT_APP_MONGODB_PORT=$MONGODB_PORT" > $GUI/.env.local
echo "REACT_APP_MONGODB_DB_NAME=$MONGODB_DB_NAME" >> $GUI/.env.local
echo "REACT_APP_LOCAL_SERVICE_PORT=$LOCAL_SERVICE_PORT" >> $GUI/.env.local
echo "REACT_APP_APP_SERVE_PORT=$APP_SERVE_PORT" >> $GUI/.env.local
echo "REACT_APP_MONGODB_PORT=$MONGODB_PORT" > $APP/.env.local
echo "REACT_APP_MONGODB_DB_NAME=$MONGODB_DB_NAME" >> $APP/.env.local
echo "REACT_APP_LOCAL_SERVICE_PORT=$LOCAL_SERVICE_PORT" >> $APP/.env.local
echo "REACT_APP_APP_SERVE_PORT=$APP_SERVE_PORT" >> $APP/.env.local

echo "LOCAL_SERVICE_PORT=$LOCAL_SERVICE_PORT" > $LOCALSERVICE/.env.local

Expand Down
9 changes: 6 additions & 3 deletions scripts/pause_dockers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ set -o errexit
# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source ../config.file
source $APP/config.file

# override config if there are any local config changes
if [ -f "../config.file.local" ]; then
source ../config.file.local
if [ -f "$APP/config.file.local" ]; then
source $APP/config.file.local
fi

echo " "
Expand Down
33 changes: 29 additions & 4 deletions scripts/remove_dockers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,39 @@ set -o errexit
# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source $APP/config.file

# override config if there are any local config changes
if [ -f "$APP/config.file.local" ]; then
source $APP/config.file.local
fi

RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'

SCRIPTPATH="$( pwd -P )/../.."
EOSDOCKER="$SCRIPTPATH/docker-eosio-nodeos"
MONGODOCKER="$SCRIPTPATH/docker-mongodb"
COMPILER="$SCRIPTPATH/api-eosio-compiler/docker-eosio-cdt"
if [ 'node_modules' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally, dependencies are installed as siblings directory
DEPENDENCIES_ROOT="$(dirname "$(dirname "$( pwd -P )")")/$DEPENDENCIES_SCOPE_NAME"

elif [ '@ptb1' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally with scope, dependencies are installed as siblings directory of one level upper
DEPENDENCIES_ROOT="$(dirname "$(dirname "$(dirname "$( pwd -P )")")")/$DEPENDENCIES_SCOPE_NAME"
else

# yarn installed locally, dependencies are installed under current's project directory
DEPENDENCIES_ROOT="$(dirname "$( pwd -P )")/node_modules/$DEPENDENCIES_SCOPE_NAME"
fi

EOSDOCKER="$DEPENDENCIES_ROOT/docker-eosio-nodeos"
MONGODOCKER="$DEPENDENCIES_ROOT/docker-mongodb"
COMPILER="$DEPENDENCIES_ROOT/api-eosio-compiler/docker-eosio-cdt"

# remove existing dockers
echo " "
Expand Down
38 changes: 27 additions & 11 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,39 @@ set -o errexit
# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source ../config.file
source $APP/config.file

# override config if there are any local config changes
if [ -f "../config.file.local" ]; then
source ../config.file.local
if [ -f "$APP/config.file.local" ]; then
source $APP/config.file.local
fi

RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'

BUILDPATH="$( pwd -P )/.."
SCRIPTPATH="$( pwd -P )/../.."
EOSDOCKER="$SCRIPTPATH/docker-eosio-nodeos"
MONGODOCKER="$SCRIPTPATH/docker-mongodb"
GUI="$SCRIPTPATH/eosio-explorer"
if [ 'node_modules' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally, dependencies are installed as siblings directory
DEPENDENCIES_ROOT="$(dirname "$(dirname "$( pwd -P )")")/$DEPENDENCIES_SCOPE_NAME"

elif [ '@ptb1' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally with scope, dependencies are installed as siblings directory of one level upper
DEPENDENCIES_ROOT="$(dirname "$(dirname "$(dirname "$( pwd -P )")")")/$DEPENDENCIES_SCOPE_NAME"
else

# yarn installed locally, dependencies are installed under current's project directory
DEPENDENCIES_ROOT="$(dirname "$( pwd -P )")/node_modules/$DEPENDENCIES_SCOPE_NAME"
fi

EOSDOCKER="$DEPENDENCIES_ROOT/docker-eosio-nodeos"
MONGODOCKER="$DEPENDENCIES_ROOT/docker-mongodb"

ISDEV=false
ISDELETE=false
ISINIT=false
Expand All @@ -47,13 +63,13 @@ do
esac
done

# If either of these conditions are true:
# If either of these conditions are true:
# init is being run
# user has not added -dev flag but:
# has added -d flag
# the build folder does not exist
# Then build with a new timestamp.
if ( $ISINIT || (!($ISDEV) && ($ISDELETE || [ ! -e $BUILDPATH"/build" ])) ); then
if ( $ISINIT || (!($ISDEV) && ($ISDELETE || [ ! -e $APP"/build" ])) ); then
BUILDAPPLICATION=true
fi

Expand Down Expand Up @@ -143,7 +159,7 @@ if ( $BUILDAPPLICATION ); then
echo "=============================="

# Set environment variable "REACT_APP_LAST_INIT_TIMESTAMP" at build time to create a new timestamp while serving the app.
(cd $GUI && REACT_APP_LAST_INIT_TIMESTAMP=$(date +%s) yarn build && printf "${GREEN}done${NC}")
(cd $APP && REACT_APP_LAST_INIT_TIMESTAMP=$(date +%s) yarn build && printf "${GREEN}done${NC}")
fi

# build and start the application
Expand Down
45 changes: 31 additions & 14 deletions scripts/start_gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,41 @@ set -o errexit
# cd into current directory
cd $( dirname "$0" )

# App root directory is one level upper
APP=$(dirname "$( pwd -P )")

# sourcing variable from config file
source $APP/config.file

# override config if there are any local config changes
if [ -f "$APP/config.file.local" ]; then
source $APP/config.file.local
fi

RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'

SCRIPTPATH="$( pwd -P )/../.."
GUI="$SCRIPTPATH/eosio-explorer"
COMPILER="$SCRIPTPATH/api-eosio-compiler"
ISDEV=false
CLEARBROWSERSTORAGE=false
if [ 'node_modules' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# sourcing variable from config file
source ../config.file
# yarn added globally, dependencies are installed as siblings directory
DEPENDENCIES_ROOT="$(dirname "$(dirname "$( pwd -P )")")/$DEPENDENCIES_SCOPE_NAME"

# override config if there are any local config changes
if [ -f "../config.file.local" ]; then
source ../config.file.local
elif [ '@ptb1' == $(basename "$(dirname "$(dirname "$( pwd -P )")")") ]; then

# yarn added globally with scope, dependencies are installed as siblings directory of one level upper
DEPENDENCIES_ROOT="$(dirname "$(dirname "$(dirname "$( pwd -P )")")")/$DEPENDENCIES_SCOPE_NAME"
else

# yarn installed locally, dependencies are installed under current's project directory
DEPENDENCIES_ROOT="$(dirname "$( pwd -P )")/node_modules/$DEPENDENCIES_SCOPE_NAME"
fi

COMPILER="$DEPENDENCIES_ROOT/api-eosio-compiler"

ISDEV=false
CLEARBROWSERSTORAGE=false

# check for arguments
for arg in $@
do
Expand All @@ -36,7 +53,7 @@ do
done

# kill cdt service when you stop application
trap "exit" INT TERM ERR
trap "exit" INT TERM ERR
trap "kill 0" EXIT

echo " "
Expand Down Expand Up @@ -68,14 +85,14 @@ echo "=============================="
if $ISDEV; then
if $CLEARBROWSERSTORAGE; then
# Set environment variable "REACT_APP_LAST_INIT_TIMESTAMP" at dev build to create a new timestamp in CRA development
(cd $GUI && REACT_APP_LAST_INIT_TIMESTAMP=$(date +%s) PORT=$APP_DEV_PORT yarn start)
(cd $APP && REACT_APP_LAST_INIT_TIMESTAMP=$(date +%s) PORT=$APP_DEV_PORT yarn start)
else
(cd $GUI && PORT=$APP_DEV_PORT yarn start)
(cd $APP && PORT=$APP_DEV_PORT yarn start)
fi
else
if [ "$(netstat -nat | grep $APP_SERVE_PORT | grep LISTEN)" ]; then
echo "port $APP_SERVE_PORT is already open, you should try browsing http://localhost:$APP_SERVE_PORT if it doesnt work you may have to change the port in config file or release the port $APP_SERVE_PORT"
else
(cd $GUI && yarn serve)
(cd $APP && yarn serve)
fi
fi
Loading

0 comments on commit 6a9f72e

Please sign in to comment.