Add scaffolding to point dev server at local functions
This commit is contained in:
parent
f58801d4f1
commit
908917e4d9
|
@ -12,7 +12,9 @@ export class APIError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getFunctionUrl(name: string) {
|
export function getFunctionUrl(name: string) {
|
||||||
if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) {
|
if (process.env.NEXT_PUBLIC_FUNCTIONS_URL) {
|
||||||
|
return `${process.env.NEXT_PUBLIC_FUNCTIONS_URL}/${name}`
|
||||||
|
} else if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) {
|
||||||
const { projectId, region } = ENV_CONFIG.firebaseConfig
|
const { projectId, region } = ENV_CONFIG.firebaseConfig
|
||||||
return `http://localhost:5001/${projectId}/${region}/${name}`
|
return `http://localhost:5001/${projectId}/${region}/${name}`
|
||||||
} else {
|
} else {
|
||||||
|
|
26
dev.sh
Executable file
26
dev.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ENV=${1:-dev}
|
||||||
|
case $ENV in
|
||||||
|
dev)
|
||||||
|
FIREBASE_PROJECT=dev
|
||||||
|
NEXT_ENV=DEV ;;
|
||||||
|
prod)
|
||||||
|
FIREBASE_PROJECT=prod
|
||||||
|
NEXT_ENV=PROD ;;
|
||||||
|
*)
|
||||||
|
echo "Invalid environment; must be dev or prod."
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
firebase use $FIREBASE_PROJECT
|
||||||
|
|
||||||
|
# run all of: local functions, next.js dev server, typechecking on web project
|
||||||
|
npx concurrently \
|
||||||
|
-n FUNCTIONS,NEXT,TS \
|
||||||
|
-c white,magenta,cyan \
|
||||||
|
"yarn --cwd=functions dev" \
|
||||||
|
"cross-env NEXT_PUBLIC_FUNCTIONS_URL=http://localhost:8080 \
|
||||||
|
NEXT_PUBLIC_FIREBASE_ENV=${NEXT_ENV} \
|
||||||
|
yarn --cwd=web serve" \
|
||||||
|
"cross-env yarn --cwd=web ts-watch"
|
|
@ -12,6 +12,7 @@
|
||||||
"start": "yarn shell",
|
"start": "yarn shell",
|
||||||
"deploy": "firebase deploy --only functions",
|
"deploy": "firebase deploy --only functions",
|
||||||
"logs": "firebase functions:log",
|
"logs": "firebase functions:log",
|
||||||
|
"dev": "nodemon src/serve.ts",
|
||||||
"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",
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"devdev": "cross-env NEXT_PUBLIC_FIREBASE_ENV=DEV yarn dev",
|
"devdev": "cross-env NEXT_PUBLIC_FIREBASE_ENV=DEV yarn dev",
|
||||||
"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:emulate": "cross-env NEXT_PUBLIC_FIRESTORE_EMULATE=TRUE yarn devdev",
|
"dev:emulate": "cross-env NEXT_PUBLIC_FIRESTORE_EMULATE=TRUE yarn devdev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user