#!/usr/bin/env bash ## ## ## ## ## : ========================================== : Introduction : ========================================== # This script initializes a local project directory for Data Connect: # : curl -sL https://firebase.tools/init/dataconnect | bash # # If you do not want to use this script, follow the manual setup instructions: # https://firebase.google.com/docs/data-connect/quickstart?userflow=manual#prerequisites # # If you only want to install dev tools, see: https://firebase.tools/dataconnect : ----------------------------------------- : Uninstalling - default false : ----------------------------------------- # You can uninstall the dev environment by passing the "uninstall" flag. # : curl -sL https://firebase.tools/init/dataconnect | uninstall=true bash # # This will remove the Firebase CLI standalone binary some cached files. # Node/npm won't be touched -- the script neither installs or uninstalls them. : ========================================== : Advanced Usage : ========================================== : ----------------------------------------- : Setup Editor - default: false : ----------------------------------------- # You can also setup the editor by passing the "editor" flag. # : curl -sL https://firebase.tools/init/dataconnect | editor=false bash # # This can come handy if you need to edit the GraphQL files locally in your # project directory. The VS Code extension also allows you to easily run the # emulators and deploy your local changes. : ========================================== : Source Code : ========================================== editor=${editor:-false} editor_open=false sorry() { echo echo "Something went wrong, local dev setup has not been finished." echo "Please try manual installation to setup your development environment." echo "https://firebase.google.com/docs/data-connect/quickstart?userflow=manual#prerequisites" echo exit 1 } CACHE_DIR=$HOME/.cache mkdir -p "$CACHE_DIR" || sorry SCRIPT_FILE="$CACHE_DIR/fdc-install.sh" curl -fsSL "https://firebase.tools/dataconnect" -o "$SCRIPT_FILE" || sorry source "$SCRIPT_FILE" PROJECT_DIR="." if [ "$(pwd -P)" = "$HOME" ]; then # We don't want to run firebase init in the home directory since it will dump # project files into the home directory. PROJECT_DIR="${FIREBASE_PROJECT:-my-project}-$(date +%Y%m%d-%H%M%S)" mkdir -p "$PROJECT_DIR" || sorry echo "-- Created project directory $PROJECT_DIR (feel free to rename it later)" cd "$PROJECT_DIR" fi ("$FIREBASE_BINARY" login && "$FIREBASE_BINARY" init dataconnect)