Skip to content

Commit

Permalink
v1.0.0-beta.2 (#106)
Browse files Browse the repository at this point in the history
* fix(core): prevent initializeApp from being called multiple times when using emulators
* build(deps): bump acorn from 7.1.0 to 7.1.1 (#103) - @dependabot
* build(deps): bump acorn in /examples/react-redux-firebase (#105) - @dependabot

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
prescottprue and dependabot[bot] authored Mar 23, 2020
1 parent c590f3b commit f527ebb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
5 changes: 3 additions & 2 deletions examples/react-redux-firebase/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,9 @@ acorn-walk@^6.0.1:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-6.1.0.tgz#c957f4a1460da46af4a0388ce28b4c99355b0cbc"

acorn@^5.0.0, acorn@^5.0.3, acorn@^5.5.3, acorn@^5.6.0, acorn@^5.6.2:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
version "5.7.4"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==

acorn@^6.0.1, acorn@^6.0.2:
version "6.0.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/typescript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1984,9 +1984,9 @@ acorn-walk@^6.0.1:
integrity sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==

acorn@^5.5.3:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==
version "5.7.4"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e"
integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==

acorn@^6.0.1, acorn@^6.0.4, acorn@^6.2.1:
version "6.3.0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-firebase",
"version": "1.0.0-beta",
"version": "1.0.0-beta.2",
"description": "Utilities to help testing Firebase projects with Cypress.",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
48 changes: 25 additions & 23 deletions src/firebase-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,35 +96,37 @@ export function initializeFirebase(adminInstance: any): admin.app.App {
/* eslint-enable no-console */
adminInstance.firestore().settings(firestoreSettings);
}
} else {
// Get service account from local file falling back to environment variables
const serviceAccount = getServiceAccount();
const projectId = serviceAccount?.project_id;
if (!isString(projectId)) {
const missingProjectIdErr =
'Error project_id from service account to initialize Firebase.';
console.error(`cypress-firebase: ${missingProjectIdErr}`); // eslint-disable-line no-console
throw new Error(missingProjectIdErr);
}
const cleanProjectId = (projectId as string).replace(
'firebase-top-agent-int',
'top-agent-int',
);
/* eslint-disable no-console */
console.log(
`cypress-firebase: Initialized with Service Account for project "${cleanProjectId}"`,
);
/* eslint-enable no-console */
fbInstance = adminInstance.initializeApp({
credential: adminInstance.credential.cert(serviceAccount as any),
databaseURL: `https://${cleanProjectId}.firebaseio.com`,
});
}
// Get service account from local file falling back to environment variables
const serviceAccount = getServiceAccount();
const projectId = serviceAccount?.project_id;
if (!isString(projectId)) {
const missingProjectIdErr =
'Error project_id from service account to initialize Firebase.';
console.error(`cypress-firebase: ${missingProjectIdErr}`); // eslint-disable-line no-console
throw new Error(missingProjectIdErr);
}
const cleanProjectId = (projectId as string).replace(
'firebase-top-agent-int',
'top-agent-int',
);
/* eslint-disable no-console */
console.log(
`cypress-firebase: Initialized with Service Account for project "${cleanProjectId}"`,
);
/* eslint-enable no-console */
fbInstance = adminInstance.initializeApp({
credential: adminInstance.credential.cert(serviceAccount as any),
databaseURL: `https://${cleanProjectId}.firebaseio.com`,
});

return fbInstance;
} catch (err) {
/* eslint-disable no-console */
console.error(
'cypress-firebase: Error initializing firebase-admin instance from service account.',
'cypress-firebase: Error initializing firebase-admin instance:',
err.message,
);
/* eslint-enable no-console */
throw err;
Expand Down

0 comments on commit f527ebb

Please sign in to comment.