diff --git a/configuration/.gitignore b/configuration/.gitignore new file mode 100644 index 0000000..2fe9c16 --- /dev/null +++ b/configuration/.gitignore @@ -0,0 +1 @@ +firebaseconfig.json* diff --git a/configuration/README.md b/configuration/README.md index 7d4a258..2cc087d 100644 --- a/configuration/README.md +++ b/configuration/README.md @@ -3,20 +3,10 @@ ``` git clone https://github.com/FirstBuild/green-bean-connect-utils cd green-bean-connect-utils/configuration -npm install -``` - -If you want to use something other than FirstBuild's firebase sandbox, edit generateFirebaseLoginAndToken: -``` -var ref = new Firebase('https://firstbuild-sandbox.firebaseio.com/'); //<---change to url you want -``` - -Finally, run - -``` -node generateFirebaseLoginAndToken +./script/bootstrap ``` +After npm install runs, you'll be prompted to enter a Firebase sandbox name. If you want to use FirstBuild's, just hit enter. This will create a new user in the firebase you specified and generate a firebase file. with credentials. By default it creates a make believe user, so modify if you would like to create with a valid email. Simple login must be enabled on the firebase instance you are using (it is on FirstBuild sandbox). Now that you have the information necessary to setup your Green Bean Connect Perform the next steps: diff --git a/configuration/generateFirebaseLoginAndToken.js b/configuration/generateFirebaseLoginAndToken.js index 5b808d7..9b410a6 100644 --- a/configuration/generateFirebaseLoginAndToken.js +++ b/configuration/generateFirebaseLoginAndToken.js @@ -2,7 +2,7 @@ var Firebase = require('firebase'); var uuid = require('node-uuid'); -var ref = new Firebase('https://firstbuild-sandbox.firebaseio.com/'); //<---change to url you want +var ref = new Firebase(process.env.FIREBASE_SANDBOX_URL); //<---change to url you want var fs = require('fs'); var generatePassword = require('password-generator'); var Moniker = require('moniker'); diff --git a/configuration/script/bootstrap b/configuration/script/bootstrap new file mode 100755 index 0000000..43a3c84 --- /dev/null +++ b/configuration/script/bootstrap @@ -0,0 +1,26 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd )" +PRJ_ROOT=$(dirname "${SCRIPT_DIR}") +cd $PRJ_ROOT + +npm install + +echo "Let's pick a firebase sandbox." +echo "Enter YOUR_FIREBASE: (https://.firebaseio.com), or hit enter" +printf "> " +read input + +if [[ -z $input ]]; then + FIREBASE_SANDBOX='firstbuild-sandbox' +else + FIREBASE_SANDBOX=$input +fi + +# Pass as env var to generateFireBaseLoginAndToken +export FIREBASE_SANDBOX_URL="https://$FIREBASE_SANDBOX.firebaseio.com/" + +echo "Using $FIREBASE_SANDBOX_URL" + +node generateFirebaseLoginAndToken + diff --git a/script/bootstrap b/script/bootstrap deleted file mode 100644 index 9e740a5..0000000 --- a/script/bootstrap +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -x - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" && pwd )" -PRJ_ROOT=$(dirname "${SCRIPT_DIR}") -cd $PRJ_ROOT/configuration - -npm install - -read "Do you want to use FirstBuild's firebase sandbox, or your own? (y/n)> " -# if no, use default: https://firstbuild-sandbox.firebaseio.com/ -# if yes, prompt to enter a firebase sandbox - -# Pass as env var to generateFireBaseLoginAndToken -node generateFirebaseLoginAndToken \ No newline at end of file