Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
Last active August 22, 2017 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnycyk/5a83c56f19d6f891255a320cccbcc3b4 to your computer and use it in GitHub Desktop.
Save sunnycyk/5a83c56f19d6f891255a320cccbcc3b4 to your computer and use it in GitHub Desktop.
myscript
#!/bin/sh
echo "Start loopback scaffolding for $1"
echo "Enter name for application:"
read app
echo "Creating $app"
## create loopback and client framework
if [ $1 == "loopback" ]; then
lb $app
echo "install client framework"
echo "Enter name for client"
read newApp
if [ $# -eq 2 ];
then
if [ $2 == "angular" ]; then
ng new $newApp --directory ./$app/client
# remove default route
sed "/router.get('\/'/s//\/\/router.get('\/'/g" ./$app/server/boot/root.js > ./$app/server/boot/tmp.js
mv ./$app/server/boot/tmp.js ./$app/server/boot/root.js
fi
else
ng new $newApp --directory ./$app/client
sed "/router.get('\/'/s//\/\/router.get('\/'/g" ./$app/server/boot/root.js > ./$app/server/boot/tmp.js
mv ./$app/server/boot/tmp.js ./$app/server/boot/root.js
fi
sed '/"files": {}/s//\"files\": { \"loopback#static\": {\"params\" : \"$!..\/client\/dist\"}}/g' ./$app/server/middleware.json > ./$app/server/tmp.json
mv ./$app/server/tmp.json ./$app/server/middleware.json
sed '/"node ."/s//"cd .\/client \&\& ng build \&\& cd .. \&\& node ."/g' ./$app/package.json > ./$app/tmp.json
mv ./$app/tmp.json ./$app/package.json
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment