backend-manager 2.4.6 → 2.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -21,9 +21,13 @@ Module.prototype.main = function () {
|
|
|
21
21
|
if (!payload.user.roles.admin) {
|
|
22
22
|
return reject(assistant.errorManager(`Admin required.`, {code: 401, sentry: false, send: false, log: false}).error)
|
|
23
23
|
} else {
|
|
24
|
-
const client = new self.libraries.admin.firestore.v1.FirestoreAdminClient({
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const client = new self.libraries.admin.firestore.v1.FirestoreAdminClient({
|
|
25
|
+
credential: Manager.libraries.admin.credential.cert(
|
|
26
|
+
require(Manager.project.serviceAccountPath)
|
|
27
|
+
),
|
|
28
|
+
});
|
|
29
|
+
const projectId = Manager.project.projectId;
|
|
30
|
+
const resourceZone = Manager.project.resourceZone;
|
|
27
31
|
const databaseName = client.databasePath(projectId, '(default)');
|
|
28
32
|
const bucketName = `bm-backup-firestore-${projectId}`;
|
|
29
33
|
const bucketAddress = `gs://${bucketName}`;
|
package/src/manager/index.js
CHANGED
|
@@ -63,20 +63,14 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
63
63
|
Analytics: null,
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
// Manager inner variables
|
|
67
|
-
// self._inner = {
|
|
68
|
-
// ip: '',
|
|
69
|
-
// country: '',
|
|
70
|
-
// referrer: '',
|
|
71
|
-
// userAgent: '',
|
|
72
|
-
// };
|
|
73
|
-
|
|
74
66
|
// Set properties
|
|
67
|
+
self.cwd = process.cwd();
|
|
68
|
+
|
|
75
69
|
self.options = options;
|
|
76
70
|
self.project = options.firebaseConfig || JSON.parse(process.env.FIREBASE_CONFIG || '{}');
|
|
77
71
|
self.project.resourceZone = options.resourceZone;
|
|
72
|
+
self.project.serviceAccountPath = path.resolve(self.cwd, options.serviceAccountPath)
|
|
78
73
|
|
|
79
|
-
self.cwd = process.cwd();
|
|
80
74
|
self.package = resolveProjectPackage();
|
|
81
75
|
self.config = merge(
|
|
82
76
|
require(path.resolve(self.cwd, 'backend-manager-config.json')),
|
|
@@ -86,13 +80,13 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
86
80
|
// Init assistant
|
|
87
81
|
self.assistant = self.Assistant().init(undefined, options.assistant);
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// set more properties (need to wait for assistant to determine if DEV)
|
|
83
|
+
// Set more properties (need to wait for assistant to determine if DEV)
|
|
92
84
|
self.project.functionsUrl = self.assistant.meta.environment === 'development'
|
|
93
85
|
? `http://localhost:5001/${self.project.projectId}/${self.project.resourceZone}`
|
|
94
86
|
: `https://${self.project.resourceZone}-${self.project.projectId}.cloudfunctions.net`;
|
|
95
87
|
|
|
88
|
+
process.env.ENVIRONMENT = !process.env.ENVIRONMENT ? self.assistant.meta.environment : process.env.ENVIRONMENT;
|
|
89
|
+
|
|
96
90
|
// Use the working Firebase logger that they disabled for whatever reason
|
|
97
91
|
if (self.assistant.meta.environment !== 'development' && options.useFirebaseLogger) {
|
|
98
92
|
require('firebase-functions/lib/logger/compat');
|
|
@@ -137,7 +131,7 @@ Manager.prototype.init = function (exporter, options) {
|
|
|
137
131
|
} else {
|
|
138
132
|
self.libraries.initializedAdmin = self.libraries.admin.initializeApp({
|
|
139
133
|
credential: self.libraries.admin.credential.cert(
|
|
140
|
-
require(
|
|
134
|
+
require(self.project.serviceAccountPath)
|
|
141
135
|
),
|
|
142
136
|
databaseURL: self.project.databaseURL,
|
|
143
137
|
}, options.uniqueAppName);
|