Skip to content

Commit

Permalink
Made extra dev Firebase environment
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
Benjamin Van Renterghem committed Apr 13, 2019
1 parent d1c8a1b commit 27d96c6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 24 deletions.
9 changes: 5 additions & 4 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"projects": {
"default": "stud-plan"
}
}
"projects": {
"prod": "stud-plan",
"dev": "stud-plan-dev"
}
}
39 changes: 26 additions & 13 deletions firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{
// Example:
//
// "indexes": [
// {
// "collectionId": "widgets",
// "fields": [
// { "fieldPath": "foo", "mode": "ASCENDING" },
// { "fieldPath": "bar", "mode": "DESCENDING" }
// ]
// }
// ]
"indexes": []
}
"indexes": [
{
"collectionId": "students",
"fields": [
{ "fieldPath": "isPlanned", "mode": "ASCENDING" },
{ "fieldPath": "firstName", "mode": "ASCENDING" },
{ "fieldPath": "lastName", "mode": "ASCENDING" }
]
},
{
"collectionId": "students",
"fields": [
{ "fieldPath": "isPlanned", "mode": "ASCENDING" },
{ "fieldPath": "schoolId", "mode": "ASCENDING" },
{ "fieldPath": "internship.startDate", "mode": "ASCENDING" }
]
},
{
"collectionId": "students",
"fields": [
{ "fieldPath": "isPlanned", "mode": "ASCENDING" },
{ "fieldPath": "internship.startDate", "mode": "ASCENDING" }
]
}
]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build": "react-scripts build",
"test": "react-scripts test",
"lint": "tslint --project tsconfig.json",
"deploy": "run-s lint build && firebase deploy"
"deploy:prod": "run-s lint build && firebase use prod && firebase deploy",
"deploy:dev": "cross-env REACT_APP_FIREBASE_DEPLOY=dev run-s lint build && firebase use dev && firebase deploy"
},
"browserslist": [
">0.2%",
Expand All @@ -40,6 +41,7 @@
"@types/react-helmet": "5.0.7",
"@types/react-router": "4.4.3",
"@types/react-router-dom": "4.3.1",
"cross-env": "^5.2.0",
"node-sass": "4.11.0",
"npm-run-all": "4.1.5",
"react-scripts": "2.1.1",
Expand Down
20 changes: 15 additions & 5 deletions src/services/FirebaseInitializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";

const firebaseConfig = {
const firebaseProdConfig = {
apiKey: "AIzaSyAhHD7f5dudCPHiuidXqWQFzSyOmsmvWcU",
authDomain: "stud-plan.firebaseapp.com",
databaseURL: "https://stud-plan.firebaseio.com",
Expand All @@ -11,16 +11,26 @@ const firebaseConfig = {
storageBucket: "stud-plan.appspot.com",
};

const firebaseDevConfig = {
apiKey: "AIzaSyCFOU0G3d9mClLhf-PdYCF7sVYiObt-v94",
authDomain: "stud-plan-dev.firebaseapp.com",
databaseURL: "https://stud-plan-dev.firebaseio.com",
messagingSenderId: "203179880570",
projectId: "stud-plan-dev",
storageBucket: "",
};

export class FirebaseInitializer {
public static initialize(): void {
firebase.initializeApp(firebaseConfig);

firebase.firestore().settings({ timestampsInSnapshots: true });
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV === "development" || process.env.REACT_APP_FIREBASE_DEPLOY === "dev") {
firebase.initializeApp(firebaseDevConfig);
firebase.firestore.setLogLevel("error");
} else {
firebase.initializeApp(firebaseProdConfig);
firebase.firestore.setLogLevel("silent");
}

firebase.firestore().settings({ timestampsInSnapshots: true });
firebase.firestore().enablePersistence();
}
}
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,14 @@ [email protected]:
fbjs "^0.8.0"
gud "^1.0.0"

cross-env@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==
dependencies:
cross-spawn "^6.0.5"
is-windows "^1.0.0"

[email protected], cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
Expand Down Expand Up @@ -5687,7 +5695,7 @@ is-utf8@^0.2.0:
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=

is-windows@^1.0.1, is-windows@^1.0.2:
is-windows@^1.0.0, is-windows@^1.0.1, is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
Expand Down

0 comments on commit 27d96c6

Please sign in to comment.