Enable emulator in dev server scaffolding
This commit is contained in:
parent
908917e4d9
commit
cf17095ab9
39
dev.sh
39
dev.sh
|
@ -4,23 +4,42 @@ ENV=${1:-dev}
|
||||||
case $ENV in
|
case $ENV in
|
||||||
dev)
|
dev)
|
||||||
FIREBASE_PROJECT=dev
|
FIREBASE_PROJECT=dev
|
||||||
NEXT_ENV=DEV ;;
|
NEXT_ENV=DEV
|
||||||
|
EMULATOR=false ;;
|
||||||
prod)
|
prod)
|
||||||
FIREBASE_PROJECT=prod
|
FIREBASE_PROJECT=prod
|
||||||
NEXT_ENV=PROD ;;
|
NEXT_ENV=PROD
|
||||||
|
EMULATOR=false ;;
|
||||||
|
localdb)
|
||||||
|
FIREBASE_PROJECT=dev
|
||||||
|
NEXT_ENV=DEV
|
||||||
|
EMULATOR=true ;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid environment; must be dev or prod."
|
echo "Invalid environment; must be dev, prod, or localdb."
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
firebase use $FIREBASE_PROJECT
|
firebase use $FIREBASE_PROJECT
|
||||||
|
|
||||||
# run all of: local functions, next.js dev server, typechecking on web project
|
if [ ! -z $EMULATOR ]
|
||||||
npx concurrently \
|
then
|
||||||
-n FUNCTIONS,NEXT,TS \
|
npx concurrently \
|
||||||
-c white,magenta,cyan \
|
-n FIRESTORE,FUNCTIONS,NEXT,TS \
|
||||||
"yarn --cwd=functions dev" \
|
-c green,white,magenta,cyan \
|
||||||
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8080 \
|
"yarn --cwd=functions firestore" \
|
||||||
|
"cross-env FIRESTORE_EMULATOR_HOST=localhost:8080 yarn --cwd=functions dev" \
|
||||||
|
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8088 \
|
||||||
|
NEXT_PUBLIC_FIREBASE_EMULATE=TRUE \
|
||||||
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
||||||
yarn --cwd=web serve" \
|
yarn --cwd=web serve" \
|
||||||
"cross-env yarn --cwd=web ts-watch"
|
"cross-env yarn --cwd=web ts-watch"
|
||||||
|
else
|
||||||
|
npx concurrently \
|
||||||
|
-n FUNCTIONS,NEXT,TS \
|
||||||
|
-c white,magenta,cyan \
|
||||||
|
"yarn --cwd=functions dev" \
|
||||||
|
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8088 \
|
||||||
|
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
||||||
|
yarn --cwd=web serve" \
|
||||||
|
"cross-env yarn --cwd=web ts-watch"
|
||||||
|
fi
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"deploy": "firebase deploy --only functions",
|
"deploy": "firebase deploy --only functions",
|
||||||
"logs": "firebase functions:log",
|
"logs": "firebase functions:log",
|
||||||
"dev": "nodemon src/serve.ts",
|
"dev": "nodemon src/serve.ts",
|
||||||
|
"firestore": "firebase emulators:start --only firestore --import=./firestore_export",
|
||||||
"serve": "firebase use dev && yarn build && firebase emulators:start --only functions,firestore --import=./firestore_export",
|
"serve": "firebase use dev && yarn build && firebase emulators:start --only functions,firestore --import=./firestore_export",
|
||||||
"db:update-local-from-remote": "yarn db:backup-remote && gsutil rsync -r gs://$npm_package_config_firestore/firestore_export ./firestore_export",
|
"db:update-local-from-remote": "yarn db:backup-remote && gsutil rsync -r gs://$npm_package_config_firestore/firestore_export ./firestore_export",
|
||||||
"db:backup-local": "firebase emulators:export --force ./firestore_export",
|
"db:backup-local": "firebase emulators:export --force ./firestore_export",
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as express from 'express'
|
||||||
import { Express } from 'express'
|
import { Express } from 'express'
|
||||||
import { EndpointDefinition } from './api'
|
import { EndpointDefinition } from './api'
|
||||||
|
|
||||||
const PORT = 8080
|
const PORT = 8088
|
||||||
|
|
||||||
import { initAdmin } from './scripts/script-init'
|
import { initAdmin } from './scripts/script-init'
|
||||||
initAdmin()
|
initAdmin()
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"dev:dev": "yarn devdev",
|
"dev:dev": "yarn devdev",
|
||||||
"dev:the": "cross-env NEXT_PUBLIC_FIREBASE_ENV=THEOREMONE yarn dev",
|
"dev:the": "cross-env NEXT_PUBLIC_FIREBASE_ENV=THEOREMONE yarn dev",
|
||||||
"dev:local": "cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8080 yarn devdev",
|
"dev:local": "cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8080 yarn devdev",
|
||||||
"dev:emulate": "cross-env NEXT_PUBLIC_FIRESTORE_EMULATE=TRUE yarn devdev",
|
"dev:emulate": "cross-env NEXT_PUBLIC_FIREBASE_EMULATE=TRUE yarn devdev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user