backend-manager 3.2.157 → 3.2.159

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.157",
3
+ "version": "3.2.159",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -211,12 +211,14 @@ Manager.prototype.init = function (exporter, options) {
211
211
  // Initialize Firebase
212
212
  if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
213
213
  self.libraries.initializedAdmin = self.libraries.admin.initializeApp();
214
+ // self.app = self.libraries.initializedAdmin;
214
215
  } else {
215
216
  const serviceAccount = require(self.project.serviceAccountPath);
216
217
  self.libraries.initializedAdmin = self.libraries.admin.initializeApp({
217
218
  credential: self.libraries.admin.credential.cert(serviceAccount),
218
219
  databaseURL: self.project.databaseURL || `https://${self.project.projectId}.firebaseio.com`,
219
220
  }, options.uniqueAppName);
221
+ // self.app = self.libraries.initializedAdmin;
220
222
 
221
223
  const loadedProjectId = serviceAccount.project_id;
222
224
  if (!loadedProjectId || !loadedProjectId.includes(appId)) {
@@ -504,17 +506,23 @@ Manager.prototype.storage = function (options) {
504
506
  options.clear = typeof options.clear === 'undefined' ? true : options.clear;
505
507
  options.log = typeof options.log === 'undefined' ? false : options.log;
506
508
 
509
+ // Set path
510
+ const subfolder = `storage/${self.options.uniqueAppName || 'primary'}/${options.name}`;
511
+
512
+ // Setup lowdb
507
513
  const low = require('lowdb');
508
514
  const FileSync = require('lowdb/adapters/FileSync');
509
515
  const location = options.temporary
510
- ? `${require('os').tmpdir()}/storage/${options.name}.json`
511
- : `./.data/storage/${options.name}.json`;
516
+ ? `${require('os').tmpdir()}/${subfolder}.json`
517
+ : `./.data/${subfolder}.json`;
512
518
  const adapter = new FileSync(location);
513
519
 
520
+ // Log
514
521
  if (options.log) {
515
522
  self.assistant.log('storage(): Location', location);
516
523
  }
517
524
 
525
+ // Clear temporary storage
518
526
  if (
519
527
  options.temporary
520
528
  && self.assistant.isDevelopment()
@@ -524,6 +532,7 @@ Manager.prototype.storage = function (options) {
524
532
  jetpack.remove(location);
525
533
  }
526
534
 
535
+ // Setup options
527
536
  options.clearInvalid = typeof options.clearInvalid === 'undefined'
528
537
  ? true
529
538
  : options.clearInvalid;